Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: lib/filterListener.js

Issue 29737558: Issue 6538, 6781 - Implement support for snippet filters (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Left Patch Set: Rebase, rename to ScriptFilter, ignore element hiding exceptions Created May 23, 2018, 3:54 a.m.
Right Patch Set: Improve comment formatting Created July 11, 2018, 1:02 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 */ 136 */
137 function addFilter(filter) 137 function addFilter(filter)
138 { 138 {
139 if (!(filter instanceof ActiveFilter) || filter.disabled) 139 if (!(filter instanceof ActiveFilter) || filter.disabled)
140 return; 140 return;
141 141
142 let hasEnabled = false; 142 let hasEnabled = false;
143 for (let i = 0; i < filter.subscriptions.length; i++) 143 for (let i = 0; i < filter.subscriptions.length; i++)
144 { 144 {
145 if (!filter.subscriptions[i].disabled) 145 if (!filter.subscriptions[i].disabled)
146 {
146 hasEnabled = true; 147 hasEnabled = true;
148 break;
149 }
147 } 150 }
148 if (!hasEnabled) 151 if (!hasEnabled)
149 return; 152 return;
150 153
151 if (filter instanceof RegExpFilter) 154 if (filter instanceof RegExpFilter)
152 defaultMatcher.add(filter); 155 defaultMatcher.add(filter);
153 else if (filter instanceof ElemHideBase) 156 else if (filter instanceof ElemHideBase)
154 { 157 {
155 if (filter instanceof ElemHideEmulationFilter) 158 if (filter instanceof ElemHideEmulationFilter)
156 ElemHideEmulation.add(filter); 159 ElemHideEmulation.add(filter);
(...skipping 13 matching lines...) Expand all
170 { 173 {
171 if (!(filter instanceof ActiveFilter)) 174 if (!(filter instanceof ActiveFilter))
172 return; 175 return;
173 176
174 if (!filter.disabled) 177 if (!filter.disabled)
175 { 178 {
176 let hasEnabled = false; 179 let hasEnabled = false;
177 for (let i = 0; i < filter.subscriptions.length; i++) 180 for (let i = 0; i < filter.subscriptions.length; i++)
178 { 181 {
179 if (!filter.subscriptions[i].disabled) 182 if (!filter.subscriptions[i].disabled)
183 {
180 hasEnabled = true; 184 hasEnabled = true;
185 break;
186 }
181 } 187 }
182 if (hasEnabled) 188 if (hasEnabled)
183 return; 189 return;
184 } 190 }
185 191
186 if (filter instanceof RegExpFilter) 192 if (filter instanceof RegExpFilter)
187 defaultMatcher.remove(filter); 193 defaultMatcher.remove(filter);
188 else if (filter instanceof ElemHideBase) 194 else if (filter instanceof ElemHideBase)
189 { 195 {
190 if (filter instanceof ElemHideEmulationFilter) 196 if (filter instanceof ElemHideEmulationFilter)
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 FilterListener.setDirty(1); 240 FilterListener.setDirty(1);
235 241
236 if (!subscription.disabled) 242 if (!subscription.disabled)
237 subscription.filters.forEach(removeFilter); 243 subscription.filters.forEach(removeFilter);
238 } 244 }
239 245
240 function onSubscriptionDisabled(subscription, newValue) 246 function onSubscriptionDisabled(subscription, newValue)
241 { 247 {
242 FilterListener.setDirty(1); 248 FilterListener.setDirty(1);
243 249
244 if (subscription.url in FilterStorage.knownSubscriptions) 250 if (FilterStorage.knownSubscriptions.has(subscription.url))
245 { 251 {
246 if (newValue == false) 252 if (newValue == false)
247 addFilters(subscription.filters); 253 addFilters(subscription.filters);
248 else 254 else
249 subscription.filters.forEach(removeFilter); 255 subscription.filters.forEach(removeFilter);
250 } 256 }
251 } 257 }
252 258
253 function onSubscriptionUpdated(subscription) 259 function onSubscriptionUpdated(subscription)
254 { 260 {
255 FilterListener.setDirty(1); 261 FilterListener.setDirty(1);
256 262
257 if (subscription.url in FilterStorage.knownSubscriptions && 263 if (!subscription.disabled &&
258 !subscription.disabled) 264 FilterStorage.knownSubscriptions.has(subscription.url))
259 { 265 {
260 subscription.oldFilters.forEach(removeFilter); 266 subscription.oldFilters.forEach(removeFilter);
261 addFilters(subscription.filters); 267 addFilters(subscription.filters);
262 } 268 }
263 } 269 }
264 270
265 function onFilterHitCount(filter, newValue) 271 function onFilterHitCount(filter, newValue)
266 { 272 {
267 if (newValue == 0) 273 if (newValue == 0)
268 FilterListener.setDirty(0); 274 FilterListener.setDirty(0);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 { 324 {
319 if (!subscription.disabled) 325 if (!subscription.disabled)
320 addFilters(subscription.filters); 326 addFilters(subscription.filters);
321 } 327 }
322 } 328 }
323 329
324 function onSave() 330 function onSave()
325 { 331 {
326 isDirty = 0; 332 isDirty = 0;
327 } 333 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld