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

Side by Side Diff: lib/filterClasses.js

Issue 29324599: Issue 2392/2393 - Created container for CSS property filters (Closed)
Patch Set: Rebased and addressed comments Created Nov. 25, 2015, 11:12 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 * @return {Filter} 110 * @return {Filter}
111 */ 111 */
112 Filter.fromText = function(text) 112 Filter.fromText = function(text)
113 { 113 {
114 if (text in Filter.knownFilters) 114 if (text in Filter.knownFilters)
115 return Filter.knownFilters[text]; 115 return Filter.knownFilters[text];
116 116
117 let ret; 117 let ret;
118 let match = (text.indexOf("#") >= 0 ? Filter.elemhideRegExp.exec(text) : null) ; 118 let match = (text.indexOf("#") >= 0 ? Filter.elemhideRegExp.exec(text) : null) ;
119 if (match) 119 if (match)
120 ret = ElemHideBase.fromText(text, match[1], match[2], match[3], match[4], ma tch[5]); 120 ret = ElemHideBase.fromText(text, match[1], !!match[2], match[3], match[4], match[5]);
121 else if (text[0] == "!") 121 else if (text[0] == "!")
122 ret = new CommentFilter(text); 122 ret = new CommentFilter(text);
123 else 123 else
124 ret = RegExpFilter.fromText(text); 124 ret = RegExpFilter.fromText(text);
125 125
126 Filter.knownFilters[ret.text] = ret; 126 Filter.knownFilters[ret.text] = ret;
127 return ret; 127 return ret;
128 }; 128 };
129 129
130 /** 130 /**
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 /** 888 /**
889 * CSS selector for the HTML elements that should be hidden 889 * CSS selector for the HTML elements that should be hidden
890 * @type String 890 * @type String
891 */ 891 */
892 selector: null 892 selector: null
893 }; 893 };
894 894
895 /** 895 /**
896 * Creates an element hiding filter from a pre-parsed text representation 896 * Creates an element hiding filter from a pre-parsed text representation
897 * 897 *
898 * @param {String} text same as in Filter() 898 * @param {String} text same as in Filter()
899 * @param {String} domain domain part of the text representation (can be emp ty) 899 * @param {String} domain domain part of the text representation (can be e mpty)
900 * @param {String} tagName tag name part (can be empty) 900 * @param {Boolean} isException exception rule indicator
901 * @param {String} attrRules attribute matching rules (can be empty) 901 * @param {String} tagName tag name part (can be empty)
902 * @param {String} selector raw CSS selector (can be empty) 902 * @param {String} attrRules attribute matching rules (can be empty)
903 * @param {String} selector raw CSS selector (can be empty)
903 * @return {ElemHideFilter|ElemHideException|CSSPropertyFilter|InvalidFilter} 904 * @return {ElemHideFilter|ElemHideException|CSSPropertyFilter|InvalidFilter}
904 */ 905 */
905 ElemHideBase.fromText = function(text, domain, isException, tagName, attrRules, selector) 906 ElemHideBase.fromText = function(text, domain, isException, tagName, attrRules, selector)
906 { 907 {
907 if (!selector) 908 if (!selector)
908 { 909 {
909 if (tagName == "*") 910 if (tagName == "*")
910 tagName = ""; 911 tagName = "";
911 912
912 let id = null; 913 let id = null;
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
1060 // several times on Safari, due to WebKit bug 132872 1061 // several times on Safari, due to WebKit bug 132872
1061 let prop = Object.getOwnPropertyDescriptor(this, "regexpString"); 1062 let prop = Object.getOwnPropertyDescriptor(this, "regexpString");
1062 if (prop) 1063 if (prop)
1063 return prop.value; 1064 return prop.value;
1064 1065
1065 let regexp = Filter.toRegExp(this.regexpSource); 1066 let regexp = Filter.toRegExp(this.regexpSource);
1066 Object.defineProperty(this, "regexpString", {value: regexp}); 1067 Object.defineProperty(this, "regexpString", {value: regexp});
1067 return regexp; 1068 return regexp;
1068 } 1069 }
1069 }; 1070 };
OLDNEW
« lib/cssRules.js ('K') | « lib/cssRules.js ('k') | lib/filterListener.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld