selectors::context

Struct MatchingContext

Source
pub struct MatchingContext<'a, Impl>
where Impl: SelectorImpl,
{
Show 19 fields matching_mode: MatchingMode, pub bloom_filter: Option<&'a BloomFilter>, pub scope_element: Option<OpaqueElement>, pub current_host: Option<OpaqueElement>, visited_handling: VisitedHandlingMode, pub include_starting_style: IncludeStartingStyle, pub has_starting_style: bool, pub featureless: bool, nesting_level: usize, in_negation: bool, pub pseudo_element_matching_fn: Option<&'a dyn Fn(&Impl::PseudoElement) -> bool>, pub extra_data: Impl::ExtraMatchingData<'a>, current_relative_selector_anchor: Option<OpaqueElement>, quirks_mode: QuirksMode, needs_selector_flags: NeedsSelectorFlags, matching_for_invalidation: MatchingForInvalidation, pub selector_caches: &'a mut SelectorCaches, classes_and_ids_case_sensitivity: CaseSensitivity, _impl: PhantomData<Impl>,
}
Expand description

Data associated with the matching process for a element. This context is used across many selectors for an element, so it’s not appropriate for transient data that applies to only a single selector.

Fields§

§matching_mode: MatchingMode

Input with the matching mode we should use when matching selectors.

§bloom_filter: Option<&'a BloomFilter>

Input with the bloom filter used to fast-reject selectors.

§scope_element: Option<OpaqueElement>

The element which is going to match :scope pseudo-class. It can be either one :scope element, or the scoping element.

Note that, although in theory there can be multiple :scope elements, in current specs, at most one is specified, and when there is one, scoping element is not relevant anymore, so we use a single field for them.

When this is None, :scope will match the root element.

See https://drafts.csswg.org/selectors-4/#scope-pseudo

§current_host: Option<OpaqueElement>

The current shadow host we’re collecting :host rules for.

§visited_handling: VisitedHandlingMode

Controls how matching for links is handled.

§include_starting_style: IncludeStartingStyle

Controls if we should match rules in @starting-style.

§has_starting_style: bool

Whether there are any rules inside @starting-style.

§featureless: bool

Whether we’re currently matching a featureless element.

§nesting_level: usize

The current nesting level of selectors that we’re matching.

§in_negation: bool

Whether we’re inside a negation or not.

§pseudo_element_matching_fn: Option<&'a dyn Fn(&Impl::PseudoElement) -> bool>

An optional hook function for checking whether a pseudo-element should match when matching_mode is ForStatelessPseudoElement.

§extra_data: Impl::ExtraMatchingData<'a>

Extra implementation-dependent matching data.

§current_relative_selector_anchor: Option<OpaqueElement>

The current element we’re anchoring on for evaluating the relative selector.

§quirks_mode: QuirksMode§needs_selector_flags: NeedsSelectorFlags§matching_for_invalidation: MatchingForInvalidation

Whether we’re matching in the contect of invalidation.

§selector_caches: &'a mut SelectorCaches

Caches to speed up expensive selector matches.

§classes_and_ids_case_sensitivity: CaseSensitivity§_impl: PhantomData<Impl>

Implementations§

Source§

impl<'a, Impl> MatchingContext<'a, Impl>
where Impl: SelectorImpl,

Source

pub fn new( matching_mode: MatchingMode, bloom_filter: Option<&'a BloomFilter>, selector_caches: &'a mut SelectorCaches, quirks_mode: QuirksMode, needs_selector_flags: NeedsSelectorFlags, matching_for_invalidation: MatchingForInvalidation, ) -> Self

Constructs a new MatchingContext.

Source

pub fn new_for_visited( matching_mode: MatchingMode, bloom_filter: Option<&'a BloomFilter>, selector_caches: &'a mut SelectorCaches, visited_handling: VisitedHandlingMode, include_starting_style: IncludeStartingStyle, quirks_mode: QuirksMode, needs_selector_flags: NeedsSelectorFlags, matching_for_invalidation: MatchingForInvalidation, ) -> Self

Constructs a new MatchingContext for use in visited matching.

Source

pub fn nth_index_cache( &mut self, is_of_type: bool, is_from_end: bool, selectors: &[Selector<Impl>], ) -> &mut NthIndexCacheInner

Source

pub fn is_nested(&self) -> bool

Whether we’re matching a nested selector.

Source

pub fn in_negation(&self) -> bool

Whether we’re matching inside a :not(..) selector.

Source

pub fn quirks_mode(&self) -> QuirksMode

The quirks mode of the document.

Source

pub fn matching_mode(&self) -> MatchingMode

The matching-mode for this selector-matching operation.

Source

pub fn needs_selector_flags(&self) -> bool

Whether we need to set selector flags.

Source

pub fn matching_for_invalidation(&self) -> bool

Whether or not we’re matching to invalidate.

Source

pub fn matching_for_invalidation_comparison(&self) -> Option<bool>

Whether or not we’re comparing for invalidation, if we are matching for invalidation.

Source

pub fn for_invalidation_comparison<F, R>(&mut self, f: F) -> R
where F: FnOnce(&mut Self) -> R,

Run the given matching function for before/after invalidation comparison.

Source

pub fn classes_and_ids_case_sensitivity(&self) -> CaseSensitivity

The case-sensitivity for class and ID selectors

Source

pub fn nest<F, R>(&mut self, f: F) -> R
where F: FnOnce(&mut Self) -> R,

Runs F with a deeper nesting level.

Source

pub fn nest_for_negation<F, R>(&mut self, f: F) -> R
where F: FnOnce(&mut Self) -> R,

Runs F with a deeper nesting level, and marking ourselves in a negation, for a :not(..) selector, for example.

Source

pub fn visited_handling(&self) -> VisitedHandlingMode

Source

pub fn with_featureless<F, R>(&mut self, featureless: bool, f: F) -> R
where F: FnOnce(&mut Self) -> R,

Runs F with a different featureless element flag.

Source

pub fn featureless(&self) -> bool

Returns whether the currently matching element is acting as a featureless element (e.g., because we’ve crossed a shadow boundary). This is used to implement the :host selector rules properly.

Source

pub fn with_visited_handling_mode<F, R>( &mut self, handling_mode: VisitedHandlingMode, f: F, ) -> R
where F: FnOnce(&mut Self) -> R,

Runs F with a different VisitedHandlingMode.

Source

pub fn with_shadow_host<F, E, R>(&mut self, host: Option<E>, f: F) -> R
where E: Element, F: FnOnce(&mut Self) -> R,

Runs F with a given shadow host which is the root of the tree whose rules we’re matching.

Source

pub fn shadow_host(&self) -> Option<OpaqueElement>

Returns the current shadow host whose shadow root we’re matching rules against.

Source

pub fn nest_for_relative_selector<F, R>( &mut self, anchor: OpaqueElement, f: F, ) -> R
where F: FnOnce(&mut Self) -> R,

Runs F with a deeper nesting level, with the given element as the anchor, for a :has(…) selector, for example.

Source

pub fn nest_for_scope<F, R>(&mut self, scope: Option<OpaqueElement>, f: F) -> R
where F: FnOnce(&mut Self) -> R,

Runs F with a deeper nesting level, with the given element as the scope.

Source

pub fn nest_for_scope_condition<F, R>( &mut self, scope: Option<OpaqueElement>, f: F, ) -> R
where F: FnOnce(&mut Self) -> R,

Runs F with a deeper nesting level, with the given element as the scope, for matching scope-start and/or scope-end conditions.

Source

pub fn relative_selector_anchor(&self) -> Option<OpaqueElement>

Returns the current anchor element to evaluate the relative selector against.

Auto Trait Implementations§

§

impl<'a, Impl> Freeze for MatchingContext<'a, Impl>
where <Impl as SelectorImpl>::ExtraMatchingData<'a>: Freeze,

§

impl<'a, Impl> !RefUnwindSafe for MatchingContext<'a, Impl>

§

impl<'a, Impl> !Send for MatchingContext<'a, Impl>

§

impl<'a, Impl> !Sync for MatchingContext<'a, Impl>

§

impl<'a, Impl> Unpin for MatchingContext<'a, Impl>
where <Impl as SelectorImpl>::ExtraMatchingData<'a>: Unpin, Impl: Unpin,

§

impl<'a, Impl> !UnwindSafe for MatchingContext<'a, Impl>

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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.