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 13:53:17 +0200
changeset 417573 43742dde8a6ca85986fe0955d422c123ed797d43
parent 417572 322c64ae8465d4842d178ad12f09e2728a394b95
child 532119 33e6f08b98d1d5f60c124579dbdcede62a234837
push id30433
push usermdeboer@mozilla.com
push dateMon, 26 Sep 2016 11:53:51 +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: 7AMMICyXEiL
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;
   });
 });