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-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 = new Map(); | 69 let defaultDomains = new Map([["", true]]); |
70 defaultDomains.set("", true); | |
Wladimir Palant
2017/09/21 08:11:44
You can initialize the Map object immediately: new
sergei
2017/09/21 10:50:33
Done.
| |
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 20 matching lines...) Expand all Loading... | |
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, isIncluded] of 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); |
Wladimir Palant
2017/09/21 08:11:44
Shouldn't this be turned in to a Map object as wel
sergei
2017/09/21 10:50:33
No, I find the change of filtersByDomain self-cont
| |
112 | 111 |
113 if (isIncluded) | 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 |
(...skipping 265 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 }; |
LEFT | RIGHT |