Bug 1303874 - clear the dictionary for the current find window only upon restart of the iterator, not each reset. r=jaws
authorMike de Boer <mdeboer@mozilla.com>
Mon, 26 Sep 2016 16:07:53 +0200
changeset 315253 ee066384095172f059aab32ed55839e66372cce5
parent 315252 1aaa9010a9a18ca16ee3dfedfc8aa0f085fb4510
child 315254 cdb6410f3b71e713b6de2213201cd8180fa20658
push id30745
push usercbook@mozilla.com
push dateTue, 27 Sep 2016 09:18:23 +0000
treeherdermozilla-central@7b050ca8ec64 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws
bugs1303874
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 1303874 - clear the dictionary for the current find window only upon restart of the iterator, not each reset. r=jaws MozReview-Commit-ID: Gp2rnr5z12n
toolkit/content/tests/chrome/bug263683_window.xul
toolkit/modules/FinderHighlighter.jsm
toolkit/modules/tests/browser/browser_FinderHighlighter.js
--- a/toolkit/content/tests/chrome/bug263683_window.xul
+++ b/toolkit/content/tests/chrome/bug263683_window.xul
@@ -218,17 +218,17 @@
           .QueryInterface(Ci.nsIInterfaceRequestor)
           .getInterface(Ci.nsIWebNavigation)
           .QueryInterface(Ci.nsIDocShell));
         Assert.equal(selection.rangeCount, 0, "Correctly removed the range");
 
         content.document.documentElement.focus();
       });
 
-      gFindBar.close();
+      gFindBar.close(true);
       yield new Promise(resolve => setTimeout(resolve, kIteratorTimeout));
     }
   ]]></script>
 
   <browser type="content-primary" flex="1" id="content" src="about:blank"/>
   <browser type="content-primary" flex="1" id="content-remote" remote="true" src="about:blank"/>
   <findbar id="FindToolbar" browserid="content"/>
 </window>
--- a/toolkit/modules/FinderHighlighter.jsm
+++ b/toolkit/modules/FinderHighlighter.jsm
@@ -228,22 +228,22 @@ FinderHighlighter.prototype = {
 
   // FinderIterator listener implementation
 
   onIteratorRangeFound(range) {
     this.highlightRange(range);
     this._found = true;
   },
 
-  onIteratorReset() {
+  onIteratorReset() {},
+
+  onIteratorRestart() {
     this.clear(this.finder._getWindow());
   },
 
-  onIteratorRestart() {},
-
   onIteratorStart(params) {
     let window = this.finder._getWindow();
     let dict = this.getForWindow(window);
     // Save a clean params set for use later in the `update()` method.
     dict.lastIteratorParams = params;
     if (!this._modal)
       this.hide(window, this.finder._fastFind.getFoundRange());
     this.clear(window);
@@ -506,18 +506,21 @@ FinderHighlighter.prototype = {
    * When 'Highlight All' is toggled during a session, this callback is invoked
    * and when it's turned off, the found occurrences will be removed from the mask.
    *
    * @param {Boolean} highlightAll
    */
   onHighlightAllChange(highlightAll) {
     this._highlightAll = highlightAll;
     if (!highlightAll) {
-      this.clear();
-      this._scheduleRepaintOfMask(this.finder._getWindow());
+      let window = this.finder._getWindow();
+      if (!this._modal)
+        this.hide(window);
+      this.clear(window);
+      this._scheduleRepaintOfMask(window);
     }
   },
 
   /**
    * Utility; removes all ranges from the find selection that belongs to a
    * controller. Optionally skips a specific range.
    *
    * @param  {nsISelectionController} controller
--- a/toolkit/modules/tests/browser/browser_FinderHighlighter.js
+++ b/toolkit/modules/tests/browser/browser_FinderHighlighter.js
@@ -353,17 +353,17 @@ add_task(function* testHighlightAllToggl
       removeCalls: [0, 1]
     };
     promise = promiseTestHighlighterOutput(browser, word, expectedResult);
     yield SpecialPowers.pushPrefEnv({ "set": [[ kHighlightAllPref, false ]] });
     yield promise;
 
     // For posterity, let's switch back.
     expectedResult = {
-      rectCount: 2,
+      rectCount: 1,
       insertCalls: [1, 3],
       removeCalls: [0, 1]
     };
     promise = promiseTestHighlighterOutput(browser, word, expectedResult);
     yield SpecialPowers.pushPrefEnv({ "set": [[ kHighlightAllPref, true ]] });
     yield promise;
   });
 });