Skip to content

Commit

Permalink
Bug 1391110: Part 4 - Remove unnecessary nsIFrameLoaderOwner QIs. r=s…
Browse files Browse the repository at this point in the history
…maug

The FrameLoaderOwner interface has been implemented in WebIDL for several
years now, so these QIs are simply unnecessary overhead.

MozReview-Commit-ID: LAzvfm5Qhy0
  • Loading branch information
kmaglione committed Aug 19, 2017
1 parent cb7c13d commit 58994bd
Show file tree
Hide file tree
Showing 24 changed files with 53 additions and 91 deletions.
3 changes: 1 addition & 2 deletions accessible/jsat/Utils.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,7 @@ this.Utils = { // jshint ignore:line

getMessageManager: function getMessageManager(aBrowser) {
try {
return aBrowser.QueryInterface(Ci.nsIFrameLoaderOwner).
frameLoader.messageManager;
return aBrowser.frameLoader.messageManager;
} catch (x) {
return null;
}
Expand Down
1 change: 0 additions & 1 deletion browser/base/content/aboutaccounts/aboutaccounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ var wrapper = {

let iframe = document.getElementById("remote");
this.iframe = iframe;
this.iframe.QueryInterface(Ci.nsIFrameLoaderOwner);
let docShell = this.iframe.frameLoader.docShell;
docShell.QueryInterface(Ci.nsIWebProgress);
docShell.addProgressListener(this.iframeListener,
Expand Down
18 changes: 7 additions & 11 deletions browser/base/content/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -5361,17 +5361,13 @@ nsBrowserAccess.prototype = {
: Ci.nsIScriptSecurityManager.DEFAULT_USER_CONTEXT_ID

let referrer = aParams.referrer ? makeURI(aParams.referrer) : null;
let browser = this._openURIInNewTab(aURI, referrer,
aParams.referrerPolicy,
aParams.isPrivate,
isExternal, false,
userContextId, null, aParams.openerBrowser,
aParams.triggeringPrincipal,
aNextTabParentId, aName);
if (browser)
return browser.QueryInterface(Ci.nsIFrameLoaderOwner);

return null;
return this._openURIInNewTab(aURI, referrer,
aParams.referrerPolicy,
aParams.isPrivate,
isExternal, false,
userContextId, null, aParams.openerBrowser,
aParams.triggeringPrincipal,
aNextTabParentId, aName);
},

isTabContentWindow(aWindow) {
Expand Down
6 changes: 3 additions & 3 deletions browser/base/content/tabbrowser.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2115,7 +2115,7 @@
if (aParams.remoteType) {
throw new Error("Cannot set opener window on a remote browser!");
}
b.QueryInterface(Ci.nsIFrameLoaderOwner).presetOpenerWindow(aParams.openerWindow);
b.presetOpenerWindow(aParams.openerWindow);
}
if (!aParams.isPreloadBrowser && this.hasAttribute("autocompletepopup")) {
Expand Down Expand Up @@ -4132,7 +4132,7 @@
this.setTabStateNoAction(tab, state);
let browser = tab.linkedBrowser;
let {tabParent} = browser.QueryInterface(Ci.nsIFrameLoaderOwner).frameLoader;
let {tabParent} = browser.frameLoader;
if (state == this.STATE_LOADING) {
this.assert(!this.minimizedOrFullyOccluded);
browser.docShellIsActive = true;
Expand Down Expand Up @@ -4719,7 +4719,7 @@
this.requestedTab = tab;
let browser = this.requestedTab.linkedBrowser;
let fl = browser.QueryInterface(Ci.nsIFrameLoaderOwner).frameLoader;
let fl = browser.frameLoader;
if (fl && fl.tabParent && !this.activeSuppressDisplayport.has(fl.tabParent)) {
fl.tabParent.suppressDisplayport(true);
Expand Down
2 changes: 1 addition & 1 deletion browser/components/sessionstore/SessionStore.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -4756,7 +4756,7 @@ var SessionStoreInternal = {
if (options.tabData.storage) {
for (let origin of Object.getOwnPropertyNames(options.tabData.storage)) {
try {
let {frameLoader} = browser.QueryInterface(Components.interfaces.nsIFrameLoaderOwner);
let {frameLoader} = browser;
if (frameLoader.tabParent) {
let attrs = browser.contentPrincipal.originAttributes;
let dataPrincipal = Services.scriptSecurityManager.createCodebasePrincipalFromOrigin(origin);
Expand Down
4 changes: 2 additions & 2 deletions browser/modules/ProcessHangMonitor.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ var ProcessHangMonitor = {
* Find a active hang report for the given <browser> element.
*/
findActiveReport(browser) {
let frameLoader = browser.QueryInterface(Ci.nsIFrameLoaderOwner).frameLoader;
let frameLoader = browser.frameLoader;
for (let report of this._activeReports) {
if (report.isReportForBrowser(frameLoader)) {
return report;
Expand All @@ -237,7 +237,7 @@ var ProcessHangMonitor = {
* Find a paused hang report for the given <browser> element.
*/
findPausedReport(browser) {
let frameLoader = browser.QueryInterface(Ci.nsIFrameLoaderOwner).frameLoader;
let frameLoader = browser.frameLoader;
for (let [report, ] of this._pausedReports) {
if (report.isReportForBrowser(frameLoader)) {
return report;
Expand Down
5 changes: 2 additions & 3 deletions devtools/client/framework/toolbox-init.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,9 @@ if (url.search.length > 1) {
throw new Error("Unable to find the targeted iframe to debug");
}

// Need to use a xray and query some interfaces to have
// attributes and behavior expected by devtools codebase
// Need to use a xray to have attributes and behavior expected by
// devtools codebase
iframe = XPCNativeWrapper(iframe);
iframe.QueryInterface(Ci.nsIFrameLoaderOwner);

// Fake a xul:tab object as we don't have one.
// linkedBrowser is the only one attribute being queried by client.getTab
Expand Down
3 changes: 1 addition & 2 deletions devtools/shim/devtools-startup.js
Original file line number Diff line number Diff line change
Expand Up @@ -627,8 +627,7 @@ const JsonView = {
// The following code emulates saveBrowser, but:
// - Uses the given blob URL containing the custom contents to save.
// - Obtains the file name from the URL of the document, not the blob.
let persistable = browser.QueryInterface(Ci.nsIFrameLoaderOwner)
.frameLoader.QueryInterface(Ci.nsIWebBrowserPersistable);
let persistable = browser.frameLoader;
persistable.startPersistence(message.data.windowID, {
onDocumentReady(doc) {
let uri = chrome.makeURI(doc.documentURI, doc.characterSet);
Expand Down
3 changes: 1 addition & 2 deletions layout/tools/reftest/reftest.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,7 @@ this.OnRefTestLoad = function OnRefTestLoad(win)
logger.warning("Could not get test plugin tags.");
}

gBrowserMessageManager = gBrowser.QueryInterface(CI.nsIFrameLoaderOwner)
.frameLoader.messageManager;
gBrowserMessageManager = gBrowser.frameLoader.messageManager;
// The content script waits for the initial onload, then notifies
// us.
RegisterMessageListenersAndLoadContentScript();
Expand Down
1 change: 0 additions & 1 deletion mobile/android/chrome/content/aboutAccounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ var wrapper = {

let iframe = document.getElementById("remote");
this.iframe = iframe;
this.iframe.QueryInterface(Ci.nsIFrameLoaderOwner);
let docShell = this.iframe.frameLoader.docShell;
docShell.QueryInterface(Ci.nsIWebProgress);
docShell.addProgressListener(this.iframeListener,
Expand Down
5 changes: 1 addition & 4 deletions mobile/android/chrome/content/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -3426,10 +3426,7 @@ nsBrowserAccess.prototype = {
//
// We also ignore aName if it is set, as it is currently only used on the
// e10s codepath.
let browser = this._getBrowser(aURI, null, aWhere, aFlags, null);
if (browser)
return browser.QueryInterface(Ci.nsIFrameLoaderOwner);
return null;
return this._getBrowser(aURI, null, aWhere, aFlags, null);
},

isTabContentWindow: function(aWindow) {
Expand Down
2 changes: 1 addition & 1 deletion mobile/android/modules/geckoview/GeckoViewNavigation.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class GeckoViewNavigation extends GeckoViewModule {

if (aWhere === Ci.nsIBrowserDOMWindow.OPEN_DEFAULTWINDOW ||
aWhere === Ci.nsIBrowserDOMWindow.OPEN_CURRENTWINDOW) {
return this.browser.QueryInterface(Ci.nsIFrameLoaderOwner);
return this.browser;
}

throw Cr.NS_ERROR_ABORT;
Expand Down
3 changes: 1 addition & 2 deletions testing/marionette/frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,7 @@ frame.Manager = class {

getFrameMM(winId, frameId) {
let oopFrame = this.getOopFrame(winId, frameId);
let mm = oopFrame.QueryInterface(Ci.nsIFrameLoaderOwner)
.frameLoader.messageManager;
let mm = oopFrame.frameLoader.messageManager;
return mm;
}

Expand Down
16 changes: 4 additions & 12 deletions testing/specialpowers/content/SpecialPowersObserver.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,7 @@ SpecialPowersObserver.prototype.receiveMessage = function(aMessage) {
switch (aMessage.name) {
case "SPPingService":
if (aMessage.json.op == "ping") {
aMessage.target
.QueryInterface(Ci.nsIFrameLoaderOwner)
.frameLoader
aMessage.target.frameLoader
.messageManager
.sendAsyncMessage("SPPingService", { op: "pong" });
}
Expand Down Expand Up @@ -277,22 +275,16 @@ SpecialPowersObserver.prototype.receiveMessage = function(aMessage) {
});

Promise.all(promises).then(function() {
aMessage.target
.QueryInterface(Ci.nsIFrameLoaderOwner)
.frameLoader
aMessage.target.frameLoader
.messageManager
.sendAsyncMessage("SpecialPowers.FilesCreated", filePaths);
}, function(e) {
aMessage.target
.QueryInterface(Ci.nsIFrameLoaderOwner)
.frameLoader
aMessage.target.frameLoader
.messageManager
.sendAsyncMessage("SpecialPowers.FilesError", e.toString());
});
} catch (e) {
aMessage.target
.QueryInterface(Ci.nsIFrameLoaderOwner)
.frameLoader
aMessage.target.frameLoader
.messageManager
.sendAsyncMessage("SpecialPowers.FilesError", e.toString());
}
Expand Down
8 changes: 2 additions & 6 deletions testing/specialpowers/content/SpecialPowersObserverAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,7 @@ SpecialPowersObserverAPI.prototype = {
},

_sendReply(aMessage, aReplyName, aReplyMsg) {
let mm = aMessage.target
.QueryInterface(Ci.nsIFrameLoaderOwner)
.frameLoader
let mm = aMessage.target.frameLoader
.messageManager;
mm.sendAsyncMessage(aReplyName, aReplyMsg);
},
Expand Down Expand Up @@ -471,9 +469,7 @@ SpecialPowersObserverAPI.prototype = {
sandboxOptions = {}
}
let sb = Components.utils.Sandbox(systemPrincipal, sandboxOptions);
let mm = aMessage.target
.QueryInterface(Ci.nsIFrameLoaderOwner)
.frameLoader
let mm = aMessage.target.frameLoader
.messageManager;
sb.sendAsyncMessage = (name, message) => {
mm.sendAsyncMessage("SPChromeScriptMessage",
Expand Down
2 changes: 1 addition & 1 deletion testing/specialpowers/content/specialpowers.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ SpecialPowers.prototype.nestedFrameSetup = function() {
if (frameId === "nested-parent-frame") {
Services.obs.removeObserver(onRemoteBrowserShown, "remote-browser-shown");

let mm = frame.QueryInterface(Components.interfaces.nsIFrameLoaderOwner).frameLoader.messageManager;
let mm = frame.frameLoader.messageManager;
self._grandChildFrameMM = mm;

self.SP_SYNC_MESSAGES.forEach(function(msgname) {
Expand Down
4 changes: 1 addition & 3 deletions testing/specialpowers/content/specialpowersAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -1804,9 +1804,7 @@ SpecialPowersAPI.prototype = {
* Get the message manager associated with an <iframe mozbrowser>.
*/
getBrowserFrameMessageManager(aFrameElement) {
return this.wrap(aFrameElement.QueryInterface(Ci.nsIFrameLoaderOwner)
.frameLoader
.messageManager);
return this.wrap(aFrameElement.frameLoader.messageManager);
},

_getPrincipalFromArg(arg) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ _ContextualIdentityService.prototype = {
return new Promise(resolve => {
let tabParentIds = new Set();
this._forEachContainerTab((tab, tabbrowser) => {
let frameLoader = tab.linkedBrowser.QueryInterface(Ci.nsIFrameLoaderOwner).frameLoader;
let frameLoader = tab.linkedBrowser.frameLoader;

// We don't have tabParent in non-e10s mode.
if (frameLoader.tabParent) {
Expand Down
4 changes: 2 additions & 2 deletions toolkit/components/extensions/ExtensionUtils.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,8 @@ function promiseObserved(topic, test = () => true) {
}

function getMessageManager(target) {
if (target instanceof Ci.nsIFrameLoaderOwner) {
return target.QueryInterface(Ci.nsIFrameLoaderOwner).frameLoader.messageManager;
if (target.frameLoader) {
return target.frameLoader.messageManager;
}
return target.QueryInterface(Ci.nsIMessageSender);
}
Expand Down
6 changes: 2 additions & 4 deletions toolkit/content/contentAreaUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,13 @@ function saveImageURL(aURL, aFileName, aFilePickerTitleKey, aShouldBypassCache,
}

// This is like saveDocument, but takes any browser/frame-like element
// (nsIFrameLoaderOwner) and saves the current document inside it,
// and saves the current document inside it,
// whether in-process or out-of-process.
function saveBrowser(aBrowser, aSkipPrompt, aOuterWindowID = 0) {
if (!aBrowser) {
throw "Must have a browser when calling saveBrowser";
}
let persistable = aBrowser.QueryInterface(Ci.nsIFrameLoaderOwner)
.frameLoader
.QueryInterface(Ci.nsIWebBrowserPersistable);
let persistable = aBrowser.frameLoader;
let stack = Components.stack.caller;
persistable.startPersistence(aOuterWindowID, {
onDocumentReady(document) {
Expand Down
18 changes: 8 additions & 10 deletions toolkit/content/widgets/browser.xml
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@
if (this._docShell)
return this._docShell;
let frameLoader = this.QueryInterface(Components.interfaces.nsIFrameLoaderOwner).frameLoader;
let {frameLoader} = this;
if (!frameLoader)
return null;
this._docShell = frameLoader.docShell;
Expand All @@ -266,7 +266,7 @@
if (this._loadContext)
return this._loadContext;
let frameLoader = this.QueryInterface(Components.interfaces.nsIFrameLoaderOwner).frameLoader;
let {frameLoader} = this;
if (!frameLoader)
return null;
this._loadContext = frameLoader.loadContext;
Expand Down Expand Up @@ -347,11 +347,10 @@
readonly="true">
<getter>
<![CDATA[
var owner = this.QueryInterface(Components.interfaces.nsIFrameLoaderOwner);
if (!owner.frameLoader) {
return null;
if (this.frameLoader) {
return this.frameLoader.messageManager;
}
return owner.frameLoader.messageManager;
return null;
]]>
</getter>

Expand Down Expand Up @@ -1569,14 +1568,13 @@
<parameter name="aPrintProgressListener"/>
<body>
<![CDATA[
var owner = this.QueryInterface(Components.interfaces.nsIFrameLoaderOwner);
if (!owner.frameLoader) {
if (!this.frameLoader) {
throw Components.Exception("No frame loader.",
Components.results.NS_ERROR_FAILURE);
}
owner.frameLoader.print(aOuterWindowID, aPrintSettings,
aPrintProgressListener);
this.frameLoader.print(aOuterWindowID, aPrintSettings,
aPrintProgressListener);
]]>
</body>
</method>
Expand Down
9 changes: 4 additions & 5 deletions toolkit/content/widgets/editor.xml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
onget="return this.webNavigation.document;"/>
<property name="docShell" readonly="true">
<getter><![CDATA[
let frameLoader = this.QueryInterface(Components.interfaces.nsIFrameLoaderOwner).frameLoader;
let {frameLoader} = this;
return frameLoader ? frameLoader.docShell : null;
]]></getter>
</property>
Expand Down Expand Up @@ -168,11 +168,10 @@
readonly="true">
<getter>
<![CDATA[
var owner = this.QueryInterface(Components.interfaces.nsIFrameLoaderOwner);
if (!owner.frameLoader) {
return null;
if (this.frameLoader) {
return this.frameLoader.messageManager;
}
return owner.frameLoader.messageManager;
return null;
]]>
</getter>
</property>
Expand Down
2 changes: 1 addition & 1 deletion toolkit/content/widgets/general.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
<implementation>
<property name="docShell" readonly="true">
<getter><![CDATA[
let frameLoader = this.QueryInterface(Components.interfaces.nsIFrameLoaderOwner).frameLoader;
let {frameLoader} = this;
return frameLoader ? frameLoader.docShell : null;
]]></getter>
</property>
Expand Down
Loading

0 comments on commit 58994bd

Please sign in to comment.