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

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

Issue 29328828: Issue 3129/3144 - Fixed: Findbar key handling conflicted with filter editing (Closed)
Patch Set: Implemented solution based on content script (also covers #3144) Created Oct. 5, 2015, 4:35 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 | no next file » | 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 let {BrowserUtils} = Cu.import("resource://gre/modules/BrowserUtils.jsm");
19
18 /** 20 /**
19 * Implementation of the filter search functionality. 21 * Implementation of the filter search functionality.
20 * @class 22 * @class
21 */ 23 */
22 var FilterSearch = 24 var FilterSearch =
23 { 25 {
24 /** 26 /**
25 * Initializes findbar widget. 27 * Initializes findbar widget.
26 */ 28 */
27 init: function() 29 init: function()
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 E("filtersTree").boxObject.scrollByLines(num); 229 E("filtersTree").boxObject.scrollByLines(num);
228 }, 230 },
229 scrollByPages: function(num) 231 scrollByPages: function(num)
230 { 232 {
231 E("filtersTree").boxObject.scrollByPages(num); 233 E("filtersTree").boxObject.scrollByPages(num);
232 }, 234 },
233 }, 235 },
234 236
235 messageManager: 237 messageManager:
236 { 238 {
239 FAYT_LINKS_KEY: "'".charCodeAt(0),
240 FAYT_TEXT_KEY: "/".charCodeAt(0),
237 _messageMap: { 241 _messageMap: {
238 "Findbar:Mouseup": "mouseup", 242 "Findbar:Mouseup": "mouseup",
239 "Findbar:Keypress": "keypress" 243 "Findbar:Keypress": "keypress"
240 }, 244 },
241 245
242 _messageFromEvent: function(event) 246 _messageFromEvent: function(event)
243 { 247 {
244 for (let message in this._messageMap) 248 for (let message in this._messageMap)
245 if (this._messageMap[message] == event.type) 249 if (this._messageMap[message] == event.type)
246 return {target: event.currentTarget, name: message, data: event}; 250 return {target: event.currentTarget, name: message, data: event};
247 return null; 251 return null;
248 }, 252 },
249 253
250 addMessageListener: function(message, listener) 254 addMessageListener: function(message, listener)
251 { 255 {
252 if (!this._messageMap.hasOwnProperty(message)) 256 if (!this._messageMap.hasOwnProperty(message))
253 return; 257 return;
254 258
255 if (!("_ABPHandler" in listener)) 259 if (!("_ABPHandler" in listener))
256 listener._ABPHandler = (event) => listener.receiveMessage(this._messageF romEvent(event)); 260 {
261 listener._ABPHandler = (event) => {
262 if (event.type == "keypress")
263 {
264 if (event.ctrlKey || event.altKey || event.metaKey
265 || event.defaultPrevented)
266 return;
267
268 let findbar = E("findbar");
269 if (findbar.findMode == findbar.FIND_NORMAL
270 && !findbar.findAsYouType
271 && event.charCode != this.FAYT_LINKS_KEY
272 && event.charCode != this.FAYT_TEXT_KEY)
273 return;
274
275 let target = Services.focus.getFocusedElementForWindow(window, true, {});
276 if (!BrowserUtils.shouldFastFind(target, window))
277 return;
278 }
279
280 listener.receiveMessage(this._messageFromEvent(event));
281 };
282 }
257 283
258 E("filtersTree").addEventListener(this._messageMap[message], listener._ABP Handler, false); 284 E("filtersTree").addEventListener(this._messageMap[message], listener._ABP Handler, false);
259 }, 285 },
260 286
261 removeMessageListener: function(message, listener) 287 removeMessageListener: function(message, listener)
262 { 288 {
263 if (this._messageMap.hasOwnProperty(message) && listener._ABPHandler) 289 if (this._messageMap.hasOwnProperty(message) && listener._ABPHandler)
264 E("filtersTree").removeEventListener(this._messageMap[message], listener ._ABPHandler, false); 290 E("filtersTree").removeEventListener(this._messageMap[message], listener ._ABPHandler, false);
265 }, 291 },
266 292
267 sendAsyncMessage: function() {} 293 sendAsyncMessage: function() {}
268 } 294 }
269 }; 295 };
270 296
271 window.addEventListener("load", function() 297 window.addEventListener("load", function()
272 { 298 {
273 FilterSearch.init(); 299 FilterSearch.init();
274 }, false); 300 }, false);
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld