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: Rebase Created March 20, 2018, 1:35 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 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 { 476 {
477 return patterns.some(pattern => pattern.dependsOnCharacterData); 477 return patterns.some(pattern => pattern.dependsOnCharacterData);
478 } 478 }
479 479
480 function ElemHideEmulation(addSelectorsFunc, hideElemsFunc) 480 function ElemHideEmulation(addSelectorsFunc, hideElemsFunc)
481 { 481 {
482 this.document = document; 482 this.document = document;
483 this.addSelectorsFunc = addSelectorsFunc; 483 this.addSelectorsFunc = addSelectorsFunc;
484 this.hideElemsFunc = hideElemsFunc; 484 this.hideElemsFunc = hideElemsFunc;
485 this.observer = new MutationObserver(this.observe.bind(this)); 485 this.observer = new MutationObserver(this.observe.bind(this));
486 this.useInlineStyles = true;
486 } 487 }
487 488
488 ElemHideEmulation.prototype = { 489 ElemHideEmulation.prototype = {
489 isSameOrigin(stylesheet) 490 isSameOrigin(stylesheet)
490 { 491 {
491 try 492 try
492 { 493 {
493 return new URL(stylesheet.href).origin == this.document.location.origin; 494 return new URL(stylesheet.href).origin == this.document.location.origin;
494 } 495 }
495 catch (e) 496 catch (e)
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 646
646 pattern = patterns.shift(); 647 pattern = patterns.shift();
647 648
648 generator = evaluate(pattern.selectors, 0, "", 649 generator = evaluate(pattern.selectors, 0, "",
649 this.document, cssStyles); 650 this.document, cssStyles);
650 } 651 }
651 for (let selector of generator) 652 for (let selector of generator)
652 { 653 {
653 if (selector != null) 654 if (selector != null)
654 { 655 {
655 if (pattern.isSelectorHidingOnlyPattern()) 656 if (!this.useInlineStyles ||
657 pattern.isSelectorHidingOnlyPattern())
656 { 658 {
657 selectors.push(selector); 659 selectors.push(selector);
658 selectorFilters.push(pattern.text); 660 selectorFilters.push(pattern.text);
659 } 661 }
660 else 662 else
661 { 663 {
662 for (let element of this.document.querySelectorAll(selector)) 664 for (let element of this.document.querySelectorAll(selector))
663 { 665 {
664 elements.push(element); 666 elements.push(element);
665 elementFilters.push(pattern.text); 667 elementFilters.push(pattern.text);
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 characterData: shouldObserveCharacterData(this.patterns), 811 characterData: shouldObserveCharacterData(this.patterns),
810 subtree: true 812 subtree: true
811 } 813 }
812 ); 814 );
813 this.document.addEventListener("load", this.onLoad.bind(this), true); 815 this.document.addEventListener("load", this.onLoad.bind(this), true);
814 } 816 }
815 } 817 }
816 }; 818 };
817 819
818 exports.ElemHideEmulation = ElemHideEmulation; 820 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