зеркало из https://github.com/mozilla/gecko-dev.git
Do more filtering of onStateChange notifications in nsBrowserStatusFilter instead of in the nsBrowserStatusHandler JS code. b=168732 sr=jag r=caillon
This commit is contained in:
Родитель
1c6bf921b4
Коммит
681427e926
|
@ -207,29 +207,24 @@ nsBrowserStatusHandler.prototype =
|
|||
const nsIChannel = Components.interfaces.nsIChannel;
|
||||
var ctype;
|
||||
if (aStateFlags & nsIWebProgressListener.STATE_START) {
|
||||
// If this is a network start or the first stray request (the first
|
||||
// request outside of the document load), initialize the throbber and his
|
||||
// friends.
|
||||
if (aStateFlags & nsIWebProgressListener.STATE_IS_NETWORK ||
|
||||
(aStateFlags & nsIWebProgressListener.STATE_IS_REQUEST &&
|
||||
!aWebProgress.isLoadingDocument &&
|
||||
this.totalRequests == this.finishedRequests)) {
|
||||
// This (thanks to the filter) is a network start or the first
|
||||
// stray request (the first request outside of the document load),
|
||||
// initialize the throbber and his friends.
|
||||
|
||||
// Call start document load listeners (only if this is a network load)
|
||||
if (aStateFlags & nsIWebProgressListener.STATE_IS_NETWORK &&
|
||||
aRequest && aWebProgress.DOMWindow == content)
|
||||
this.startDocumentLoad(aRequest);
|
||||
// Call start document load listeners (only if this is a network load)
|
||||
if (aStateFlags & nsIWebProgressListener.STATE_IS_NETWORK &&
|
||||
aRequest && aWebProgress.DOMWindow == content)
|
||||
this.startDocumentLoad(aRequest);
|
||||
|
||||
// Turn the throbber on.
|
||||
this.throbberElement.setAttribute("busy", true);
|
||||
// Turn the throbber on.
|
||||
this.throbberElement.setAttribute("busy", "true");
|
||||
|
||||
// XXX: These need to be based on window activity...
|
||||
this.stopButton.disabled = false;
|
||||
this.stopMenu.removeAttribute('disabled');
|
||||
this.stopContext.removeAttribute('disabled');
|
||||
// XXX: These need to be based on window activity...
|
||||
this.stopButton.disabled = false;
|
||||
this.stopMenu.removeAttribute('disabled');
|
||||
this.stopContext.removeAttribute('disabled');
|
||||
|
||||
this.locationChanged = false;
|
||||
}
|
||||
this.locationChanged = false;
|
||||
}
|
||||
else if (aStateFlags & nsIWebProgressListener.STATE_STOP) {
|
||||
if (aStateFlags & nsIWebProgressListener.STATE_IS_NETWORK) {
|
||||
|
@ -239,71 +234,66 @@ nsBrowserStatusHandler.prototype =
|
|||
}
|
||||
}
|
||||
|
||||
// If this is a network stop or the last request stop outside of loading
|
||||
// the document, stop throbbers and progress bars and such
|
||||
if (aStateFlags & nsIWebProgressListener.STATE_IS_NETWORK ||
|
||||
(aStateFlags & nsIWebProgressListener.STATE_IS_REQUEST &&
|
||||
!aWebProgress.isLoadingDocument &&
|
||||
this.totalRequests == this.finishedRequests)) {
|
||||
// This (thanks to the filter) is a network stop or the last
|
||||
// request stop outside of loading the document, stop throbbers
|
||||
// and progress bars and such
|
||||
if (aRequest) {
|
||||
var msg = "";
|
||||
// Get the channel if the request is a channel
|
||||
var channel;
|
||||
try {
|
||||
channel = aRequest.QueryInterface(nsIChannel);
|
||||
}
|
||||
catch(e) { };
|
||||
|
||||
if (aRequest) {
|
||||
var msg = "";
|
||||
// Get the channel if the request is a channel
|
||||
var channel;
|
||||
try {
|
||||
channel = aRequest.QueryInterface(nsIChannel);
|
||||
}
|
||||
catch(e) { };
|
||||
|
||||
if (channel) {
|
||||
var location = channel.URI.spec;
|
||||
if (location != "about:blank") {
|
||||
const kErrorBindingAborted = 2152398850;
|
||||
const kErrorNetTimeout = 2152398862;
|
||||
switch (aStatus) {
|
||||
case kErrorBindingAborted:
|
||||
msg = gNavigatorBundle.getString("nv_stopped");
|
||||
break;
|
||||
case kErrorNetTimeout:
|
||||
msg = gNavigatorBundle.getString("nv_timeout");
|
||||
break;
|
||||
}
|
||||
if (channel) {
|
||||
var location = channel.URI.spec;
|
||||
if (location != "about:blank") {
|
||||
const kErrorBindingAborted = 2152398850;
|
||||
const kErrorNetTimeout = 2152398862;
|
||||
switch (aStatus) {
|
||||
case kErrorBindingAborted:
|
||||
msg = gNavigatorBundle.getString("nv_stopped");
|
||||
break;
|
||||
case kErrorNetTimeout:
|
||||
msg = gNavigatorBundle.getString("nv_timeout");
|
||||
break;
|
||||
}
|
||||
}
|
||||
// If msg is false then we did not have an error (channel may have
|
||||
// been null, in the case of a stray image load).
|
||||
if (!msg) {
|
||||
msg = gNavigatorBundle.getString("nv_done");
|
||||
}
|
||||
this.status = "";
|
||||
this.setDefaultStatus(msg);
|
||||
|
||||
//if the location hasn't been changed, the document may be null(eg a full-page plugin),
|
||||
//we may not be able to get the correct content-type.
|
||||
//so we need to skip the test and keep the menu status.
|
||||
//otherwise(this.locationChanged = true), test normally.
|
||||
if (channel && this.locationChanged) {
|
||||
try {
|
||||
ctype = channel.contentType;
|
||||
if (this.mimeTypeIsTextBased(ctype))
|
||||
this.isImage.removeAttribute('disabled');
|
||||
else
|
||||
this.isImage.setAttribute('disabled', 'true');
|
||||
}
|
||||
catch (e) {}
|
||||
}
|
||||
}
|
||||
|
||||
// Turn the progress meter and throbber off.
|
||||
this.statusMeter.value = 0; // be sure to clear the progress bar
|
||||
this.throbberElement.removeAttribute("busy");
|
||||
|
||||
// XXX: These need to be based on window activity...
|
||||
// XXXjag: <command id="cmd_stop"/> ?
|
||||
this.stopButton.disabled = true;
|
||||
this.stopMenu.setAttribute('disabled', 'true');
|
||||
this.stopContext.setAttribute('disabled', 'true');
|
||||
// If msg is false then we did not have an error (channel may have
|
||||
// been null, in the case of a stray image load).
|
||||
if (!msg) {
|
||||
msg = gNavigatorBundle.getString("nv_done");
|
||||
}
|
||||
this.status = "";
|
||||
this.setDefaultStatus(msg);
|
||||
|
||||
//if the location hasn't been changed, the document may be null(eg a full-page plugin),
|
||||
//we may not be able to get the correct content-type.
|
||||
//so we need to skip the test and keep the menu status.
|
||||
//otherwise(this.locationChanged = true), test normally.
|
||||
if (channel && this.locationChanged) {
|
||||
try {
|
||||
ctype = channel.contentType;
|
||||
if (this.mimeTypeIsTextBased(ctype))
|
||||
this.isImage.removeAttribute('disabled');
|
||||
else
|
||||
this.isImage.setAttribute('disabled', 'true');
|
||||
}
|
||||
catch (e) {}
|
||||
}
|
||||
}
|
||||
|
||||
// Turn the progress meter and throbber off.
|
||||
this.statusMeter.value = 0; // be sure to clear the progress bar
|
||||
this.throbberElement.removeAttribute("busy");
|
||||
|
||||
// XXX: These need to be based on window activity...
|
||||
// XXXjag: <command id="cmd_stop"/> ?
|
||||
this.stopButton.disabled = true;
|
||||
this.stopMenu.setAttribute('disabled', 'true');
|
||||
this.stopContext.setAttribute('disabled', 'true');
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -164,10 +164,24 @@ nsBrowserStatusFilter::OnStateChange(nsIWebProgress *aWebProgress,
|
|||
return OnProgressChange(nsnull, nsnull, 0, 0, mFinishedRequests, mTotalRequests);
|
||||
}
|
||||
|
||||
// no need to forward this state change
|
||||
return NS_OK;
|
||||
} else {
|
||||
// no need to forward this state change
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// If we're here, we have either STATE_START or STATE_STOP. The
|
||||
// listener only cares about these in certain conditions.
|
||||
PRBool isLoadingDocument = PR_FALSE;
|
||||
if (! (aStateFlags & nsIWebProgressListener::STATE_IS_NETWORK ||
|
||||
(aStateFlags & nsIWebProgressListener::STATE_IS_REQUEST &&
|
||||
mTotalRequests == mFinishedRequests &&
|
||||
(aWebProgress->GetIsLoadingDocument(&isLoadingDocument),
|
||||
!isLoadingDocument))))
|
||||
return NS_OK;
|
||||
|
||||
|
||||
return mListener->OnStateChange(aWebProgress, aRequest, aStateFlags, aStatus);
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче