style: Add a way to skip the "invalidation on eager pseudo invalidates self" bit.

This commit is contained in:
Emilio Cobos Álvarez 2017-10-12 17:55:38 +02:00
parent ecdb10ef5c
commit 9034e6a732
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
2 changed files with 12 additions and 1 deletions

View file

@ -57,6 +57,11 @@ impl<E> InvalidationProcessor<E> for StateAndAttrInvalidationProcessor
where where
E: TElement, 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( fn collect_invalidations(
&self, &self,
element: E, element: E,

View file

@ -25,6 +25,11 @@ pub trait InvalidationProcessor<E>
where where
E: TElement, 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. /// Collect invalidations for a given element's descendants and siblings.
/// ///
/// Returns whether the element itself was invalidated. /// Returns whether the element itself was invalidated.
@ -670,7 +675,8 @@ where
// //
// Note that we'll also restyle the pseudo-element because // Note that we'll also restyle the pseudo-element because
// it would match this invalidation. // it would match this invalidation.
if pseudo.is_eager() { if self.processor.invalidates_on_eager_pseudo_element() &&
pseudo.is_eager() {
invalidated_self = true; invalidated_self = true;
} }
} }