| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   59 /** |   59 /** | 
|   60  * This array caches the values of filterKeyBySelector table (filterIds for |   60  * This array caches the values of filterKeyBySelector table (filterIds for | 
|   61  * selectors which unconditionally apply on all domains). It will be null if the |   61  * selectors which unconditionally apply on all domains). It will be null if the | 
|   62  * cache needs to be rebuilt. |   62  * cache needs to be rebuilt. | 
|   63  */ |   63  */ | 
|   64 let unconditionalFilterKeys = null; |   64 let unconditionalFilterKeys = null; | 
|   65  |   65  | 
|   66 /** |   66 /** | 
|   67  * Object to be used instead when a filter has a blank domains property. |   67  * Object to be used instead when a filter has a blank domains property. | 
|   68  */ |   68  */ | 
|   69 let defaultDomains = Object.create(null); |   69 let defaultDomains = new Map([["", true]]); | 
|   70 defaultDomains[""] = true; |  | 
|   71  |   70  | 
|   72 /** |   71 /** | 
|   73  * Lookup table, keys are known element hiding exceptions |   72  * Lookup table, keys are known element hiding exceptions | 
|   74  * @type {Object} |   73  * @type {Object} | 
|   75  */ |   74  */ | 
|   76 let knownExceptions = Object.create(null); |   75 let knownExceptions = Object.create(null); | 
|   77  |   76  | 
|   78 /** |   77 /** | 
|   79  * Lookup table, lists of element hiding exceptions by selector |   78  * Lookup table, lists of element hiding exceptions by selector | 
|   80  * @type {Object} |   79  * @type {Object} | 
| (...skipping 16 matching lines...) Expand all  Loading... | 
|   97     filterKeyBySelector = Object.create(null); |   96     filterKeyBySelector = Object.create(null); | 
|   98     unconditionalSelectors = unconditionalFilterKeys = null; |   97     unconditionalSelectors = unconditionalFilterKeys = null; | 
|   99     knownExceptions = Object.create(null); |   98     knownExceptions = Object.create(null); | 
|  100     exceptions = Object.create(null); |   99     exceptions = Object.create(null); | 
|  101     FilterNotifier.emit("elemhideupdate"); |  100     FilterNotifier.emit("elemhideupdate"); | 
|  102   }, |  101   }, | 
|  103  |  102  | 
|  104   _addToFiltersByDomain(key, filter) |  103   _addToFiltersByDomain(key, filter) | 
|  105   { |  104   { | 
|  106     let domains = filter.domains || defaultDomains; |  105     let domains = filter.domains || defaultDomains; | 
|  107     for (let domain in domains) |  106     for (let [domain, isIncluded] of domains) | 
|  108     { |  107     { | 
|  109       let filters = filtersByDomain[domain]; |  108       let filters = filtersByDomain[domain]; | 
|  110       if (!filters) |  109       if (!filters) | 
|  111         filters = filtersByDomain[domain] = Object.create(null); |  110         filters = filtersByDomain[domain] = Object.create(null); | 
|  112  |  111  | 
|  113       if (domains[domain]) |  112       if (isIncluded) | 
|  114         filters[key] = filter; |  113         filters[key] = filter; | 
|  115       else |  114       else | 
|  116         filters[key] = false; |  115         filters[key] = false; | 
|  117     } |  116     } | 
|  118   }, |  117   }, | 
|  119  |  118  | 
|  120   /** |  119   /** | 
|  121    * Add a new element hiding filter |  120    * Add a new element hiding filter | 
|  122    * @param {ElemHideFilter} filter |  121    * @param {ElemHideFilter} filter | 
|  123    */ |  122    */ | 
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  175     if (filterKeyBySelector[filter.selector] == key) |  174     if (filterKeyBySelector[filter.selector] == key) | 
|  176     { |  175     { | 
|  177       delete filterKeyBySelector[filter.selector]; |  176       delete filterKeyBySelector[filter.selector]; | 
|  178       unconditionalSelectors = unconditionalFilterKeys = null; |  177       unconditionalSelectors = unconditionalFilterKeys = null; | 
|  179       return; |  178       return; | 
|  180     } |  179     } | 
|  181  |  180  | 
|  182     // We haven't found this filter in unconditional filters, look in |  181     // We haven't found this filter in unconditional filters, look in | 
|  183     // filtersByDomain. |  182     // filtersByDomain. | 
|  184     let domains = filter.domains || defaultDomains; |  183     let domains = filter.domains || defaultDomains; | 
|  185     for (let domain in domains) |  184     for (let domain of domains.keys()) | 
|  186     { |  185     { | 
|  187       let filters = filtersByDomain[domain]; |  186       let filters = filtersByDomain[domain]; | 
|  188       if (filters) |  187       if (filters) | 
|  189         delete filters[key]; |  188         delete filters[key]; | 
|  190     } |  189     } | 
|  191   }, |  190   }, | 
|  192  |  191  | 
|  193   /** |  192   /** | 
|  194    * Removes an element hiding filter |  193    * Removes an element hiding filter | 
|  195    * @param {ElemHideFilter} filter |  194    * @param {ElemHideFilter} filter | 
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  387  |  386  | 
|  388       let nextDot = currentDomain.indexOf("."); |  387       let nextDot = currentDomain.indexOf("."); | 
|  389       currentDomain = nextDot == -1 ? "" : currentDomain.substr(nextDot + 1); |  388       currentDomain = nextDot == -1 ? "" : currentDomain.substr(nextDot + 1); | 
|  390     } |  389     } | 
|  391  |  390  | 
|  392     if (provideFilterKeys) |  391     if (provideFilterKeys) | 
|  393       return [selectors, filterKeys]; |  392       return [selectors, filterKeys]; | 
|  394     return selectors; |  393     return selectors; | 
|  395   } |  394   } | 
|  396 }; |  395 }; | 
| OLD | NEW |