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

Side by Side Diff: chrome/content/ui/filters-search.js

Issue 4964592316841984: Issue 2041 - Filter Preferences: Findbar not fully functional in Firefox 36 (Closed)
Patch Set: Created Feb. 25, 2015, 5:08 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | metadata.gecko » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 /** 18 /**
19 * Implementation of the filter search functionality. 19 * Implementation of the filter search functionality.
20 * @class 20 * @class
21 */ 21 */
22 var FilterSearch = 22 var FilterSearch =
23 { 23 {
24 /** 24 /**
25 * Initializes findbar widget. 25 * Initializes findbar widget.
26 */ 26 */
27 init: function() 27 init: function()
28 { 28 {
29 let filters = E("filtersTree");
30 for (let prop in FilterSearch.fakeBrowser)
31 filters[prop] = FilterSearch.fakeBrowser[prop];
32 Object.defineProperty(filters, "_lastSearchString", {
33 get: function()
34 {
35 return this.finder.searchString;
36 },
37 enumerable: true,
38 configurable: true
39 });
40
29 let findbar = E("findbar"); 41 let findbar = E("findbar");
30 findbar.browser = FilterSearch.fakeBrowser; 42 findbar.browser = filters;
31 43
32 findbar.addEventListener("keypress", function(event) 44 findbar.addEventListener("keypress", function(event)
33 { 45 {
34 // Work-around for bug 490047 46 // Work-around for bug 490047
35 if (event.keyCode == KeyEvent.DOM_VK_RETURN) 47 if (event.keyCode == KeyEvent.DOM_VK_RETURN)
36 event.preventDefault(); 48 event.preventDefault();
37 }, false); 49 }, false);
38 50
39 // Hack to prevent "highlight all" from getting enabled 51 // Hack to prevent "highlight all" from getting enabled
40 findbar.toggleHighlight = function() {}; 52 findbar.toggleHighlight = function() {};
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 208
197 // Irrelevant for us 209 // Irrelevant for us
198 requestMatchesCount: function(searchString, matchLimit, linksOnly) {}, 210 requestMatchesCount: function(searchString, matchLimit, linksOnly) {},
199 highlight: function(highlight, word) {}, 211 highlight: function(highlight, word) {},
200 enableSelection: function() {}, 212 enableSelection: function() {},
201 removeSelection: function() {}, 213 removeSelection: function() {},
202 focusContent: function() {}, 214 focusContent: function() {},
203 keyPress: function() {} 215 keyPress: function() {}
204 }, 216 },
205 217
206 get _lastSearchString()
207 {
208 return this.finder.searchString;
209 },
210
211 // This was used before Firefox 27 instead of the "finder" property.
Thomas Greiner 2015/02/27 15:57:46 According to metadata.gecko, this version is still
Wladimir Palant 2015/02/27 16:20:53 Please see review description ;)
212 fastFind:
213 {
214 get searchString()
215 {
216 return FilterSearch.fakeBrowser.finder.searchString;
217 },
218
219 set searchString(searchString)
220 {
221 FilterSearch.fakeBrowser.finder.searchString = searchString;
222 },
223
224 foundLink: null,
225 foundEditable: null,
226
227 get caseSensitive()
228 {
229 return FilterSearch.fakeBrowser.finder.caseSensitive;
230 },
231
232 set caseSensitive(caseSensitive)
233 {
234 FilterSearch.fakeBrowser.finder.caseSensitive = caseSensitive;
235 },
236
237 get currentWindow() FilterSearch.fakeBrowser.contentWindow,
238
239 find: function(searchString, linksOnly)
240 {
241 FilterSearch.fakeBrowser.finder.fastFind(searchString, linksOnly);
242 return FilterSearch.fakeBrowser.finder.lastResult;
243 },
244
245 findAgain: function(findBackwards, linksOnly)
246 {
247 FilterSearch.fakeBrowser.finder.findAgain(findBackwards, linksOnly);
248 return FilterSearch.fakeBrowser.finder.lastResult;
249 },
250
251 // Irrelevant for us
252 init: function() {},
253 setDocShell: function() {},
254 setSelectionModeAndRepaint: function() {},
255 collapseSelection: function() {}
256 },
257 currentURI: Utils.makeURI("http://example.com/"), 218 currentURI: Utils.makeURI("http://example.com/"),
258 contentWindow: 219 contentWindow:
259 { 220 {
260 focus: function() 221 focus: function()
261 { 222 {
262 E("filtersTree").focus(); 223 E("filtersTree").focus();
263 }, 224 },
264 scrollByLines: function(num) 225 scrollByLines: function(num)
265 { 226 {
266 E("filtersTree").boxObject.scrollByLines(num); 227 E("filtersTree").boxObject.scrollByLines(num);
267 }, 228 },
268 scrollByPages: function(num) 229 scrollByPages: function(num)
269 { 230 {
270 E("filtersTree").boxObject.scrollByPages(num); 231 E("filtersTree").boxObject.scrollByPages(num);
271 }, 232 },
272 }, 233 }
273
274 addEventListener: function(event, handler, capture)
275 {
276 E("filtersTree").addEventListener(event, handler, capture);
277 },
278 removeEventListener: function(event, handler, capture)
279 {
280 E("filtersTree").addEventListener(event, handler, capture);
281 },
282 }; 234 };
283 235
284 window.addEventListener("load", function() 236 window.addEventListener("load", function()
285 { 237 {
286 FilterSearch.init(); 238 FilterSearch.init();
287 }, false); 239 }, false);
OLDNEW
« no previous file with comments | « no previous file | metadata.gecko » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld