Bug 1403965 fix context menu position in extension sidebar, r=kmag
authorShane Caraveo <scaraveo@mozilla.com>
Tue, 24 Apr 2018 13:01:00 -0500
changeset 471538 93d49d1a2688bfb4f185f4a586ac05b9477dacdc
parent 471537 723a9f786923d9d3ca265f09f4bd7900b79e19af
child 471539 8ef95c56df04726659b7c172dc473cecb4c099fc
push id1728
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:12:27 +0000
treeherdermozilla-release@c296fde26f5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskmag
bugs1403965
milestone61.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 1403965 fix context menu position in extension sidebar, r=kmag MozReview-Commit-ID: 37XgWflt2qG
browser/base/content/browser-sidebar.js
browser/base/content/webext-panels.js
--- a/browser/base/content/browser-sidebar.js
+++ b/browser/base/content/browser-sidebar.js
@@ -184,16 +184,21 @@ var SidebarUI = {
       appcontent.ordinal = boxOrdinal;
       // Indicate we've switched ordering to the box
       this._box.setAttribute("positionend", true);
     } else {
       this._box.removeAttribute("positionend");
     }
 
     this.hideSwitcherPanel();
+
+    let content = SidebarUI.browser.contentWindow;
+    if (content && content.updatePosition) {
+      content.updatePosition();
+    }
   },
 
   /**
    * Try and adopt the status of the sidebar from another window.
    * @param {Window} sourceWindow - Window to use as a source for sidebar status.
    * @return true if we adopted the state, or false if the caller should
    * initialize the state itself.
    */
--- a/browser/base/content/webext-panels.js
+++ b/browser/base/content/webext-panels.js
@@ -88,16 +88,27 @@ var gBrowser = {
   getTabModalPromptBox(browser) {
     if (!browser.tabModalPromptBox) {
       browser.tabModalPromptBox = new TabModalPromptBox(browser);
     }
     return browser.tabModalPromptBox;
   },
 };
 
+function updatePosition() {
+  // We need both of these to make sure we update the position
+  // after any lower level updates have finished.
+  requestAnimationFrame(() => setTimeout(() => {
+    let browser = document.getElementById("webext-panels-browser");
+    if (browser && browser.isRemoteBrowser) {
+      browser.frameLoader.requestUpdatePosition();
+    }
+  }, 0));
+}
+
 function loadPanel(extensionId, extensionUrl, browserStyle) {
   let browserEl = document.getElementById("webext-panels-browser");
   if (browserEl) {
     if (browserEl.currentURI.spec === extensionUrl) {
       return;
     }
     // Forces runtime disconnect.  Remove the stack (parent).
     browserEl.parentNode.remove();