Struct style::invalidation::element::invalidation_map::Dependency
source · pub struct Dependency {
pub selector: Selector<SelectorImpl>,
pub selector_offset: usize,
pub parent: Option<Arc<Dependency>>,
relative_kind: Option<RelativeDependencyInvalidationKind>,
}
Expand description
Mapping between (partial) CompoundSelectors (and the combinator to their right) and the states and attributes they depend on.
In general, for all selectors in all applicable stylesheets of the form:
|a _ b _ c _ d _ e|
Where:
- |b| and |d| are simple selectors that depend on state (like :hover) or attributes (like [attr…], .foo, or #foo).
- |a|, |c|, and |e| are arbitrary simple selectors that do not depend on state or attributes.
We generate a Dependency for both |a _ b:X _| and |a _ b:X _ c _ d:Y _|, even though those selectors may not appear on their own in any stylesheet. This allows us to quickly scan through the dependency sites of all style rules and determine the maximum effect that a given state or attribute change may have on the style of elements in the document.
Fields§
§selector: Selector<SelectorImpl>
The dependency selector.
selector_offset: usize
The offset into the selector that we should match on.
parent: Option<Arc<Dependency>>
The parent dependency for an ancestor selector. For example, consider the following:
.foo .bar:where(.baz span) .qux
^ ^ ^
A B C
We’d generate:
- One dependency for .qux (offset: 0, parent: None)
- One dependency for .baz pointing to B with parent being a dependency pointing to C.
- One dependency from .bar pointing to C (parent: None)
- One dependency from .foo pointing to A (parent: None)
relative_kind: Option<RelativeDependencyInvalidationKind>
What kind of relative selector invalidation this generates. None if this dependency is not within a relative selector.
Implementations§
source§impl Dependency
impl Dependency
sourcepub fn for_full_selector_invalidation(selector: Selector<SelectorImpl>) -> Self
pub fn for_full_selector_invalidation(selector: Selector<SelectorImpl>) -> Self
Creates a dummy dependency to invalidate the whole selector.
This is necessary because document state invalidation wants to invalidate all elements in the document.
The offset is such as that Invalidation::new(self) returns a zero offset. That is, it points to a virtual “combinator” outside of the selector, so calling combinator() on such a dependency will panic.
sourcefn combinator(&self) -> Option<Combinator>
fn combinator(&self) -> Option<Combinator>
Returns the combinator to the right of the partial selector this dependency represents.
TODO(emilio): Consider storing inline if it helps cache locality?
sourcepub fn normal_invalidation_kind(&self) -> NormalDependencyInvalidationKind
pub fn normal_invalidation_kind(&self) -> NormalDependencyInvalidationKind
The kind of normal invalidation that this would generate. The dependency in question must be a normal dependency.
sourcepub fn invalidation_kind(&self) -> DependencyInvalidationKind
pub fn invalidation_kind(&self) -> DependencyInvalidationKind
The kind of invalidation that this would generate.
sourcepub fn right_combinator_is_next_sibling(&self) -> bool
pub fn right_combinator_is_next_sibling(&self) -> bool
Is the combinator to the right of this dependency’s compound selector
the next sibling combinator? This matters for insertion/removal in between
two elements connected through next sibling, e.g. .foo:has(> .a + .b)
where an element gets inserted between .a
and .b
.
sourcepub fn dependency_is_relative_with_single_next_sibling(&self) -> bool
pub fn dependency_is_relative_with_single_next_sibling(&self) -> bool
Is this dependency’s compound selector a single compound in :has
with the next sibling relative combinator i.e. :has(> .foo)
?
This matters for insertion between an anchor and an element
connected through next sibling, e.g. .a:has(> .b)
.
Trait Implementations§
source§impl Clone for Dependency
impl Clone for Dependency
source§fn clone(&self) -> Dependency
fn clone(&self) -> Dependency
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for Dependency
impl Debug for Dependency
source§impl MallocSizeOf for Dependency
impl MallocSizeOf for Dependency
source§fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
source§impl SelectorMapEntry for Dependency
impl SelectorMapEntry for Dependency
source§fn selector(&self) -> SelectorIter<'_, SelectorImpl>
fn selector(&self) -> SelectorIter<'_, SelectorImpl>
Auto Trait Implementations§
impl Freeze for Dependency
impl RefUnwindSafe for Dependency
impl Send for Dependency
impl Sync for Dependency
impl Unpin for Dependency
impl UnwindSafe for Dependency
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more