Bug 1522529 - Remove focus hack from the gURLBar getter and properly implement UrlbarInput focus and blur methods. r=adw
authorDão Gottwald <dao@mozilla.com>
Thu, 24 Jan 2019 16:49:41 +0000
changeset 512427 fb9849a4c577edac1ee88058b4711a7c968535fe
parent 512426 864bf1afa7553101acb01e75f2a76e2e2a640c12
child 512428 5b224d4205b732d43ade1249c9e1249e4e743594
push id10566
push userarchaeopteryx@coole-files.de
push dateMon, 28 Jan 2019 12:41:12 +0000
treeherdermozilla-beta@69a3d7c8d04b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersadw
bugs1522529
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1522529 - Remove focus hack from the gURLBar getter and properly implement UrlbarInput focus and blur methods. r=adw Differential Revision: https://phabricator.services.mozilla.com/D17521
browser/base/content/browser.js
browser/components/urlbar/UrlbarInput.jsm
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -185,21 +185,16 @@ XPCOMUtils.defineLazyGetter(this, "gNavT
 
 XPCOMUtils.defineLazyGetter(this, "gURLBar", () => {
   let element = document.getElementById("urlbar");
 
   if (!Services.prefs.getBoolPref("browser.urlbar.quantumbar", false)) {
     return element;
   }
 
-  // Re-focus the input field if it was focused before switching bindings.
-  if (element.hasAttribute("focused")) {
-    element.inputField.focus();
-  }
-
   return new UrlbarInput({
     textbox: element,
     panel: document.getElementById("urlbar-results"),
   });
 });
 
 // High priority notification bars shown at the top of the window.
 XPCOMUtils.defineLazyGetter(this, "gHighPriorityNotificationBox", () => {
--- a/browser/components/urlbar/UrlbarInput.jsm
+++ b/browser/components/urlbar/UrlbarInput.jsm
@@ -57,17 +57,17 @@ class UrlbarInput {
     this.userInitiatedFocus = false;
     this.isPrivate = PrivateBrowsingUtils.isWindowPrivate(this.window);
     this._untrimmedValue = "";
     this._suppressStartQuery = false;
 
     // Forward textbox methods and properties.
     const METHODS = ["addEventListener", "removeEventListener",
       "setAttribute", "hasAttribute", "removeAttribute", "getAttribute",
-      "focus", "blur", "select"];
+      "select"];
     const READ_ONLY_PROPERTIES = ["inputField", "editor"];
     const READ_WRITE_PROPERTIES = ["placeholder", "readOnly",
       "selectionStart", "selectionEnd"];
 
     for (let method of METHODS) {
       this[method] = (...args) => {
         return this.textbox[method](...args);
       };
@@ -136,16 +136,24 @@ class UrlbarInput {
     this.valueFormatter.update();
   }
 
   closePopup() {
     this.controller.cancelQuery();
     this.view.close();
   }
 
+  focus() {
+    this.inputField.focus();
+  }
+
+  blur() {
+    this.inputField.blur();
+  }
+
   /**
    * Converts an internal URI (e.g. a wyciwyg URI) into one which we can
    * expose to the user.
    *
    * @param {nsIURI} uri
    *   The URI to be converted
    * @returns {nsIURI}
    *   The converted, exposable URI