Enum selectors::matching::SelectorMatchingResult

source ·
enum SelectorMatchingResult {
    Matched,
    NotMatchedAndRestartFromClosestLaterSibling,
    NotMatchedAndRestartFromClosestDescendant,
    NotMatchedGlobally,
    Unknown,
}
Expand description

A result of selector matching, includes 3 failure types,

NotMatchedAndRestartFromClosestLaterSibling NotMatchedAndRestartFromClosestDescendant NotMatchedGlobally

When NotMatchedGlobally appears, stop selector matching completely since the succeeding selectors never matches. It is raised when Child combinator cannot find the candidate element. Descendant combinator cannot find the candidate element.

When NotMatchedAndRestartFromClosestDescendant appears, the selector matching does backtracking and restarts from the closest Descendant combinator. It is raised when NextSibling combinator cannot find the candidate element. LaterSibling combinator cannot find the candidate element. Child combinator doesn’t match on the found element.

When NotMatchedAndRestartFromClosestLaterSibling appears, the selector matching does backtracking and restarts from the closest LaterSibling combinator. It is raised when NextSibling combinator doesn’t match on the found element.

For example, when the selector “d1 d2 a” is provided and we cannot find an appropriate ancestor element for “d1”, this selector matching raises NotMatchedGlobally since even if “d2” is moved to more upper element, the candidates for “d1” becomes less than before and d1 .

The next example is siblings. When the selector “b1 + b2 ~ d1 a” is provided and we cannot find an appropriate brother element for b1, the selector matching raises NotMatchedAndRestartFromClosestDescendant. The selectors (“b1 + b2 ~”) doesn’t match and matching restart from “d1”.

The additional example is child and sibling. When the selector “b1 + c1 > b2 ~ d1 a” is provided and the selector “b1” doesn’t match on the element, this “b1” raises NotMatchedAndRestartFromClosestLaterSibling. However since the selector “c1” raises NotMatchedAndRestartFromClosestDescendant. So the selector “b1 + c1 > b2 ~ “ doesn’t match and restart matching from “d1”.

There is also the unknown result, which is used during invalidation when specific selector is being tested for before/after comparison. More specifically, selectors that are too expensive to correctly compute during invalidation may return unknown, as the computation will be thrown away and only to be recomputed during styling. For most cases, the unknown result can be treated as matching. This is because a compound of selectors acts like &&, and unknown && matched == matched and unknown && not-matched == not-matched. However, some selectors, like :is(), behave like || i.e. :is(.a, .b) == a || b. Treating unknown == matching then causes these selectors to always return matching, which undesired for before/after comparison. Coercing to not-matched doesn’t work since each inner selector may have compounds: e.g. Toggling .foo in :is(.foo:has(..)) with coersion to not-matched would result in an invalid before/after comparison of not-matched/not-matched.

Variants§

§

Matched

§

NotMatchedAndRestartFromClosestLaterSibling

§

NotMatchedAndRestartFromClosestDescendant

§

NotMatchedGlobally

§

Unknown

Trait Implementations§

source§

impl Clone for SelectorMatchingResult

source§

fn clone(&self) -> SelectorMatchingResult

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 From<SelectorMatchingResult> for KleeneValue

source§

fn from(value: SelectorMatchingResult) -> Self

Converts to this type from the input type.
source§

impl PartialEq for SelectorMatchingResult

source§

fn eq(&self, other: &SelectorMatchingResult) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for SelectorMatchingResult

source§

impl Eq for SelectorMatchingResult

source§

impl StructuralPartialEq for SelectorMatchingResult

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where 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 T
where 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> ToOwned for T
where 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 T
where 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 T
where 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.