Bug 1388029 - remove the remaining uses of AREA_PANEL, r?jaws draft
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Tue, 07 Nov 2017 12:15:18 +0000
changeset 697175 e569c8c8c7c9b219a04705f9967d1c46902f503e
parent 697174 a2a5ee13cd4c26cbe255f8f604019e893d8ffdee
child 697176 a5fd09e13572385485be04a780c7f3d968c4757c
push id88916
push userbmo:gijskruitbosch+bugs@gmail.com
push dateMon, 13 Nov 2017 14:22:40 +0000
reviewersjaws
bugs1388029
milestone59.0a1
Bug 1388029 - remove the remaining uses of AREA_PANEL, r?jaws MozReview-Commit-ID: L017kRfHfOv
browser/base/content/browser.js
browser/components/customizableui/CustomizableUI.jsm
browser/components/customizableui/CustomizableWidgets.jsm
browser/components/customizableui/test/head.js
browser/modules/ZoomUI.jsm
devtools/shim/devtools-startup.js
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -3772,21 +3772,16 @@ const BrowserSearch = {
 
     let searchBar = this.searchBar;
     let placement = CustomizableUI.getPlacementOfWidget("search-container");
     let focusSearchBar = () => {
       searchBar = this.searchBar;
       searchBar.select();
       focusUrlBarIfSearchFieldIsNotActive(searchBar);
     };
-    if (placement && placement.area == CustomizableUI.AREA_PANEL) {
-      // The panel is not constructed until the first time it is shown.
-      PanelUI.show().then(focusSearchBar);
-      return;
-    }
     if (placement && searchBar &&
         ((searchBar.parentNode.getAttribute("overflowedItem") == "true" &&
           placement.area == CustomizableUI.AREA_NAVBAR) ||
          placement.area == CustomizableUI.AREA_FIXED_OVERFLOW_PANEL)) {
       let navBar = document.getElementById(CustomizableUI.AREA_NAVBAR);
       navBar.overflowable.show().then(focusSearchBar);
       return;
     }
--- a/browser/components/customizableui/CustomizableUI.jsm
+++ b/browser/components/customizableui/CustomizableUI.jsm
@@ -154,18 +154,16 @@ var gUIStateBeforeReset = {
   uiCustomizationState: null,
   drawInTitlebar: null,
   extraDragSpace: null,
   currentTheme: null,
   uiDensity: null,
   autoTouchMode: null,
 };
 
-var gDefaultPanelPlacements = null;
-
 XPCOMUtils.defineLazyGetter(this, "log", () => {
   let scope = {};
   Cu.import("resource://gre/modules/Console.jsm", scope);
   let debug = Services.prefs.getBoolPref(kPrefCustomizationDebug, false);
   let consoleOptions = {
     maxLogLevel: debug ? "all" : "log",
     prefix: "CustomizableUI",
   };
@@ -1643,20 +1641,17 @@ var CustomizableUIInternal = {
       }
     } else {
       // XXXunf Need to think this through more, and formalize.
       Services.obs.notifyObservers(aNode, "customizedui-widget-click", aWidget.id);
     }
   },
 
   _getPanelForNode(aNode) {
-    let panel = aNode;
-    while (panel && panel.localName != "panel")
-      panel = panel.parentNode;
-    return panel;
+    return aNode.closest("panel");
   },
 
   /*
    * If people put things in the panel which need more than single-click interaction,
    * we don't want to close it. Right now we check for text inputs and menu buttons.
    * We also check for being outside of any toolbaritem/toolbarbutton, ie on a blank
    * part of the menu.
    */
@@ -2956,21 +2951,16 @@ var CustomizableUIInternal = {
       }
     }
   },
 };
 Object.freeze(CustomizableUIInternal);
 
 this.CustomizableUI = {
   /**
-   * Constant reference to the ID of the menu panel.
-   * DEPRECATED.
-   */
-  AREA_PANEL: "PanelUI-contents",
-  /**
    * Constant reference to the ID of the navigation toolbar.
    */
   AREA_NAVBAR: "nav-bar",
   /**
    * Constant reference to the ID of the menubar's toolbar.
    */
   AREA_MENUBAR: "toolbar-menubar",
   /**
--- a/browser/components/customizableui/CustomizableWidgets.jsm
+++ b/browser/components/customizableui/CustomizableWidgets.jsm
@@ -147,17 +147,16 @@ function clearSubview(aSubview) {
 
 const CustomizableWidgets = [
   {
     id: "history-panelmenu",
     type: "view",
     viewId: "PanelUI-history",
     shortcutId: "key_gotoHistory",
     tooltiptext: "history-panelmenu.tooltiptext2",
-    defaultArea: CustomizableUI.AREA_PANEL,
     recentlyClosedTabsPanel: "appMenu-library-recentlyClosedTabs",
     recentlyClosedWindowsPanel: "appMenu-library-recentlyClosedWindows",
     handleEvent(event) {
       switch (event.type) {
         case "PanelMultiViewHidden":
           this.onPanelMultiViewHidden(event);
           break;
         case "ViewShowing":
@@ -239,17 +238,16 @@ const CustomizableWidgets = [
       panelview.appendChild(footer);
     }
   }, {
     id: "sync-button",
     label: "remotetabs-panelmenu.label",
     tooltiptext: "remotetabs-panelmenu.tooltiptext2",
     type: "view",
     viewId: "PanelUI-remotetabs",
-    defaultArea: CustomizableUI.AREA_PANEL,
     deckIndices: {
       DECKINDEX_TABS: 0,
       DECKINDEX_TABSDISABLED: 1,
       DECKINDEX_FETCHING: 2,
       DECKINDEX_NOCLIENTS: 3,
     },
     TABS_PER_PAGE: 25,
     NEXT_PAGE_MIN_TABS: 5, // Minimum number of tabs displayed when we click "Show All"
@@ -518,46 +516,42 @@ const CustomizableWidgets = [
         e.stopPropagation();
         this._showTabs({ clientId, maxTabs: showCount });
       });
       return showAllItem;
     }
   }, {
     id: "privatebrowsing-button",
     shortcutId: "key_privatebrowsing",
-    defaultArea: CustomizableUI.AREA_PANEL,
     onCommand(e) {
       let win = e.target.ownerGlobal;
       win.OpenBrowserWindow({private: true});
     }
   }, {
     id: "save-page-button",
     shortcutId: "key_savePage",
     tooltiptext: "save-page-button.tooltiptext3",
-    defaultArea: CustomizableUI.AREA_PANEL,
     onCommand(aEvent) {
       let win = aEvent.target.ownerGlobal;
       win.saveBrowser(win.gBrowser.selectedBrowser);
     }
   }, {
     id: "find-button",
     shortcutId: "key_find",
     tooltiptext: "find-button.tooltiptext3",
-    defaultArea: CustomizableUI.AREA_PANEL,
     onCommand(aEvent) {
       let win = aEvent.target.ownerGlobal;
       if (win.gFindBar) {
         win.gFindBar.onFindCommand();
       }
     }
   }, {
     id: "open-file-button",
     shortcutId: "openFileKb",
     tooltiptext: "open-file-button.tooltiptext3",
-    defaultArea: CustomizableUI.AREA_PANEL,
     onCommand(aEvent) {
       let win = aEvent.target.ownerGlobal;
       win.BrowserOpenFileWindow();
     }
   }, {
     id: "sidebar-button",
     tooltiptext: "sidebar-button.tooltiptext2",
     onCommand(aEvent) {
@@ -576,26 +570,24 @@ const CustomizableWidgets = [
 
       aNode.appendChild(obChecked);
       aNode.appendChild(obPosition);
     }
   }, {
     id: "add-ons-button",
     shortcutId: "key_openAddons",
     tooltiptext: "add-ons-button.tooltiptext3",
-    defaultArea: CustomizableUI.AREA_PANEL,
     onCommand(aEvent) {
       let win = aEvent.target.ownerGlobal;
       win.BrowserOpenAddonsMgr();
     }
   }, {
     id: "zoom-controls",
     type: "custom",
     tooltiptext: "zoom-controls.tooltiptext2",
-    defaultArea: CustomizableUI.AREA_PANEL,
     onBuild(aDocument) {
       let buttons = [{
         id: "zoom-out-button",
         command: "cmd_fullZoomReduce",
         label: true,
         closemenu: "none",
         tooltiptext: "tooltiptext2",
         shortcutId: "key_fullZoomReduce",
@@ -634,17 +626,16 @@ const CustomizableWidgets = [
         node.appendChild(btnNode);
       });
       return node;
     }
   }, {
     id: "edit-controls",
     type: "custom",
     tooltiptext: "edit-controls.tooltiptext2",
-    defaultArea: CustomizableUI.AREA_PANEL,
     onBuild(aDocument) {
       let buttons = [{
         id: "cut-button",
         command: "cmd_cut",
         label: true,
         tooltiptext: "tooltiptext2",
         shortcutId: "key_cut",
         "class": "toolbarbutton-1 toolbarbutton-combined",
@@ -703,17 +694,16 @@ const CustomizableWidgets = [
       return node;
     }
   },
   {
     id: "feed-button",
     type: "view",
     viewId: "PanelUI-feeds",
     tooltiptext: "feed-button.tooltiptext2",
-    defaultArea: CustomizableUI.AREA_PANEL,
     onClick(aEvent) {
       let win = aEvent.target.ownerGlobal;
       let feeds = win.gBrowser.selectedBrowser.feeds;
 
       // Here, we only care about the case where we have exactly 1 feed and the
       // user clicked...
       let isClick = (aEvent.button == 0 || aEvent.button == 1);
       if (feeds && feeds.length == 1 && isClick) {
@@ -743,17 +733,16 @@ const CustomizableWidgets = [
       }
     }
   }, {
     id: "characterencoding-button",
     label: "characterencoding-button2.label",
     type: "view",
     viewId: "PanelUI-characterEncodingView",
     tooltiptext: "characterencoding-button2.tooltiptext",
-    defaultArea: CustomizableUI.AREA_PANEL,
     maybeDisableMenu(aDocument) {
       let window = aDocument.defaultView;
       return !(window.gBrowser &&
                window.gBrowser.selectedBrowser.mayEnableCharacterEncodingMenu);
     },
     populateList(aDocument, aContainerId, aSection) {
       let containerElem = aDocument.getElementById(aContainerId);
 
@@ -916,17 +905,16 @@ const CustomizableWidgets = [
     onCommand(aEvent) {
       let win = aEvent.view;
       win.MailIntegration.sendLinkForBrowser(win.gBrowser.selectedBrowser);
     }
   }];
 
 let preferencesButton = {
   id: "preferences-button",
-  defaultArea: CustomizableUI.AREA_PANEL,
   onCommand(aEvent) {
     let win = aEvent.target.ownerGlobal;
     win.openPreferences(undefined, {origin: "preferencesButton"});
   }
 };
 if (AppConstants.platform == "win") {
   preferencesButton.label = "preferences-button.labelWin";
   preferencesButton.tooltiptext = "preferences-button.tooltipWin2";
--- a/browser/components/customizableui/test/head.js
+++ b/browser/components/customizableui/test/head.js
@@ -120,20 +120,16 @@ function removeNonReleaseButtons(areaPan
     areaPanelPlacements.splice(areaPanelPlacements.indexOf("developer-button"), 1);
   }
 }
 
 function removeNonOriginalButtons() {
   CustomizableUI.removeWidgetFromArea("sync-button");
 }
 
-function restoreNonOriginalButtons() {
-  CustomizableUI.addWidgetToArea("sync-button", CustomizableUI.AREA_PANEL);
-}
-
 function assertAreaPlacements(areaId, expectedPlacements) {
   let actualPlacements = getAreaWidgetIds(areaId);
   placementArraysEqual(areaId, actualPlacements, expectedPlacements);
 }
 
 function placementArraysEqual(areaId, actualPlacements, expectedPlacements) {
   info("Actual placements: " + actualPlacements.join(", "));
   info("Expected placements: " + expectedPlacements.join(", "));
--- a/browser/modules/ZoomUI.jsm
+++ b/browser/modules/ZoomUI.jsm
@@ -96,23 +96,17 @@ function updateZoomUI(aBrowser, aAnimate
     } else {
       urlbarZoomButton.removeAttribute("animate");
     }
     urlbarZoomButton.setAttribute("label", label);
   }
 }
 
 Components.utils.import("resource:///modules/CustomizableUI.jsm");
-let customizationListener = {
-  onAreaNodeRegistered(aAreaType, aAreaNode) {
-    if (aAreaType == CustomizableUI.AREA_PANEL) {
-      updateZoomUI(aAreaNode.ownerGlobal.gBrowser.selectedBrowser);
-    }
-  }
-};
+let customizationListener = {};
 customizationListener.onWidgetAdded =
 customizationListener.onWidgetRemoved =
 customizationListener.onWidgetMoved = function(aWidgetId) {
   if (aWidgetId == "zoom-controls") {
     for (let window of CustomizableUI.windows) {
       updateZoomUI(window.gBrowser.selectedBrowser);
     }
   }
--- a/devtools/shim/devtools-startup.js
+++ b/devtools/shim/devtools-startup.js
@@ -309,19 +309,16 @@ DevToolsStartup.prototype = {
       return;
     }
     let item = {
       id: id,
       type: "view",
       viewId: "PanelUI-developer",
       shortcutId: "key_toggleToolbox",
       tooltiptext: "developer-button.tooltiptext2",
-      defaultArea: AppConstants.MOZ_DEV_EDITION ?
-                     CustomizableUI.AREA_NAVBAR :
-                     CustomizableUI.AREA_PANEL,
       onViewShowing: (event) => {
         if (Services.prefs.getBoolPref(DEVTOOLS_ENABLED_PREF)) {
           // If DevTools are enabled, initialize DevTools to create all menuitems in the
           // system menu before trying to copy them.
           this.initDevTools("HamburgerMenu");
         }
 
         // Populate the subview with whatever menuitems are in the developer
@@ -356,16 +353,19 @@ DevToolsStartup.prototype = {
         let view = doc.createElement("panelview");
         view.id = "PanelUI-developerItems";
         let panel = doc.createElement("vbox");
         panel.setAttribute("class", "panel-subview-body");
         view.appendChild(panel);
         doc.getElementById("PanelUI-multiView").appendChild(view);
       }
     };
+    if (AppConstants.MOZ_DEV_EDITION) {
+      item.defaultArea = CustomizableUI.AREA_NAVBAR;
+    }
     CustomizableUI.createWidget(item);
     CustomizableWidgets.push(item);
   },
 
   /*
    * We listen to the "Web Developer" system menu, which is under "Tools" main item.
    * This menu item is hardcoded empty in Firefox UI. We listen for its opening to
    * populate it lazily. Loading main DevTools module is going to populate it.