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

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

Issue 29847558: Issue 6504 - Remove useInlineStyles for now (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Remove useInlineStyles flag Created Aug. 14, 2018, 5:45 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 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 { 597 {
598 return patterns.some(pattern => pattern.dependsOnCharacterData); 598 return patterns.some(pattern => pattern.dependsOnCharacterData);
599 } 599 }
600 600
601 function ElemHideEmulation(addSelectorsFunc, hideElemsFunc) 601 function ElemHideEmulation(addSelectorsFunc, hideElemsFunc)
602 { 602 {
603 this.document = document; 603 this.document = document;
604 this.addSelectorsFunc = addSelectorsFunc; 604 this.addSelectorsFunc = addSelectorsFunc;
605 this.hideElemsFunc = hideElemsFunc; 605 this.hideElemsFunc = hideElemsFunc;
606 this.observer = new MutationObserver(this.observe.bind(this)); 606 this.observer = new MutationObserver(this.observe.bind(this));
607 this.useInlineStyles = true;
608 } 607 }
609 608
610 ElemHideEmulation.prototype = { 609 ElemHideEmulation.prototype = {
611 isSameOrigin(stylesheet) 610 isSameOrigin(stylesheet)
612 { 611 {
613 try 612 try
614 { 613 {
615 return new URL(stylesheet.href).origin == this.document.location.origin; 614 return new URL(stylesheet.href).origin == this.document.location.origin;
616 } 615 }
617 catch (e) 616 catch (e)
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 if (!this.useInlineStyles) 798 if (!this.useInlineStyles)
800 evaluationTargets = null; 799 evaluationTargets = null;
801 800
802 generator = evaluate(pattern.selectors, 0, "", 801 generator = evaluate(pattern.selectors, 0, "",
803 this.document, cssStyles, evaluationTargets); 802 this.document, cssStyles, evaluationTargets);
804 } 803 }
805 for (let selector of generator) 804 for (let selector of generator)
806 { 805 {
807 if (selector != null) 806 if (selector != null)
808 { 807 {
809 if (!this.useInlineStyles) 808 for (let element of this.document.querySelectorAll(selector))
810 { 809 {
811 selectors.push(selector); 810 elements.push(element);
812 selectorFilters.push(pattern.text); 811 elementFilters.push(pattern.text);
813 }
814 else
815 {
816 for (let element of this.document.querySelectorAll(selector))
817 {
818 elements.push(element);
819 elementFilters.push(pattern.text);
820 }
821 } 812 }
822 } 813 }
823 if (performance.now() - cycleStart > MAX_SYNCHRONOUS_PROCESSING_TIME) 814 if (performance.now() - cycleStart > MAX_SYNCHRONOUS_PROCESSING_TIME)
824 { 815 {
825 setTimeout(processPatterns, 0); 816 setTimeout(processPatterns, 0);
826 return; 817 return;
827 } 818 }
828 } 819 }
829 pattern = null; 820 pattern = null;
830 return processPatterns(); 821 return processPatterns();
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
979 characterData: shouldObserveCharacterData(this.patterns), 970 characterData: shouldObserveCharacterData(this.patterns),
980 subtree: true 971 subtree: true
981 } 972 }
982 ); 973 );
983 this.document.addEventListener("load", this.onLoad.bind(this), true); 974 this.document.addEventListener("load", this.onLoad.bind(this), true);
984 } 975 }
985 } 976 }
986 }; 977 };
987 978
988 exports.ElemHideEmulation = ElemHideEmulation; 979 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