Bug 384458 - part 2: change the matches count timeout to 100ms, up the limit to a 1000 counts and capture the state of 'Highlight All' in a pref which will be TRUE by default in the browser. r=jaws
☠☠ backed out by d03332bc9097 ☠ ☠
authorMike de Boer <mdeboer@mozilla.com>
Wed, 08 Jun 2016 19:54:07 +0200
changeset 301224 091c5465acf79b6da8807e6a959417755016cae2
parent 301223 5eabde153def61f4577dbcf7d3726dc1d0b0f5c5
child 301225 3b025cbfbe3c0b24677b71c466ec1ce3bc9e2773
push id78263
push usercbook@mozilla.com
push dateThu, 09 Jun 2016 10:13:31 +0000
treeherdermozilla-inbound@3d132a280ca0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws
bugs384458
milestone50.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 384458 - part 2: change the matches count timeout to 100ms, up the limit to a 1000 counts and capture the state of 'Highlight All' in a pref which will be TRUE by default in the browser. r=jaws
browser/app/profile/firefox.js
modules/libpref/init/all.js
toolkit/content/widgets/browser.xml
toolkit/content/widgets/editor.xml
toolkit/content/widgets/findbar.xml
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -609,16 +609,17 @@ pref("network.protocol-handler.expose.ma
 pref("network.protocol-handler.expose.news", false);
 pref("network.protocol-handler.expose.snews", false);
 pref("network.protocol-handler.expose.nntp", false);
 
 pref("accessibility.typeaheadfind", false);
 pref("accessibility.typeaheadfind.timeout", 5000);
 pref("accessibility.typeaheadfind.linksonly", false);
 pref("accessibility.typeaheadfind.flashBar", 1);
+pref("findbar.highlightAll", true);
 
 // Tracks when accessibility is loaded into the previous session.
 pref("accessibility.loadedInLastSession", false);
 
 pref("plugins.update.url", "https://www.mozilla.org/%LOCALE%/plugincheck/?utm_source=firefox-browser&utm_medium=firefox-browser&utm_campaign=plugincheck-update");
 pref("plugins.update.notifyUser", false);
 
 pref("plugins.click_to_play", true);
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -851,18 +851,19 @@ pref("accessibility.typeaheadfind.timeou
 pref("accessibility.typeaheadfind.enabletimeout", true);
 pref("accessibility.typeaheadfind.soundURL", "beep");
 pref("accessibility.typeaheadfind.enablesound", true);
 #ifdef XP_MACOSX
 pref("accessibility.typeaheadfind.prefillwithselection", false);
 #else
 pref("accessibility.typeaheadfind.prefillwithselection", true);
 #endif
-pref("accessibility.typeaheadfind.matchesCountTimeout", 250);
-pref("accessibility.typeaheadfind.matchesCountLimit", 100);
+pref("accessibility.typeaheadfind.matchesCountTimeout", 100);
+pref("accessibility.typeaheadfind.matchesCountLimit", 1000);
+pref("findbar.highlightAll", false);
 
 // use Mac OS X Appearance panel text smoothing setting when rendering text, disabled by default
 pref("gfx.use_text_smoothing_setting", false);
 
 // Number of characters to consider emphasizing for rich autocomplete results
 pref("toolkit.autocomplete.richBoundaryCutoff", 200);
 
 // Variable controlling logging for osfile.
--- a/toolkit/content/widgets/browser.xml
+++ b/toolkit/content/widgets/browser.xml
@@ -431,17 +431,16 @@
               throw e;
             }
             return null;
           }
         ]]></getter>
       </property>
 
       <field name="_lastSearchString">null</field>
-      <field name="_lastSearchHighlight">false</field>
 
       <property name="webProgress"
                 readonly="true"
                 onget="return this.docShell.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIWebProgress);"/>
 
       <field name="_contentWindow">null</field>
 
       <property name="contentWindow"
--- a/toolkit/content/widgets/editor.xml
+++ b/toolkit/content/widgets/editor.xml
@@ -119,17 +119,16 @@
             this._fastFind.init(this.docShell);
           }
           return this._fastFind;
         ]]>
         </getter>
       </property>
 
       <field name="_lastSearchString">null</field>
-      <field name="_lastSearchHighlight">false</field>
 
       <property name="editortype"
                 onget="return this.getAttribute('editortype');"
                 onset="this.setAttribute('editortype', val); return val;"/>
       <property name="webNavigation"
                 onget="return this.docShell.QueryInterface(Components.interfaces.nsIWebNavigation);"
                 readonly="true"/>
       <property name="contentDocument" readonly="true"
--- a/toolkit/content/widgets/findbar.xml
+++ b/toolkit/content/widgets/findbar.xml
@@ -285,92 +285,104 @@
           if (this._browser) {
             // Need to do this to ensure the correct initial state.
             this._updateBrowserWithState();
             this._browser.messageManager.addMessageListener("Findbar:Keypress", this);
             this._browser.messageManager.addMessageListener("Findbar:Mouseup", this);
             this._browser.finder.addResultListener(this);
 
             this._findField.value = this._browser._lastSearchString;
-            this.toggleHighlight(this.browser._lastSearchHighlight);
           }
           return val;
         ]]></setter>
       </property>
 
+      <field name="__prefsvc">null</field>
+      <property name="_prefsvc">
+        <getter><![CDATA[
+          if (!this.__prefsvc) {
+            this.__prefsvc = Components.classes["@mozilla.org/preferences-service;1"]
+              .getService(Components.interfaces.nsIPrefBranch);
+          }
+          return this.__prefsvc;
+        ]]></getter>
+      </property>
+
       <field name="_observer"><![CDATA[({
         _self: this,
 
         QueryInterface: function(aIID) {
           if (aIID.equals(Components.interfaces.nsIObserver) ||
               aIID.equals(Components.interfaces.nsISupportsWeakReference) ||
               aIID.equals(Components.interfaces.nsISupports))
             return this;
 
           throw Components.results.NS_ERROR_NO_INTERFACE;
         },
 
         observe: function(aSubject, aTopic, aPrefName) {
           if (aTopic != "nsPref:changed")
             return;
 
-          let prefsvc =
-            aSubject.QueryInterface(Components.interfaces.nsIPrefBranch);
+          let prefsvc = this._self._prefsvc;
 
           switch (aPrefName) {
             case "accessibility.typeaheadfind":
               this._self._findAsYouType = prefsvc.getBoolPref(aPrefName);
               break;
             case "accessibility.typeaheadfind.linksonly":
               this._self._typeAheadLinksOnly = prefsvc.getBoolPref(aPrefName);
               break;
             case "accessibility.typeaheadfind.casesensitive":
               this._self._setCaseSensitivity(prefsvc.getIntPref(aPrefName));
               break;
+            case "findbar.highlightAll":
+              this._self.toggleHighlight(prefsvc.getBoolPref(aPrefName), true);
+              break;
           }
         }
       })]]></field>
 
       <field name="_destroyed">false</field>
 
       <constructor><![CDATA[
         // These elements are accessed frequently and are therefore cached
         this._findField = this.getElement("findbar-textbox");
         this._foundMatches = this.getElement("found-matches");
         this._findStatusIcon = this.getElement("find-status-icon");
         this._findStatusDesc = this.getElement("find-status");
 
         this._foundURL = null;
 
-        let prefsvc =
-          Components.classes["@mozilla.org/preferences-service;1"]
-                    .getService(Components.interfaces.nsIPrefBranch);
+        let prefsvc = this._prefsvc;
 
         this._quickFindTimeoutLength =
           prefsvc.getIntPref("accessibility.typeaheadfind.timeout");
         this._flashFindBar =
           prefsvc.getIntPref("accessibility.typeaheadfind.flashBar");
         this._matchesCountTimeoutLength =
           prefsvc.getIntPref("accessibility.typeaheadfind.matchesCountTimeout");
         this._matchesCountLimit =
           prefsvc.getIntPref("accessibility.typeaheadfind.matchesCountLimit");
 
         prefsvc.addObserver("accessibility.typeaheadfind",
                             this._observer, false);
         prefsvc.addObserver("accessibility.typeaheadfind.linksonly",
                             this._observer, false);
         prefsvc.addObserver("accessibility.typeaheadfind.casesensitive",
                             this._observer, false);
+        prefsvc.addObserver("findbar.highlightAll", this._observer, false);
 
         this._findAsYouType =
           prefsvc.getBoolPref("accessibility.typeaheadfind");
         this._typeAheadLinksOnly =
           prefsvc.getBoolPref("accessibility.typeaheadfind.linksonly");
         this._typeAheadCaseSensitive =
           prefsvc.getIntPref("accessibility.typeaheadfind.casesensitive");
+        this._highlightAll = prefsvc.getBoolPref("findbar.highlightAll");
 
         // Convenience
         this.nsITypeAheadFind = Components.interfaces.nsITypeAheadFind;
         this.nsISelectionController = Components.interfaces.nsISelectionController;
         this._findSelection = this.nsISelectionController.SELECTION_FIND;
 
         this._findResetTimeout = -1;
 
@@ -390,25 +402,24 @@
       <method name="destroy">
         <body><![CDATA[
           if (this._destroyed)
             return;
           this._destroyed = true;
 
           this.browser = null;
 
-          let prefsvc =
-            Components.classes["@mozilla.org/preferences-service;1"]
-                      .getService(Components.interfaces.nsIPrefBranch);
+          let prefsvc = this._prefsvc;
           prefsvc.removeObserver("accessibility.typeaheadfind",
                                  this._observer);
           prefsvc.removeObserver("accessibility.typeaheadfind.linksonly",
                                  this._observer);
           prefsvc.removeObserver("accessibility.typeaheadfind.casesensitive",
                                  this._observer);
+          prefsvc.removeObserver("findbar.highlightAll", this._observer);
 
           // Clear all timers that might still be running.
           this._cancelTimers();
         ]]></body>
       </method>
 
       <method name="_cancelTimers">
         <body><![CDATA[
@@ -486,37 +497,72 @@
             }, this._matchesCountTimeoutLength);
         ]]></body>
       </method>
 
       <!--
         - Turns highlight on or off.
         - @param aHighlight (boolean)
         -        Whether to turn the highlight on or off
+        - @param aFromPrefObserver (boolean)
+        -        Whether the callee is the pref observer, which means we should
+        -        not set the same pref again.
         -->
       <method name="toggleHighlight">
         <parameter name="aHighlight"/>
+        <parameter name="aFromPrefObserver"/>
         <body><![CDATA[
-          if (!this._dispatchFindEvent("highlightallchange"))
+          if (aHighlight === this._highlightAll) {
             return;
+          }
+          this._highlightAll = aHighlight;
+
+          if (!this._dispatchFindEvent("highlightallchange")) {
+            return;
+          }
+
+          this._setHighlightAll(aHighlight, aFromPrefObserver);
 
           let word = this._findField.value;
           // Bug 429723. Don't attempt to highlight ""
           if (aHighlight && !word)
             return;
 
-          this.browser._lastSearchHighlight = aHighlight;
           this.browser.finder.highlight(aHighlight, word);
 
           // Update the matches count
           this._updateMatchesCount(this.nsITypeAheadFind.FIND_FOUND);
         ]]></body>
       </method>
 
       <!--
+        - Updates the highlight-all mode of the findbar and its UI.
+        - @param aHighlight (boolean)
+        -        Whether to turn the highlight on or off.
+        - @param aFromPrefObserver (boolean)
+        -        Whether the callee is the pref observer, which means we should
+        -        not set the same pref again.
+        -->
+      <method name="_setHighlightAll">
+        <parameter name="aHighlight"/>
+        <parameter name="aFromPrefObserver"/>
+        <body><![CDATA[
+          if (typeof aHighlight != "boolean") {
+            aHighlight = this._highlightAll;
+          }
+          if (aHighlight !== this._highlightAll && !aFromPrefObserver) {
+            this._prefsvc.setBoolPref("findbar.highlightAll", aHighlight);
+          }
+          this._highlightAll = aHighlight;
+          let checkbox = this.getElement("highlight");
+          checkbox.checked = this._highlightAll;
+        ]]></body>
+      </method>
+
+      <!--
         - Updates the case-sensitivity mode of the findbar and its UI.
         - @param [optional] aString
         -        The string for which case sensitivity might be turned on.
         -        This only used when case-sensitivity is in auto mode,
         -        @see _shouldBeCaseSensitive. The default value for this
         -        parameter is the find-field value.
         -->
       <method name="_updateCaseSensitivity">
