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

Side by Side Diff: lib/content/elemHideEmulation.js

Issue 29713583: Issue 6504 - Add useInlineStyles flag to ElemHideEmulation (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Change to ElemHideEmulation.useInlineStyles Created March 5, 2018, 1:17 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 | no next file » | 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 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 ) 409 )
410 ); 410 );
411 } 411 }
412 412
413 function ElemHideEmulation(addSelectorsFunc, hideElemsFunc) 413 function ElemHideEmulation(addSelectorsFunc, hideElemsFunc)
414 { 414 {
415 this.document = document; 415 this.document = document;
416 this.addSelectorsFunc = addSelectorsFunc; 416 this.addSelectorsFunc = addSelectorsFunc;
417 this.hideElemsFunc = hideElemsFunc; 417 this.hideElemsFunc = hideElemsFunc;
418 this.observer = new MutationObserver(this.observe.bind(this)); 418 this.observer = new MutationObserver(this.observe.bind(this));
419 this.useInlineStyles = true;
kzar 2018/03/19 21:18:54 This doesn't match `alwaysHideWithSelector` in the
Manish Jethani 2018/03/20 11:20:23 Done.
419 } 420 }
420 421
421 ElemHideEmulation.prototype = { 422 ElemHideEmulation.prototype = {
422 isSameOrigin(stylesheet) 423 isSameOrigin(stylesheet)
423 { 424 {
424 try 425 try
425 { 426 {
426 return new URL(stylesheet.href).origin == this.document.location.origin; 427 return new URL(stylesheet.href).origin == this.document.location.origin;
427 } 428 }
428 catch (e) 429 catch (e)
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 pattern = null; 567 pattern = null;
567 return processPatterns(); 568 return processPatterns();
568 } 569 }
569 generator = evaluate(pattern.selectors, 0, "", 570 generator = evaluate(pattern.selectors, 0, "",
570 this.document, cssStyles); 571 this.document, cssStyles);
571 } 572 }
572 for (let selector of generator) 573 for (let selector of generator)
573 { 574 {
574 if (selector != null) 575 if (selector != null)
575 { 576 {
576 if (isSelectorHidingOnlyPattern(pattern)) 577 if (!this.useInlineStyles ||
578 isSelectorHidingOnlyPattern(pattern))
577 { 579 {
578 selectors.push(selector); 580 selectors.push(selector);
579 selectorFilters.push(pattern.text); 581 selectorFilters.push(pattern.text);
580 } 582 }
581 else 583 else
582 { 584 {
583 for (let element of this.document.querySelectorAll(selector)) 585 for (let element of this.document.querySelectorAll(selector))
584 { 586 {
585 elements.push(element); 587 elements.push(element);
586 elementFilters.push(pattern.text); 588 elementFilters.push(pattern.text);
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 characterData: shouldObserveCharacterData(this.patterns), 714 characterData: shouldObserveCharacterData(this.patterns),
713 subtree: true 715 subtree: true
714 } 716 }
715 ); 717 );
716 this.document.addEventListener("load", this.onLoad.bind(this), true); 718 this.document.addEventListener("load", this.onLoad.bind(this), true);
717 } 719 }
718 } 720 }
719 }; 721 };
720 722
721 exports.ElemHideEmulation = ElemHideEmulation; 723 exports.ElemHideEmulation = ElemHideEmulation;
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld