Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: chrome/content/ui/filters-search.js

Issue 5938722247802880: Support the new findbar API (Closed)
Patch Set: Added remaining stubs Created March 18, 2014, 3:51 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/content/ui/filters-search.js
===================================================================
--- a/chrome/content/ui/filters-search.js
+++ b/chrome/content/ui/filters-search.js
@@ -134,23 +134,100 @@
*/
FilterSearch.fakeBrowser =
{
+ finder:
+ {
+ _resultListeners: [],
+ searchString: null,
+ caseSensitive: false,
+ lastResult: null,
+
+ _notifyResultListeners: function(result, findBackwards)
+ {
+ this.lastResult = result;
+ for each (let listener in this._resultListeners)
+ listener.onFindResult(result, findBackwards);
+ },
+
+ fastFind: function(searchString, linksOnly, drawOutline)
+ {
+ this.searchString = searchString;
+ let result = FilterSearch.search(this.searchString, 0,
+ this.caseSensitive);
+ this._notifyResultListeners(result, false);
+ },
+
+ findAgain: function(findBackwards, linksOnly, drawOutline)
+ {
+ let result = FilterSearch.search(this.searchString,
+ findBackwards ? -1 : 1,
+ this.caseSensitive);
+ this._notifyResultListeners(result, findBackwards);
+ },
+
+ addResultListener: function(listener)
+ {
+ if (this._resultListeners.indexOf(listener) === -1)
+ this._resultListeners.push(listener);
+ },
+
+ removeResultListener: function(listener)
+ {
+ let index = this._resultListeners.indexOf(listener);
+ if (index !== -1)
+ this._resultListeners.splice(index, 1);
+ },
+
+ // Irrelevant for us
+ highlight: function(highlight, word) {},
+ enableSelection: function() {},
+ removeSelection: function() {},
+ focusContent: function() {},
+ keyPress: function() {}
+ },
+
+ get _lastSearchString()
+ {
+ return this.finder.searchString;
+ },
+
+ // This was used before Firefox 27 instead of the "finder" property.
fastFind:
{
- searchString: null,
+ get searchString()
+ {
+ return FilterSearch.fakeBrowser.finder.searchString;
+ },
+
+ set searchString(searchString)
+ {
+ FilterSearch.fakeBrowser.finder.searchString = searchString;
+ },
+
foundLink: null,
foundEditable: null,
- caseSensitive: false,
+
+ get caseSensitive()
+ {
+ return FilterSearch.fakeBrowser.finder.caseSensitive;
+ },
+
+ set caseSensitive(caseSensitive)
+ {
+ FilterSearch.fakeBrowser.finder.caseSensitive = caseSensitive;
+ },
+
get currentWindow() FilterSearch.fakeBrowser.contentWindow,
find: function(searchString, linksOnly)
{
- this.searchString = searchString;
- return FilterSearch.search(this.searchString, 0, this.caseSensitive);
+ FilterSearch.fakeBrowser.finder.fastFind(searchString, linksOnly);
+ return FilterSearch.fakeBrowser.finder.lastResult;
},
findAgain: function(findBackwards, linksOnly)
{
- return FilterSearch.search(this.searchString, findBackwards ? -1 : 1, this.caseSensitive);
+ FilterSearch.fakeBrowser.finder.findAgain(findBackwards, linksOnly);
+ return FilterSearch.fakeBrowser.finder.lastResult;
},
// Irrelevant for us
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld