From febfae1f78d641bbca92796080bf54e4517d991b Mon Sep 17 00:00:00 2001 From: "gavin%gavinsharp.com" Date: Thu, 23 Mar 2006 03:31:18 +0000 Subject: [PATCH] =?UTF-8?q?Bug=20327604:=20Status=20bar=20message=20text?= =?UTF-8?q?=20persists=20when=20switching=20tabs=20while=20page=20is=20loa?= =?UTF-8?q?ding,=20patch=20by=20Simon=20B=C3=BCnzli=20,?= =?UTF-8?q?=20r+a=3Dmconnor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: svn://10.0.0.236/branches/MOZILLA_1_8_BRANCH@192831 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/browser/base/content/browser.js | 32 ++++++++++++++----- .../toolkit/content/widgets/tabbrowser.xml | 27 ++++++++++++++++ 2 files changed, 51 insertions(+), 8 deletions(-) diff --git a/mozilla/browser/base/content/browser.js b/mozilla/browser/base/content/browser.js index ee50afcadb8..1cedeb0ffa4 100644 --- a/mozilla/browser/base/content/browser.js +++ b/mozilla/browser/base/content/browser.js @@ -3412,14 +3412,9 @@ nsBrowserStatusHandler.prototype = // 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 (channel) { - var location = channel.URI; + // Get the URI either from a channel or a pseudo-object + if (aRequest instanceof nsIChannel || "URI" in aRequest) { + var location = aRequest.URI; // For keyword URIs clear the user typed value since they will be changed into real URIs if (location.scheme == "keyword" && aWebProgress.DOMWindow == content) @@ -3643,6 +3638,27 @@ nsBrowserStatusHandler.prototype = lockIcon.setAttribute("tooltiptext", securityUI.tooltipText); }, + // simulate all change notifications after switching tabs + onUpdateCurrentBrowser : function(aStateFlags, aStatus, aMessage, aTotalProgress) + { + var nsIWebProgressListener = Components.interfaces.nsIWebProgressListener; + var loadingDone = aStateFlags & nsIWebProgressListener.STATE_STOP; + // use a pseudo-object instead of a (potentially non-existing) channel for getting + // a correct error message - and make sure that the UI is always either in + // loading (STATE_START) or done (STATE_STOP) mode + this.onStateChange( + gBrowser.webProgress, + { URI: gBrowser.currentURI }, + loadingDone ? nsIWebProgressListener.STATE_STOP : nsIWebProgressListener.STATE_START, + aStatus + ); + // status message and progress value are undefined if we're done with loading + if (loadingDone) + return; + this.onStatusChange(gBrowser.webProgress, null, 0, aMessage); + this.onProgressChange(gBrowser.webProgress, 0, 0, aTotalProgress, 1); + }, + startDocumentLoad : function(aRequest) { // It's okay to clear what the user typed when we start diff --git a/mozilla/toolkit/content/widgets/tabbrowser.xml b/mozilla/toolkit/content/widgets/tabbrowser.xml index edf148ee3a0..0a1a4645ed4 100644 --- a/mozilla/toolkit/content/widgets/tabbrowser.xml +++ b/mozilla/toolkit/content/widgets/tabbrowser.xml @@ -295,6 +295,12 @@ mBlank: aStartsBlank, mLastURI: null, + // cache flags for correct status bar update after tab switching + mStateFlags: 0, + mStatus: 0, + mMessage: "", + mTotalProgress: 0, + onProgressChange : function (aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress) @@ -308,6 +314,8 @@ aCurTotalProgress, aMaxTotalProgress); } } + + this.mTotalProgress = aMaxTotalProgress ? aCurTotalProgress / aMaxTotalProgress : 0; }, onStateChange : function(aWebProgress, aRequest, aStateFlags, aStatus) @@ -377,6 +385,15 @@ p.onStateChange(aWebProgress, aRequest, aStateFlags, aStatus); } } + + if (aStateFlags & (nsIWebProgressListener.STATE_START | + nsIWebProgressListener.STATE_STOP)) { + // reset cached temporary values at beginning and end + this.mMessage = ""; + this.mTotalProgress = 0; + } + this.mStateFlags = aStateFlags; + this.mStatus = aStatus; }, onLocationChange : function(aWebProgress, aRequest, aLocation) @@ -410,6 +427,8 @@ p.onStatusChange(aWebProgress, aRequest, aStatus, aMessage); } } + + this.mMessage = aMessage; }, onSecurityChange : function(aWebProgress, aRequest, aState) @@ -694,6 +713,14 @@ p.onLocationChange(webProgress, null, loc); if (securityUI) p.onSecurityChange(webProgress, null, securityUI.state); + + // make sure that all status indicators are properly updated + if ("onUpdateCurrentBrowser" in p) { + var listener = this.mTabListeners[this.mTabContainer.selectedIndex] || null; + if (listener && listener.mStateFlags) + p.onUpdateCurrentBrowser(listener.mStateFlags, listener.mStatus, + listener.mMessage, listener.mTotalProgress); + } } }