Bug 1398630: Part 3 - Use document.docShell rather than longer/slower XPC paths. r?zombie
MozReview-Commit-ID: 5oD0Uvv1pvx
--- a/browser/components/extensions/ext-browser.js
+++ b/browser/components/extensions/ext-browser.js
@@ -512,18 +512,17 @@ class TabTracker extends TabTrackerBase
this.emit("tab-removed", {nativeTab, tabId, windowId, isWindowClosing});
});
}
getBrowserData(browser) {
if (browser.ownerDocument.documentURI === "about:addons") {
// When we're loaded into a <browser> inside about:addons, we need to go up
// one more level.
- browser = browser.ownerGlobal.QueryInterface(Ci.nsIInterfaceRequestor)
- .getInterface(Ci.nsIDocShell)
+ browser = browser.ownerGlobal.document.docShell
.chromeEventHandler;
}
let result = {
tabId: -1,
windowId: -1,
};
--- a/browser/components/extensions/ext-tabs.js
+++ b/browser/components/extensions/ext-tabs.js
@@ -729,19 +729,17 @@ this.tabs = class extends ExtensionAPI {
let zoomListener = event => {
let browser = event.originalTarget;
// For non-remote browsers, this event is dispatched on the document
// rather than on the <browser>.
if (browser instanceof Ci.nsIDOMDocument) {
- browser = browser.defaultView.QueryInterface(Ci.nsIInterfaceRequestor)
- .getInterface(Ci.nsIDocShell)
- .chromeEventHandler;
+ browser = browser.docShell.chromeEventHandler;
}
let {gBrowser} = browser.ownerGlobal;
let nativeTab = gBrowser.getTabForBrowser(browser);
if (!nativeTab) {
// We only care about zoom events in the top-level browser of a tab.
return;
}
--- a/toolkit/components/extensions/ExtensionCommon.jsm
+++ b/toolkit/components/extensions/ExtensionCommon.jsm
@@ -190,18 +190,17 @@ class BaseContext {
this.messageManager = null;
this.docShell = null;
this.contentWindow = null;
this.innerWindowID = 0;
}
setContentWindow(contentWindow) {
let {document} = contentWindow;
- let docShell = contentWindow.QueryInterface(Ci.nsIInterfaceRequestor)
- .getInterface(Ci.nsIDocShell);
+ let {docShell} = document;
this.innerWindowID = getInnerWindowID(contentWindow);
this.messageManager = docShell.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
if (this.incognito == null) {
this.incognito = PrivateBrowsingUtils.isContentWindowPrivate(contentWindow);
}
--- a/toolkit/components/extensions/ExtensionPageChild.jsm
+++ b/toolkit/components/extensions/ExtensionPageChild.jsm
@@ -358,18 +358,17 @@ ExtensionPageChild = {
let context = this.extensionContexts.get(windowId);
if (context) {
if (context.extension !== extension) {
throw new Error("A different extension context already exists for this frame");
}
throw new Error("An extension context was already initialized for this frame");
}
- let mm = contentWindow.QueryInterface(Ci.nsIInterfaceRequestor)
- .getInterface(Ci.nsIDocShell)
+ let mm = contentWindow.document.docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
let {viewType, tabId, devtoolsToolboxInfo} = getFrameData(mm) || {};
let uri = contentWindow.document.documentURIObject;
if (devtoolsToolboxInfo) {
--- a/toolkit/components/extensions/ExtensionParent.jsm
+++ b/toolkit/components/extensions/ExtensionParent.jsm
@@ -479,18 +479,17 @@ class ExtensionPageContextParent extends
this.extension.views.add(this);
extension.emit("extension-proxy-context-load", this);
}
// The window that contains this context. This may change due to moving tabs.
get xulWindow() {
let win = this.xulBrowser.ownerGlobal;
- return win.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDocShell)
- .QueryInterface(Ci.nsIDocShellTreeItem).rootTreeItem
+ return win.document.docShell.rootTreeItem
.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindow);
}
get currentWindow() {
if (this.viewType !== "background") {
return this.xulWindow;
}
}
--- a/toolkit/components/extensions/ext-tabs-base.js
+++ b/toolkit/components/extensions/ext-tabs-base.js
@@ -689,19 +689,18 @@ class WindowBase {
}
/**
* @property {nsIXULWindow} xulWindow
* The nsIXULWindow object for this browser window.
* @readonly
*/
get xulWindow() {
- return this.window.QueryInterface(Ci.nsIInterfaceRequestor)
- .getInterface(Ci.nsIDocShell)
- .treeOwner.QueryInterface(Ci.nsIInterfaceRequestor)
+ return this.window.document.docShell.treeOwner
+ .QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIXULWindow);
}
/**
* Returns true if this window is the current window for the given extension
* context, false otherwise.
*
* @param {BaseContext} context