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-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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 yield null; | 220 yield null; |
221 } | 221 } |
222 | 222 |
223 function PlainSelector(selector) | 223 function PlainSelector(selector) |
224 { | 224 { |
225 this._selector = selector; | 225 this._selector = selector; |
226 this.maybeDependsOnAttributes = /[#.]|\[.+\]/.test(selector); | 226 this.maybeDependsOnAttributes = /[#.]|\[.+\]/.test(selector); |
227 } | 227 } |
228 | 228 |
229 PlainSelector.prototype = { | 229 PlainSelector.prototype = { |
| 230 preferHideWithSelector: true, |
| 231 |
230 /** | 232 /** |
231 * Generator function returning a pair of selector | 233 * Generator function returning a pair of selector |
232 * string and subtree. | 234 * string and subtree. |
233 * @param {string} prefix the prefix for the selector. | 235 * @param {string} prefix the prefix for the selector. |
234 * @param {Node} subtree the subtree we work on. | 236 * @param {Node} subtree the subtree we work on. |
235 * @param {StringifiedStyle[]} styles the stringified style objects. | 237 * @param {StringifiedStyle[]} styles the stringified style objects. |
236 */ | 238 */ |
237 *getSelectors(prefix, subtree, styles) | 239 *getSelectors(prefix, subtree, styles) |
238 { | 240 { |
239 yield [prefix + this._selector, subtree]; | 241 yield [prefix + this._selector, subtree]; |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 { | 403 { |
402 this.selectors = selectors; | 404 this.selectors = selectors; |
403 this.text = text; | 405 this.text = text; |
404 } | 406 } |
405 | 407 |
406 Pattern.prototype = { | 408 Pattern.prototype = { |
407 isSelectorHidingOnlyPattern() | 409 isSelectorHidingOnlyPattern() |
408 { | 410 { |
409 return getCachedPropertyValue( | 411 return getCachedPropertyValue( |
410 this, "_selectorHidingOnlyPattern", | 412 this, "_selectorHidingOnlyPattern", |
411 () => this.selectors.some(selector => selector.preferHideWithSelector) && | 413 () => this.selectors.every(selector => selector.preferHideWithSelector) && |
412 !this.selectors.some(selector => selector.requiresHiding) | 414 !this.selectors.some(selector => selector.requiresHiding) |
413 ); | 415 ); |
414 }, | 416 }, |
415 | 417 |
416 get dependsOnStyles() | 418 get dependsOnStyles() |
417 { | 419 { |
418 return getCachedPropertyValue( | 420 return getCachedPropertyValue( |
419 this, "_dependsOnStyles", | 421 this, "_dependsOnStyles", |
420 () => this.selectors.some(selector => selector.dependsOnStyles) | 422 () => this.selectors.some(selector => selector.dependsOnStyles) |
421 ); | 423 ); |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
835 characterData: shouldObserveCharacterData(this.patterns), | 837 characterData: shouldObserveCharacterData(this.patterns), |
836 subtree: true | 838 subtree: true |
837 } | 839 } |
838 ); | 840 ); |
839 this.document.addEventListener("load", this.onLoad.bind(this), true); | 841 this.document.addEventListener("load", this.onLoad.bind(this), true); |
840 } | 842 } |
841 } | 843 } |
842 }; | 844 }; |
843 | 845 |
844 exports.ElemHideEmulation = ElemHideEmulation; | 846 exports.ElemHideEmulation = ElemHideEmulation; |
OLD | NEW |