Bug 1402845 - Fix panelview sizing when customRectGetter is used. r=mikedeboer,Paolo
authorSam Foster <sfoster@mozilla.com>
Thu, 05 Oct 2017 10:23:53 -0700
changeset 461776 d41993e69c7e73369c68205ea93aab77794c0f3e
parent 461775 b03fd1004cacad2e79713f85ab055099ae4b0da2
child 461777 d06ed3c943eb9b22e8ead8af32874f744ae9dd69
push id1683
push usersfraser@mozilla.com
push dateThu, 26 Apr 2018 16:43:40 +0000
treeherdermozilla-release@5af6cb21869d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmikedeboer, Paolo
bugs1402845
milestone60.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1402845 - Fix panelview sizing when customRectGetter is used. r=mikedeboer,Paolo * The extension content drives the sizing of the browser and popup that contains it via the Extension:BrowserResized message. The ignoreResizes property throttles/debounces this initially, stashing the dimensions received rather than triggering resize of the popup for every message. When the popup is a subview and fixedWidth, we ignore width but *do* want to use the stashed height value. * Until the panel is given visibility, it has 0 height, so after setting visibility, wait until the next refresh-driver tick before measuring any header which should get added to the overall view height MozReview-Commit-ID: AgcruVb9QPA
browser/components/customizableui/PanelMultiView.jsm
browser/components/extensions/ExtensionPopups.jsm
--- a/browser/components/customizableui/PanelMultiView.jsm
+++ b/browser/components/customizableui/PanelMultiView.jsm
@@ -870,21 +870,25 @@ var PanelMultiView = class extends Assoc
     } else if (viewNode.customRectGetter) {
       // We use a customRectGetter for WebExtensions panels, because they need
       // to query the size from an embedded browser. The presence of this
       // getter also provides an indication that the view node shouldn't be
       // moved around, otherwise the state of the browser would get disrupted.
       let width = prevPanelView.knownWidth;
       let height = prevPanelView.knownHeight;
       viewRect = Object.assign({height, width}, viewNode.customRectGetter());
+      nextPanelView.visible = true;
+      // Until the header is visible, it has 0 height.
+      // Wait for layout before measuring it
       let header = viewNode.firstChild;
       if (header && header.classList.contains("panel-header")) {
-        viewRect.height += this._dwu.getBoundsWithoutFlushing(header).height;
+        viewRect.height += await window.promiseDocumentFlushed(() => {
+          return this._dwu.getBoundsWithoutFlushing(header).height;
+        });
       }
-      nextPanelView.visible = true;
       await nextPanelView.descriptionHeightWorkaround();
     } else {
       this._offscreenViewStack.style.minHeight = olderView.knownHeight + "px";
       this._offscreenViewStack.appendChild(viewNode);
       nextPanelView.visible = true;
 
       // Now that the subview is visible, we can check the height of the
       // description elements it contains.
--- a/browser/components/extensions/ExtensionPopups.jsm
+++ b/browser/components/extensions/ExtensionPopups.jsm
@@ -507,17 +507,20 @@ class ViewPopup extends BasePopup {
     let browser = this.browser;
     await this.createBrowser(this.viewNode);
 
     this.ignoreResizes = false;
 
     this.browser.swapDocShells(browser);
     this.destroyBrowser(browser);
 
-    if (this.dimensions && !this.fixedWidth) {
+    if (this.dimensions) {
+      if (this.fixedWidth) {
+        delete this.dimensions.width;
+      }
       this.resizeBrowser(this.dimensions);
     }
 
     this.viewNode.customRectGetter = () => {
       return {height: this.lastCalculatedInViewHeight || this.viewHeight};
     };
 
     this.tempPanel.remove();