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

Unified Diff: lib/elemHide.js

Issue 29737558: Issue 6538, 6781 - Implement support for snippet filters (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Add filter to known filters Created May 7, 2018, 7:02 p.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
« no previous file with comments | « no previous file | lib/filterClasses.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/elemHide.js
===================================================================
--- a/lib/elemHide.js
+++ b/lib/elemHide.js
@@ -103,38 +103,38 @@
*/
add(filter)
{
if (knownFilters.has(filter))
return;
if (filter instanceof ElemHideException)
{
- let {selector} = filter;
- let list = exceptions.get(selector);
+ let {code} = filter;
+ let list = exceptions.get(code);
if (list)
list.push(filter);
else
- exceptions.set(selector, [filter]);
+ exceptions.set(code, [filter]);
// If this is the first exception for a previously unconditionally
// applied element hiding selector we need to take care to update the
// lookups.
- let unconditionalFilterForSelector = filterBySelector.get(selector);
+ let unconditionalFilterForSelector = filterBySelector.get(code);
if (unconditionalFilterForSelector)
{
this._addToFiltersByDomain(unconditionalFilterForSelector);
- filterBySelector.delete(selector);
+ filterBySelector.delete(code);
unconditionalSelectors = null;
}
}
- else if (!(filter.domains || exceptions.has(filter.selector)))
+ else if (!(filter.domains || exceptions.has(filter.code)))
{
// The new filter's selector is unconditionally applied to all domains
- filterBySelector.set(filter.selector, filter);
+ filterBySelector.set(filter.code, filter);
unconditionalSelectors = null;
}
else
{
// The new filter's selector only applies to some domains
this._addToFiltersByDomain(filter);
}
@@ -149,25 +149,25 @@
remove(filter)
{
if (!knownFilters.has(filter))
return;
// Whitelisting filters
if (filter instanceof ElemHideException)
{
- let list = exceptions.get(filter.selector);
+ let list = exceptions.get(filter.code);
let index = list.indexOf(filter);
if (index >= 0)
list.splice(index, 1);
}
// Unconditially applied element hiding filters
- else if (filterBySelector.get(filter.selector) == filter)
+ else if (filterBySelector.get(filter.code) == filter)
{
- filterBySelector.delete(filter.selector);
+ filterBySelector.delete(filter.code);
unconditionalSelectors = null;
}
// Conditionally applied element hiding filters
else
{
let domains = filter.domains || defaultDomains;
for (let domain of domains.keys())
{
@@ -185,17 +185,17 @@
* Checks whether an exception rule is registered for a filter on a particular
* domain.
* @param {Filter} filter
* @param {string} docDomain
* @return {ElemHideException}
*/
getException(filter, docDomain)
{
- let list = exceptions.get(filter.selector);
+ let list = exceptions.get(filter.code);
if (!list)
return null;
for (let i = list.length - 1; i >= 0; i--)
{
if (list[i].isActiveOnDomain(docDomain))
return list[i];
}
@@ -269,17 +269,17 @@
{
if (!isIncluded)
{
excluded.add(filter);
}
else if ((excluded.size == 0 || !excluded.has(filter)) &&
!this.getException(filter, domain))
{
- selectors.push(filter.selector);
+ selectors.push(filter.code);
}
}
}
if (currentDomain == "")
break;
let nextDot = currentDomain.indexOf(".");
« no previous file with comments | « no previous file | lib/filterClasses.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld