Bug 1476145 part 7. Stop using getInterface(nsIDOMWindowUtils) in mobile/. r=snorp

This commit is contained in:
Boris Zbarsky 2018-07-24 19:47:42 -04:00
parent 6e84b66899
commit d5546b23ee
15 changed files with 35 additions and 59 deletions

View file

@ -57,7 +57,7 @@ var MemoryObserver = {
},
gc: function() {
window.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils).garbageCollect();
window.windowUtils.garbageCollect();
Cu.forceGC();
},

View file

@ -73,8 +73,7 @@ var PluginHelper = {
},
playAllPlugins: function(aContentWindow) {
let cwu = aContentWindow.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils);
let cwu = aContentWindow.windowUtils;
// XXX not sure if we should enable plugins for the parent documents...
let plugins = cwu.plugins;
if (!plugins || !plugins.length)

View file

@ -1081,7 +1081,7 @@ var BrowserApp = {
},
contentDocumentChanged: function() {
window.top.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils).isFirstPaint = true;
window.top.windowUtils.isFirstPaint = true;
Services.androidBridge.contentDocumentChanged(window);
},
@ -1650,8 +1650,7 @@ var BrowserApp = {
return;
}
let dwu = aBrowser.contentWindow.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils);
let dwu = aBrowser.contentWindow.windowUtils;
if (!dwu) {
return;
}
@ -3824,7 +3823,7 @@ Tab.prototype = {
reloadWithMode: function (aDesktopMode) {
// notify desktopmode for PIDOMWindow
let win = this.browser.contentWindow;
let dwi = win.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
let dwi = win.windowUtils;
dwi.setDesktopModeViewport(aDesktopMode);
// Set desktop mode for tab and send change to Java
@ -4781,7 +4780,7 @@ Tab.prototype = {
case "audioFocusChanged":
case "mediaControl":
let win = this.browser.contentWindow;
let utils = win.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
let utils = win.windowUtils;
let suspendTypes = Ci.nsISuspendedTypes;
switch (aData) {
case "lostAudioFocus":

View file

@ -68,7 +68,7 @@ class GeckoViewContent extends GeckoViewContentModule {
// Save the current document resolution.
let zoom = { value: 1 };
let domWindowUtils = content.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
let domWindowUtils = content.windowUtils;
domWindowUtils.getResolution(zoom);
scrolldata = scrolldata || {};
scrolldata.zoom = {};
@ -96,23 +96,20 @@ class GeckoViewContent extends GeckoViewContentModule {
switch (aMsg.name) {
case "GeckoView:DOMFullscreenEntered":
if (content) {
content.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils)
content.windowUtils
.handleFullscreenRequests();
}
break;
case "GeckoView:DOMFullscreenExited":
if (content) {
content.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils)
content.windowUtils
.exitFullscreen();
}
break;
case "GeckoView:ZoomToInput": {
let dwu = content.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils);
let dwu = content.windowUtils;
let zoomToFocusedInput = function() {
if (!dwu.flushApzRepaints()) {
@ -294,7 +291,7 @@ class GeckoViewContent extends GeckoViewContentModule {
if (this._savedState) {
const scrolldata = this._savedState.scrolldata;
if (scrolldata && scrolldata.zoom && scrolldata.zoom.displaySize) {
let utils = content.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
let utils = content.windowUtils;
// Restore zoom level.
utils.setRestoreResolution(scrolldata.zoom.resolution,
scrolldata.zoom.displaySize.width,

View file

@ -43,8 +43,7 @@ class GeckoViewContentSettings extends GeckoViewContentModule {
if (this.useDesktopMode === aUse) {
return;
}
let utils = content.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils);
let utils = content.windowUtils;
utils.setDesktopModeViewport(aUse);
this._useDesktopMode = aUse;
}

View file

@ -83,7 +83,7 @@ ContentDispatchChooser.prototype =
// We couldn't open this. If this was from a click, it's likely that we just
// want this to fail silently. If the user entered this on the address bar, though,
// we want to show the neterror page.
let dwu = window.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
let dwu = window.windowUtils;
let millis = dwu.millisSinceLastUserInput;
if (millis < 0 || millis >= 1000) {
window.document.docShell.displayLoadError(Cr.NS_ERROR_UNKNOWN_PROTOCOL, aURI, null);

View file

@ -168,7 +168,7 @@ FilePicker.prototype = {
show: function() {
if (this._domWin) {
this.fireDialogEvent(this._domWin, "DOMWillOpenModalDialog");
let winUtils = this._domWin.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
let winUtils = this._domWin.windowUtils;
winUtils.enterModalState();
}
@ -179,7 +179,7 @@ FilePicker.prototype = {
delete this._promptActive;
if (this._domWin) {
let winUtils = this._domWin.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
let winUtils = this._domWin.windowUtils;
winUtils.leaveModalState();
this.fireDialogEvent(this._domWin, "DOMModalDialogClosed");
}
@ -275,8 +275,7 @@ FilePicker.prototype = {
return;
let event = aDomWin.document.createEvent("Events");
event.initEvent(aEventName, true, true);
let winUtils = aDomWin.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils);
let winUtils = aDomWin.windowUtils;
winUtils.dispatchEventToChromeOnly(aDomWin, event);
} catch (ex) {
}

View file

@ -145,7 +145,7 @@ InternalPrompt.prototype = {
showPrompt: function showPrompt(aPrompt) {
if (this._domWin) {
PromptUtils.fireDialogEvent(this._domWin, "DOMWillOpenModalDialog");
let winUtils = this._domWin.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
let winUtils = this._domWin.windowUtils;
winUtils.enterModalState();
}
@ -158,7 +158,7 @@ InternalPrompt.prototype = {
Services.tm.spinEventLoopUntil(() => retval != null);
if (this._domWin) {
let winUtils = this._domWin.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
let winUtils = this._domWin.windowUtils;
winUtils.leaveModalState();
PromptUtils.fireDialogEvent(this._domWin, "DOMModalDialogClosed");
}
@ -793,8 +793,7 @@ var PromptUtils = {
return;
let event = aDomWin.document.createEvent("Events");
event.initEvent(aEventName, true, true);
let winUtils = aDomWin.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils);
let winUtils = aDomWin.windowUtils;
winUtils.dispatchEventToChromeOnly(aDomWin, event);
} catch (ex) {
}

View file

@ -937,8 +937,7 @@ SessionStore.prototype = {
// Save the current document resolution.
let zoom = { value: 1 };
content.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(
Ci.nsIDOMWindowUtils).getResolution(zoom);
content.windowUtils.getResolution(zoom);
scrolldata.zoom = {};
scrolldata.zoom.resolution = zoom.value;
log("onTabScroll() zoom level: " + zoom.value);
@ -958,8 +957,7 @@ SessionStore.prototype = {
_getContentViewerSize: function ss_getContentViewerSize(aWindow) {
let displaySize = {};
let width = {}, height = {};
aWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(
Ci.nsIDOMWindowUtils).getContentViewerSize(width, height);
aWindow.windowUtils.getContentViewerSize(width, height);
displaySize.width = width.value;
displaySize.height = height.value;
@ -1401,8 +1399,7 @@ SessionStore.prototype = {
log("_restoreZoom(), resolution: " + aScrollData.zoom.resolution +
", old displayWidth: " + aScrollData.zoom.displaySize.width);
let utils = aBrowser.contentWindow.QueryInterface(
Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
let utils = aBrowser.contentWindow.windowUtils;
// Restore zoom level.
utils.setRestoreResolution(aScrollData.zoom.resolution,
aScrollData.zoom.displaySize.width,

View file

@ -27,8 +27,7 @@ async function navigateToAddonDetails(addonId) {
let rect = item.getBoundingClientRect();
const x = rect.left + rect.width / 2;
const y = rect.top + rect.height / 2;
let domWinUtils = content.window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils);
let domWinUtils = content.window.windowUtils;
domWinUtils.sendMouseEventToWindow("mousedown", x, y, 0, 1, 0);
domWinUtils.sendMouseEventToWindow("mouseup", x, y, 0, 1, 0);

View file

@ -365,8 +365,7 @@ PromptDelegate.prototype = {
}
// Accessing the document object can throw if this window no longer exists. See bug 789888.
try {
let winUtils = this._domWin.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils);
let winUtils = this._domWin.windowUtils;
if (!aEntering) {
winUtils.leaveModalState();
}

View file

@ -125,13 +125,11 @@ class GeckoViewContent extends GeckoViewModule {
switch (aMsg.name) {
case "GeckoView:DOMFullscreenExit":
this.window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils)
this.window.windowUtils
.remoteFrameFullscreenReverted();
break;
case "GeckoView:DOMFullscreenRequest":
this.window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils)
this.window.windowUtils
.remoteFrameFullscreenChanged(aMsg.target);
break;
case "GeckoView:SaveStateFinish":

View file

@ -59,7 +59,7 @@
};
function doFullGc(aCallback, aIterations) {
var domWindowUtils = gWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
var domWindowUtils = gWindow.windowUtils;
function runSoon(f) {
Services.tm.dispatchToMainThread({ run: f });

View file

@ -60,9 +60,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1265818
}
function setZoomLevel(browser, zoom) {
browser.contentWindow.QueryInterface(
Ci.nsIInterfaceRequestor).getInterface(
Ci.nsIDOMWindowUtils).setResolutionAndScaleTo(zoom);
browser.contentWindow.windowUtils.setResolutionAndScaleTo(zoom);
}
// Track the tabs where the tests are happening.
@ -95,8 +93,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1265818
yield promiseTabEvent(browser, "SSTabScrollCaptured");
// Check that we've actually scrolled.
let ifreq = browser.contentWindow.QueryInterface(Ci.nsIInterfaceRequestor);
let utils = ifreq.getInterface(Ci.nsIDOMWindowUtils);
let utils = browser.contentWindow.windowUtils;
let scrollX = {}, scrollY = {};
utils.getScrollXY(false, scrollX, scrollY);
is(scrollX.value, 0, "scrollX set correctly");
@ -119,8 +116,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1265818
await promiseBrowserEvent(browser, "AboutReaderContentReady");
// Check the scroll position.
let ifreq = browser.contentWindow.QueryInterface(Ci.nsIInterfaceRequestor);
let utils = ifreq.getInterface(Ci.nsIDOMWindowUtils);
let utils = browser.contentWindow.windowUtils;
let scrollX = {}, scrollY = {};
utils.getScrollXY(false, scrollX, scrollY);
is(scrollX.value, 0, "scrollX restored correctly");
@ -145,8 +141,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1265818
yield promiseTabEvent(browser, "SSTabScrollCaptured");
// Check that we've actually scrolled and zoomed.
let ifreq = browser.contentWindow.QueryInterface(Ci.nsIInterfaceRequestor);
let utils = ifreq.getInterface(Ci.nsIDOMWindowUtils);
let utils = browser.contentWindow.windowUtils;
let scrollX = {}, scrollY = {}, zoom = {};
utils.getResolution(zoom);
utils.getScrollXY(false, scrollX, scrollY);
@ -189,8 +184,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1265818
await scroll;
// Check the scroll position and zoom level.
let ifreq = browser.contentWindow.QueryInterface(Ci.nsIInterfaceRequestor);
let utils = ifreq.getInterface(Ci.nsIDOMWindowUtils);
let utils = browser.contentWindow.windowUtils;
let scrollX = {}, scrollY = {}, zoom = {};
utils.getResolution(zoom);
utils.getScrollXY(false, scrollX, scrollY);
@ -232,8 +226,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1265818
yield promiseTabEvent(browser, "SSTabScrollCaptured");
// Check that we've actually scrolled and zoomed.
let ifreq = browser.contentWindow.QueryInterface(Ci.nsIInterfaceRequestor);
let utils = ifreq.getInterface(Ci.nsIDOMWindowUtils);
let utils = browser.contentWindow.windowUtils;
let scrollX = {}, scrollY = {}, zoom = {};
utils.getResolution(zoom);
utils.getScrollXY(false, scrollX, scrollY);
@ -265,8 +258,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1265818
await promiseBrowserEvent(browser, "pageshow");
// Check the scroll position and zoom level.
let ifreq = browser.contentWindow.QueryInterface(Ci.nsIInterfaceRequestor);
let utils = ifreq.getInterface(Ci.nsIDOMWindowUtils);
let utils = browser.contentWindow.windowUtils;
let scrollX = {}, scrollY = {}, zoom = {};
utils.getResolution(zoom);
utils.getScrollXY(false, scrollX, scrollY);

View file

@ -109,8 +109,7 @@ function getCharPressPoint(doc, element, char, expected) {
* @return Selection state helper-result object.
*/
function getLongPressResult(browser, midPoint) {
let domWinUtils = browser.contentWindow.
QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
let domWinUtils = browser.contentWindow.windowUtils;
// AccessibleCarets expect longtap between touchstart/end.
domWinUtils.sendTouchEventToWindow("touchstart", [0], [midPoint.x], [midPoint.y],