Module selectors::parser

source ·

Re-exports

pub use crate::visitor::SelectorVisitor;

Macros

Structs

Ancestor hashes for the bloom filter. We precompute these and store them inline with selectors to optimize cache performance during matching. This matters a lot.
An iterator over all simple selectors belonging to ancestors.
A Selector stores a sequence of simple selectors and combinators. The iterator classes allow callers to iterate at either the raw sequence level or at the level of sequences of simple selectors separated by combinators. Most callers want the higher-level iterator.
Flags that indicate at which point of parsing a selector are we.

Enums

An attribute selector can have ‘s’ or ‘i’ as flags, or no flags at all.
A CSS simple selector or combinator. We store both in the same enum for optimal packing and cache performance, see [1].
How to treat invalid selectors in a selector list.

Traits

A trait that represents a pseudo-class.
A trait that represents a pseudo-element.
This trait allows to define the parser implementation in regards of pseudo-classes/elements

Functions

Returns whether the name corresponds to a CSS2 pseudo-element that can be specified with the single colon syntax (in addition to the double-colon syntax, which can be used for all pseudo-elements).
simple_selector_sequence : [ type_selector | universal ] [ HASH | class | attrib | pseudo | negation ]* | [ HASH | class | attrib | pseudo | negation ]+
Parses one compound selector suitable for nested stuff like :-moz-any, etc.
Level 3: Parse one simple_selector. (Though we might insert a second implied “|*” type selector.)
Parse a simple selector other than a type selector.
  • Err(()): Invalid selector, abort
  • Ok(None(token)): Not a simple selector, could be something else. input was not consumed, but the token is still returned.
  • Ok(Some(namespace, local_name)): None for the local name means a * universal selector
  • Build up a Selector. selector : simple_selector_sequence [ combinator simple_selector_sequence ]* ;
  • Err(()): Invalid selector, abort
  • Ok(false): Not a type selector, could be something else. input was not consumed.
  • Ok(true): Length 0 (*|*), 1 (*|E or ns|*) or 2 (|E or ns|E)
  • Returns a Cow::Borrowed if s is already ASCII lowercase, and a Cow::Owned if s had to be converted into ASCII lowercase.

    Type Definitions