Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
98 // type constant by type description and type description by type constant | 98 // type constant by type description and type description by type constant |
99 let iface = Ci.nsIContentPolicy; | 99 let iface = Ci.nsIContentPolicy; |
100 for (let typeName of contentTypes) | 100 for (let typeName of contentTypes) |
101 { | 101 { |
102 if ("TYPE_" + typeName in iface) | 102 if ("TYPE_" + typeName in iface) |
103 { | 103 { |
104 let id = iface["TYPE_" + typeName]; | 104 let id = iface["TYPE_" + typeName]; |
105 this.type[typeName] = id; | 105 this.type[typeName] = id; |
106 this.typeDescr[id] = typeName; | 106 this.typeDescr[id] = typeName; |
107 this.localizedDescr[id] = Utils.getString("type_label_" + typeName.toLow erCase()); | 107 this.localizedDescr[id] = Utils.getString("type_label_" + typeName.toLow erCase()); |
108 this.typeMask[id] = RegExpFilter.toTypeMask(typeName); | 108 this.typeMask[id] = RegExpFilter.typeMap[typeName]; |
109 } | 109 } |
110 } | 110 } |
111 | 111 |
112 this.type.ELEMHIDE = 0xFFFD; | 112 this.type.ELEMHIDE = 0xFFFD; |
113 this.typeDescr[0xFFFD] = "ELEMHIDE"; | 113 this.typeDescr[0xFFFD] = "ELEMHIDE"; |
114 this.localizedDescr[0xFFFD] = Utils.getString("type_label_elemhide"); | 114 this.localizedDescr[0xFFFD] = Utils.getString("type_label_elemhide"); |
115 this.typeMask[0xFFFD] = RegExpFilter.toTypeMask("ELEMHIDE"); | 115 this.typeMask[0xFFFD] = RegExpFilter.typeMap.ELEMHIDE; |
116 | 116 |
117 this.type.POPUP = 0xFFFE; | 117 this.type.POPUP = 0xFFFE; |
118 this.typeDescr[0xFFFE] = "POPUP"; | 118 this.typeDescr[0xFFFE] = "POPUP"; |
119 this.localizedDescr[0xFFFE] = Utils.getString("type_label_popup"); | 119 this.localizedDescr[0xFFFE] = Utils.getString("type_label_popup"); |
120 this.typeMask[0xFFFE] = RegExpFilter.toTypeMask("POPUP"); | 120 this.typeMask[0xFFFE] = RegExpFilter.typeMap.POPUP; |
121 | |
122 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.
| |
123 | 121 |
124 for (let type of nonVisualTypes) | 122 for (let type of nonVisualTypes) |
125 this.nonVisual[this.type[type]] = true; | 123 this.nonVisual[this.type[type]] = true; |
126 | 124 |
127 // whitelisted URL schemes | 125 // whitelisted URL schemes |
128 for (let scheme of Prefs.whitelistschemes.toLowerCase().split(" ")) | 126 for (let scheme of Prefs.whitelistschemes.toLowerCase().split(" ")) |
129 this.whitelistSchemes[scheme] = true; | 127 this.whitelistSchemes[scheme] = true; |
130 | 128 |
131 // Generate class identifier used to collapse node and register correspondin g | 129 // Generate class identifier used to collapse node and register correspondin g |
132 // stylesheet. | 130 // stylesheet. |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
203 let locationText = location.spec; | 201 let locationText = location.spec; |
204 if (!match && contentType == Policy.type.ELEMHIDE) | 202 if (!match && contentType == Policy.type.ELEMHIDE) |
205 { | 203 { |
206 let testWnd = wnd; | 204 let testWnd = wnd; |
207 let parentWndLocation = getWindowLocation(testWnd); | 205 let parentWndLocation = getWindowLocation(testWnd); |
208 while (true) | 206 while (true) |
209 { | 207 { |
210 let testWndLocation = parentWndLocation; | 208 let testWndLocation = parentWndLocation; |
211 parentWndLocation = (testWnd == testWnd.parent ? testWndLocation : getWi ndowLocation(testWnd.parent)); | 209 parentWndLocation = (testWnd == testWnd.parent ? testWndLocation : getWi ndowLocation(testWnd.parent)); |
212 let parentDocDomain = getHostname(parentWndLocation); | 210 let parentDocDomain = getHostname(parentWndLocation); |
213 match = defaultMatcher.matchesAny(testWndLocation, Policy.typeMask[Polic y.type.ELEMHIDE], parentDocDomain, false, sitekey); | 211 match = defaultMatcher.matchesAny(testWndLocation, RegExpFilter.typeMap. ELEMHIDE, parentDocDomain, false, sitekey); |
214 if (match instanceof WhitelistFilter) | 212 if (match instanceof WhitelistFilter) |
215 { | 213 { |
216 FilterStorage.increaseHitCount(match, wnd); | 214 FilterStorage.increaseHitCount(match, wnd); |
217 RequestNotifier.addNodeData(testWnd.document, topWnd, contentType, par entDocDomain, false, testWndLocation, match); | 215 RequestNotifier.addNodeData(testWnd.document, topWnd, contentType, par entDocDomain, false, testWndLocation, match); |
218 return true; | 216 return true; |
219 } | 217 } |
220 | 218 |
221 if (testWnd.parent == testWnd) | 219 if (testWnd.parent == testWnd) |
222 break; | 220 break; |
223 else | 221 else |
(...skipping 11 matching lines...) Expand all Loading... | |
235 if (exception) | 233 if (exception) |
236 { | 234 { |
237 FilterStorage.increaseHitCount(exception, wnd); | 235 FilterStorage.increaseHitCount(exception, wnd); |
238 RequestNotifier.addNodeData(node, topWnd, contentType, docDomain, false, locationText, exception); | 236 RequestNotifier.addNodeData(node, topWnd, contentType, docDomain, false, locationText, exception); |
239 return true; | 237 return true; |
240 } | 238 } |
241 } | 239 } |
242 | 240 |
243 let thirdParty = (contentType == Policy.type.ELEMHIDE ? false : isThirdParty (location, docDomain)); | 241 let thirdParty = (contentType == Policy.type.ELEMHIDE ? false : isThirdParty (location, docDomain)); |
244 | 242 |
245 if (!match && Prefs.enabled) | 243 if (!match && Prefs.enabled && contentType in Policy.typeMask) |
246 { | 244 { |
247 match = defaultMatcher.matchesAny(locationText, Policy.typeMask[contentTyp e] || Policy.defaultTypeMask, docDomain, thirdParty, sitekey); | 245 match = defaultMatcher.matchesAny(locationText, Policy.typeMask[contentTyp e], 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.
| |
248 if (match instanceof BlockingFilter && node.ownerDocument && !(contentType in Policy.nonVisual)) | 246 if (match instanceof BlockingFilter && node.ownerDocument && !(contentType in Policy.nonVisual)) |
249 { | 247 { |
250 let prefCollapse = (match.collapse != null ? match.collapse : !Prefs.fas tcollapse); | 248 let prefCollapse = (match.collapse != null ? match.collapse : !Prefs.fas tcollapse); |
251 if (collapse || prefCollapse) | 249 if (collapse || prefCollapse) |
252 schedulePostProcess(node); | 250 schedulePostProcess(node); |
253 } | 251 } |
254 | 252 |
255 // Track mouse events for objects | 253 // Track mouse events for objects |
256 if (!match && contentType == Policy.type.OBJECT && node.nodeType == Ci.nsI DOMNode.ELEMENT_NODE) | 254 if (!match && contentType == Policy.type.OBJECT && node.nodeType == Ci.nsI DOMNode.ELEMENT_NODE) |
257 { | 255 { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
296 return null; | 294 return null; |
297 | 295 |
298 if (!parentUrl) | 296 if (!parentUrl) |
299 parentUrl = url; | 297 parentUrl = url; |
300 | 298 |
301 // Ignore fragment identifier | 299 // Ignore fragment identifier |
302 let index = url.indexOf("#"); | 300 let index = url.indexOf("#"); |
303 if (index >= 0) | 301 if (index >= 0) |
304 url = url.substring(0, index); | 302 url = url.substring(0, index); |
305 | 303 |
306 let result = defaultMatcher.matchesAny(url, Policy.typeMask[Policy.type.DOCU MENT], getHostname(parentUrl), false, sitekey); | 304 let result = defaultMatcher.matchesAny(url, RegExpFilter.typeMap.DOCUMENT, g etHostname(parentUrl), false, sitekey); |
307 return (result instanceof WhitelistFilter ? result : null); | 305 return (result instanceof WhitelistFilter ? result : null); |
308 }, | 306 }, |
309 | 307 |
310 /** | 308 /** |
311 * Checks whether the page loaded in a window is whitelisted for indication in the UI. | 309 * Checks whether the page loaded in a window is whitelisted for indication in the UI. |
312 * @param wnd {nsIDOMWindow} | 310 * @param wnd {nsIDOMWindow} |
313 * @return {Filter} matching exception rule or null if not whitelisted | 311 * @return {Filter} matching exception rule or null if not whitelisted |
314 */ | 312 */ |
315 isWindowWhitelisted: function(wnd) | 313 isWindowWhitelisted: function(wnd) |
316 { | 314 { |
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
797 if (!wnd || wnd.closed) | 795 if (!wnd || wnd.closed) |
798 return; | 796 return; |
799 | 797 |
800 if (entry.type == Policy.type.OBJECT) | 798 if (entry.type == Policy.type.OBJECT) |
801 { | 799 { |
802 node.removeEventListener("mouseover", objectMouseEventHander, true); | 800 node.removeEventListener("mouseover", objectMouseEventHander, true); |
803 node.removeEventListener("mouseout", objectMouseEventHander, true); | 801 node.removeEventListener("mouseout", objectMouseEventHander, true); |
804 } | 802 } |
805 Policy.processNode(wnd, node, entry.type, Utils.makeURI(entry.location), true) ; | 803 Policy.processNode(wnd, node, entry.type, Utils.makeURI(entry.location), true) ; |
806 } | 804 } |
LEFT | RIGHT |