summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMoonchild <mcwerewolf@gmail.com>2018-04-28 16:23:20 +0200
committerGitHub <noreply@github.com>2018-04-28 16:23:20 +0200
commitde057c7a5635e65f45ce47162d226b1ddf24e8aa (patch)
tree6572ebe84892595d3a94b22d73152328cf65d39b
parentbddefd4211ea893df4a5a86d40d4a16b608f42fc (diff)
parentfd10ee105af74c5559c0021c2ada0997e943ac87 (diff)
downloadUXP-de057c7a5635e65f45ce47162d226b1ddf24e8aa.tar
UXP-de057c7a5635e65f45ce47162d226b1ddf24e8aa.tar.gz
UXP-de057c7a5635e65f45ce47162d226b1ddf24e8aa.tar.lz
UXP-de057c7a5635e65f45ce47162d226b1ddf24e8aa.tar.xz
UXP-de057c7a5635e65f45ce47162d226b1ddf24e8aa.zip
Merge pull request #282 from JustOff/PR_urlbarChangeTracker
[PALEMOON] Use `urlbarChangeTracker` instead of `userTypedClear` to track address bar changes
-rw-r--r--application/palemoon/base/content/tabbrowser.xml41
-rw-r--r--application/palemoon/components/sessionstore/SessionStore.jsm8
2 files changed, 20 insertions, 29 deletions
diff --git a/application/palemoon/base/content/tabbrowser.xml b/application/palemoon/base/content/tabbrowser.xml
index 14bd99619..c06b49af0 100644
--- a/application/palemoon/base/content/tabbrowser.xml
+++ b/application/palemoon/base/content/tabbrowser.xml
@@ -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;"/>
diff --git a/application/palemoon/components/sessionstore/SessionStore.jsm b/application/palemoon/components/sessionstore/SessionStore.jsm
index f7c495be8..b8d126e21 100644
--- a/application/palemoon/components/sessionstore/SessionStore.jsm
+++ b/application/palemoon/components/sessionstore/SessionStore.jsm
@@ -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;