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
--- 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;
});
});