Bug 1139655 - pressing enter in the searchbar should ignore button selections from mouseover, r=Gijs.
☠☠ backed out by 1199232e985b ☠ ☠
authorFlorian Quèze <florian@queze.net>
Fri, 11 Sep 2015 14:18:15 +0200
changeset 294729 d79fb9007765485213040ea6d869d41b499de80a
parent 294728 5fad2760f199ef526149024f44fbce189c923f43
child 294730 c3f13feea4cd861d0e2a884ac521fed5ebaff59b
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1139655
milestone43.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 1139655 - pressing enter in the searchbar should ignore button selections from mouseover, r=Gijs.
browser/components/search/content/search.xml
--- a/browser/components/search/content/search.xml
+++ b/browser/components/search/content/search.xml
@@ -722,17 +722,17 @@
       <!-- override |onTextEntered| in autocomplete.xml -->
       <method name="onTextEntered">
         <parameter name="aEvent"/>
         <body><![CDATA[
           var evt = aEvent || this.mEnterEvent;
 
           let engine;
           let oneOff = this.selectedButton;
-          if (oneOff) {
+          if (oneOff && !this.selectionFromMouseOver) {
             if (!oneOff.engine) {
               oneOff.doCommand();
               this.mEnterEvent = null;
               return;
             }
             engine = oneOff.engine;
           }
           if (this.mEnterEvent && this._selectionDetails &&
@@ -744,16 +744,19 @@
 
           this.mEnterEvent = null;
         ]]></body>
       </method>
 
       <field name="_selectedButton"/>
       <property name="selectedButton" onget="return this._selectedButton;">
         <setter><![CDATA[
+          // Set to true from the mouseover handler right after this setter call.
+          this.selectionFromMouseOver = false;
+
           if (this._selectedButton)
             this._selectedButton.removeAttribute("selected");
 
           let textbox = document.getBindingParent(this).textbox;
           let header =
             document.getAnonymousElementByAttribute(this.popup, "anonid",
                                                     "search-panel-one-offs-header");
           // Avoid selecting dummy buttons.
@@ -1198,20 +1201,16 @@
             addEngineList.appendChild(button);
           }
         }
 
         // Finally, build the list of one-off buttons.
         while (list.firstChild)
           list.firstChild.remove();
 
-        // Avoid setting the selection based on mouse events before
-        // the 'popupshown' event has fired.
-        this._ignoreMouseEvents = true;
-
         let Preferences =
           Cu.import("resource://gre/modules/Preferences.jsm", {}).Preferences;
         let pref = Preferences.get("browser.search.hiddenOneOffs");
         let hiddenList = pref ? pref.split(",") : [];
 
         let currentEngineName = Services.search.currentEngine.name;
         let engines = Services.search.getVisibleEngines()
                               .filter(e => e.name != currentEngineName &&
@@ -1293,41 +1292,34 @@
 
           if (!--dummyItems)
             button.classList.add("last-of-row");
 
           list.appendChild(button);
         }
       ]]></handler>
 
-      <handler event="popupshown"><![CDATA[
-        this._ignoreMouseEvents = false;
-      ]]></handler>
-
       <handler event="mousedown"><![CDATA[
         // Required to receive click events from the buttons on Linux.
         event.preventDefault();
       ]]></handler>
 
       <handler event="mouseover"><![CDATA[
         let target = event.originalTarget;
         if (target.localName != "button")
           return;
 
-        // We ignore mouse events between the popupshowing and popupshown
-        // events to avoid selecting the button that happens to be under the
-        // mouse when the panel opens.
-        if (this._ignoreMouseEvents)
-          return;
-
         if ((target.classList.contains("searchbar-engine-one-off-item") &&
              !target.classList.contains("dummy")) ||
             target.classList.contains("addengine-item") ||
-            target.classList.contains("search-setting-button"))
-          document.getElementById("searchbar").textbox.selectedButton = target;
+            target.classList.contains("search-setting-button")) {
+          let textbox = document.getElementById("searchbar").textbox;
+          textbox.selectedButton = target;
+          textbox.selectionFromMouseOver = true;
+        }
       ]]></handler>
 
       <handler event="mouseout"><![CDATA[
         let target = event.originalTarget;
         if (target.localName != "button")
           return;
 
         let textbox = document.getElementById("searchbar").textbox;