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

source

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.

source

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?

source

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.

source

pub fn invalidation_kind(&self) -> DependencyInvalidationKind

The kind of invalidation that this would generate.

source

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.

source

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

source§

fn clone(&self) -> Dependency

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Dependency

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl MallocSizeOf for Dependency

source§

fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize

Measure the heap usage of all descendant heap-allocated structures, but not the space taken up by the value itself.
source§

impl SelectorMapEntry for Dependency

source§

fn selector(&self) -> SelectorIter<'_, SelectorImpl>

Gets the selector we should use to index in the selector map.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>where F: FnOnce(&Self) -> bool,

Converts 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
source§

impl<T> MaybeBoxed<Box<T, Global>> for T

source§

fn maybe_boxed(self) -> Box<T, Global>

Convert
source§

impl<T> MaybeBoxed<T> for T

source§

fn maybe_boxed(self) -> T

Convert
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> Erased for T

source§

impl<T> ErasedDestructor for Twhere T: 'static,

source§

impl<T> MaybeSendSync for T