[f10s] Remove isRootWindow and use currentInnerWindowId instead [r=mfinkle]

This commit is contained in:
Vivien Nicolas 2010-06-09 22:07:32 +02:00
parent fe3f292da7
commit 22ab6bbb0c
3 changed files with 137 additions and 36 deletions

View File

@ -17,53 +17,53 @@ let WebProgressListener = {
notifyFlags |= Ci.nsIWebProgress.NOTIFY_STATE_WINDOW;
let json = {
isRootWindow: aWebProgress.DOMWindow == content,
windowId: aWebProgress.DOMWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils).currentInnerWindowID,
stateFlags: aStateFlags,
status: aStatus,
notifyFlags: notifyFlags
};
sendAsyncMessage("WebProgress:StateChange", json);
sendSyncMessage("WebProgress:StateChange", json);
},
onProgressChange: function onProgressChange(aWebProgress, aRequest, aCurSelf, aMaxSelf, aCurTotal, aMaxTotal) {
let json = {
isRootWindow: aWebProgress.DOMWindow == content,
windowId: aWebProgress.DOMWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils).currentInnerWindowID,
curSelf: aCurSelf,
maxSelf: aMaxSelf,
curTotal: aCurTotal,
maxTotal: aMaxTotal
};
sendAsyncMessage("WebProgress:ProgressChange", json);
sendSyncMessage("WebProgress:ProgressChange", json);
},
onLocationChange: function onLocationChange(aWebProgress, aRequest, aLocationURI) {
let location = aLocationURI ? aLocationURI.spec : "";
let json = {
isRootWindow: aWebProgress.DOMWindow == content,
windowId: aWebProgress.DOMWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils).currentInnerWindowID,
documentURI: aWebProgress.DOMWindow.document.documentURIObject.spec,
location: location,
canGoBack: docShell.canGoBack,
canGoForward: docShell.canGoForward
};
sendAsyncMessage("WebProgress:LocationChange", json);
sendSyncMessage("WebProgress:LocationChange", json);
},
onStatusChange: function onStatusChange(aWebProgress, aRequest, aStatus, aMessage) {
let json = {
isRootWindow: aWebProgress.DOMWindow == content,
windowId: aWebProgress.DOMWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils).currentInnerWindowID,
status: aStatus,
message: aMessage
};
sendAsyncMessage("WebProgress:StatusChange", json);
sendSyncMessage("WebProgress:StatusChange", json);
},
onSecurityChange: function onSecurityChange(aWebProgress, aRequest, aState) {
let json = {
isRootWindow: aWebProgress.DOMWindow == content,
windowId: aWebProgress.DOMWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils).currentInnerWindowID,
identity: this._getIdentityData(),
state: aState
};
sendAsyncMessage("WebProgress:SecurityChange", json);
sendSyncMessage("WebProgress:SecurityChange", json);
},
QueryInterface: function QueryInterface(aIID) {
@ -211,7 +211,7 @@ let DOMEvents = {
if (document.documentURIObject.spec == "about:blank")
return;
sendAsyncMessage("DOMContentLoaded", { });
sendSyncMessage("DOMContentLoaded", { });
break;
case "pageshow":
@ -224,7 +224,7 @@ let DOMEvents = {
persisted: aEvent.persisted
};
sendAsyncMessage(aEvent.type, json);
sendSyncMessage(aEvent.type, json);
break;
}
@ -241,12 +241,12 @@ let DOMEvents = {
popupWindowName: aEvent.popupWindowName
};
sendAsyncMessage("DOMPopupBlocked", json);
sendSyncMessage("DOMPopupBlocked", json);
break;
}
case "DOMTitleChanged":
sendAsyncMessage("DOMTitleChanged", { title: document.title });
sendSyncMessage("DOMTitleChanged", { title: document.title });
break;
case "DOMLinkAdded":
@ -263,7 +263,7 @@ let DOMEvents = {
type: target.type
};
sendAsyncMessage("DOMLinkAdded", json);
sendSyncMessage("DOMLinkAdded", json);
break;
case "DOMWillOpenModalDialog":

View File

@ -62,6 +62,8 @@
onget="return gIOService.newURI(this._documentURI, null, null)"
readonly="true"/>
<field name="contentWindowId">null</field>
<property name="messageManager"
onget="return this.QueryInterface(Components.interfaces.nsIFrameLoaderOwner).frameLoader.messageManager;"
readonly="true"/>
@ -142,30 +144,132 @@
<field name="_webProgress"><![CDATA[
({
_listeners: [],
_browser: this,
// We only need the onLocationChange for the local-browser and we don't need
// to support holding listeners and firing notifications.
_init: function() {
this._browser.messageManager.addMessageListener("WebProgress:StateChange", this);
this._browser.messageManager.addMessageListener("WebProgress:ProgressChange", this);
this._browser.messageManager.addMessageListener("WebProgress:LocationChange", this);
this._browser.messageManager.addMessageListener("WebProgress:StatusChange", this);
this._browser.messageManager.addMessageListener("WebProgress:SecurityChange", this);
},
addProgressListener: function(aListener, aNotifyFlags) {
function hasFilter(item) {
return item.listener == aListener;
}
if (this._listeners.some(hasFilter))
return;
this._listeners.push({
listener: aListener,
flags: aNotifyFlags
});
},
removeProgressListener: function(aListener) {
function hasFilter(item) {
return item.listener != aListener;
}
this._listeners = this._listeners.filter(hasFilter);
},
get DOMWindow() { throw "DOMWindow: Not Remoteable" },
get isLoadingDocument() { throw "isLoadingDocument: Not Remoteable"; },
receiveMessage: function(aMessage) {
let args;
let json = aMessage.json;
switch (aMessage.name) {
case "WebProgress:StateChange":
args = [
{ windowId: json.windowId, browser: this._browser },
{},
json.stateFlags,
json.status
];
this._notify(json.notifyFlags, "onStateChange", args);
break;
case "WebProgress:ProgressChange":
args = [
{ windowId: json.windowId, browser: this._browser },
{},
json.curSelf,
json.maxSelf,
json.curTotal,
json.maxTotal
];
this._notify(Components.interfaces.nsIWebProgress.NOTIFY_PROGRESS,
"onProgressChange",
args);
break;
case "WebProgress:LocationChange":
if (json.isRootWindow) {
let locationURI = this._browser._ios.newURI(json.location, null, null);
args = [
{ windowId: json.windowId, browser: this._browser },
{},
locationURI
];
if (this._browser.contentWindowId != json.windowId) {
this._browser.contentWindowId = json.windowId;
this._browser._documentURI = json.documentURI;
this._browser._searchEngines = [];
}
this._notify(Components.interfaces.nsIWebProgress.NOTIFY_LOCATION,
"onLocationChange",
args);
break;
case "WebProgress:StatusChange":
args = [
{ windowId: json.windowId, browser: this._browser },
{},
json.status,
json.message
];
this._notify(Components.interfaces.nsIWebProgress.NOTIFY_STATUS,
"onStatusChange",
args);
break;
case "WebProgress:SecurityChange":
args = [
{ windowId: json.windowId, browser: this._browser, identity: json.identity },
{},
json.state
];
this._notify(Components.interfaces.nsIWebProgress.NOTIFY_SECURITY,
"onSecurityChange",
args);
break;
}
return {};
},
_notify: function(aFlags, aName, aArguments) {
this._listeners.forEach(function(item) {
if (item.flags & aFlags) {
item.listener[aName].apply(item.listener, aArguments);
}
});
}
})
]]></field>
<property name="webProgress"
readonly="true"
onget="return this._webProgress"/>
<method name="onPageShow">
<parameter name="aMessage"/>
<body>
@ -377,10 +481,10 @@
function hasFilter(item) {
return item.listener == aListener;
}
if (this._listeners.some(hasFilter))
return;
this._listeners.push({
listener: aListener,
flags: aNotifyFlags
@ -395,7 +499,7 @@
this._listeners = this._listeners.filter(hasFilter);
},
get DOMWindow() { throw "DOMWindow: Not Remoteable" },
isLoadingDocument: false,
get isLoadingDocument() { throw "isLoadingDocument: Not Remoteable"; },
receiveMessage: function(aMessage) {
let args;
@ -403,7 +507,7 @@
switch (aMessage.name) {
case "WebProgress:StateChange":
args = [
{ isRootWindow: json.isRootWindow, browser: this._browser },
{ windowId: json.windowId, browser: this._browser },
{},
json.stateFlags,
json.status
@ -414,7 +518,7 @@
case "WebProgress:ProgressChange":
args = [
{ isRootWindow: json.isRootWindow, browser: this._browser },
{ windowId: json.windowId, browser: this._browser },
{},
json.curSelf,
json.maxSelf,
@ -427,18 +531,19 @@
break;
case "WebProgress:LocationChange":
let currentURI = this._browser._ios.newURI(json.location, null, null);
this._browser._webNavigation._currentURI = currentURI;
let locationURI = this._browser._ios.newURI(json.location, null, null);
this._browser._webNavigation._currentURI = locationURI;
this._browser._webNavigation.canGoBack = json.canGoBack;
this._browser._webNavigation.canGoForward = json.canGoForward;
args = [
{ isRootWindow: json.isRootWindow, browser: this._browser },
{ windowId: json.windowId, browser: this._browser },
{},
currentURI
locationURI
];
if (json.isRootWindow) {
if (this._browser.contentWindowId != json.windowId) {
this._browser.contentWindowId = json.windowId;
this._browser._documentURI = json.documentURI;
this._browser._searchEngines = [];
}
@ -451,7 +556,7 @@
case "WebProgress:StatusChange":
args = [
{ isRootWindow: json.isRootWindow, browser: this._browser },
{ windowId: json.windowId, browser: this._browser },
{},
json.status,
json.message
@ -463,7 +568,7 @@
case "WebProgress:SecurityChange":
args = [
{ isRootWindow: json.isRootWindow, browser: this._browser, identity: json.identity },
{ windowId: json.windowId, browser: this._browser, identity: json.identity },
{},
json.state
];
@ -485,10 +590,6 @@
})
]]></field>
<property name="webProgress"
readonly="true"
onget="return this._webProgress"/>
<property name="contentWindow"
readonly="true"
onget="throw 'Not Remoteable'"/>

View File

@ -2715,7 +2715,7 @@ ProgressController.prototype = {
onStateChange: function onStateChange(aWebProgress, aRequest, aStateFlags, aStatus) {
// ignore notification that aren't about the main document (iframes, etc)
if (aWebProgress.DOMWindow != this._tab.browser.contentWindow)
if (aWebProgress.windowId != this._tab.browser.contentWindowId && this._tab.browser.contentWindowId)
return;
// If you want to observe other state flags, be sure they're listed in the
@ -2748,7 +2748,7 @@ ProgressController.prototype = {
/** This method is called to indicate a change to the current location. */
onLocationChange: function onLocationChange(aWebProgress, aRequest, aLocationURI) {
// ignore notification that aren't about the main document (iframes, etc)
if (aWebProgress.DOMWindow != this._tab.browser.contentWindow)
if (aWebProgress.windowId != this._tab.browser.contentWindowId)
return;
let spec = aLocationURI ? aLocationURI.spec : "";