@@ -849,16 +895,17 @@
             if (node == wrapper || node == foundMatches)
                continue;
             node.hidden = showMinimalUI;
           }
           this.getElement("find-next").hidden =
             this.getElement("find-previous").hidden = showMinimalUI;
           foundMatches.hidden = showMinimalUI || !foundMatches.value;
           this._updateCaseSensitivity();
+          this._setHighlightAll();
 
           if (showMinimalUI)
             this._findField.classList.add("minimal");
           else
             this._findField.classList.remove("minimal");
 
           if (this._findMode == this.FIND_TYPEAHEAD)
             this._findField.placeholder = this._fastFindStr;
@@ -1003,17 +1050,17 @@
       <method name="_dispatchFindEvent">
         <parameter name="aType"/>
         <parameter name="aFindPrevious"/>
         <body><![CDATA[
           let event = document.createEvent("CustomEvent");
           event.initCustomEvent("find" + aType, true, true, {
             query: this._findField.value,
             caseSensitive: !!this._typeAheadCaseSensitive,
-            highlightAll: this.getElement("highlight").checked,
+            highlightAll: this._highlightAll,
             findPrevious: aFindPrevious
           });
           return this.dispatchEvent(event);
         ]]></body>
       </method>
 
 
       <!--
@@ -1022,19 +1069,17 @@
         - @param aMode
         -        the find mode to be used, which is either FIND_NORMAL,
         -        FIND_TYPEAHEAD or FIND_LINKS. If not passed, the last
         -        find mode if any or FIND_NORMAL.
         -->
       <method name="startFind">
         <parameter name="aMode"/>
         <body><![CDATA[
-          let prefsvc =
-            Components.classes["@mozilla.org/preferences-service;1"]
-                      .getService(Components.interfaces.nsIPrefBranch);
+          let prefsvc = this._prefsvc;
           let userWantsPrefill = true;
           this.open(aMode);
 
           if (this._flashFindBar) {
             this._flashFindBarTimeout = setInterval(() => this._flash(), 500);
             prefsvc.setIntPref("accessibility.typeaheadfind.flashBar",
                                --this._flashFindBar);
           }
@@ -1126,19 +1171,17 @@
           let searchString = this.browser.finder.setSearchStringToSelection();
           if (searchString)
             this._findField.value = searchString;
         ]]></body>
       </method>
 
       <method name="_onFindFieldFocus">
         <body><![CDATA[
-          let prefsvc =
-            Components.classes["@mozilla.org/preferences-service;1"]
-                      .getService(Components.interfaces.nsIPrefBranch);
+          let prefsvc = this._prefsvc;
           const kPref = "accessibility.typeaheadfind.prefillwithselection";
           if (this.prefillWithSelection && prefsvc.getBoolPref(kPref))
             return;
 
           let clipboardSearchString = this._browser.finder.clipboardSearchString;
           if (clipboardSearchString && this._findField.value != clipboardSearchString &&
               !this._findField._willfullyDeleted) {
             this._findField.value = clipboardSearchString;