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

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

Issue 29728579: Issue 6437 - Apply :-abp-contains() to matching roots only (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created March 20, 2018, 10:41 a.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 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 for (let element of this.getElements(prefix, subtree, styles)) 323 for (let element of this.getElements(prefix, subtree, styles))
324 yield [makeSelector(element, ""), subtree]; 324 yield [makeSelector(element, ""), subtree];
325 }, 325 },
326 326
327 *getElements(prefix, subtree, styles) 327 *getElements(prefix, subtree, styles)
328 { 328 {
329 let actualPrefix = (!prefix || incompletePrefixRegexp.test(prefix)) ? 329 let actualPrefix = (!prefix || incompletePrefixRegexp.test(prefix)) ?
330 prefix + "*" : prefix; 330 prefix + "*" : prefix;
331 331
332 let elements = scopedQuerySelectorAll(subtree, actualPrefix); 332 let elements = scopedQuerySelectorAll(subtree, actualPrefix);
333
333 if (elements) 334 if (elements)
334 { 335 {
336 let lastRoot = null;
335 for (let element of elements) 337 for (let element of elements)
336 { 338 {
339 // For a filter like div:-abp-contains(Hello) and a subtree like
340 // <div id="a"><div id="b"><div id="c">Hello</div></div></div>
341 // we're only interested in div#a
342 if (lastRoot && lastRoot.contains(element))
343 {
344 yield null;
345 continue;
346 }
347
348 lastRoot = element;
349
337 if (this._regexp && this._regexp.test(element.textContent)) 350 if (this._regexp && this._regexp.test(element.textContent))
338 yield element; 351 yield element;
339 else 352 else
340 yield null; 353 yield null;
341 } 354 }
342 } 355 }
343 } 356 }
344 }; 357 };
345 358
346 function PropsSelector(propertyExpression) 359 function PropsSelector(propertyExpression)
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 characterData: shouldObserveCharacterData(this.patterns), 822 characterData: shouldObserveCharacterData(this.patterns),
810 subtree: true 823 subtree: true
811 } 824 }
812 ); 825 );
813 this.document.addEventListener("load", this.onLoad.bind(this), true); 826 this.document.addEventListener("load", this.onLoad.bind(this), true);
814 } 827 }
815 } 828 }
816 }; 829 };
817 830
818 exports.ElemHideEmulation = ElemHideEmulation; 831 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