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

Side by Side Diff: lib/contentPolicy.js

Issue 29329754: Issue 3251 - Delegate processing of element hiding hits to shouldAllowAsync() so that hits show up (Closed)
Patch Set: Reversed logic and improved JSDoc comments Created Nov. 6, 2015, 11:26 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
« no previous file with comments | « lib/child/elemHide.js ('k') | lib/elemHide.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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 Utils.styleService.loadAndRegisterSheet(collapseStyle, Ci.nsIStyleSheetServi ce.USER_SHEET); 93 Utils.styleService.loadAndRegisterSheet(collapseStyle, Ci.nsIStyleSheetServi ce.USER_SHEET);
94 onShutdown.add(() => 94 onShutdown.add(() =>
95 { 95 {
96 Utils.styleService.unregisterSheet(collapseStyle, Ci.nsIStyleSheetService. USER_SHEET); 96 Utils.styleService.unregisterSheet(collapseStyle, Ci.nsIStyleSheetService. USER_SHEET);
97 }); 97 });
98 }, 98 },
99 99
100 /** 100 /**
101 * Checks whether a node should be blocked, hides it if necessary 101 * Checks whether a node should be blocked, hides it if necessary
102 * @param contentType {String} 102 * @param contentType {String}
103 * @param location {String} 103 * @param location {String} location of the request, filter key if contentType is ELEMHIDE
104 * @param fremes {Object[]} 104 * @param frames {Object[]}
105 * @param isPrivate {Boolean} true if the request belongs to a private browsi ng window 105 * @param isPrivate {Boolean} true if the request belongs to a private browsi ng window
106 * @return {Object} An object containing properties block, collapse and hits 106 * @return {Object} An object containing properties block, collapse and hits
107 * indicating how this request should be handled. 107 * indicating how this request should be handled.
108 */ 108 */
109 shouldAllow: function({contentType, location, frames, isPrivate}) 109 shouldAllow: function({contentType, location, frames, isPrivate})
110 { 110 {
111 let hits = []; 111 let hits = [];
112 112
113 function addHit(frameIndex, contentType, docDomain, thirdParty, location, fi lter) 113 function addHit(frameIndex, contentType, docDomain, thirdParty, location, fi lter)
114 { 114 {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 nogenericMatch); 171 nogenericMatch);
172 } 172 }
173 173
174 if (frame == testSitekeyFrame) 174 if (frame == testSitekeyFrame)
175 [testSitekey, testSitekeyFrame] = getSitekey(frames.slice(i + 1)); 175 [testSitekey, testSitekeyFrame] = getSitekey(frames.slice(i + 1));
176 } 176 }
177 } 177 }
178 178
179 if (!match && contentType == "ELEMHIDE") 179 if (!match && contentType == "ELEMHIDE")
180 { 180 {
181 match = location; 181 match = ElemHide.getFilterByKey(location);
182 location = match.text.replace(/^.*?#/, '#'); 182 location = match.text.replace(/^.*?#/, '#');
183 183
184 if (!match.isActiveOnDomain(docDomain)) 184 if (!match.isActiveOnDomain(docDomain))
185 return response(true, false); 185 return response(true, false);
186 186
187 let exception = ElemHide.getException(match, docDomain); 187 let exception = ElemHide.getException(match, docDomain);
188 if (exception) 188 if (exception)
189 { 189 {
190 addHit(null, contentType, docDomain, false, location, exception); 190 addHit(null, contentType, docDomain, false, location, exception);
191 return response(true, false); 191 return response(true, false);
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 if (!wnd || wnd.closed) 403 if (!wnd || wnd.closed)
404 return; 404 return;
405 405
406 if (entry.type == "OBJECT") 406 if (entry.type == "OBJECT")
407 { 407 {
408 node.removeEventListener("mouseover", objectMouseEventHander, true); 408 node.removeEventListener("mouseover", objectMouseEventHander, true);
409 node.removeEventListener("mouseout", objectMouseEventHander, true); 409 node.removeEventListener("mouseout", objectMouseEventHander, true);
410 } 410 }
411 Policy.processNode(wnd, node, entry.type, entry.location, true); 411 Policy.processNode(wnd, node, entry.type, entry.location, true);
412 } 412 }
OLDNEW
« no previous file with comments | « lib/child/elemHide.js ('k') | lib/elemHide.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld