Bug 868859 - Use CPOWs to pass browser.contentWindow and webProgress.DOMWindow in e10s. r=felipe

This commit is contained in:
Tom Schuster 2013-07-17 09:27:49 -04:00
parent 4c1eac10e2
commit 724e96453f
3 changed files with 36 additions and 5 deletions

View File

@ -29,12 +29,24 @@ let WebProgressListener = {
};
},
_setupObjects: function setupObjects(aWebProgress) {
let win = docShell.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindow);
return {
contentWindow: win,
// DOMWindow is not necessarily the content-window with subframes.
DOMWindow: aWebProgress.DOMWindow
};
},
onStateChange: function onStateChange(aWebProgress, aRequest, aStateFlags, aStatus) {
let json = this._setupJSON(aWebProgress, aRequest);
let objects = this._setupObjects(aWebProgress);
json.stateFlags = aStateFlags;
json.status = aStatus;
sendAsyncMessage("Content:StateChange", json);
sendAsyncMessage("Content:StateChange", json, objects);
},
onProgressChange: function onProgressChange(aWebProgress, aRequest, aCurSelf, aMaxSelf, aCurTotal, aMaxTotal) {
@ -45,29 +57,35 @@ let WebProgressListener = {
let charset = content.document.characterSet;
let json = this._setupJSON(aWebProgress, aRequest);
let objects = this._setupObjects(aWebProgress);
json.documentURI = aWebProgress.DOMWindow.document.documentURIObject.spec;
json.location = spec;
json.canGoBack = docShell.canGoBack;
json.canGoForward = docShell.canGoForward;
json.charset = charset.toString();
sendAsyncMessage("Content:LocationChange", json);
sendAsyncMessage("Content:LocationChange", json, objects);
},
onStatusChange: function onStatusChange(aWebProgress, aRequest, aStatus, aMessage) {
let json = this._setupJSON(aWebProgress, aRequest);
let objects = this._setupObjects(aWebProgress);
json.status = aStatus;
json.message = aMessage;
sendAsyncMessage("Content:StatusChange", json);
sendAsyncMessage("Content:StatusChange", json, objects);
},
onSecurityChange: function onSecurityChange(aWebProgress, aRequest, aState) {
let json = this._setupJSON(aWebProgress, aRequest);
let objects = this._setupObjects(aWebProgress);
json.state = aState;
json.status = SecurityUI.getSSLStatusAsString();
sendAsyncMessage("Content:SecurityChange", json);
sendAsyncMessage("Content:SecurityChange", json, objects);
},
QueryInterface: function QueryInterface(aIID) {

View File

@ -62,6 +62,16 @@
onget="return this._characterSet"
readonly="true"/>
<field name="_contentWindow">null</field>
<property name="contentWindow"
onget="return this._contentWindow"
readonly="true"/>
<property name="contentDocument"
onget="return this.contentWindow ? this.contentWindow.document : null"
readonly="true"/>
<constructor>
<![CDATA[
this.messageManager.addMessageListener("DOMTitleChanged", this);

View File

@ -27,6 +27,7 @@ function RemoteWebProgress(browser)
{
this._browser = browser;
this._isDocumentLoading = false;
this._DOMWindow = null;
this._isTopLevel = true;
this._progressListeners = [];
}
@ -60,7 +61,7 @@ RemoteWebProgress.prototype = {
},
get isLoadingDocument() { return this._isDocumentLoading },
get DOMWindow() { return null; },
get DOMWindow() { return this._DOMWindow; },
get DOMWindowID() { return 0; },
get isTopLevel() { return this._isTopLevel; },
@ -81,7 +82,9 @@ RemoteWebProgress.prototype = {
},
receiveMessage: function WP_ReceiveMessage(aMessage) {
this._DOMWindow = aMessage.objects.DOMWindow;
this._isTopLevel = aMessage.json.isTopLevel;
this._browser._contentWindow = aMessage.objects.contentWindow;
let req = this._uriSpec(aMessage.json.requestURI);
switch (aMessage.name) {