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: Return code directly from getScriptsForDomain Created May 2, 2018, 8:01 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
@@ -112,65 +112,65 @@
*/
add(filter)
{
if (filter instanceof ElemHideException)
{
if (knownExceptions.has(filter.text))
return;
- 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 filterKey = filterKeyBySelector.get(selector);
+ let filterKey = filterKeyBySelector.get(code);
if (typeof filterKey != "undefined")
{
this._addToFiltersByDomain(filterKey, filterByKey[filterKey]);
- filterKeyBySelector.delete(selector);
+ filterKeyBySelector.delete(code);
unconditionalSelectors = null;
}
knownExceptions.add(filter.text);
}
else
{
if (keyByFilter.has(filter))
return;
let key = filterByKey.push(filter) - 1;
keyByFilter.set(filter, key);
- if (!(filter.domains || exceptions.has(filter.selector)))
+ if (!(filter.domains || exceptions.has(filter.code)))
{
// The new filter's selector is unconditionally applied to all domains
- filterKeyBySelector.set(filter.selector, key);
+ filterKeyBySelector.set(filter.code, key);
unconditionalSelectors = null;
}
else
{
// The new filter's selector only applies to some domains
this._addToFiltersByDomain(key, filter);
}
}
FilterNotifier.emit("elemhideupdate");
},
_removeFilterKey(key, filter)
{
- if (filterKeyBySelector.get(filter.selector) == key)
+ if (filterKeyBySelector.get(filter.code) == key)
{
- filterKeyBySelector.delete(filter.selector);
+ filterKeyBySelector.delete(filter.code);
unconditionalSelectors = null;
return;
}
// We haven't found this filter in unconditional filters, look in
// filtersByDomain.
let domains = filter.domains || defaultDomains;
for (let domain of domains.keys())
@@ -187,17 +187,17 @@
*/
remove(filter)
{
if (filter instanceof ElemHideException)
{
if (!knownExceptions.has(filter.text))
return;
- let list = exceptions.get(filter.selector);
+ let list = exceptions.get(filter.code);
let index = list.indexOf(filter);
if (index >= 0)
list.splice(index, 1);
knownExceptions.delete(filter.text);
}
else
{
let key = keyByFilter.get(filter);
@@ -216,17 +216,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];
}
@@ -305,17 +305,17 @@
{
for (let [filterKey, filter] of filters)
{
if (seenFilters.has(filterKey))
continue;
seenFilters.add(filterKey);
if (filter && !this.getException(filter, domain))
- selectors.push(filter.selector);
+ selectors.push(filter.code);
}
}
if (currentDomain == "")
break;
let nextDot = currentDomain.indexOf(".");
currentDomain = nextDot == -1 ? "" : currentDomain.substr(nextDot + 1);
« 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