Bug 1374691 - don't instantiate the panelmultiview and panelview bindings until necessary, r?mconley draft
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Thu, 22 Jun 2017 09:11:45 +0100
changeset 600600 9b82137b55c8d7bf344ed493751a99e70cf79f35
parent 600597 53477d584130945864c4491632f88da437353356
child 635028 d085cb842fbf8d53eea48bbdab5bb379d17593e8
push id65797
push usergijskruitbosch@gmail.com
push dateTue, 27 Jun 2017 12:05:41 +0000
reviewersmconley
bugs1374691
milestone56.0a1
Bug 1374691 - don't instantiate the panelmultiview and panelview bindings until necessary, r?mconley MozReview-Commit-ID: L0P1eKxRf3A
browser/base/content/browser.css
browser/components/customizableui/CustomizeMode.jsm
--- a/browser/base/content/browser.css
+++ b/browser/base/content/browser.css
@@ -99,16 +99,22 @@ photonpanelmultiview {
   -moz-binding: url("chrome://browser/content/customizableui/panelUI.xml#photonpanelmultiview");
 }
 
 panelview {
   -moz-binding: url("chrome://browser/content/customizableui/panelUI.xml#panelview");
   -moz-box-orient: vertical;
 }
 
+panel[hidden] panelmultiview,
+panel[hidden] photonpanelmultiview,
+panel[hidden] panelview {
+  -moz-binding: none;
+}
+
 .panel-mainview {
   transition: transform var(--panelui-subview-transition-duration);
 }
 
 panelview:not([mainview]):not([current]) {
   transition: visibility 0s linear var(--panelui-subview-transition-duration);
   visibility: collapse;
 }
--- a/browser/components/customizableui/CustomizeMode.jsm
+++ b/browser/components/customizableui/CustomizeMode.jsm
@@ -308,23 +308,29 @@ CustomizeMode.prototype = {
           paletteContainer.appendChild(footer);
           customizationContainer.removeAttribute("photon");
           doneButton.hidden = true;
         }
         window.PanelUI.menuButton.addEventListener("command", this);
         window.PanelUI.menuButton.open = true;
         window.PanelUI.beginBatchUpdate();
 
-        // The menu panel is lazy, and registers itself when the popup shows. We
-        // need to force the menu panel to register itself, or else customization
-        // is really not going to work. We pass "true" to ensureReady to
-        // indicate that we're handling calling startBatchUpdate and
-        // endBatchUpdate.
+        // The menu panel is lazy, and registers itself when the popup shows.
+        // If it hasn't been opened yet, we need to force the menu panel to
+        // register itself, or else customization is not going to work.
+        // We pass "true" to ensureReady to indicate that we're handling
+        // calling startBatchUpdate and endBatchUpdate.
         if (!window.PanelUI.isReady) {
           await window.PanelUI.ensureReady(true);
+          // Up to now, it will have been hidden, and its XBL bindings won't have
+          // been constructed. Unhiding it won't trigger the construction of
+          // those bindings immediately, but the next layout flush will.
+          // Because we don't want to sync flush layout, we wait for the next
+          // natural style/layout flush.
+          await new Promise(resolve => window.requestIdleCallback(resolve));
         }
 
         // Hide the palette before starting the transition for increased perf.
         this.visiblePalette.hidden = true;
         this.visiblePalette.removeAttribute("showing");
 
         // Disable the button-text fade-out mask
         // during the transition for increased perf.