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

Side by Side Diff: include.preload.js

Issue 29555932: Issue 5781 - Merge messages for regular and emulated element hiding filters (Closed)
Patch Set: Addressed comments Created Sept. 26, 2017, 9:49 p.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 | « no previous file | lib/cssInjection.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-present eyeo GmbH 3 * Copyright (C) 2006-present 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 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 clearTimeout(this.timeout); 338 clearTimeout(this.timeout);
339 } 339 }
340 }; 340 };
341 341
342 function ElemHide() 342 function ElemHide()
343 { 343 {
344 this.shadow = this.createShadowTree(); 344 this.shadow = this.createShadowTree();
345 this.style = null; 345 this.style = null;
346 this.tracer = null; 346 this.tracer = null;
347 this.inject = true; 347 this.inject = true;
348 this.emulatedPatterns = null;
348 349
349 this.elemHideEmulation = new ElemHideEmulation( 350 this.elemHideEmulation = new ElemHideEmulation(
350 window, 351 window,
351 callback => 352 callback => callback(this.emulatedPatterns),
352 {
353 ext.backgroundPage.sendMessage({
354 type: "filters.get",
355 what: "elemhideemulation"
356 }, callback);
357 },
358 this.addSelectors.bind(this), 353 this.addSelectors.bind(this),
359 this.hideElements.bind(this) 354 this.hideElements.bind(this)
360 ); 355 );
361 } 356 }
362 ElemHide.prototype = { 357 ElemHide.prototype = {
363 selectorGroupSize: 200, 358 selectorGroupSize: 200,
364 359
365 createShadowTree() 360 createShadowTree()
366 { 361 {
367 // Use Shadow DOM if available as to not mess with with web pages that 362 // Use Shadow DOM if available as to not mess with with web pages that
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 if (response.trace) 494 if (response.trace)
500 this.tracer = new ElementHidingTracer(); 495 this.tracer = new ElementHidingTracer();
501 496
502 this.inject = response.inject; 497 this.inject = response.inject;
503 498
504 if (this.inject) 499 if (this.inject)
505 this.addSelectors(response.selectors); 500 this.addSelectors(response.selectors);
506 else if (this.tracer) 501 else if (this.tracer)
507 this.tracer.addSelectors(response.selectors); 502 this.tracer.addSelectors(response.selectors);
508 503
504 this.emulatedPatterns = response.emulatedPatterns;
509 this.elemHideEmulation.apply(); 505 this.elemHideEmulation.apply();
506 this.emulatedPatterns = null;
Sebastian Noack 2017/09/26 21:50:40 Don't leak memory.
510 }); 507 });
511 } 508 }
512 }; 509 };
513 510
514 if (document instanceof HTMLDocument) 511 if (document instanceof HTMLDocument)
515 { 512 {
516 checkSitekey(); 513 checkSitekey();
517 514
518 elemhide = new ElemHide(); 515 elemhide = new ElemHide();
519 elemhide.apply(); 516 elemhide.apply();
520 517
521 document.addEventListener("error", event => 518 document.addEventListener("error", event =>
522 { 519 {
523 checkCollapse(event.target); 520 checkCollapse(event.target);
524 }, true); 521 }, true);
525 522
526 document.addEventListener("load", event => 523 document.addEventListener("load", event =>
527 { 524 {
528 let element = event.target; 525 let element = event.target;
529 if (/^i?frame$/.test(element.localName)) 526 if (/^i?frame$/.test(element.localName))
530 checkCollapse(element); 527 checkCollapse(element);
531 }, true); 528 }, true);
532 } 529 }
OLDNEW
« no previous file with comments | « no previous file | lib/cssInjection.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld