| Left: | ||
| Right: |
| LEFT | RIGHT |
|---|---|
| 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-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 54 */ | 54 */ |
| 55 var filtersByDomain = Object.create(null); | 55 var filtersByDomain = Object.create(null); |
| 56 | 56 |
| 57 /** | 57 /** |
| 58 * Lookup table, filters by selector. (Only contains filters that have a | 58 * Lookup table, filters by selector. (Only contains filters that have a |
| 59 * selector that is unconditionally matched for all domains.) | 59 * selector that is unconditionally matched for all domains.) |
| 60 */ | 60 */ |
| 61 var filtersBySelector = Object.create(null); | 61 var filtersBySelector = Object.create(null); |
| 62 | 62 |
| 63 /** | 63 /** |
| 64 * Array of selectors which unconditionally apply to all domains, or null if | 64 * This array caches the keys of filtersBySelector table (selectors which |
| 65 * the array needs to be regenerated. | 65 * unconditionally apply on all domains). It will be null if the cache needs to |
|
Wladimir Palant
2016/05/25 10:43:03
Maybe change the description to better indicate wh
kzar
2016/05/25 10:51:28
Done.
| |
| 66 */ | 66 * be rebuilt. |
| 67 var unconditionalSelectors = []; | 67 */ |
|
Wladimir Palant
2016/05/25 10:43:03
Nit: Please initialize with null here and in clear
kzar
2016/05/25 10:51:28
Done.
| |
| 68 var unconditionalSelectors = null; | |
| 68 | 69 |
| 69 /** | 70 /** |
| 70 * Object to be used instead when a filter has a blank domains property. | 71 * Object to be used instead when a filter has a blank domains property. |
| 71 */ | 72 */ |
| 72 var defaultDomains = Object.create(null); | 73 var defaultDomains = Object.create(null); |
| 73 defaultDomains[""] = true; | 74 defaultDomains[""] = true; |
| 74 | 75 |
| 75 /** | 76 /** |
| 76 * Lookup table, keys are known element hiding exceptions | 77 * Lookup table, keys are known element hiding exceptions |
| 77 * @type Object | 78 * @type Object |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 127 | 128 |
| 128 /** | 129 /** |
| 129 * Removes all known filters | 130 * Removes all known filters |
| 130 */ | 131 */ |
| 131 clear: function() | 132 clear: function() |
| 132 { | 133 { |
| 133 filterByKey = []; | 134 filterByKey = []; |
| 134 keyByFilter = Object.create(null); | 135 keyByFilter = Object.create(null); |
| 135 filtersByDomain = Object.create(null); | 136 filtersByDomain = Object.create(null); |
| 136 filtersBySelector = Object.create(null); | 137 filtersBySelector = Object.create(null); |
| 137 unconditionalSelectors = []; | 138 unconditionalSelectors = null; |
| 138 knownExceptions = Object.create(null); | 139 knownExceptions = Object.create(null); |
| 139 exceptions = Object.create(null); | 140 exceptions = Object.create(null); |
| 140 ElemHide.isDirty = false; | 141 ElemHide.isDirty = false; |
| 141 ElemHide.unapply(); | 142 ElemHide.unapply(); |
| 142 }, | 143 }, |
| 143 | 144 |
| 144 _addToFiltersByDomain: function(filter) | 145 _addToFiltersByDomain: function(filter) |
| 145 { | 146 { |
| 146 let key = keyByFilter[filter.text]; | 147 let key = keyByFilter[filter.text]; |
| 147 let domains = filter.domains || defaultDomains; | 148 let domains = filter.domains || defaultDomains; |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 525 if (currentDomain == "") | 526 if (currentDomain == "") |
| 526 break; | 527 break; |
| 527 | 528 |
| 528 let nextDot = currentDomain.indexOf("."); | 529 let nextDot = currentDomain.indexOf("."); |
| 529 currentDomain = nextDot == -1 ? "" : currentDomain.substr(nextDot + 1); | 530 currentDomain = nextDot == -1 ? "" : currentDomain.substr(nextDot + 1); |
| 530 } | 531 } |
| 531 | 532 |
| 532 return selectors; | 533 return selectors; |
| 533 } | 534 } |
| 534 }; | 535 }; |
| LEFT | RIGHT |