| Index: lib/contentPolicy.js |
| diff --git a/lib/contentPolicy.js b/lib/contentPolicy.js |
| index b1a49c1353d9c6af75e43ba9fc1ceb220db5ac1a..b3eb5f1f4e39834ebe8813ff33092e9595edb44b 100644 |
| --- a/lib/contentPolicy.js |
| +++ b/lib/contentPolicy.js |
| @@ -25,7 +25,7 @@ Cu.import("resource://gre/modules/Services.jsm"); |
| let {Utils} = require("utils"); |
| let {Prefs} = require("prefs"); |
| let {FilterStorage} = require("filterStorage"); |
| -let {BlockingFilter, WhitelistFilter} = require("filterClasses"); |
| +let {BlockingFilter, WhitelistFilter, RegExpFilter} = require("filterClasses"); |
| let {defaultMatcher} = require("matcher"); |
| let {objectMouseEventHander} = require("objectTabs"); |
| let {RequestNotifier} = require("requestNotifier"); |
| @@ -67,6 +67,12 @@ let Policy = exports.Policy = |
| typeDescr: {}, |
| /** |
| + * Map of numerical content types with their corresponding masks |
| + * @type Object |
| + */ |
| + typeMask: {}, |
| + |
| + /** |
| * Map of localized content type names by their identifiers. |
| * @type Object |
| */ |
| @@ -99,16 +105,21 @@ let Policy = exports.Policy = |
| this.type[typeName] = id; |
| this.typeDescr[id] = typeName; |
| this.localizedDescr[id] = Utils.getString("type_label_" + typeName.toLowerCase()); |
| + this.typeMask[id] = RegExpFilter.toTypeMask(typeName); |
| } |
| } |
| this.type.ELEMHIDE = 0xFFFD; |
| this.typeDescr[0xFFFD] = "ELEMHIDE"; |
| this.localizedDescr[0xFFFD] = Utils.getString("type_label_elemhide"); |
| + this.typeMask[0xFFFD] = RegExpFilter.toTypeMask("ELEMHIDE"); |
| this.type.POPUP = 0xFFFE; |
| this.typeDescr[0xFFFE] = "POPUP"; |
| this.localizedDescr[0xFFFE] = Utils.getString("type_label_popup"); |
| + this.typeMask[0xFFFE] = RegExpFilter.toTypeMask("POPUP"); |
| + |
| + this.defaultTypeMask = RegExpFilter.toTypeMask(""); |
|
Wladimir Palant
2015/07/10 21:07:00
It's a bit mask - the default is always 0.
kzar
2015/07/12 13:59:39
Egad, that was stupid of me.
Done.
|
| for (let type of nonVisualTypes) |
| this.nonVisual[this.type[type]] = true; |
| @@ -199,7 +210,7 @@ let Policy = exports.Policy = |
| let testWndLocation = parentWndLocation; |
| parentWndLocation = (testWnd == testWnd.parent ? testWndLocation : getWindowLocation(testWnd.parent)); |
| let parentDocDomain = getHostname(parentWndLocation); |
| - match = defaultMatcher.matchesAny(testWndLocation, "ELEMHIDE", parentDocDomain, false, sitekey); |
| + match = defaultMatcher.matchesAny(testWndLocation, Policy.typeMask[Policy.type.ELEMHIDE], parentDocDomain, false, sitekey); |
| if (match instanceof WhitelistFilter) |
| { |
| FilterStorage.increaseHitCount(match, wnd); |
| @@ -233,7 +244,7 @@ let Policy = exports.Policy = |
| if (!match && Prefs.enabled) |
| { |
| - match = defaultMatcher.matchesAny(locationText, Policy.typeDescr[contentType] || "", docDomain, thirdParty, sitekey); |
| + match = defaultMatcher.matchesAny(locationText, Policy.typeMask[contentType] || Policy.defaultTypeMask, docDomain, thirdParty, sitekey); |
|
Wladimir Palant
2015/07/10 21:07:00
This cannot possibly return a match if type mask i
kzar
2015/07/12 13:59:39
Done.
|
| if (match instanceof BlockingFilter && node.ownerDocument && !(contentType in Policy.nonVisual)) |
| { |
| let prefCollapse = (match.collapse != null ? match.collapse : !Prefs.fastcollapse); |
| @@ -292,7 +303,7 @@ let Policy = exports.Policy = |
| if (index >= 0) |
| url = url.substring(0, index); |
| - let result = defaultMatcher.matchesAny(url, "DOCUMENT", getHostname(parentUrl), false, sitekey); |
| + let result = defaultMatcher.matchesAny(url, Policy.typeMask[Policy.type.DOCUMENT], getHostname(parentUrl), false, sitekey); |
| return (result instanceof WhitelistFilter ? result : null); |
| }, |