Bug 1474340 - Remove toolbox XBL property from toolbar. r=Gijs
authorMike Conley <mconley@mozilla.com>
Tue, 18 Sep 2018 14:20:23 +0000
changeset 436968 e1c0d8cbad372a23defa707164b405af703af394
parent 436967 941266ad9f8f4093f5de294955ffabe67fcb1e08
child 436969 1d9298b20b46aacf52eb69bf024c188b354fb00e
push id34667
push useraiakab@mozilla.com
push dateWed, 19 Sep 2018 02:13:23 +0000
treeherdermozilla-central@3857cbe7b717 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1474340
milestone64.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1474340 - Remove toolbox XBL property from toolbar. r=Gijs Differential Revision: https://phabricator.services.mozilla.com/D6078
browser/components/customizableui/CustomizableUI.jsm
browser/components/customizableui/content/toolbar.xml
--- a/browser/components/customizableui/CustomizableUI.jsm
+++ b/browser/components/customizableui/CustomizableUI.jsm
@@ -847,17 +847,17 @@ var CustomizableUIInternal = {
         if (gResetting) {
           this.notifyListeners("onWidgetReset", node, container);
         } else if (gUndoResetting) {
           this.notifyListeners("onWidgetUndoMove", node, container);
         }
       }
 
       if (currentNode) {
-        let palette = aAreaNode.toolbox ? aAreaNode.toolbox.palette : null;
+        let palette = window.gNavToolbox ? window.gNavToolbox.palette : null;
         let limit = currentNode.previousElementSibling;
         let node = container.lastElementChild;
         while (node && node != limit) {
           let previousSibling = node.previousElementSibling;
           // Nodes opt-in to removability. If they're removable, and we haven't
           // seen them in the placements array, then we toss them into the palette
           // if one exists. If no palette exists, we just remove the node. If the
           // node is not removable, we leave it where it is. However, we can only
@@ -995,19 +995,16 @@ var CustomizableUIInternal = {
     return [null, null];
   },
 
   registerMenuPanel(aPanelContents, aArea) {
     if (gBuildAreas.has(aArea) && gBuildAreas.get(aArea).has(aPanelContents)) {
       return;
     }
 
-    let document = aPanelContents.ownerDocument;
-
-    aPanelContents.toolbox = document.getElementById("navigator-toolbox");
     aPanelContents.customizationTarget = aPanelContents;
 
     this.addPanelCloseListeners(this._getPanelForNode(aPanelContents));
 
     let placements = gPlacements.get(aArea);
     this.buildArea(aArea, placements, aPanelContents);
     this.notifyListeners("onAreaNodeRegistered", aArea, aPanelContents);
 
@@ -1068,17 +1065,17 @@ var CustomizableUIInternal = {
       // We remove location attributes here to make sure they're gone too when a
       // widget is removed from a toolbar to the palette. See bug 930950.
       this.removeLocationAttributes(widgetNode);
       // We also need to remove the panel context menu if it's there:
       this.ensureButtonContextMenu(widgetNode);
       if (gPalette.has(aWidgetId) || this.isSpecialWidget(aWidgetId)) {
         container.removeChild(widgetNode);
       } else {
-        areaNode.toolbox.palette.appendChild(widgetNode);
+        window.gNavToolbox.palette.appendChild(widgetNode);
       }
       this.notifyListeners("onWidgetAfterDOMChange", widgetNode, null, container, true);
 
       if (isToolbar) {
         areaNode.setAttribute("currentset", gPlacements.get(aArea).join(","));
       }
 
       let windowCache = gSingleWrapperCache.get(window);
@@ -1107,18 +1104,18 @@ var CustomizableUIInternal = {
     // cleaned up when unloading.
     let window = aNode.ownerGlobal;
     if (window.closed) {
       return;
     }
     this.registerBuildWindow(window);
 
     // Also register this build area's toolbox.
-    if (aNode.toolbox) {
-      gBuildWindows.get(window).add(aNode.toolbox);
+    if (window.gNavToolbox) {
+      gBuildWindows.get(window).add(window.gNavToolbox);
     }
 
     if (!gBuildAreas.has(aArea)) {
       gBuildAreas.set(aArea, new Set());
     }
 
     gBuildAreas.get(aArea).add(aNode);
 
@@ -1394,17 +1391,17 @@ var CustomizableUIInternal = {
         parent = parent.parentNode;
       }
 
       if (parent) {
         let nodeInArea = node.parentNode.localName == "toolbarpaletteitem" ?
                          node.parentNode : node;
         // Check if we're in a customization target, or in the palette:
         if ((parent.customizationTarget == nodeInArea.parentNode &&
-             gBuildWindows.get(aWindow).has(parent.toolbox)) ||
+             gBuildWindows.get(aWindow).has(aWindow.gNavToolbox)) ||
             aWindow.gNavToolbox.palette == nodeInArea.parentNode) {
           // Normalize the removable attribute. For backwards compat, if
           // the widget is not located in a toolbox palette then absence
           // of the "removable" attribute means it is not removable.
           if (!node.hasAttribute("removable")) {
             // If we first see this in customization mode, it may be in the
             // customization palette instead of the toolbox palette.
             node.setAttribute("removable", !parent.customizationTarget);
@@ -4230,17 +4227,16 @@ function OverflowableToolbar(aToolbarNod
   this._enabled = true;
   this._toolbar.addEventListener("overflow", this);
   this._toolbar.addEventListener("underflow", this);
 
   this._toolbar.setAttribute("overflowable", "true");
   let doc = this._toolbar.ownerDocument;
   this._target = this._toolbar.customizationTarget;
   this._list = doc.getElementById(this._toolbar.getAttribute("overflowtarget"));
-  this._list.toolbox = this._toolbar.toolbox;
   this._list.customizationTarget = this._list;
 
   let window = this._toolbar.ownerGlobal;
   if (window.gBrowserInit.delayedStartupFinished) {
     this.init();
   } else {
     Services.obs.addObserver(this, "browser-delayed-startup-finished");
   }
--- a/browser/components/customizableui/content/toolbar.xml
+++ b/browser/components/customizableui/content/toolbar.xml
@@ -12,17 +12,17 @@
     <implementation>
       <constructor><![CDATA[
           let scope = {};
           ChromeUtils.import("resource:///modules/CustomizableUI.jsm", scope);
           let CustomizableUI = scope.CustomizableUI;
 
           // Searching for the toolbox palette in the toolbar binding because
           // toolbars are constructed first.
-          let toolbox = this.toolbox;
+          let toolbox = this.closest("toolbox");
           if (toolbox && !toolbox.palette) {
             for (let node of toolbox.children) {
               if (node.localName == "toolbarpalette") {
                 // Hold on to the palette but remove it from the document.
                 toolbox.palette = node;
                 toolbox.removeChild(node);
                 break;
               }
@@ -78,38 +78,16 @@
             this._customizationTarget.insertItem = this.insertItem.bind(this);
           else
             this._customizationTarget = this;
 
           return this._customizationTarget;
         ]]></getter>
       </property>
 
-      <property name="toolbox" readonly="true">
-        <getter><![CDATA[
-          if (this._toolbox)
-            return this._toolbox;
-
-          let toolboxId = this.getAttribute("toolboxid");
-          if (toolboxId) {
-            let toolbox = document.getElementById(toolboxId);
-            if (toolbox) {
-              this._toolbox = toolbox;
-            }
-          }
-
-          if (!this._toolbox && this.parentNode &&
-              this.parentNode.localName == "toolbox") {
-            this._toolbox = this.parentNode;
-          }
-
-          return this._toolbox;
-        ]]></getter>
-      </property>
-
       <property name="currentSet">
         <getter><![CDATA[
           let currentWidgets = new Set();
           for (let node of this.customizationTarget.children) {
             let realNode = node.localName == "toolbarpaletteitem" ? node.firstElementChild : node;
             if (realNode.getAttribute("skipintoolbarset") != "true") {
               currentWidgets.add(realNode.id);
             }
@@ -165,28 +143,16 @@
       </property>
 
 
     </implementation>
   </binding>
 
   <binding id="toolbar-menubar-stub">
     <implementation>
-      <property name="toolbox" readonly="true">
-        <getter><![CDATA[
-          if (this._toolbox)
-            return this._toolbox;
-
-          if (this.parentNode && this.parentNode.localName == "toolbox") {
-            this._toolbox = this.parentNode;
-          }
-
-          return this._toolbox;
-        ]]></getter>
-      </property>
       <property name="currentSet" readonly="true">
         <getter><![CDATA[
           return this.getAttribute("defaultset");
         ]]></getter>
       </property>
       <method name="insertItem">
         <body><![CDATA[
           return null;