зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1533943, modify WebNavigation to inherit from JSWindowActor, r=mconley
Differential Revision: https://phabricator.services.mozilla.com/D50886 --HG-- extra : source : 6e3c105cfcde3a6821120a83674f77692f5c7bf2
This commit is contained in:
Родитель
1d1b44bdd9
Коммит
fd6f562cbe
|
@ -14,12 +14,12 @@ const Services = require("Services");
|
|||
* helps mozbrowser elements support this.
|
||||
*
|
||||
* It attempts to use the mozbrowser API wherever possible, however some methods don't
|
||||
* exist yet, so we fallback to the WebNavigation frame script messages in those cases.
|
||||
* exist yet, so we fallback to the WebNavigation actor in those cases.
|
||||
* Ideally the mozbrowser API would eventually be extended to cover all properties and
|
||||
* methods used here.
|
||||
*
|
||||
* This is largely copied from RemoteWebNavigation.js, which uses the message manager to
|
||||
* perform all actions.
|
||||
* This is largely copied from RemoteWebNavigation.js, which uses the WebNavigation
|
||||
* actor to perform all actions.
|
||||
*/
|
||||
function BrowserElementWebNavigation(browser) {
|
||||
this._browser = browser;
|
||||
|
@ -28,10 +28,6 @@ function BrowserElementWebNavigation(browser) {
|
|||
BrowserElementWebNavigation.prototype = {
|
||||
QueryInterface: ChromeUtils.generateQI([Ci.nsIWebNavigation]),
|
||||
|
||||
get _mm() {
|
||||
return this._browser.frameLoader.messageManager;
|
||||
},
|
||||
|
||||
canGoBack: false,
|
||||
canGoForward: false,
|
||||
|
||||
|
@ -78,7 +74,7 @@ BrowserElementWebNavigation.prototype = {
|
|||
);
|
||||
referrerInfo.init(referrerPolicy, true, referrer);
|
||||
|
||||
this._browser.frameLoader.browsingContext.loadURI(uri, {
|
||||
this._browser.browsingContext.loadURI(uri, {
|
||||
loadFlags: flags,
|
||||
referrerInfo,
|
||||
postData,
|
||||
|
@ -139,7 +135,15 @@ BrowserElementWebNavigation.prototype = {
|
|||
|
||||
_sendMessage(message, data) {
|
||||
try {
|
||||
this._mm.sendAsyncMessage(message, data);
|
||||
if (this._browser.frameLoader) {
|
||||
const windowGlobal = this._browser.browsingContext
|
||||
.currentWindowGlobal;
|
||||
if (windowGlobal) {
|
||||
windowGlobal
|
||||
.getActor("WebNavigation")
|
||||
.sendAsyncMessage(message, data);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
Cu.reportError(e);
|
||||
}
|
||||
|
|
|
@ -6,13 +6,9 @@
|
|||
|
||||
var EXPORTED_SYMBOLS = ["WebNavigationChild"];
|
||||
|
||||
const { ActorChild } = ChromeUtils.import(
|
||||
"resource://gre/modules/ActorChild.jsm"
|
||||
);
|
||||
|
||||
class WebNavigationChild extends ActorChild {
|
||||
class WebNavigationChild extends JSWindowActorChild {
|
||||
get webNavigation() {
|
||||
return this.mm.docShell.QueryInterface(Ci.nsIWebNavigation);
|
||||
return this.docShell.QueryInterface(Ci.nsIWebNavigation);
|
||||
}
|
||||
|
||||
receiveMessage(message) {
|
||||
|
@ -42,7 +38,7 @@ class WebNavigationChild extends ActorChild {
|
|||
try {
|
||||
fn();
|
||||
} finally {
|
||||
this.mm.docShell
|
||||
this.docShell
|
||||
.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIBrowserChild)
|
||||
.notifyNavigationFinished();
|
||||
|
@ -50,22 +46,24 @@ class WebNavigationChild extends ActorChild {
|
|||
}
|
||||
|
||||
goBack(params) {
|
||||
if (this.webNavigation.canGoBack) {
|
||||
this.mm.docShell.setCancelContentJSEpoch(params.cancelContentJSEpoch);
|
||||
this._wrapURIChangeCall(() => this.webNavigation.goBack());
|
||||
let wn = this.webNavigation;
|
||||
if (wn.canGoBack) {
|
||||
this.docShell.setCancelContentJSEpoch(params.cancelContentJSEpoch);
|
||||
this._wrapURIChangeCall(() => wn.goBack());
|
||||
}
|
||||
}
|
||||
|
||||
goForward(params) {
|
||||
if (this.webNavigation.canGoForward) {
|
||||
this.mm.docShell.setCancelContentJSEpoch(params.cancelContentJSEpoch);
|
||||
this._wrapURIChangeCall(() => this.webNavigation.goForward());
|
||||
let wn = this.webNavigation;
|
||||
if (wn.canGoForward) {
|
||||
this.docShell.setCancelContentJSEpoch(params.cancelContentJSEpoch);
|
||||
this._wrapURIChangeCall(() => wn.goForward());
|
||||
}
|
||||
}
|
||||
|
||||
gotoIndex(params) {
|
||||
let { index, cancelContentJSEpoch } = params || {};
|
||||
this.mm.docShell.setCancelContentJSEpoch(cancelContentJSEpoch);
|
||||
this.docShell.setCancelContentJSEpoch(cancelContentJSEpoch);
|
||||
this._wrapURIChangeCall(() => this.webNavigation.gotoIndex(index));
|
||||
}
|
||||
|
||||
|
@ -77,7 +75,7 @@ class WebNavigationChild extends ActorChild {
|
|||
"WebNavigationChild.js",
|
||||
line
|
||||
);
|
||||
debug.abort("WebNavigationChild.js", line);
|
||||
debug.abort("WebNavigationChild.jsm", line);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -155,7 +155,7 @@ RemoteWebNavigation.prototype = {
|
|||
|
||||
_sendMessage(aMessage, aData) {
|
||||
try {
|
||||
this._browser.messageManager.sendAsyncMessage(aMessage, aData);
|
||||
this._browser.sendMessageToActor(aMessage, aData, "WebNavigation");
|
||||
} catch (e) {
|
||||
Cu.reportError(e);
|
||||
}
|
||||
|
|
|
@ -236,6 +236,13 @@ let ACTORS = {
|
|||
allFrames: true,
|
||||
},
|
||||
|
||||
PurgeSessionHistory: {
|
||||
child: {
|
||||
moduleURI: "resource://gre/actors/PurgeSessionHistoryChild.jsm",
|
||||
},
|
||||
allFrames: true,
|
||||
},
|
||||
|
||||
Select: {
|
||||
parent: {
|
||||
moduleURI: "resource://gre/actors/SelectParent.jsm",
|
||||
|
@ -273,6 +280,24 @@ let ACTORS = {
|
|||
},
|
||||
},
|
||||
|
||||
UAWidgets: {
|
||||
child: {
|
||||
moduleURI: "resource://gre/actors/UAWidgetsChild.jsm",
|
||||
events: {
|
||||
UAWidgetSetupOrChange: {},
|
||||
UAWidgetTeardown: {},
|
||||
},
|
||||
},
|
||||
|
||||
allFrames: true,
|
||||
},
|
||||
|
||||
WebNavigation: {
|
||||
child: {
|
||||
moduleURI: "resource://gre/actors/WebNavigationChild.jsm",
|
||||
},
|
||||
},
|
||||
|
||||
Zoom: {
|
||||
parent: {
|
||||
moduleURI: "resource://gre/actors/ZoomParent.jsm",
|
||||
|
@ -288,24 +313,6 @@ let ACTORS = {
|
|||
|
||||
allFrames: true,
|
||||
},
|
||||
|
||||
UAWidgets: {
|
||||
child: {
|
||||
moduleURI: "resource://gre/actors/UAWidgetsChild.jsm",
|
||||
events: {
|
||||
UAWidgetSetupOrChange: {},
|
||||
UAWidgetTeardown: {},
|
||||
},
|
||||
},
|
||||
|
||||
allFrames: true,
|
||||
},
|
||||
PurgeSessionHistory: {
|
||||
child: {
|
||||
moduleURI: "resource://gre/actors/PurgeSessionHistoryChild.jsm",
|
||||
},
|
||||
allFrames: true,
|
||||
},
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -459,20 +466,6 @@ let LEGACY_ACTORS = {
|
|||
messages: ["Browser:UnselectedTabHover"],
|
||||
},
|
||||
},
|
||||
|
||||
WebNavigation: {
|
||||
child: {
|
||||
module: "resource://gre/actors/WebNavigationChild.jsm",
|
||||
messages: [
|
||||
"WebNavigation:GoBack",
|
||||
"WebNavigation:GoForward",
|
||||
"WebNavigation:GotoIndex",
|
||||
"WebNavigation:Reload",
|
||||
"WebNavigation:SetOriginAttributes",
|
||||
"WebNavigation:Stop",
|
||||
],
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
class ActorSet {
|
||||
|
|
Загрузка…
Ссылка в новой задаче