Bug 1403965 fix context menu position in extension sidebar, r?kmag
MozReview-Commit-ID: 37XgWflt2qG
--- 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();