Bug 1374691 - don't instantiate the panelmultiview and panelview bindings until necessary, r?mconley
MozReview-Commit-ID: L0P1eKxRf3A
--- 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.