diff --git a/components/style/invalidation/element/collector.rs b/components/style/invalidation/element/collector.rs index 08456e032e7..9b8f6aca747 100644 --- a/components/style/invalidation/element/collector.rs +++ b/components/style/invalidation/element/collector.rs @@ -57,6 +57,11 @@ impl InvalidationProcessor for StateAndAttrInvalidationProcessor where E: TElement, { + /// We need to invalidate style on an eager pseudo-element, in order to + /// process changes that could otherwise end up in ::before or ::after + /// content being generated. + fn invalidates_on_eager_pseudo_element(&self) -> bool { true } + fn collect_invalidations( &self, element: E, diff --git a/components/style/invalidation/element/invalidator.rs b/components/style/invalidation/element/invalidator.rs index 072577d6f44..d0c77cc48df 100644 --- a/components/style/invalidation/element/invalidator.rs +++ b/components/style/invalidation/element/invalidator.rs @@ -25,6 +25,11 @@ pub trait InvalidationProcessor where E: TElement, { + /// Whether an invalidation that contains only an eager pseudo-element + /// selector like ::before or ::after triggers invalidation of the element + /// that would originate it. + fn invalidates_on_eager_pseudo_element(&self) -> bool { false } + /// Collect invalidations for a given element's descendants and siblings. /// /// Returns whether the element itself was invalidated. @@ -670,7 +675,8 @@ where // // Note that we'll also restyle the pseudo-element because // it would match this invalidation. - if pseudo.is_eager() { + if self.processor.invalidates_on_eager_pseudo_element() && + pseudo.is_eager() { invalidated_self = true; } }