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

Delta Between Two Patch Sets: include.preload.js

Issue 6393086494113792: Issue 154 - Added devtools panel showing blocked and blockable items (Closed)
Left Patch Set: Fixed issues in content script breaking element hide tracing Created Jan. 30, 2016, 6:19 p.m.
Right Patch Set: Adapt for UI changes generating domain specific filters when necessary Created Feb. 3, 2016, 10:40 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « dependencies ('k') | lib/devtools.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 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 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 document.addEventListener("DOMContentLoaded", this.trace); 205 document.addEventListener("DOMContentLoaded", this.trace);
206 else 206 else
207 this.trace(); 207 this.trace();
208 } 208 }
209 ElementHidingTracer.prototype = { 209 ElementHidingTracer.prototype = {
210 checkNodes: function(nodes) 210 checkNodes: function(nodes)
211 { 211 {
212 var matchedSelectors = []; 212 var matchedSelectors = [];
213 213
214 // Find all selectors that match any hidden element inside the given nodes. 214 // Find all selectors that match any hidden element inside the given nodes.
215 for (var i = 0; i < this.selectors.length; i++) 215 for (var i = 0; i < this.selectors.length; i++)
kzar 2016/01/31 13:33:51 Nit: Could you use `for ... of ...` for these loop
Sebastian Noack 2016/02/02 10:39:52 This is a content script. So there is no jsHydra m
kzar 2016/02/02 15:42:09 Acknowledged.
216 { 216 {
217 var selector = this.selectors[i]; 217 var selector = this.selectors[i];
218 218
219 for (var j = 0; j < nodes.length; j++) 219 for (var j = 0; j < nodes.length; j++)
220 { 220 {
221 var elements = nodes[j].querySelectorAll(selector); 221 var elements = nodes[j].querySelectorAll(selector);
222 var matched = false; 222 var matched = false;
223 223
224 for (var k = 0; k < elements.length; k++) 224 for (var k = 0; k < elements.length; k++)
225 { 225 {
226 // Only consider selectors that actually have an effect on the 226 // Only consider selectors that actually have an effect on the
227 // computed styles, and aren't overridden by rules with higher 227 // computed styles, and aren't overridden by rules with higher
228 // priority, or haven't been circumvented in a different way. 228 // priority, or haven't been circumvented in a different way.
229 if (getComputedStyle(elements[k]).display == "none") 229 if (getComputedStyle(elements[k]).display == "none")
230 { 230 {
231 matchedSelectors.push(selector); 231 matchedSelectors.push(selector);
232 matched = true; 232 matched = true;
233 break; 233 break;
234 } 234 }
235 } 235 }
236 236
237 if (matched) 237 if (matched)
238 break; 238 break;
239 } 239 }
240 } 240 }
241 241
242 if (matchedSelectors.length > 0) 242 if (matchedSelectors.length > 0)
243 ext.backgroundPage.sendMessage({type: "trace-elemhide", selectors: matched Selectors}); 243 ext.backgroundPage.sendMessage({
kzar 2016/01/31 13:33:51 Nit: Mind wrapping this long line?
Sebastian Noack 2016/02/02 10:39:52 Done.
244 type: "trace-elemhide",
245 selectors: matchedSelectors
246 });
244 }, 247 },
245 248
246 onTimeout: function() 249 onTimeout: function()
247 { 250 {
248 this.checkNodes(this.changedNodes); 251 this.checkNodes(this.changedNodes);
249 this.changedNodes = []; 252 this.changedNodes = [];
250 this.timeout = null; 253 this.timeout = null;
251 }, 254 },
252 255
253 observe: function(mutations) 256 observe: function(mutations)
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 // document_start content scripts (like this one) don't 552 // document_start content scripts (like this one) don't
550 // run either in those frames due to https://crbug.com/416907. 553 // run either in those frames due to https://crbug.com/416907.
551 // So we have to apply element hiding from the parent frame. 554 // So we have to apply element hiding from the parent frame.
552 if (!("init" in contentWindow)) 555 if (!("init" in contentWindow))
553 init(contentDocument); 556 init(contentDocument);
554 557
555 // Moreover, "load" and "error" events aren't dispatched for elements 558 // Moreover, "load" and "error" events aren't dispatched for elements
556 // in dynamically created frames due to https://crbug.com/442107. 559 // in dynamically created frames due to https://crbug.com/442107.
557 // So we also have to apply element collpasing from the parent frame. 560 // So we also have to apply element collpasing from the parent frame.
558 if (!contentWindow.collapsing) 561 if (!contentWindow.collapsing)
559 [].forEach.call(contentDocument.querySelectorAll(Object.keys(typeMap ).join(",")), checkCollapse); 562 Array.prototype.forEach.call(
563 contentDocument.querySelectorAll(Object.keys(typeMap).join(",")),
564 checkCollapse
565 );
560 } 566 }
561 } 567 }
562 } 568 }
563 }, true); 569 }, true);
564 570
565 return updateStylesheet; 571 return updateStylesheet;
566 } 572 }
567 573
568 if (document instanceof HTMLDocument) 574 if (document instanceof HTMLDocument)
569 { 575 {
570 checkSitekey(); 576 checkSitekey();
571 window.updateStylesheet = init(document); 577 window.updateStylesheet = init(document);
572 } 578 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld