Bug 1446027 - Prevents synchronous uninterruptible reflow from ExtensionPopups.jsm.
MozReview-Commit-ID: Kjmn67ZfNWd
--- a/browser/components/extensions/ExtensionPopups.jsm
+++ b/browser/components/extensions/ExtensionPopups.jsm
@@ -507,53 +507,56 @@ class ViewPopup extends BasePopup {
if (this.destroyed) {
CustomizableUI.hidePanelForNode(viewNode);
return false;
}
this.attached = true;
-
- // Store the initial height of the view, so that we never resize menu panel
- // sub-views smaller than the initial height of the menu.
- this.viewHeight = this.viewNode.boxObject.height;
-
- // Calculate the extra height available on the screen above and below the
- // menu panel. Use that to calculate the how much the sub-view may grow.
- let popupRect = this.panel.getBoundingClientRect();
-
this.setBackground(this.background);
- let win = this.window;
- let popupBottom = win.mozInnerScreenY + popupRect.bottom;
- let popupTop = win.mozInnerScreenY + popupRect.top;
+ let flushPromise = this.window.promiseDocumentFlushed(() => {
+ let win = this.window;
+
+ // Calculate the extra height available on the screen above and below the
+ // menu panel. Use that to calculate the how much the sub-view may grow.
+ let popupRect = this.panel.getBoundingClientRect();
+ let screenBottom = win.screen.availTop + win.screen.availHeight;
+ let popupBottom = win.mozInnerScreenY + popupRect.bottom;
+ let popupTop = win.mozInnerScreenY + popupRect.top;
- let screenBottom = win.screen.availTop + win.screen.availHeight;
- this.extraHeight = {
- bottom: Math.max(0, screenBottom - popupBottom),
- top: Math.max(0, popupTop - win.screen.availTop),
- };
+ // Store the initial height of the view, so that we never resize menu panel
+ // sub-views smaller than the initial height of the menu.
+ this.viewHeight = this.viewNode.boxObject.height;
+
+ this.extraHeight = {
+ bottom: Math.max(0, screenBottom - popupBottom),
+ top: Math.max(0, popupTop - win.screen.availTop),
+ };
+ });
// Create a new browser in the real popup.
let browser = this.browser;
await this.createBrowser(this.viewNode);
- this.ignoreResizes = false;
-
this.browser.swapDocShells(browser);
this.destroyBrowser(browser);
+ await flushPromise;
+
if (this.dimensions) {
if (this.fixedWidth) {
delete this.dimensions.width;
}
this.resizeBrowser(this.dimensions);
}
+ this.ignoreResizes = false;
+
this.viewNode.customRectGetter = () => {
return {height: this.lastCalculatedInViewHeight || this.viewHeight};
};
this.removeTempPanel();
this.shown = true;