Bug 1071631 - fix findbar re-filling in last character, r=mikedeboer
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Mon, 19 Oct 2015 21:20:29 +0100
changeset 269089 3a9921a0dbc780456b6c3a1de18c52f30f7ed938
parent 269088 4c4a8135b8c65d69f0bf8e64e52832d287c1645b
child 269090 eb5224bab72b8379c63847879c00cc43030548e6
push id15826
push usergijskruitbosch@gmail.com
push dateFri, 23 Oct 2015 07:31:16 +0000
treeherderfx-team@3a9921a0dbc7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmikedeboer
bugs1071631
milestone44.0a1
Bug 1071631 - fix findbar re-filling in last character, r=mikedeboer
toolkit/content/widgets/findbar.xml
--- a/toolkit/content/widgets/findbar.xml
+++ b/toolkit/content/widgets/findbar.xml
@@ -69,16 +69,24 @@
         // We should do nothing during composition.  E.g., composing string
         // before converting may matches a forward word of expected word.
         // After that, even if user converts the composition string to the
         // expected word, it may find second or later searching word in the
         // document.
         if (this.findbar._isIMEComposing) {
           return;
         }
+
+        if (this._hadValue && !this.value) {
+          this._willfullyDeleted = true;
+          this._hadValue = false;
+        } else if (this.value.trim()) {
+          this._hadValue = true;
+          this._willfullyDeleted = false;
+        }
         this.findbar._find(this.value);
       ]]></handler>
 
       <handler event="keypress"><![CDATA[
         let shouldHandle = !event.altKey && !event.ctrlKey &&
                            !event.metaKey && !event.shiftKey;
 
         switch (event.keyCode) {
@@ -1096,18 +1104,20 @@
           let prefsvc =
             Components.classes["@mozilla.org/preferences-service;1"]
                       .getService(Components.interfaces.nsIPrefBranch);
           const kPref = "accessibility.typeaheadfind.prefillwithselection";
           if (this.prefillWithSelection && prefsvc.getBoolPref(kPref))
             return;
 
           let clipboardSearchString = this._browser.finder.clipboardSearchString;
-          if (clipboardSearchString && this._findField.value != clipboardSearchString) {
+          if (clipboardSearchString && this._findField.value != clipboardSearchString &&
+              !this._findField._willfullyDeleted) {
             this._findField.value = clipboardSearchString;
+            this._findField._hadValue = true;
             // Changing the search string makes the previous status invalid, so
             // we better clear it here.
             this._updateStatusUI();
           }
         ]]></body>
       </method>
 #endif