Bug 1303874 - clear the dictionary for the current find window only upon restart of the iterator, not each reset. r?jaws draft
authorMike de Boer <mdeboer@mozilla.com>
Mon, 26 Sep 2016 16:07:53 +0200
changeset 417652 096cfdec4e8807176e392b06114eaab265aabf2a
parent 417572 322c64ae8465d4842d178ad12f09e2728a394b95
child 417695 3a2f0e25a8f94e7881c5bad9d5c85e91b6201118
child 417707 6dcaf4770a3be2465fa24e4ab565257c1094a0f4
push id30445
push usermdeboer@mozilla.com
push dateMon, 26 Sep 2016 14:08:24 +0000
reviewersjaws
bugs1303874
milestone52.0a1
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;
   });
 });