Bug 1474179 - Part 1: Removes browser.urlbar.decodeURLsOnCopy, and always lets "copy" menuitem copy the Unicode URL, if any. r?valentin draft
authorZhang Junzhi <zjz@zjz.name>
Thu, 12 Jul 2018 20:53:32 +0800
changeset 817380 5d8b3e628db7aa62a498f1b27c08f327e57c81c0
parent 817076 3aca103e49150145dbff910be15e7886b7c4495a
child 817381 263ab29e962de647d2b2779f2a1847e9d2ba705b
push id116050
push userbmo:zjz@zjz.name
push dateThu, 12 Jul 2018 16:06:02 +0000
reviewersvalentin
bugs1474179
milestone63.0a1
Bug 1474179 - Part 1: Removes browser.urlbar.decodeURLsOnCopy, and always lets "copy" menuitem copy the Unicode URL, if any. r?valentin MozReview-Commit-ID: 5XaKojLo7jp
browser/app/profile/firefox.js
browser/base/content/urlbarBindings.xml
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -326,20 +326,16 @@ pref("browser.urlbar.maxCharsForSearchSu
 // Typed suggestion works only if history is set to true.
 pref("browser.urlbar.suggest.history.onlyTyped",    false);
 
 pref("browser.urlbar.formatting.enabled", true);
 pref("browser.urlbar.trimURLs", true);
 
 pref("browser.urlbar.oneOffSearches", true);
 
-// If changed to true, copying the entire URL from the location bar will put the
-// human readable (percent-decoded) URL on the clipboard.
-pref("browser.urlbar.decodeURLsOnCopy", false);
-
 // Whether or not to move tabs into the active window when using the "Switch to
 // Tab" feature of the awesomebar.
 pref("browser.urlbar.switchTabs.adoptIntoActiveWindow", false);
 
 // Whether addresses and search results typed into the address bar
 // should be opened in new tabs by default.
 pref("browser.urlbar.openintab", false);
 
--- a/browser/base/content/urlbarBindings.xml
+++ b/browser/base/content/urlbarBindings.xml
@@ -1128,44 +1128,31 @@ file, You can obtain one at http://mozil
               return selectedVal;
           }
 
           // If the value was filled by a search suggestion, just return it.
           let action = this._parseActionUrl(this.value);
           if (action && action.type == "searchengine")
             return selectedVal;
 
-          let uriFixup = Cc["@mozilla.org/docshell/urifixup;1"].getService(Ci.nsIURIFixup);
-
           let uri;
           if (this.getAttribute("pageproxystate") == "valid") {
             uri = gBrowser.currentURI;
           } else {
             // We're dealing with an autocompleted value, create a new URI from that.
             try {
+              let uriFixup = Cc["@mozilla.org/docshell/urifixup;1"].getService(Ci.nsIURIFixup);
               uri = uriFixup.createFixupURI(inputVal, Ci.nsIURIFixup.FIXUP_FLAG_NONE);
             } catch (e) {}
             if (!uri)
               return selectedVal;
           }
 
-          uri = this.makeURIReadable(uri);
-
-          // If the entire URL is selected, just use the actual loaded URI,
-          // unless we want a decoded URI, or it's a data: or javascript: URI,
-          // since those are hard to read when encoded.
-          if (inputVal == selectedVal &&
-              !uri.schemeIs("javascript") && !uri.schemeIs("data") &&
-              !Services.prefs.getBoolPref("browser.urlbar.decodeURLsOnCopy")) {
-            return uri.displaySpec;
-          }
-
-          // Just the beginning of the URL is selected, or we want a decoded
-          // url. First check for a trimmed value.
-          let spec = uri.displaySpec;
+          // Check for a trimmed value.
+          let spec = this.makeURIReadable(uri).displaySpec;
           let trimmedSpec = this.trimValue(spec);
           if (spec != trimmedSpec) {
             // Prepend the portion that trimValue removed from the beginning.
             // This assumes trimValue will only truncate the URL at
             // the beginning or end (or both).
             let trimmedSegments = spec.split(trimmedSpec);
             selectedVal = trimmedSegments[0] + selectedVal;
           }