Bug 1355542 - [1.1] Respect filter mask in remote web progress notification dispatching. r=felipe

This commit is contained in:
Eugen Sawin 2017-04-11 23:17:31 +02:00
parent 4a9976e555
commit dcad97fb02

View File

@ -62,8 +62,8 @@ RemoteWebProgress.prototype = {
get isTopLevel() { return this._isTopLevel },
get loadType() { return this._loadType; },
addProgressListener(aListener) {
this._manager.addProgressListener(aListener);
addProgressListener(aListener, aNotifyMask) {
this._manager.addProgressListener(aListener, aNotifyMask);
},
removeProgressListener(aListener) {
@ -132,14 +132,17 @@ RemoteWebProgressManager.prototype = {
return this._topLevelWebProgress;
},
addProgressListener(aListener) {
addProgressListener(aListener, aNotifyMask) {
let listener = aListener.QueryInterface(Ci.nsIWebProgressListener);
this._progressListeners.push(listener);
this._progressListeners.push({
listener,
mask: aNotifyMask || Ci.nsIWebProgress.NOTIFY_ALL
});
},
removeProgressListener(aListener) {
this._progressListeners =
this._progressListeners.filter(l => l != aListener);
this._progressListeners.filter(l => l.listener != aListener);
},
_fixSSLStatusAndState(aStatus, aState) {
@ -162,16 +165,18 @@ RemoteWebProgressManager.prototype = {
remoteWebNav._currentURI = aURI;
let webProgress = this.topLevelWebProgress;
for (let p of this._progressListeners) {
p.onLocationChange(webProgress, null, aURI);
for (let { listener, mask } of this._progressListeners) {
if (mask & Ci.nsIWebProgress.NOTIFY_LOCATION) {
listener.onLocationChange(webProgress, null, aURI);
}
}
},
_callProgressListeners(methodName, ...args) {
for (let p of this._progressListeners) {
if (p[methodName]) {
_callProgressListeners(type, methodName, ...args) {
for (let { listener, mask } of this._progressListeners) {
if ((mask & type) && listener[methodName]) {
try {
p[methodName].apply(p, args);
listener[methodName].apply(listener, args);
} catch (ex) {
Cu.reportError("RemoteWebProgress failed to call " + methodName + ": " + ex + "\n");
}
@ -232,7 +237,10 @@ RemoteWebProgressManager.prototype = {
if (isTopLevel) {
this._browser._documentURI = newURI(json.documentURI);
}
this._callProgressListeners("onStateChange", webProgress, request, json.stateFlags, json.status);
this._callProgressListeners(
Ci.nsIWebProgress.NOTIFY_STATE_ALL, "onStateChange", webProgress,
request, json.stateFlags, json.status
);
break;
case "Content:LocationChange":
@ -254,7 +262,10 @@ RemoteWebProgressManager.prototype = {
this._browser._innerWindowID = json.innerWindowID;
}
this._callProgressListeners("onLocationChange", webProgress, request, location, flags);
this._callProgressListeners(
Ci.nsIWebProgress.NOTIFY_LOCATION, "onLocationChange", webProgress,
request, location, flags
);
break;
case "Content:SecurityChange":
@ -268,15 +279,24 @@ RemoteWebProgressManager.prototype = {
this._browser._securityUI._update(status, state);
}
this._callProgressListeners("onSecurityChange", webProgress, request, state);
this._callProgressListeners(
Ci.nsIWebProgress.NOTIFY_SECURITY, "onSecurityChange", webProgress,
request, state
);
break;
case "Content:StatusChange":
this._callProgressListeners("onStatusChange", webProgress, request, json.status, json.message);
this._callProgressListeners(
Ci.nsIWebProgress.NOTIFY_STATUS, "onStatusChange", webProgress, request,
json.status, json.message
);
break;
case "Content:ProgressChange":
this._callProgressListeners("onProgressChange", webProgress, request, json.curSelf, json.maxSelf, json.curTotal, json.maxTotal);
this._callProgressListeners(
Ci.nsIWebProgress.NOTIFY_PROGRESS, "onProgressChange", webProgress,
request, json.curSelf, json.maxSelf, json.curTotal, json.maxTotal
);
break;
}
},