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: Update issue number in comment Created Aug. 10, 2018, 2:27 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
608 // This flag is supposed to indicate whether we should prefer setting the
609 // style attribute of the element over using CSS selectors. It is set by the
610 // web extension if the tabs.removeCSS API is available (Firefox 53+). But
611 // because of issues with performance (see #6504), we are ignoring the value
612 // of this flag for now; we always set the style attribute.
613 // https://issues.adblockplus.org/ticket/6504#comment:9
607 this.useInlineStyles = true; 614 this.useInlineStyles = true;
hub 2018/08/10 19:43:16 so if we don't use it, and since the code below ge
Manish Jethani 2018/08/14 16:50:16 I left it there with a comment sorta hoping that s
hub 2018/08/14 17:24:41 Since you remove the code below, I believe it is p
Manish Jethani 2018/08/14 17:46:22 Sounds OK to me. Done.
608 } 615 }
609 616
610 ElemHideEmulation.prototype = { 617 ElemHideEmulation.prototype = {
611 isSameOrigin(stylesheet) 618 isSameOrigin(stylesheet)
612 { 619 {
613 try 620 try
614 { 621 {
615 return new URL(stylesheet.href).origin == this.document.location.origin; 622 return new URL(stylesheet.href).origin == this.document.location.origin;
616 } 623 }
617 catch (e) 624 catch (e)
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 if (!this.useInlineStyles) 806 if (!this.useInlineStyles)
800 evaluationTargets = null; 807 evaluationTargets = null;
801 808
802 generator = evaluate(pattern.selectors, 0, "", 809 generator = evaluate(pattern.selectors, 0, "",
803 this.document, cssStyles, evaluationTargets); 810 this.document, cssStyles, evaluationTargets);
804 } 811 }
805 for (let selector of generator) 812 for (let selector of generator)
806 { 813 {
807 if (selector != null) 814 if (selector != null)
808 { 815 {
809 if (!this.useInlineStyles) 816 for (let element of this.document.querySelectorAll(selector))
810 { 817 {
811 selectors.push(selector); 818 elements.push(element);
812 selectorFilters.push(pattern.text); 819 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 } 820 }
822 } 821 }
823 if (performance.now() - cycleStart > MAX_SYNCHRONOUS_PROCESSING_TIME) 822 if (performance.now() - cycleStart > MAX_SYNCHRONOUS_PROCESSING_TIME)
824 { 823 {
825 setTimeout(processPatterns, 0); 824 setTimeout(processPatterns, 0);
826 return; 825 return;
827 } 826 }
828 } 827 }
829 pattern = null; 828 pattern = null;
830 return processPatterns(); 829 return processPatterns();
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
979 characterData: shouldObserveCharacterData(this.patterns), 978 characterData: shouldObserveCharacterData(this.patterns),
980 subtree: true 979 subtree: true
981 } 980 }
982 ); 981 );
983 this.document.addEventListener("load", this.onLoad.bind(this), true); 982 this.document.addEventListener("load", this.onLoad.bind(this), true);
984 } 983 }
985 } 984 }
986 }; 985 };
987 986
988 exports.ElemHideEmulation = ElemHideEmulation; 987 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