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

Side by Side Diff: lib/content/elemHideEmulation.js

Issue 29714606: Issue 6505 - Make selector parameter in makeSelector optional (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created March 5, 2018, 7:57 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-present eyeo GmbH 3 * Copyright (C) 2006-present 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 18 matching lines...) Expand all
29 */ 29 */
30 function positionInParent(node) 30 function positionInParent(node)
31 { 31 {
32 let {children} = node.parentNode; 32 let {children} = node.parentNode;
33 for (let i = 0; i < children.length; i++) 33 for (let i = 0; i < children.length; i++)
34 if (children[i] == node) 34 if (children[i] == node)
35 return i + 1; 35 return i + 1;
36 return 0; 36 return 0;
37 } 37 }
38 38
39 function makeSelector(node, selector) 39 function makeSelector(node, selector = "")
40 { 40 {
41 if (node == null) 41 if (node == null)
42 return null; 42 return null;
43 if (!node.parentElement) 43 if (!node.parentElement)
44 { 44 {
45 let newSelector = ":root"; 45 let newSelector = ":root";
46 if (selector) 46 if (selector)
47 newSelector += " > " + selector; 47 newSelector += " > " + selector;
48 return newSelector; 48 return newSelector;
49 } 49 }
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 get maybeDependsOnAttributes() 260 get maybeDependsOnAttributes()
261 { 261 {
262 return this._innerSelectors.some( 262 return this._innerSelectors.some(
263 selector => selector.maybeDependsOnAttributes 263 selector => selector.maybeDependsOnAttributes
264 ); 264 );
265 }, 265 },
266 266
267 *getSelectors(prefix, subtree, styles) 267 *getSelectors(prefix, subtree, styles)
268 { 268 {
269 for (let element of this.getElements(prefix, subtree, styles)) 269 for (let element of this.getElements(prefix, subtree, styles))
270 yield [makeSelector(element, ""), element]; 270 yield [makeSelector(element), element];
271 }, 271 },
272 272
273 /** 273 /**
274 * Generator function returning selected elements. 274 * Generator function returning selected elements.
275 * @param {string} prefix the prefix for the selector. 275 * @param {string} prefix the prefix for the selector.
276 * @param {Node} subtree the subtree we work on. 276 * @param {Node} subtree the subtree we work on.
277 * @param {StringifiedStyle[]} styles the stringified style objects. 277 * @param {StringifiedStyle[]} styles the stringified style objects.
278 */ 278 */
279 *getElements(prefix, subtree, styles) 279 *getElements(prefix, subtree, styles)
280 { 280 {
(...skipping 23 matching lines...) Expand all
304 this._regexp = makeRegExpParameter(textContent); 304 this._regexp = makeRegExpParameter(textContent);
305 } 305 }
306 306
307 ContainsSelector.prototype = { 307 ContainsSelector.prototype = {
308 requiresHiding: true, 308 requiresHiding: true,
309 dependsOnCharacterData: true, 309 dependsOnCharacterData: true,
310 310
311 *getSelectors(prefix, subtree, styles) 311 *getSelectors(prefix, subtree, styles)
312 { 312 {
313 for (let element of this.getElements(prefix, subtree, styles)) 313 for (let element of this.getElements(prefix, subtree, styles))
314 yield [makeSelector(element, ""), subtree]; 314 yield [makeSelector(element), subtree];
315 }, 315 },
316 316
317 *getElements(prefix, subtree, styles) 317 *getElements(prefix, subtree, styles)
318 { 318 {
319 let actualPrefix = (!prefix || incompletePrefixRegexp.test(prefix)) ? 319 let actualPrefix = (!prefix || incompletePrefixRegexp.test(prefix)) ?
320 prefix + "*" : prefix; 320 prefix + "*" : prefix;
321 321
322 let elements = scopedQuerySelectorAll(subtree, actualPrefix); 322 let elements = scopedQuerySelectorAll(subtree, actualPrefix);
323 if (elements) 323 if (elements)
324 { 324 {
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 characterData: shouldObserveCharacterData(this.patterns), 712 characterData: shouldObserveCharacterData(this.patterns),
713 subtree: true 713 subtree: true
714 } 714 }
715 ); 715 );
716 this.document.addEventListener("load", this.onLoad.bind(this), true); 716 this.document.addEventListener("load", this.onLoad.bind(this), true);
717 } 717 }
718 } 718 }
719 }; 719 };
720 720
721 exports.ElemHideEmulation = ElemHideEmulation; 721 exports.ElemHideEmulation = ElemHideEmulation;
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