From acb27de71c60f0f0f671ab0b1bf60daf147a8615 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Mon, 26 Jun 2017 23:23:04 -0700 Subject: [PATCH] Fix dynamic restyling that changes whether our element may generate a pseudo to clear out stale pseudo styles. Gecko bug 1324618 part 1: https://bugzilla.mozilla.org/show_bug.cgi?id=1324618 --- components/style/matching.rs | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/components/style/matching.rs b/components/style/matching.rs index d6c79e91791..dd351c08c92 100644 --- a/components/style/matching.rs +++ b/components/style/matching.rs @@ -1202,14 +1202,6 @@ pub trait MatchMethods : TElement { // Compute rule nodes for eagerly-cascaded pseudo-elements. let mut matches_different_pseudos = false; SelectorImpl::each_eagerly_cascaded_pseudo_element(|pseudo| { - let bloom_filter = context.thread_local.bloom_filter.filter(); - - let mut matching_context = - MatchingContext::new_for_visited(MatchingMode::ForStatelessPseudoElement, - Some(bloom_filter), - visited_handling, - context.shared.quirks_mode); - // For pseudo-elements, we only try to match visited rules if there // are also unvisited rules. (This matches Gecko's behavior.) if visited_handling == VisitedHandlingMode::RelevantLinkVisited && @@ -1217,11 +1209,15 @@ pub trait MatchMethods : TElement { return } - if !self.may_generate_pseudo(&pseudo, data.styles.primary()) { - return; - } + if self.may_generate_pseudo(&pseudo, data.styles.primary()) { + let bloom_filter = context.thread_local.bloom_filter.filter(); + + let mut matching_context = + MatchingContext::new_for_visited(MatchingMode::ForStatelessPseudoElement, + Some(bloom_filter), + visited_handling, + context.shared.quirks_mode); - { let map = &mut context.thread_local.selector_flags; let mut set_selector_flags = |element: &Self, flags: ElementSelectorFlags| { self.apply_selector_flags(map, element, flags);