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

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

Issue 29760699: Issue 6619 - Qualify CSS selectors in document style sheet correctly (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Reinclude test/common.js Created May 15, 2018, 5:18 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 | « lib/common.js ('k') | test/common.js » ('j') | 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
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 "use strict"; 18 "use strict";
19 19
20 const {textToRegExp, filterToRegExp, splitSelector} = require("../common"); 20 const {textToRegExp, filterToRegExp, splitSelector,
21 qualifySelector} = require("../common");
21 const {indexOf} = require("../coreUtils"); 22 const {indexOf} = require("../coreUtils");
22 23
23 let MIN_INVOCATION_INTERVAL = 3000; 24 let MIN_INVOCATION_INTERVAL = 3000;
24 const MAX_SYNCHRONOUS_PROCESSING_TIME = 50; 25 const MAX_SYNCHRONOUS_PROCESSING_TIME = 50;
25 const abpSelectorRegexp = /:-abp-([\w-]+)\(/i; 26 const abpSelectorRegexp = /:-abp-([\w-]+)\(/i;
26 27
27 function getCachedPropertyValue(object, name, defaultValueFunc = () => {}) 28 function getCachedPropertyValue(object, name, defaultValueFunc = () => {})
28 { 29 {
29 let value = object[name]; 30 let value = object[name];
30 if (typeof value == "undefined") 31 if (typeof value == "undefined")
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 for (let subSelector of style.subSelectors) 378 for (let subSelector of style.subSelectors)
378 { 379 {
379 if (subSelector.startsWith("*") && 380 if (subSelector.startsWith("*") &&
380 !incompletePrefixRegexp.test(prefix)) 381 !incompletePrefixRegexp.test(prefix))
381 { 382 {
382 subSelector = subSelector.substr(1); 383 subSelector = subSelector.substr(1);
383 } 384 }
384 let idx = subSelector.lastIndexOf("::"); 385 let idx = subSelector.lastIndexOf("::");
385 if (idx != -1) 386 if (idx != -1)
386 subSelector = subSelector.substr(0, idx); 387 subSelector = subSelector.substr(0, idx);
387 yield prefix + subSelector; 388 yield qualifySelector(subSelector, prefix);
388 } 389 }
389 }, 390 },
390 391
391 *getSelectors(prefix, subtree, styles) 392 *getSelectors(prefix, subtree, styles)
392 { 393 {
393 for (let selector of this.findPropsSelectors(styles, prefix, this._regexp)) 394 for (let selector of this.findPropsSelectors(styles, prefix, this._regexp))
394 yield [selector, subtree]; 395 yield [selector, subtree];
395 } 396 }
396 }; 397 };
397 398
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
865 characterData: shouldObserveCharacterData(this.patterns), 866 characterData: shouldObserveCharacterData(this.patterns),
866 subtree: true 867 subtree: true
867 } 868 }
868 ); 869 );
869 this.document.addEventListener("load", this.onLoad.bind(this), true); 870 this.document.addEventListener("load", this.onLoad.bind(this), true);
870 } 871 }
871 } 872 }
872 }; 873 };
873 874
874 exports.ElemHideEmulation = ElemHideEmulation; 875 exports.ElemHideEmulation = ElemHideEmulation;
OLDNEW
« no previous file with comments | « lib/common.js ('k') | test/common.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld