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: Created Sept. 25, 2017, 11:07 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') | lib/cssInjection.js » ('J')
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 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 348
349 this.elemHideEmulationPatterns = null;
349 this.elemHideEmulation = new ElemHideEmulation( 350 this.elemHideEmulation = new ElemHideEmulation(
350 window, 351 window,
351 callback => 352 callback => { callback(this.elemHideEmulationPatterns); },
Sebastian Noack 2017/09/25 23:13:19 In the next step we should pass patterns just as a
Manish Jethani 2017/09/26 11:50:18 This might read better as another method of ElemHi
Sebastian Noack 2017/09/26 21:50:40 Since you don't have a strong opinion, I think I p
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.elemHideEmulationPatterns = response.emulated;
509 this.elemHideEmulation.apply(); 505 this.elemHideEmulation.apply();
510 }); 506 });
511 } 507 }
512 }; 508 };
513 509
514 if (document instanceof HTMLDocument) 510 if (document instanceof HTMLDocument)
515 { 511 {
516 checkSitekey(); 512 checkSitekey();
517 513
518 elemhide = new ElemHide(); 514 elemhide = new ElemHide();
519 elemhide.apply(); 515 elemhide.apply();
520 516
521 document.addEventListener("error", event => 517 document.addEventListener("error", event =>
522 { 518 {
523 checkCollapse(event.target); 519 checkCollapse(event.target);
524 }, true); 520 }, true);
525 521
526 document.addEventListener("load", event => 522 document.addEventListener("load", event =>
527 { 523 {
528 let element = event.target; 524 let element = event.target;
529 if (/^i?frame$/.test(element.localName)) 525 if (/^i?frame$/.test(element.localName))
530 checkCollapse(element); 526 checkCollapse(element);
531 }, true); 527 }, true);
532 } 528 }
OLDNEW
« no previous file with comments | « no previous file | lib/cssInjection.js » ('j') | lib/cssInjection.js » ('J')

Powered by Google App Engine
This is Rietveld