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

Unified Diff: lib/filterComposer.js

Issue 29321504: Issue 2738 - Pass bit masks to matching functions (Closed)
Patch Set: Updated adblockplus dependency Created July 14, 2015, 2:45 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 | « dependencies ('k') | lib/whitelisting.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/filterComposer.js
diff --git a/lib/filterComposer.js b/lib/filterComposer.js
index 1eb31b9bc075ee67c5e6250f0089803616f155bc..12b260f76bf3c4077e53693a3295045accc4baf7 100644
--- a/lib/filterComposer.js
+++ b/lib/filterComposer.js
@@ -20,6 +20,7 @@
let {extractHostFromFrame, stringifyURL, isThirdParty} = require("url");
let {getKey, isFrameWhitelisted} = require("whitelisting");
let {defaultMatcher} = require("matcher");
+let {RegExpFilter} = require("filterClasses");
function escapeChar(chr)
{
@@ -87,8 +88,9 @@ exports.composeFilters = function(details)
let page = details.page;
let frame = details.frame;
- if (!isFrameWhitelisted(page, frame, "DOCUMENT"))
+ if (!isFrameWhitelisted(page, frame, RegExpFilter.typeMap.DOCUMENT))
{
+ let typeMask = RegExpFilter.typeMap[details.type];
let docDomain = extractHostFromFrame(frame);
// Add a blocking filter for each URL of the element that can be blocked
@@ -98,7 +100,7 @@ exports.composeFilters = function(details)
url = stringifyURL(urlObj);
let filter = defaultMatcher.whitelist.matchesAny(
- url, details.type, docDomain,
+ url, typeMask, docDomain,
isThirdParty(urlObj, docDomain),
getKey(page, frame)
);
@@ -114,7 +116,7 @@ exports.composeFilters = function(details)
// If we couldn't generate any blocking filters, fallback to element hiding
let selectors = [];
- if (filters.length == 0 && !isFrameWhitelisted(page, frame, "ELEMHIDE"))
+ if (filters.length == 0 && !isFrameWhitelisted(page, frame, RegExpFilter.typeMap.ELEMHIDE))
{
// Generate CSS selectors based on the element's "id" and "class" attribute
if (details.id)
« no previous file with comments | « dependencies ('k') | lib/whitelisting.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld