From 9034e6a73251fa8841a245ce60b1150ba7ced58a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Thu, 12 Oct 2017 17:55:38 +0200 Subject: [PATCH] style: Add a way to skip the "invalidation on eager pseudo invalidates self" bit. --- components/style/invalidation/element/collector.rs | 5 +++++ components/style/invalidation/element/invalidator.rs | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) 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; } }