Bug 1148716 - Do not re-open location bar suggestion when dropmarker is clicked while the suggestion is opened. r=mak
authorTooru Fujisawa <arai_a@mac.com>
Tue, 27 Sep 2016 10:42:13 +0900
changeset 315314 74aff44c528af7a3ee1d4a35eb447f36e3e1520f
parent 315313 2a5b15755b6e4c61b584c0dc5949481713f297ef
child 315315 ca3ca7a3befafc0c9eb189a9d08f305e368308c8
push id30747
push usercbook@mozilla.com
push dateTue, 27 Sep 2016 09:22:00 +0000
treeherdermozilla-central@66a77b9bfe5d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs1148716
milestone52.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 1148716 - Do not re-open location bar suggestion when dropmarker is clicked while the suggestion is opened. r=mak
toolkit/content/widgets/autocomplete.xml
--- a/toolkit/content/widgets/autocomplete.xml
+++ b/toolkit/content/widgets/autocomplete.xml
@@ -399,17 +399,20 @@
             this.focus();
           this.attachController();
           this.mController.startSearch("");
         ]]></body>
       </method>
 
       <method name="toggleHistoryPopup">
         <body><![CDATA[
-          if (!this.popup.popupOpen)
+          // If this method is called on the same event tick as the popup gets
+          // hidden, do nothing to avoid re-opening the popup when the drop
+          // marker is clicked while the popup is still open.
+          if (!this.popup.isPopupHidingTick && !this.popup.popupOpen)
             this.showHistoryPopup();
           else
             this.closePopup();
         ]]></body>
       </method>
 
       <!-- ::::::::::::: event dispatching ::::::::::::: -->
 
@@ -868,28 +871,32 @@
     </implementation>
   </binding>
 
   <binding id="autocomplete-base-popup" role="none"
 extends="chrome://global/content/bindings/popup.xml#popup">
     <implementation implements="nsIAutoCompletePopup">
       <field name="mInput">null</field>
       <field name="mPopupOpen">false</field>
+      <field name="mIsPopupHidingTick">false</field>
 
       <!-- =================== nsIAutoCompletePopup =================== -->
 
       <property name="input" readonly="true"
                 onget="return this.mInput"/>
 
       <property name="overrideValue" readonly="true"
                 onget="return null;"/>
 
       <property name="popupOpen" readonly="true"
                 onget="return this.mPopupOpen;"/>
 
+      <property name="isPopupHidingTick" readonly="true"
+                onget="return this.mIsPopupHidingTick;"/>
+
       <method name="closePopup">
         <body>
           <![CDATA[
           if (this.mPopupOpen) {
             this.hidePopup();
             this.removeAttribute("width");
           }
         ]]>
@@ -986,16 +993,24 @@ extends="chrome://global/content/binding
         if (this.selectedIndex == -1)
           isListActive = false;
         var controller = this.view.QueryInterface(Components.interfaces.nsIAutoCompleteController);
         controller.stopSearch();
 
         this.removeAttribute("autocompleteinput");
         this.mPopupOpen = false;
 
+        // Prevent opening popup from historydropmarker mousedown handler
+        // on the same event tick the popup is hidden by the same mousedown
+        // event.
+        this.mIsPopupHidingTick = true;
+        setTimeout(() => {
+          this.mIsPopupHidingTick = false;
+        }, 0);
+
         // Reset the maxRows property to the cached "normal" value, and reset
         // _normalMaxRows so that we can detect whether it was set by the input
         // when the popupshowing handler runs.
 
         // Null-check this.mInput; see bug 1017914
         if (this.mInput)
           this.mInput.maxRows = this._normalMaxRows;
         this._normalMaxRows = -1;
@@ -2321,25 +2336,16 @@ extends="chrome://global/content/binding
       <xul:hbox flex="1" class="tree-bodybox">
         <children/>
       </xul:hbox>
       <xul:scrollbar xbl:inherits="collapsed=hidescrollbar" orient="vertical" class="tree-scrollbar"/>
     </content>
   </binding>
 
   <binding id="history-dropmarker" extends="chrome://global/content/bindings/general.xml#dropmarker">
-    <implementation>
-      <method name="showPopup">
-        <body><![CDATA[
-          var textbox = document.getBindingParent(this);
-          textbox.showHistoryPopup();
-        ]]></body>
-      </method>
-    </implementation>
-
     <handlers>
       <handler event="mousedown" button="0"><![CDATA[
-        this.showPopup();
+        document.getBindingParent(this).toggleHistoryPopup();
       ]]></handler>
     </handlers>
   </binding>
 
 </bindings>