bug 231393 - Tab URL does not persist on bad links if tabs switched, patch by pike@pikey.me.uk based on jag's patch for bug 103720, r=me

git-svn-id: svn://10.0.0.236/trunk@159761 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
mconnor%myrealbox.com
2004-07-24 00:24:30 +00:00
parent 78dbef1d99
commit a3c433242e
3 changed files with 53 additions and 4 deletions

View File

@@ -2515,6 +2515,10 @@ nsBrowserStatusHandler.prototype =
var browser = getBrowser().selectedBrowser;
if (aWebProgress.DOMWindow == content) {
// The document loaded correctly, clear the value if we should
if (browser.userTypedClear)
browser.userTypedValue = null;
//XXXBlake don't we have to reinit this.urlBar, etc.
// when the toolbar changes?
var userTypedValue = browser.userTypedValue;
@@ -4358,6 +4362,14 @@ function stylesheetSwitchAll(frameset, title) {
function updatePageTheme(evt)
{
// XXX - Accessing window._content.document can generate an
// onLocationChange for the current tab, this can cause the url
// bar to be cleared. Prevent that happening by setting the clear
// state to false for the duration of this function.
var browser = getBrowser().selectedBrowser;
var userTypedClear = browser.userTypedClear;
browser.userTypedClear = false;
if (!gPageThemeButton)
gPageThemeButton = document.getElementById("page-theme-button");
@@ -4383,6 +4395,9 @@ function updatePageTheme(evt)
}
else
gPageThemeButton.removeAttribute("themes");
// Restore clear state
browser.userTypedClear = userTypedClear;
}
/* End of the Page Theme functions */

View File

@@ -414,10 +414,18 @@
null
</field>
<field name="userTypedValue">
<field name="userTypedClear">
true
</field>
<field name="_userTypedValue">
null
</field>
<property name="userTypedValue"
onget="return this._userTypedValue;"
onset="this.userTypedClear = false; return this._userTypedValue = val;"/>
<field name="mFormFillAttached">
false
</field>

View File

@@ -194,10 +194,13 @@
if (aStateFlags & nsIWebProgressListener.STATE_START &&
aStateFlags & nsIWebProgressListener.STATE_IS_NETWORK) {
// Reset so we can see if the user typed between the document
// load starting and the location changing.
// It's okay to clear what the user typed when we start
// loading a document. If the user types, this flag gets
// set to false, if the document load ends without an
// onLocationChange, this flag also gets set to false
// (so we keep it while switching tabs after failed load
if (aWebProgress.DOMWindow == this.mBrowser.contentWindow)
this.mBrowser.userTypedValue = null;
this.mBrowser.userTypedClear = true;
if (!this.mBlank) {
this.mTab.setAttribute("busy", "true");
@@ -211,6 +214,11 @@
}
else if (aStateFlags & nsIWebProgressListener.STATE_STOP &&
aStateFlags & nsIWebProgressListener.STATE_IS_NETWORK) {
// The document is done loading, it's okay to clear
// the value again.
if (aWebProgress.DOMWindow == this.mBrowser.contentWindow)
this.mBrowser.userTypedClear = false;
if (this.mBlank)
this.mBlank = false;
@@ -242,6 +250,10 @@
,
onLocationChange : function(aWebProgress, aRequest, aLocation) {
// The document loaded correctly, clear the value if we should
if (this.mBrowser.userTypedClear)
this.mBrowser.userTypedValue = null;
if (!this.mBlank && this.mTabBrowser.mCurrentTab == this.mTab) {
for (var i = 0; i < this.mTabBrowser.mProgressListeners.length; i++) {
var p = this.mTabBrowser.mProgressListeners[i];
@@ -451,6 +463,11 @@
var webProgress = this.mCurrentBrowser.webProgress;
var securityUI = this.mCurrentBrowser.securityUI;
// Remember the current clear state, then set it to false
// so we don't clear the userTypedValue when just switching
// tabs. Set it back to its old state after we're done.
var userTypedClear = this.mCurrentBrowser.userTypedClear;
this.mCurrentBrowser.userTypedClear = false;
var i, p;
for (i = 0; i < this.mProgressListeners.length; i++) {
p = this.mProgressListeners[i];
@@ -463,6 +480,7 @@
p.onLinkIconAvailable(listener.mIcon);
}
}
this.mCurrentBrowser.userTypedClear = userTypedClear;
// Update the window title.
this.updateTitlebar();
@@ -817,6 +835,10 @@
this.mTabFilters[position] = filter;
if (!blank) {
// pretend the user typed this so it'll be available till
// the document successfully loads
b.userTypedValue = aURI;
if (aPostData === undefined)
aPostData = null;
b.loadURIWithFlags(aURI, nsIWebNavigation.LOAD_FLAGS_NONE,
@@ -1349,6 +1371,10 @@
onget="return this.mCurrentBrowser.canFindAgain;"
readonly="true"/>
<property name="userTypedClear"
onget="return this.mCurrentBrowser.userTypedClear;"
onset="return this.mCurrentBrowser.userTypedClear = val;"/>
<property name="userTypedValue"
onget="return this.mCurrentBrowser.userTypedValue;"
onset="return this.mCurrentBrowser.userTypedValue = val;"/>