Bug 1546309 - appmenu: copy some customizableui related changes from Firefox trunk. r=jorgk
authorPaul Morris <paul@paulwmorris.com>
Tue, 11 Jun 2019 22:28:29 -0400
changeset 35854 c358a56e279baa373a1b72cea747322f5ac78a88
parent 35853 b9426afd27bf876545398412679bc0798a567e83
child 35855 eaeb15a4f6831405de12a16581fa22fb30160681
push id392
push userclokep@gmail.com
push dateMon, 02 Sep 2019 20:17:19 +0000
reviewersjorgk
bugs1546309
Bug 1546309 - appmenu: copy some customizableui related changes from Firefox trunk. r=jorgk
mail/components/customizableui/CustomizableUI.jsm
mail/components/customizableui/CustomizableWidgets.jsm
mail/components/customizableui/CustomizeMode.jsm
mail/components/customizableui/PanelMultiView.jsm
mail/components/customizableui/content/panelUI.js
--- a/mail/components/customizableui/CustomizableUI.jsm
+++ b/mail/components/customizableui/CustomizableUI.jsm
@@ -4436,17 +4436,17 @@ OverflowableToolbar.prototype = {
     return new Promise(resolve => {
       let doc = this._panel.ownerDocument;
       this._panel.hidden = false;
       let multiview = this._panel.querySelector("panelmultiview");
       let mainViewId = multiview.getAttribute("mainViewId");
       let mainView = doc.getElementById(mainViewId);
       let contextMenu = doc.getElementById(mainView.getAttribute("context"));
       gELS.addSystemEventListener(contextMenu, "command", this, true);
-      let anchor = doc.getAnonymousElementByAttribute(this._chevron, "class", "toolbarbutton-icon");
+      let anchor = this.chevron.icon;
       // Ensure we update the gEditUIVisible flag when opening the popup, in
       // case the edit controls are in it.
       this._panel.addEventListener("popupshowing", () => doc.defaultView.updateEditUIVisibility(), {once: true});
       PanelMultiView.openPopup(this._panel, anchor || this._chevron, {
         triggerEvent: aEvent,
       }).catch(Cu.reportError);
       this._chevron.open = true;
 
--- a/mail/components/customizableui/CustomizableWidgets.jsm
+++ b/mail/components/customizableui/CustomizableWidgets.jsm
@@ -355,17 +355,18 @@ const CustomizableWidgets = [
         elem.section = aSection;
         elem.value = item.value;
         elem.setAttribute("class", "subviewbutton");
         containerElem.appendChild(elem);
       }
     },
     updateCurrentCharset(aDocument) {
       let currentCharset = aDocument.defaultView.gBrowser.selectedBrowser.characterSet;
-      currentCharset = CharsetMenu.foldCharset(currentCharset);
+      let {charsetAutodetected} = aDocument.defaultView.gBrowser.selectedBrowser;
+      currentCharset = CharsetMenu.foldCharset(currentCharset, charsetAutodetected);
 
       let pinnedContainer = aDocument.getElementById("PanelUI-characterEncodingView-pinned");
       let charsetContainer = aDocument.getElementById("PanelUI-characterEncodingView-charsets");
       let elements = [...(pinnedContainer.children), ...(charsetContainer.children)];
 
       this._updateElements(elements, currentCharset);
     },
     updateCurrentDetector(aDocument) {
--- a/mail/components/customizableui/CustomizeMode.jsm
+++ b/mail/components/customizableui/CustomizeMode.jsm
@@ -102,17 +102,17 @@ function CustomizeMode(aWindow) {
 
   let content = this.$("customization-content-container");
   if (!content) {
     this.window.MozXULElement.insertFTLIfNeeded("browser/customizeMode.ftl");
     let container = this.$("customization-container");
     container.replaceChild(this.window.MozXULElement.parseXULToFragment(container.firstChild.data), container.lastChild);
   }
   // There are two palettes - there's the palette that can be overlayed with
-  // toolbar items in browser.xul. This is invisible, and never seen by the
+  // toolbar items in browser.xhtml. This is invisible, and never seen by the
   // user. Then there's the visible palette, which gets populated and displayed
   // to the user when in customizing mode.
   this.visiblePalette = this.$(kPaletteId);
   this.pongArena = this.$("customization-pong-arena");
 
   if (this._canDrawInTitlebar()) {
     this._updateTitlebarCheckbox();
     this._updateDragSpaceCheckbox();
--- a/mail/components/customizableui/PanelMultiView.jsm
+++ b/mail/components/customizableui/PanelMultiView.jsm
@@ -1355,16 +1355,21 @@ var PanelView = class extends Associated
         "toolbarbutton[wrap]:not([hidden])",
       ].join(",");
       for (let element of this.node.querySelectorAll(selector)) {
         // Ignore items in hidden containers.
         if (element.closest("[hidden]")) {
           continue;
         }
 
+        // Ignore content inside a <toolbarbutton>
+        if (element.tagName != "toolbarbutton" && element.closest("toolbarbutton")) {
+          continue;
+        }
+
         // Take the label for toolbarbuttons; it only exists on those elements.
         element = element.multilineLabel || element;
 
         let bounds = element.getBoundingClientRect();
         let previous = gMultiLineElementsMap.get(element);
         // We don't need to (re-)apply the workaround for invisible elements or
         // on elements we've seen before and haven't changed in the meantime.
         if (!bounds.width || !bounds.height ||
--- a/mail/components/customizableui/content/panelUI.js
+++ b/mail/components/customizableui/content/panelUI.js
@@ -53,21 +53,20 @@ const PanelUI = {
       // overflowPanel: "widget-overflow",
     };
   },
 
   /**
    * Used for the View / Text Encoding view.
    * Not ideal: copied from: mozilla-central/toolkit/modules/CharsetMenu.jsm
    * This set contains encodings that are in the Encoding Standard, except:
-   *  - XSS-dangerous encodings (except ISO-2022-JP which is assumed to be
-   *    too common not to be included).
+   *  - Japanese encodings are represented by one autodetection item
    *  - x-user-defined, which practically never makes sense as an end-user-chosen
    *    override.
-   *  - Encodings that IE11 doesn't have in its correspoding menu.
+   *  - Encodings that IE11 doesn't have in its corresponding menu.
    */
   kEncodings: new Set([
     // Globally relevant
     "UTF-8",
     "windows-1252",
     // Arabic
     "windows-1256",
     "ISO-8859-6",
@@ -90,20 +89,18 @@ const PanelUI = {
     "IBM866", // Not in menu in Chromium. Maybe drop this?
     // "x-mac-cyrillic", // Not in menu in IE11 or Chromium.
     // Greek
     "windows-1253",
     "ISO-8859-7",
     // Hebrew
     "windows-1255",
     "ISO-8859-8",
-    // Japanese
-    "Shift_JIS",
-    "EUC-JP",
-    "ISO-2022-JP",
+    // Japanese (NOT AN ENCODING NAME)
+    "Japanese",
     // Korean
     "EUC-KR",
     // Thai
     "windows-874",
     // Turkish
     "windows-1254",
     // Vietnamese
     "windows-1258",
@@ -1214,21 +1211,17 @@ const PanelUI = {
     AppMenuNotifications.callMainAction(window, target.notification, false);
   },
 
   _getPopupId(notification) { return "appMenu-" + notification.id + "-notification"; },
 
   _getBadgeStatus(notification) { return notification.id; },
 
   _getPanelAnchor(candidate) {
-    let iconAnchor =
-      document.getAnonymousElementByAttribute(candidate, "class",
-                                              "toolbarbutton-badge-stack") ||
-      document.getAnonymousElementByAttribute(candidate, "class",
-                                              "toolbarbutton-icon");
+    let iconAnchor = candidate.badgeStack || candidate.icon;
     return iconAnchor || candidate;
   },
 
   // This is unused:
   // _addedShortcuts: false,
 
   _ensureShortcutsShown(view = this.mainView) {
     if (view.hasAttribute("added-shortcuts")) {