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 = []; |