Bug 1416505 - Fix popup blank for oop extensions. draft
authorLuca Greco <lgreco@mozilla.com>
Fri, 09 Mar 2018 16:14:29 +0100
changeset 766189 95bc2c3c88701384ec67adfe23283a85420509ba
parent 766174 fdd1a0082c71673239fc2f3a6a93de889c07a1be
push id102246
push userluca.greco@alcacoop.it
push dateMon, 12 Mar 2018 11:08:15 +0000
bugs1416505
milestone60.0a1
Bug 1416505 - Fix popup blank for oop extensions. MozReview-Commit-ID: 84p7HvH8CFG
browser/components/extensions/ExtensionPopups.jsm
toolkit/components/extensions/ext-browser-content.js
--- a/browser/components/extensions/ExtensionPopups.jsm
+++ b/browser/components/extensions/ExtensionPopups.jsm
@@ -514,16 +514,25 @@ class ViewPopup extends BasePopup {
 
     if (this.dimensions) {
       if (this.fixedWidth) {
         delete this.dimensions.width;
       }
       this.resizeBrowser(this.dimensions);
     }
 
+    // Force a redraw of the popup content as a workaround for
+    // rendering issues of the "oop extension" popup content
+    // (See Bug 1416505 for a rationale).
+    this.window.promiseDocumentFlushed(() => {
+      if (!this.destroyed && this.browser && this.browser.isRemoteBrowser) {
+        this.browser.messageManager.sendAsyncMessage("Extension:ForceRedraw");
+      }
+    });
+
     this.viewNode.customRectGetter = () => {
       return {height: this.lastCalculatedInViewHeight || this.viewHeight};
     };
 
     this.tempPanel.remove();
     this.tempPanel = null;
 
     this.shown = true;
--- a/toolkit/components/extensions/ext-browser-content.js
+++ b/toolkit/components/extensions/ext-browser-content.js
@@ -113,16 +113,25 @@ const BrowserListener = {
       if (this.unblockParser) {
         this.unblockParser();
         this.blockingPromise = null;
       }
     } else if (name === "Extension:GrabFocus") {
       content.window.requestAnimationFrame(() => {
         Services.focus.focusedWindow = content.window;
       });
+    } else if (name === "Extension:ForceRedraw") {
+      // Force a redraw of the popup content as a workaround for
+      // rendering issues of the "oop extension" popup content
+      // (See Bug 1416505 for a rationale).
+      const dwu = content.QueryInterface(Ci.nsIInterfaceRequestor)
+                         .getInterface(Ci.nsIDOMWindowUtils);
+      content.requestAnimationFrame(() => {
+        dwu.redraw();
+      });
     }
   },
 
   loadStylesheets() {
     let winUtils = getWinUtils(content);
 
     for (let url of this.stylesheets) {
       winUtils.addSheet(ExtensionCommon.stylesheetMap.get(url), winUtils.AGENT_SHEET);
@@ -304,16 +313,17 @@ const BrowserListener = {
 
     sendAsyncMessage("Extension:BrowserResized", result);
   },
 };
 
 addMessageListener("Extension:InitBrowser", BrowserListener);
 addMessageListener("Extension:UnblockParser", BrowserListener);
 addMessageListener("Extension:GrabFocus", BrowserListener);
+addMessageListener("Extension:ForceRedraw", BrowserListener);
 
 var WebBrowserChrome = {
   onBeforeLinkTraversal(originalTarget, linkURI, linkNode, isAppTab) {
     // isAppTab is the value for the docShell that received the click.  We're
     // handling this in the top-level frame and want traversal behavior to
     // match the value for this frame rather than any subframe, so we pass
     // through the docShell.isAppTab value rather than what we were handed.
     return BrowserUtils.onBeforeLinkTraversal(originalTarget, linkURI, linkNode, docShell.isAppTab);