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

Delta Between Two Patch Sets: chrome/content/elemHideEmulation.js

Issue 29448560: Issue 5249 - Implement :-abp-contains() (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Left Patch Set: Rebased Created June 21, 2017, 9:27 p.m.
Right Patch Set: Use includes() and improve test. Created June 28, 2017, 4:11 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/browser/elemHideEmulation.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-2017 eyeo GmbH 3 * Copyright (C) 2006-2017 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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 for (let element of this.getElements(prefix, subtree, stylesheet)) 243 for (let element of this.getElements(prefix, subtree, stylesheet))
244 yield [makeSelector(element, ""), subtree]; 244 yield [makeSelector(element, ""), subtree];
245 }, 245 },
246 246
247 *getElements(prefix, subtree, stylesheet) 247 *getElements(prefix, subtree, stylesheet)
248 { 248 {
249 let actualPrefix = (!prefix || incompletePrefixRegexp.test(prefix)) ? 249 let actualPrefix = (!prefix || incompletePrefixRegexp.test(prefix)) ?
250 prefix + "*" : prefix; 250 prefix + "*" : prefix;
251 let elements = subtree.querySelectorAll(actualPrefix); 251 let elements = subtree.querySelectorAll(actualPrefix);
252 for (let element of elements) 252 for (let element of elements)
253 if (element.textContent == this._text) 253 if (element.textContent.includes(this._text))
254 yield element; 254 yield element;
255 } 255 }
256 }; 256 };
257 257
258 function PropsSelector(propertyExpression) 258 function PropsSelector(propertyExpression)
259 { 259 {
260 let regexpString; 260 let regexpString;
261 if (propertyExpression.length >= 2 && propertyExpression[0] == "/" && 261 if (propertyExpression.length >= 2 && propertyExpression[0] == "/" &&
262 propertyExpression[propertyExpression.length - 1] == "/") 262 propertyExpression[propertyExpression.length - 1] == "/")
263 { 263 {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 `pseudo-class :-abp-${match[1]}().`)); 359 `pseudo-class :-abp-${match[1]}().`));
360 return null; 360 return null;
361 } 361 }
362 362
363 let suffix = this.parseSelector(selector.substr(content.end + 1)); 363 let suffix = this.parseSelector(selector.substr(content.end + 1));
364 if (suffix == null) 364 if (suffix == null)
365 return null; 365 return null;
366 366
367 selectors.push(...suffix); 367 selectors.push(...suffix);
368 368
369 if (selectors.length == 1 && selectors[0] instanceof ContainsSelector)
370 {
371 this.window.console.error(
372 new SyntaxError("Failed to parse Adblock Plus " +
373 `selector ${selector}, can't ` +
374 "have a lonely :-abp-contains()."));
375 return null;
376 }
369 return selectors; 377 return selectors;
370 }, 378 },
371 379
372 addSelectors(stylesheets) 380 addSelectors(stylesheets)
373 { 381 {
374 let selectors = []; 382 let selectors = [];
375 let selectorFilters = []; 383 let selectorFilters = [];
376 384
377 let elements = []; 385 let elements = [];
378 let elementFilters = []; 386 let elementFilters = [];
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 455
448 if (this.patterns.length > 0) 456 if (this.patterns.length > 0)
449 { 457 {
450 let {document} = this.window; 458 let {document} = this.window;
451 this.addSelectors(document.styleSheets); 459 this.addSelectors(document.styleSheets);
452 document.addEventListener("load", this.onLoad.bind(this), true); 460 document.addEventListener("load", this.onLoad.bind(this), true);
453 } 461 }
454 }); 462 });
455 } 463 }
456 }; 464 };
LEFTRIGHT

Powered by Google App Engine
This is Rietveld