mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-06 15:58:39 +09:00
Use urlbarChangeTracker instead of userTypedClear to track address bar changes
This commit is contained in:
parent
ff4c810e26
commit
ce9848de49
2 changed files with 20 additions and 29 deletions
|
|
@ -570,6 +570,12 @@
|
|||
|
||||
const nsIWebProgressListener = Components.interfaces.nsIWebProgressListener;
|
||||
const nsIChannel = Components.interfaces.nsIChannel;
|
||||
let location, originalLocation;
|
||||
try {
|
||||
aRequest.QueryInterface(nsIChannel)
|
||||
location = aRequest.URI;
|
||||
originalLocation = aRequest.originalURI;
|
||||
} catch (ex) {}
|
||||
|
||||
if (aStateFlags & nsIWebProgressListener.STATE_START) {
|
||||
this.mRequestCount++;
|
||||
|
|
@ -588,16 +594,8 @@
|
|||
|
||||
if (aStateFlags & nsIWebProgressListener.STATE_START &&
|
||||
aStateFlags & nsIWebProgressListener.STATE_IS_NETWORK) {
|
||||
// It's okay to clear what the user typed when we start
|
||||
// loading a document. If the user types, this counter gets
|
||||
// set to zero, if the document load ends without an
|
||||
// onLocationChange, this counter gets decremented
|
||||
// (so we keep it while switching tabs after failed loads)
|
||||
// We need to add 2 because loadURIWithFlags may have
|
||||
// cancelled a pending load which would have cleared
|
||||
// its anchor scroll detection temporary increment.
|
||||
if (aWebProgress.isTopLevel)
|
||||
this.mBrowser.userTypedClear += 2;
|
||||
this.mBrowser.urlbarChangeTracker.startedLoad();
|
||||
|
||||
if (this._shouldShowProgress(aRequest)) {
|
||||
if (!(aStateFlags & nsIWebProgressListener.STATE_RESTORING)) {
|
||||
|
|
@ -625,8 +623,8 @@
|
|||
this.mTab.removeAttribute("progress");
|
||||
|
||||
if (aWebProgress.isTopLevel) {
|
||||
if (!Components.isSuccessCode(aStatus) &&
|
||||
!isTabEmpty(this.mTab)) {
|
||||
let isSuccessful = Components.isSuccessCode(aStatus);
|
||||
if (!isSuccessful && !isTabEmpty(this.mTab)) {
|
||||
// Restore the current document's location in case the
|
||||
// request was stopped (possibly from a content script)
|
||||
// before the location changed.
|
||||
|
|
@ -635,14 +633,8 @@
|
|||
|
||||
if (this.mTab.selected && gURLBar)
|
||||
URLBarSetURI();
|
||||
} else {
|
||||
// The document is done loading, we no longer want the
|
||||
// value cleared.
|
||||
|
||||
if (this.mBrowser.userTypedClear > 1)
|
||||
this.mBrowser.userTypedClear -= 2;
|
||||
else if (this.mBrowser.userTypedClear > 0)
|
||||
this.mBrowser.userTypedClear--;
|
||||
} else if (isSuccessful) {
|
||||
this.mBrowser.urlbarChangeTracker.finishedLoad();
|
||||
}
|
||||
|
||||
if (!this.mBrowser.mIconURL)
|
||||
|
|
@ -652,8 +644,6 @@
|
|||
if (this.mBlank)
|
||||
this.mBlank = false;
|
||||
|
||||
var location = aRequest.QueryInterface(nsIChannel).URI;
|
||||
|
||||
// For keyword URIs clear the user typed value since they will be changed into real URIs
|
||||
if (location.scheme == "keyword")
|
||||
this.mBrowser.userTypedValue = null;
|
||||
|
|
@ -696,13 +686,12 @@
|
|||
let topLevel = aWebProgress.isTopLevel;
|
||||
|
||||
if (topLevel) {
|
||||
// If userTypedClear > 0, the document loaded correctly and we should be
|
||||
// clearing the user typed value. We also need to clear the typed value
|
||||
// We need to clear the typed value
|
||||
// if the document failed to load, to make sure the urlbar reflects the
|
||||
// failed URI (particularly for SSL errors). However, don't clear the value
|
||||
// if the error page's URI is about:blank, because that causes complete
|
||||
// loss of urlbar contents for invalid URI errors (see bug 867957).
|
||||
if (this.mBrowser.userTypedClear > 0 ||
|
||||
if (this.mBrowser.didStartLoadSinceLastUserTyping() ||
|
||||
((aFlags & Ci.nsIWebProgressListener.LOCATION_CHANGE_ERROR_PAGE) &&
|
||||
aLocation.spec != "about:blank"))
|
||||
this.mBrowser.userTypedValue = null;
|
||||
|
|
@ -3027,10 +3016,6 @@
|
|||
]]></body>
|
||||
</method>
|
||||
|
||||
<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;"/>
|
||||
|
|
|
|||
|
|
@ -1951,7 +1951,13 @@ var SessionStoreInternal = {
|
|||
// userTypedValue.
|
||||
if (browser.userTypedValue) {
|
||||
tabData.userTypedValue = browser.userTypedValue;
|
||||
tabData.userTypedClear = browser.userTypedClear;
|
||||
// We always used to keep track of the loading state as an integer, where
|
||||
// '0' indicated the user had typed since the last load (or no load was
|
||||
// ongoing), and any positive value indicated we had started a load since
|
||||
// the last time the user typed in the URL bar. Mimic this to keep the
|
||||
// session store representation in sync, even though we now represent this
|
||||
// more explicitly:
|
||||
tabData.userTypedClear = browser.didStartLoadSinceLastUserTyping() ? 1 : 0;
|
||||
} else {
|
||||
delete tabData.userTypedValue;
|
||||
delete tabData.userTypedClear;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue