Trait style::invalidation::element::invalidator::InvalidationProcessor
source · pub trait InvalidationProcessor<'a, 'b, E>where
E: TElement,{
// Required methods
fn check_outer_dependency(
&mut self,
dependency: &Dependency,
element: E,
) -> bool;
fn matching_context(&mut self) -> &mut MatchingContext<'b, E::Impl>;
fn sibling_traversal_map(&self) -> &SiblingTraversalMap<E>;
fn collect_invalidations(
&mut self,
element: E,
self_invalidations: &mut InvalidationVector<'a>,
descendant_invalidations: &mut DescendantInvalidationLists<'a>,
sibling_invalidations: &mut InvalidationVector<'a>,
) -> bool;
fn should_process_descendants(&mut self, element: E) -> bool;
fn recursion_limit_exceeded(&mut self, element: E);
fn invalidated_self(&mut self, element: E);
fn invalidated_sibling(&mut self, sibling: E, of: E);
fn invalidated_descendants(&mut self, element: E, child: E);
// Provided methods
fn invalidates_on_pseudo_element(&self) -> bool { ... }
fn light_tree_only(&self) -> bool { ... }
fn found_relative_selector_invalidation(
&mut self,
_element: E,
_kind: RelativeDependencyInvalidationKind,
_relative_dependency: &'a Dependency,
) { ... }
}
Expand description
A trait to abstract the collection of invalidations for a given pass.
Required Methods§
sourcefn check_outer_dependency(
&mut self,
dependency: &Dependency,
element: E,
) -> bool
fn check_outer_dependency( &mut self, dependency: &Dependency, element: E, ) -> bool
When a dependency from a :where or :is selector matches, it may still be the case that we don’t need to invalidate the full style. Consider the case of:
div .foo:where(.bar *, .baz) .qux
We can get to the *
part after a .bar class change, but you only need
to restyle the element if it also matches .foo.
Similarly, you only need to restyle .baz if the whole result of matching the selector changes.
This function is called to check the result of matching the “outer”
dependency that we generate for the parent of the :where
selector,
that is, in the case above it should match
div .foo:where(.bar *, .baz)
.
Returning true unconditionally here is over-optimistic and may over-invalidate.
sourcefn matching_context(&mut self) -> &mut MatchingContext<'b, E::Impl>
fn matching_context(&mut self) -> &mut MatchingContext<'b, E::Impl>
The matching context that should be used to process invalidations.
sourcefn sibling_traversal_map(&self) -> &SiblingTraversalMap<E>
fn sibling_traversal_map(&self) -> &SiblingTraversalMap<E>
The traversal map that should be used to process invalidations.
sourcefn collect_invalidations(
&mut self,
element: E,
self_invalidations: &mut InvalidationVector<'a>,
descendant_invalidations: &mut DescendantInvalidationLists<'a>,
sibling_invalidations: &mut InvalidationVector<'a>,
) -> bool
fn collect_invalidations( &mut self, element: E, self_invalidations: &mut InvalidationVector<'a>, descendant_invalidations: &mut DescendantInvalidationLists<'a>, sibling_invalidations: &mut InvalidationVector<'a>, ) -> bool
Collect invalidations for a given element’s descendants and siblings.
Returns whether the element itself was invalidated.
sourcefn should_process_descendants(&mut self, element: E) -> bool
fn should_process_descendants(&mut self, element: E) -> bool
Returns whether the invalidation process should process the descendants of the given element.
sourcefn recursion_limit_exceeded(&mut self, element: E)
fn recursion_limit_exceeded(&mut self, element: E)
Executes an arbitrary action when the recursion limit is exceded (if any).
sourcefn invalidated_self(&mut self, element: E)
fn invalidated_self(&mut self, element: E)
Executes an action when Self
is invalidated.
sourcefn invalidated_sibling(&mut self, sibling: E, of: E)
fn invalidated_sibling(&mut self, sibling: E, of: E)
Executes an action when sibling
is invalidated as a sibling of
of
.
sourcefn invalidated_descendants(&mut self, element: E, child: E)
fn invalidated_descendants(&mut self, element: E, child: E)
Executes an action when any descendant of Self
is invalidated.
Provided Methods§
sourcefn invalidates_on_pseudo_element(&self) -> bool
fn invalidates_on_pseudo_element(&self) -> bool
Whether an invalidation that contains only a pseudo-element selector like ::before or ::after triggers invalidation of the element that would originate it.
sourcefn light_tree_only(&self) -> bool
fn light_tree_only(&self) -> bool
Whether the invalidation processor only cares about light-tree descendants of a given element, that is, doesn’t invalidate pseudo-elements, NAC, shadow dom…
sourcefn found_relative_selector_invalidation(
&mut self,
_element: E,
_kind: RelativeDependencyInvalidationKind,
_relative_dependency: &'a Dependency,
)
fn found_relative_selector_invalidation( &mut self, _element: E, _kind: RelativeDependencyInvalidationKind, _relative_dependency: &'a Dependency, )
Executes an action when an element in a relative selector is reached. Lets the dependency to be borrowed for further processing out of the invalidation traversal.