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

Unified Diff: lib/filterListener.js

Issue 29783618: Issue 6665 - Split out element hiding exceptions into their own module (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Emit own elemhideupdate event Created May 17, 2018, 5:19 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: lib/filterListener.js
===================================================================
--- a/lib/filterListener.js
+++ b/lib/filterListener.js
@@ -24,19 +24,21 @@
const {Services} = Cu.import("resource://gre/modules/Services.jsm", {});
const {XPCOMUtils} = Cu.import("resource://gre/modules/XPCOMUtils.jsm", {});
const {FilterStorage} = require("./filterStorage");
const {FilterNotifier} = require("./filterNotifier");
const {ElemHide} = require("./elemHide");
const {ElemHideEmulation} = require("./elemHideEmulation");
+const {ElemHideExceptions} = require("./elemHideExceptions");
const {defaultMatcher} = require("./matcher");
const {ActiveFilter, RegExpFilter,
- ElemHideBase, ElemHideEmulationFilter} = require("./filterClasses");
+ ElemHideBase, ElemHideEmulationFilter,
+ ElemHideException} = require("./filterClasses");
const {Prefs} = require("prefs");
/**
* Increases on filter changes, filters will be saved if it exceeds 1.
* @type {number}
*/
let isDirty = 0;
@@ -145,16 +147,18 @@
}
if (!hasEnabled)
return;
if (filter instanceof RegExpFilter)
defaultMatcher.add(filter);
else if (filter instanceof ElemHideBase)
{
+ if (filter instanceof ElemHideException)
+ ElemHideExceptions.add(filter);
if (filter instanceof ElemHideEmulationFilter)
ElemHideEmulation.add(filter);
else
ElemHide.add(filter);
}
}
/**
@@ -178,16 +182,18 @@
if (hasEnabled)
return;
}
if (filter instanceof RegExpFilter)
defaultMatcher.remove(filter);
else if (filter instanceof ElemHideBase)
{
+ if (filter instanceof ElemHideException)
+ ElemHideExceptions.remove(filter);
if (filter instanceof ElemHideEmulationFilter)
ElemHideEmulation.remove(filter);
else
ElemHide.remove(filter);
}
}
const primes = [101, 109, 131, 149, 163, 179, 193, 211, 229, 241];
@@ -302,16 +308,17 @@
function onLoad()
{
isDirty = 0;
defaultMatcher.clear();
ElemHide.clear();
ElemHideEmulation.clear();
+ ElemHideExceptions.clear();
for (let subscription of FilterStorage.subscriptions)
{
if (!subscription.disabled)
addFilters(subscription.filters);
}
}
function onSave()

Powered by Google App Engine
This is Rietveld