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

Side by Side Diff: lib/filterClasses.js

Issue 29321478: Issue 2738 - Make RegExpFilter.matches() take a bit mask instead of content type string (Closed)
Patch Set: Changed API as discussed and addressed feedback Created July 12, 2015, 1:55 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/contentPolicy.js ('k') | lib/matcher.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 this.sitekeySource = null; 618 this.sitekeySource = null;
619 } 619 }
620 620
621 Object.defineProperty(this, "sitekeys", {value: sitekeys, enumerable: true}) ; 621 Object.defineProperty(this, "sitekeys", {value: sitekeys, enumerable: true}) ;
622 return this.sitekeys; 622 return this.sitekeys;
623 }, 623 },
624 624
625 /** 625 /**
626 * Tests whether the URL matches this filter 626 * Tests whether the URL matches this filter
627 * @param {String} location URL to be tested 627 * @param {String} location URL to be tested
628 * @param {String} contentType content type identifier of the URL 628 * @param {String} typeMask bitmask of content / request types to match
629 * @param {String} docDomain domain name of the document that loads the URL 629 * @param {String} docDomain domain name of the document that loads the URL
630 * @param {Boolean} thirdParty should be true if the URL is a third-party requ est 630 * @param {Boolean} thirdParty should be true if the URL is a third-party requ est
631 * @param {String} sitekey public key provided by the document 631 * @param {String} sitekey public key provided by the document
632 * @return {Boolean} true in case of a match 632 * @return {Boolean} true in case of a match
633 */ 633 */
634 matches: function(location, contentType, docDomain, thirdParty, sitekey) 634 matches: function(location, typeMask, docDomain, thirdParty, sitekey)
635 { 635 {
636 if ((RegExpFilter.typeMap[contentType] & this.contentType) != 0 && 636 if (this.contentType & typeMask &&
637 (this.thirdParty == null || this.thirdParty == thirdParty) && 637 (this.thirdParty == null || this.thirdParty == thirdParty) &&
638 this.isActiveOnDomain(docDomain, sitekey) && this.regexp.test(location)) 638 this.isActiveOnDomain(docDomain, sitekey) && this.regexp.test(location))
639 { 639 {
640 return true; 640 return true;
641 } 641 }
642 642
643 return false; 643 return false;
644 } 644 }
645 }; 645 };
646 646
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
1021 // several times on Safari, due to WebKit bug 132872 1021 // several times on Safari, due to WebKit bug 132872
1022 let prop = Object.getOwnPropertyDescriptor(this, "regexpString"); 1022 let prop = Object.getOwnPropertyDescriptor(this, "regexpString");
1023 if (prop) 1023 if (prop)
1024 return prop.value; 1024 return prop.value;
1025 1025
1026 let regexp = Filter.toRegExp(this.regexpSource); 1026 let regexp = Filter.toRegExp(this.regexpSource);
1027 Object.defineProperty(this, "regexpString", {value: regexp}); 1027 Object.defineProperty(this, "regexpString", {value: regexp});
1028 return regexp; 1028 return regexp;
1029 } 1029 }
1030 }; 1030 };
OLDNEW
« no previous file with comments | « lib/contentPolicy.js ('k') | lib/matcher.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld