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

Delta Between Two Patch Sets: lib/elemHide.js

Issue 29349187: Issue 4167 - getSelectorsForDomain criteria + keys (Closed)
Left Patch Set: Addressed further feedback Created Sept. 27, 2016, 12:10 p.m.
Right Patch Set: Improved comments Created Sept. 27, 2016, 1:52 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | test/elemHide.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 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
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 let selectors = this.getUnconditionalSelectors(); 321 let selectors = this.getUnconditionalSelectors();
322 unconditionalFilterKeys = []; 322 unconditionalFilterKeys = [];
323 for (let selector of selectors) 323 for (let selector of selectors)
324 unconditionalFilterKeys.push(filterKeysBySelector[selector][0]); 324 unconditionalFilterKeys.push(filterKeysBySelector[selector][0]);
325 } 325 }
326 return unconditionalFilterKeys.slice(); 326 return unconditionalFilterKeys.slice();
327 }, 327 },
328 328
329 329
330 /** 330 /**
331 * Constant used by getSelectorsForDomain's when matching all selectors. 331 * Constant used by getSelectorsForDomain to return all selectors applying to
Wladimir Palant 2016/09/27 13:08:38 Nit: why "'s"? How about: Constant used by getSel
kzar 2016/09/27 13:53:06 No idea, I guess it's a typo that I missed and the
332 * a particular hostname.
332 */ 333 */
333 ALL_MATCHING: 0, 334 ALL_MATCHING: 0,
334 335
335 /** 336 /**
336 * Constant used by getSelectorsForDomain's when not matching unconditional 337 * Constant used by getSelectorsForDomain to exclude selectors which apply to
337 * selectors. 338 * all websites without exception.
Wladimir Palant 2016/09/27 13:08:38 How about: Constant used by getSelectorsForDomain
kzar 2016/09/27 13:53:06 Done.
338 */ 339 */
339 NO_UNCONDITIONAL: 1, 340 NO_UNCONDITIONAL: 1,
340 341
341 /** 342 /**
342 * Constant used by getSelectorsForDomain's when only matching specific 343 * Constant used by getSelectorsForDomain to return only selectors for filters
343 * selectors. 344 * which specifically match the given host name.
Wladimir Palant 2016/09/27 13:08:38 Nit: Just realized, "specific selectors" makes no
kzar 2016/09/27 13:53:06 Done.
344 */ 345 */
345 SPECIFIC_ONLY: 2, 346 SPECIFIC_ONLY: 2,
346 347
347 /** 348 /**
348 * Determines from the current filter list which selectors should be applied 349 * Determines from the current filter list which selectors should be applied
349 * on a particular host name. Optionally returns the corresponding filter 350 * on a particular host name. Optionally returns the corresponding filter
350 * keys. 351 * keys.
351 * @param {String} domain 352 * @param {String} domain
352 * @param {Number} [criteria] 353 * @param {Number} [criteria]
353 * One of the following: 354 * One of the following: ElemHide.ALL_MATCHING, ElemHide.NO_UNCONDITIONAL or
Wladimir Palant 2016/09/27 13:08:38 Nit: Please indent parameter and return value desc
kzar 2016/09/27 13:53:06 Done.
354 * ElemHide.ALL_MATCHING - Returns all matching selectors for the host name. 355 * ElemHide.SPECIFIC_ONLY.
355 * ElemHide.NO_UNCONDITIONAL - Returns all matching selectors except those
356 * which match all host names unconditionally.
357 * ElemHide.SPECIFIC_ONLY - Returns only selectors for filters which
358 * specifically match the given host name.
Wladimir Palant 2016/09/27 13:08:38 Please don't document these constants twice, just
kzar 2016/09/27 13:53:06 Done.
359 * @param {Boolean} [provideFilterKeys] 356 * @param {Boolean} [provideFilterKeys]
360 * If true, the function will return a list of corresponding filter keys in 357 * If true, the function will return a list of corresponding filter keys in
361 * addition to selectors. 358 * addition to selectors.
362 * @returns {string[]|Array.<string[]>} 359 * @returns {string[]|Array.<string[]>}
363 * List of selectors or an array with two elements (list of selectors and list 360 * List of selectors or an array with two elements (list of selectors and
364 * of corresponding keys) if provideFilterKeys is true. 361 * list of corresponding keys) if provideFilterKeys is true.
365 */ 362 */
366 getSelectorsForDomain: function(domain, criteria, provideFilterKeys) 363 getSelectorsForDomain: function(domain, criteria, provideFilterKeys)
367 { 364 {
368 let filterKeys = []; 365 let filterKeys = [];
369 let selectors = []; 366 let selectors = [];
370 367
371 if (typeof criteria == "undefined") 368 if (typeof criteria == "undefined")
372 criteria = ElemHide.ALL_MATCHING; 369 criteria = ElemHide.ALL_MATCHING;
373 if (criteria < ElemHide.NO_UNCONDITIONAL) 370 if (criteria < ElemHide.NO_UNCONDITIONAL)
374 { 371 {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 let nextDot = currentDomain.indexOf("."); 407 let nextDot = currentDomain.indexOf(".");
411 currentDomain = nextDot == -1 ? "" : currentDomain.substr(nextDot + 1); 408 currentDomain = nextDot == -1 ? "" : currentDomain.substr(nextDot + 1);
412 } 409 }
413 410
414 if (provideFilterKeys) 411 if (provideFilterKeys)
415 return [selectors, filterKeys]; 412 return [selectors, filterKeys];
416 else 413 else
417 return selectors; 414 return selectors;
418 } 415 }
419 }; 416 };
LEFTRIGHT
« no previous file | test/elemHide.js » ('j') | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld