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

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

Issue 29884580: Issue 6504 - Remove element hiding emulation code related to style sheets (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Remove first parameter to constructor Created Sept. 29, 2018, 1:07 a.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 | test/browser/elemHideEmulation.js » ('j') | 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 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 return patterns.some(pattern => pattern.maybeDependsOnAttributes); 598 return patterns.some(pattern => pattern.maybeDependsOnAttributes);
599 } 599 }
600 600
601 function shouldObserveCharacterData(patterns) 601 function shouldObserveCharacterData(patterns)
602 { 602 {
603 return patterns.some(pattern => pattern.dependsOnCharacterData); 603 return patterns.some(pattern => pattern.dependsOnCharacterData);
604 } 604 }
605 605
606 class ElemHideEmulation 606 class ElemHideEmulation
607 { 607 {
608 constructor(addSelectorsFunc, hideElemsFunc) 608 constructor(hideElemsFunc)
609 { 609 {
610 this._filteringInProgress = false; 610 this._filteringInProgress = false;
611 this._lastInvocation = -MIN_INVOCATION_INTERVAL; 611 this._lastInvocation = -MIN_INVOCATION_INTERVAL;
612 this._scheduledProcessing = null; 612 this._scheduledProcessing = null;
613 613
614 this.document = document; 614 this.document = document;
615 this.addSelectorsFunc = addSelectorsFunc;
616 this.hideElemsFunc = hideElemsFunc; 615 this.hideElemsFunc = hideElemsFunc;
617 this.observer = new MutationObserver(this.observe.bind(this)); 616 this.observer = new MutationObserver(this.observe.bind(this));
618 } 617 }
619 618
620 isSameOrigin(stylesheet) 619 isSameOrigin(stylesheet)
621 { 620 {
622 try 621 try
623 { 622 {
624 return new URL(stylesheet.href).origin == this.document.location.origin; 623 return new URL(stylesheet.href).origin == this.document.location.origin;
625 } 624 }
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 * @param {function} [done] 707 * @param {function} [done]
709 * Callback to call when done. 708 * Callback to call when done.
710 */ 709 */
711 _addSelectors(stylesheets, mutations, done) 710 _addSelectors(stylesheets, mutations, done)
712 { 711 {
713 if (testInfo) 712 if (testInfo)
714 testInfo.lastProcessedElements.clear(); 713 testInfo.lastProcessedElements.clear();
715 714
716 let patterns = filterPatterns(this.patterns, {stylesheets, mutations}); 715 let patterns = filterPatterns(this.patterns, {stylesheets, mutations});
717 716
718 let selectors = [];
719 let selectorFilters = [];
720
721 let elements = []; 717 let elements = [];
722 let elementFilters = []; 718 let elementFilters = [];
723 719
724 let cssStyles = []; 720 let cssStyles = [];
725 721
726 // If neither any style sheets nor any DOM mutations have been specified, 722 // If neither any style sheets nor any DOM mutations have been specified,
727 // do full processing. 723 // do full processing.
728 if (!stylesheets && !mutations) 724 if (!stylesheets && !mutations)
729 stylesheets = this.document.styleSheets; 725 stylesheets = this.document.styleSheets;
730 726
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 let generator = null; 772 let generator = null;
777 773
778 let processPatterns = () => 774 let processPatterns = () =>
779 { 775 {
780 let cycleStart = performance.now(); 776 let cycleStart = performance.now();
781 777
782 if (!pattern) 778 if (!pattern)
783 { 779 {
784 if (!patterns.length) 780 if (!patterns.length)
785 { 781 {
786 if (selectors.length > 0)
787 this.addSelectorsFunc(selectors, selectorFilters);
788 if (elements.length > 0) 782 if (elements.length > 0)
789 this.hideElemsFunc(elements, elementFilters); 783 this.hideElemsFunc(elements, elementFilters);
790 if (typeof done == "function") 784 if (typeof done == "function")
791 done(); 785 done();
792 return; 786 return;
793 } 787 }
794 788
795 pattern = patterns.shift(); 789 pattern = patterns.shift();
796 790
797 let evaluationTargets = targets; 791 let evaluationTargets = targets;
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 characterData: shouldObserveCharacterData(this.patterns), 965 characterData: shouldObserveCharacterData(this.patterns),
972 subtree: true 966 subtree: true
973 } 967 }
974 ); 968 );
975 this.document.addEventListener("load", this.onLoad.bind(this), true); 969 this.document.addEventListener("load", this.onLoad.bind(this), true);
976 } 970 }
977 } 971 }
978 } 972 }
979 973
980 exports.ElemHideEmulation = ElemHideEmulation; 974 exports.ElemHideEmulation = ElemHideEmulation;
OLDNEW
« no previous file with comments | « no previous file | test/browser/elemHideEmulation.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld