| OLD | NEW |
| 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 { | 155 { |
| 156 let topWnd = wnd.top; | 156 let topWnd = wnd.top; |
| 157 if (!topWnd || !topWnd.location || !topWnd.location.href) | 157 if (!topWnd || !topWnd.location || !topWnd.location.href) |
| 158 return true; | 158 return true; |
| 159 | 159 |
| 160 let originWindow = Utils.getOriginWindow(wnd); | 160 let originWindow = Utils.getOriginWindow(wnd); |
| 161 let wndLocation = originWindow.location.href; | 161 let wndLocation = originWindow.location.href; |
| 162 let docDomain = getHostname(wndLocation); | 162 let docDomain = getHostname(wndLocation); |
| 163 let match = null; | 163 let match = null; |
| 164 let [sitekey, sitekeyWnd] = getSitekey(wnd); | 164 let [sitekey, sitekeyWnd] = getSitekey(wnd); |
| 165 let nogeneric = false; |
| 166 |
| 165 if (!match && Prefs.enabled) | 167 if (!match && Prefs.enabled) |
| 166 { | 168 { |
| 167 let testWnd = wnd; | 169 let testWnd = wnd; |
| 168 let testSitekey = sitekey; | 170 let testSitekey = sitekey; |
| 169 let testSitekeyWnd = sitekeyWnd; | 171 let testSitekeyWnd = sitekeyWnd; |
| 170 let parentWndLocation = getWindowLocation(testWnd); | 172 let parentWndLocation = getWindowLocation(testWnd); |
| 171 while (true) | 173 while (true) |
| 172 { | 174 { |
| 173 let testWndLocation = parentWndLocation; | 175 let testWndLocation = parentWndLocation; |
| 174 parentWndLocation = (testWnd == testWnd.parent ? testWndLocation : getWi
ndowLocation(testWnd.parent)); | 176 parentWndLocation = (testWnd == testWnd.parent ? testWndLocation : getWi
ndowLocation(testWnd.parent)); |
| 175 match = Policy.isWhitelisted(testWndLocation, parentWndLocation, testSit
ekey); | 177 match = Policy.isWhitelisted(testWndLocation, parentWndLocation, testSit
ekey); |
| 176 | 178 |
| 177 if (match instanceof WhitelistFilter) | 179 if (match instanceof WhitelistFilter) |
| 178 { | 180 { |
| 179 FilterStorage.increaseHitCount(match, wnd); | 181 FilterStorage.increaseHitCount(match, wnd); |
| 180 RequestNotifier.addNodeData(testWnd.document, topWnd, Policy.type.DOCU
MENT, getHostname(parentWndLocation), false, testWndLocation, match); | 182 RequestNotifier.addNodeData(testWnd.document, topWnd, Policy.type.DOCU
MENT, getHostname(parentWndLocation), false, testWndLocation, match); |
| 181 return true; | 183 return true; |
| 182 } | 184 } |
| 183 | 185 |
| 186 let genericType = (contentType == Policy.type.ELEMHIDE ? |
| 187 RegExpFilter.typeMap.GENERICHIDE : |
| 188 RegExpFilter.typeMap.GENERICBLOCK); |
| 189 let parentDocDomain = getHostname(parentWndLocation); |
| 190 let nogenericMatch = defaultMatcher.matchesAny( |
| 191 testWndLocation, genericType, parentDocDomain, false, testSitekey |
| 192 ); |
| 193 if (nogenericMatch instanceof WhitelistFilter) |
| 194 { |
| 195 nogeneric = true; |
| 196 |
| 197 FilterStorage.increaseHitCount(nogenericMatch, wnd); |
| 198 RequestNotifier.addNodeData(testWnd.document, topWnd, contentType, |
| 199 parentDocDomain, false, testWndLocation, |
| 200 nogenericMatch); |
| 201 } |
| 202 |
| 184 if (testWnd.parent == testWnd) | 203 if (testWnd.parent == testWnd) |
| 185 break; | 204 break; |
| 186 | 205 |
| 187 if (testWnd == testSitekeyWnd) | 206 if (testWnd == testSitekeyWnd) |
| 188 [testSitekey, testSitekeyWnd] = getSitekey(testWnd.parent); | 207 [testSitekey, testSitekeyWnd] = getSitekey(testWnd.parent); |
| 189 testWnd = testWnd.parent; | 208 testWnd = testWnd.parent; |
| 190 } | 209 } |
| 191 } | 210 } |
| 192 | 211 |
| 193 // Data loaded by plugins should be attached to the document | 212 // Data loaded by plugins should be attached to the document |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 if (!match.isActiveOnDomain(docDomain)) | 248 if (!match.isActiveOnDomain(docDomain)) |
| 230 return true; | 249 return true; |
| 231 | 250 |
| 232 let exception = ElemHide.getException(match, docDomain); | 251 let exception = ElemHide.getException(match, docDomain); |
| 233 if (exception) | 252 if (exception) |
| 234 { | 253 { |
| 235 FilterStorage.increaseHitCount(exception, wnd); | 254 FilterStorage.increaseHitCount(exception, wnd); |
| 236 RequestNotifier.addNodeData(node, topWnd, contentType, docDomain, false,
locationText, exception); | 255 RequestNotifier.addNodeData(node, topWnd, contentType, docDomain, false,
locationText, exception); |
| 237 return true; | 256 return true; |
| 238 } | 257 } |
| 258 |
| 259 if (nogeneric && match.isGeneric()) |
| 260 return true; |
| 239 } | 261 } |
| 240 | 262 |
| 241 let thirdParty = (contentType == Policy.type.ELEMHIDE ? false : isThirdParty
(location, docDomain)); | 263 let thirdParty = (contentType == Policy.type.ELEMHIDE ? false : isThirdParty
(location, docDomain)); |
| 242 | 264 |
| 243 if (!match && Prefs.enabled && contentType in Policy.typeMask) | 265 if (!match && Prefs.enabled && contentType in Policy.typeMask) |
| 244 { | 266 { |
| 245 match = defaultMatcher.matchesAny(locationText, Policy.typeMask[contentTyp
e], docDomain, thirdParty, sitekey); | 267 match = defaultMatcher.matchesAny(locationText, Policy.typeMask[contentTyp
e], |
| 268 docDomain, thirdParty, sitekey, nogeneri
c); |
| 246 if (match instanceof BlockingFilter && node.ownerDocument && !(contentType
in Policy.nonVisual)) | 269 if (match instanceof BlockingFilter && node.ownerDocument && !(contentType
in Policy.nonVisual)) |
| 247 { | 270 { |
| 248 let prefCollapse = (match.collapse != null ? match.collapse : !Prefs.fas
tcollapse); | 271 let prefCollapse = (match.collapse != null ? match.collapse : !Prefs.fas
tcollapse); |
| 249 if (collapse || prefCollapse) | 272 if (collapse || prefCollapse) |
| 250 schedulePostProcess(node); | 273 schedulePostProcess(node); |
| 251 } | 274 } |
| 252 | 275 |
| 253 // Track mouse events for objects | 276 // Track mouse events for objects |
| 254 if (!match && contentType == Policy.type.OBJECT && node.nodeType == Ci.nsI
DOMNode.ELEMENT_NODE) | 277 if (!match && contentType == Policy.type.OBJECT && node.nodeType == Ci.nsI
DOMNode.ELEMENT_NODE) |
| 255 { | 278 { |
| (...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 795 if (!wnd || wnd.closed) | 818 if (!wnd || wnd.closed) |
| 796 return; | 819 return; |
| 797 | 820 |
| 798 if (entry.type == Policy.type.OBJECT) | 821 if (entry.type == Policy.type.OBJECT) |
| 799 { | 822 { |
| 800 node.removeEventListener("mouseover", objectMouseEventHander, true); | 823 node.removeEventListener("mouseover", objectMouseEventHander, true); |
| 801 node.removeEventListener("mouseout", objectMouseEventHander, true); | 824 node.removeEventListener("mouseout", objectMouseEventHander, true); |
| 802 } | 825 } |
| 803 Policy.processNode(wnd, node, entry.type, Utils.makeURI(entry.location), true)
; | 826 Policy.processNode(wnd, node, entry.type, Utils.makeURI(entry.location), true)
; |
| 804 } | 827 } |
| OLD | NEW |