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

Unified Diff: lib/content/elemHideEmulation.js

Issue 29730630: Issue 6437 - Skip DOM-only patterns on initial load (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Check if it's the top frame Created March 22, 2018, 4:29 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/content/elemHideEmulation.js
===================================================================
--- a/lib/content/elemHideEmulation.js
+++ b/lib/content/elemHideEmulation.js
@@ -448,20 +448,28 @@
// one of the patterns.
return getCachedPropertyValue(
this, "_dependsOnCharacterData",
() => this.selectors.some(selector => selector.dependsOnCharacterData)
);
}
};
-function filterPatterns(patterns, {stylesheets, mutations})
+function filterPatterns(patterns, {stylesheets, mutations}, document)
{
if (!stylesheets && !mutations)
+ {
+ // On initial load, skip DOM-only patterns if it's the top frame, because
+ // there's usually nothing interesting to see and we can respond to any
+ // mutations later.
+ if (typeof top != "undefined" && document.defaultView == top)
+ return patterns.filter(pattern => pattern.dependsOnStyles);
+
return patterns.slice();
+ }
return patterns.filter(
pattern => (stylesheets && pattern.dependsOnStyles) ||
(mutations && pattern.dependsOnDOM)
);
}
function shouldObserveAttributes(patterns)
@@ -572,17 +580,18 @@
* made reprocessing necessary. This parameter shouldn't be passed in for
* the initial processing, the entire document will be considered
* then and all rules, including the ones not dependent on the DOM.
* @param {function} [done]
* Callback to call when done.
*/
_addSelectors(stylesheets, mutations, done)
{
- let patterns = filterPatterns(this.patterns, {stylesheets, mutations});
+ let patterns = filterPatterns(this.patterns, {stylesheets, mutations},
+ this.document);
let selectors = [];
let selectorFilters = [];
let elements = [];
let elementFilters = [];
let cssStyles = [];
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld