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
impl Clone for SelectorMatchingResult
source§fn clone(&self) -> SelectorMatchingResult
fn clone(&self) -> SelectorMatchingResult
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl From<SelectorMatchingResult> for KleeneValue
impl From<SelectorMatchingResult> for KleeneValue
source§fn from(value: SelectorMatchingResult) -> Self
fn from(value: SelectorMatchingResult) -> Self
source§impl PartialEq for SelectorMatchingResult
impl PartialEq for SelectorMatchingResult
impl Copy for SelectorMatchingResult
impl Eq for SelectorMatchingResult
impl StructuralPartialEq for SelectorMatchingResult
Auto Trait Implementations§
impl Freeze for SelectorMatchingResult
impl RefUnwindSafe for SelectorMatchingResult
impl Send for SelectorMatchingResult
impl Sync for SelectorMatchingResult
impl Unpin for SelectorMatchingResult
impl UnwindSafe for SelectorMatchingResult
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)