Bug 1354071 - use a panelmultiview for the overflow panel, r?mikedeboer draft
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Tue, 18 Apr 2017 12:16:47 +0100
changeset 564214 8602e7d8ae617f6cbd264760b0178afd5a1807bb
parent 564213 2031946745440390492e254bb2fe1971365adb5a
child 564215 e052b4fd55d8a2f2c5b53a94aa4d2c6146df3414
child 564408 48c2fffe65cebe95d9d8c5ca818aef48cd62eb55
child 565114 e4ba7dafb61176002fb35fbbb49c5950c72e441b
push id54572
push userbmo:gijskruitbosch+bugs@gmail.com
push dateTue, 18 Apr 2017 13:35:09 +0000
reviewersmikedeboer
bugs1354071
milestone55.0a1
Bug 1354071 - use a panelmultiview for the overflow panel, r?mikedeboer MozReview-Commit-ID: ERZuwC6eYQf
browser/components/customizableui/CustomizableUI.jsm
browser/components/customizableui/content/panelUI.inc.xul
browser/components/customizableui/content/panelUI.js
browser/components/customizableui/content/panelUI.xml
--- a/browser/components/customizableui/CustomizableUI.jsm
+++ b/browser/components/customizableui/CustomizableUI.jsm
@@ -1487,17 +1487,18 @@ var CustomizableUIInternal = {
                                      aWidget.id);
       }
     } else if (aWidget.type == "view") {
       let ownerWindow = aNode.ownerGlobal;
       let area = this.getPlacementOfWidget(aNode.id).area;
       let anchor = aNode;
       if (area != CustomizableUI.AREA_PANEL) {
         let wrapper = this.wrapWidget(aWidget.id).forWindow(ownerWindow);
-        if (wrapper && wrapper.anchor) {
+
+        if (wrapper && !wrapper.overflowed && wrapper.anchor) {
           this.hidePanelForNode(aNode);
           anchor = wrapper.anchor;
         }
       }
       ownerWindow.PanelUI.showSubView(aWidget.viewId, anchor, area);
     }
   },
 
--- a/browser/components/customizableui/content/panelUI.inc.xul
+++ b/browser/components/customizableui/content/panelUI.inc.xul
@@ -375,20 +375,24 @@
 
 <panel id="widget-overflow"
        role="group"
        type="arrow"
        noautofocus="true"
        context="toolbar-context-menu"
        position="bottomcenter topright"
        hidden="true">
-  <vbox id="widget-overflow-scroller">
-    <vbox id="widget-overflow-list" class="widget-overflow-list"
-          overflowfortoolbar="nav-bar"/>
-  </vbox>
+  <panelmultiview mainViewId="widget-overflow-mainView">
+    <panelview id="widget-overflow-mainView">
+      <vbox id="widget-overflow-scroller">
+        <vbox id="widget-overflow-list" class="widget-overflow-list"
+              overflowfortoolbar="nav-bar"/>
+      </vbox>
+    </panelview>
+  </panelmultiview>
 </panel>
 
 <panel id="customization-tipPanel"
        type="arrow"
        flip="none"
        side="left"
        position="leftcenter topright"
        noautohide="true"
--- a/browser/components/customizableui/content/panelUI.js
+++ b/browser/components/customizableui/content/panelUI.js
@@ -426,18 +426,19 @@ const PanelUI = {
       return;
     }
 
     if (!aAnchor) {
       Cu.reportError("Expected an anchor when opening subview with id: " + aViewId);
       return;
     }
 
-    if (aPlacementArea == CustomizableUI.AREA_PANEL) {
-      this.multiView.showSubView(aViewId, aAnchor);
+    let container = aAnchor.closest("panelmultiview");
+    if (container) {
+      container.showSubView(aViewId, aAnchor);
     } else if (!aAnchor.open) {
       aAnchor.open = true;
 
       let tempPanel = document.createElement("panel");
       tempPanel.setAttribute("type", "arrow");
       tempPanel.setAttribute("id", "customizationui-widget-panel");
       tempPanel.setAttribute("class", "cui-widget-panel");
       tempPanel.setAttribute("viewId", aViewId);
--- a/browser/components/customizableui/content/panelUI.xml
+++ b/browser/components/customizableui/content/panelUI.xml
@@ -173,16 +173,24 @@
       </method>
 
       <method name="showSubView">
         <parameter name="aViewId"/>
         <parameter name="aAnchor"/>
         <body><![CDATA[
           Task.spawn(function*() {
             let viewNode = this.querySelector("#" + aViewId);
+            if (!viewNode) {
+              viewNode = document.getElementById(aViewId);
+              if (viewNode) {
+                this._subViews.appendChild(viewNode);
+              } else {
+                throw new Error(`Subview ${aViewId} doesn't exist!`);
+              }
+            }
             viewNode.setAttribute("current", true);
             // Emit the ViewShowing event so that the widget definition has a chance
             // to lazily populate the subview with things.
             let detail = {
               blockers: new Set(),
               addBlocker(aPromise) {
                 this.blockers.add(aPromise);
               },