OLD | NEW |
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 else if (sep == "") | 43 else if (sep == "") |
44 { | 44 { |
45 if (chr == '"' || chr == "'") | 45 if (chr == '"' || chr == "'") |
46 sep = chr; | 46 sep = chr; |
47 else if (chr == "(") // don't split between parentheses | 47 else if (chr == "(") // don't split between parentheses |
48 level++; // e.g. :matches(div,span) | 48 level++; // e.g. :matches(div,span) |
49 else if (chr == ")") | 49 else if (chr == ")") |
50 level = Math.max(0, level - 1); | 50 level = Math.max(0, level - 1); |
51 else if (chr == "," && level == 0) | 51 else if (chr == "," && level == 0) |
52 { | 52 { |
53 selectors.push(selector.substring(start, i)); | 53 selectors.push(selector.substring(start, i).trim()); |
54 start = i + 1; | 54 start = i + 1; |
55 } | 55 } |
56 } | 56 } |
57 } | 57 } |
58 | 58 |
59 selectors.push(selector.substring(start)); | 59 selectors.push(selector.substring(start).trim()); |
60 return selectors; | 60 return selectors; |
61 } | 61 } |
62 | 62 |
63 /** Return position of node from parent. | 63 /** Return position of node from parent. |
64 * @param {Node} node the node to find the position of. | 64 * @param {Node} node the node to find the position of. |
65 * @return {number} One-based index like for :nth-child(), or 0 on error. | 65 * @return {number} One-based index like for :nth-child(), or 0 on error. |
66 */ | 66 */ |
67 function positionInParent(node) | 67 function positionInParent(node) |
68 { | 68 { |
69 let {children} = node.parentNode; | 69 let {children} = node.parentNode; |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 | 274 |
275 this._regexp = new RegExp(regexpString, "i"); | 275 this._regexp = new RegExp(regexpString, "i"); |
276 } | 276 } |
277 | 277 |
278 PropsSelector.prototype = { | 278 PropsSelector.prototype = { |
279 preferHideWithSelector: true, | 279 preferHideWithSelector: true, |
280 dependsOnStyles: true, | 280 dependsOnStyles: true, |
281 | 281 |
282 *findPropsSelectors(styles, prefix, regexp) | 282 *findPropsSelectors(styles, prefix, regexp) |
283 { | 283 { |
| 284 let actualPrefix = (prefix && !incompletePrefixRegexp.test(prefix)) ? |
| 285 prefix + " " : prefix; |
284 for (let style of styles) | 286 for (let style of styles) |
285 if (regexp.test(style.style)) | 287 if (regexp.test(style.style)) |
286 for (let subSelector of style.subSelectors) | 288 for (let subSelector of style.subSelectors) |
287 yield prefix + subSelector; | 289 { |
| 290 if (subSelector == "*") |
| 291 subSelector = ""; |
| 292 yield actualPrefix + subSelector; |
| 293 } |
288 }, | 294 }, |
289 | 295 |
290 *getSelectors(prefix, subtree, styles) | 296 *getSelectors(prefix, subtree, styles) |
291 { | 297 { |
292 for (let selector of this.findPropsSelectors(styles, prefix, this._regexp)) | 298 for (let selector of this.findPropsSelectors(styles, prefix, this._regexp)) |
293 yield [selector, subtree]; | 299 yield [selector, subtree]; |
294 } | 300 } |
295 }; | 301 }; |
296 | 302 |
297 function ElemHideEmulation(window, getFiltersFunc, addSelectorsFunc, | 303 function ElemHideEmulation(window, getFiltersFunc, addSelectorsFunc, |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 | 511 |
506 if (this.patterns.length > 0) | 512 if (this.patterns.length > 0) |
507 { | 513 { |
508 let {document} = this.window; | 514 let {document} = this.window; |
509 this.addSelectors(); | 515 this.addSelectors(); |
510 document.addEventListener("load", this.onLoad.bind(this), true); | 516 document.addEventListener("load", this.onLoad.bind(this), true); |
511 } | 517 } |
512 }); | 518 }); |
513 } | 519 } |
514 }; | 520 }; |
OLD | NEW |