Commit 75f358e4 authored by henry's avatar henry Committed by Pier Angelo Vendrame
Browse files

BB 44040: Modify prompt service for Base Browser.

parent 31d1f460
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -67,6 +67,8 @@ interface nsIPrompt : nsISupports

    const unsigned long BUTTON_POS_1_IS_SECONDARY  = 1 << 29;

    const unsigned long BUTTON_DEFAULT_IS_DESTRUCTIVE = 1 << 30;

    const unsigned long STD_OK_CANCEL_BUTTONS      = (BUTTON_TITLE_OK * BUTTON_POS_0) +
                                                    (BUTTON_TITLE_CANCEL * BUTTON_POS_1);
    const unsigned long STD_YES_NO_BUTTONS         = (BUTTON_TITLE_YES * BUTTON_POS_0) +
+5 −1
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ function commonDialogOnLoad() {
    ["promptUserAndPass", "promptPassword"].includes(args.promptType) ||
    args.headerIconCSSValue;
  let root = document.documentElement;
  if (needIconifiedHeader) {
  if (needIconifiedHeader && !args.noIcon) {
    root.setAttribute("neediconheader", "true");
  }
  let title = { raw: args.title };
@@ -107,6 +107,10 @@ function commonDialogOnLoad() {
    dialog.setAttribute("extra1-is-secondary", true);
  }

  if (args.isDefaultDestructive) {
    dialog.setAttribute("default-is-destructive", true);
  }

  Dialog = new CommonDialog(args, ui);
  window.addEventListener("dialogclosing", function (aEvent) {
    if (aEvent.detail?.abort) {
+4 −0
Original line number Diff line number Diff line
@@ -1507,6 +1507,10 @@ class ModalPrompter {
      args.isExtra1Secondary = true;
    }

    if (flags & Ci.nsIPrompt.BUTTON_DEFAULT_IS_DESTRUCTIVE) {
      args.isDefaultDestructive = true;
    }

    if (flags & Ci.nsIPrompt.SHOW_SPINNER) {
      args.headerIconCSSValue = "url('chrome://global/skin/icons/loading.svg')";
    }
+2 −0
Original line number Diff line number Diff line
@@ -287,6 +287,8 @@ interface nsIPromptService : nsISupports
   */
  const unsigned long BUTTON_POS_1_IS_SECONDARY  = 1 << 29;

  const unsigned long BUTTON_DEFAULT_IS_DESTRUCTIVE = 1 << 30;

  /**
   * Selects the standard set of OK/Cancel buttons.
   */
+23 −1
Original line number Diff line number Diff line
@@ -21,7 +21,8 @@
    static get observedAttributes() {
      return super.observedAttributes.concat(
        "subdialog",
        "extra1-is-secondary"
        "extra1-is-secondary",
        "default-is-destructive"
      );
    }

@@ -40,6 +41,12 @@
      if (name === "extra1-is-secondary" && AppConstants.XP_UNIX) {
        this.getButton("cancel").after(this.getButton("extra1"));
      }
      if (name === "default-is-destructive") {
        this.#setButtonIsDestructive(
          this.getButton(this.defaultButton),
          this.hasAttribute("default-is-destructive")
        );
      }
      super.attributeChangedCallback(name, oldValue, newValue);
    }

@@ -491,12 +498,17 @@
      var oldDefaultButton = this.getButton(this.defaultButton);
      if (oldDefaultButton) {
        oldDefaultButton.removeAttribute("default");
        this.#setButtonIsDestructive(oldDefaultButton, false);
      }

      var newDefaultButton = this.getButton(aNewDefault);
      if (newDefaultButton) {
        this.setAttribute("defaultButton", aNewDefault);
        newDefaultButton.setAttribute("default", "true");
        this.#setButtonIsDestructive(
          newDefaultButton,
          this.hasAttribute("default-is-destructive")
        );
      } else {
        this.setAttribute("defaultButton", "none");
        if (aNewDefault != "none") {
@@ -507,6 +519,16 @@
      }
    }

    /**
     * Mark or un-mark a button as a destructive action.
     *
     * @param {?Element} button - The button to mark.
     * @param {boolean} isDestructive - Whether the button is destructive.
     */
    #setButtonIsDestructive(button, isDestructive) {
      button?.classList.toggle("danger-button", isDestructive);
    }

    _handleButtonCommand(aEvent) {
      return this._doButtonCommand(aEvent.target.getAttribute("dlgtype"));
    }