pub enum Component<Impl: SelectorImpl> {
Show 29 variants LocalName(LocalName<Impl>), ID(Impl::Identifier), Class(Impl::Identifier), AttributeInNoNamespaceExists { local_name: Impl::LocalName, local_name_lower: Impl::LocalName, }, AttributeInNoNamespace { local_name: Impl::LocalName, operator: AttrSelectorOperator, value: Impl::AttrValue, case_sensitivity: ParsedCaseSensitivity, }, AttributeOther(Box<AttrSelectorWithOptionalNamespace<Impl>>), ExplicitUniversalType, ExplicitAnyNamespace, ExplicitNoNamespace, DefaultNamespace(Impl::NamespaceUrl), Namespace(Impl::NamespacePrefix, Impl::NamespaceUrl), Negation(SelectorList<Impl>), Root, Empty, Scope, ParentSelector, Nth(NthSelectorData), NthOf(NthOfSelectorData<Impl>), NonTSPseudoClass(Impl::NonTSPseudoClass), Slotted(Selector<Impl>), Part(Box<[Impl::Identifier]>), Host(Option<Selector<Impl>>), Where(SelectorList<Impl>), Is(SelectorList<Impl>), Has(Box<[RelativeSelector<Impl>]>), Invalid(Arc<String>), PseudoElement(Impl::PseudoElement), Combinator(Combinator), RelativeSelectorAnchor,
}
Expand description

A CSS simple selector or combinator. We store both in the same enum for optimal packing and cache performance, see [1].

[1] https://bugzilla.mozilla.org/show_bug.cgi?id=1357973

Variants§

§

LocalName(LocalName<Impl>)

§

ID(Impl::Identifier)

§

Class(Impl::Identifier)

§

AttributeInNoNamespaceExists

Fields

§local_name: Impl::LocalName
§local_name_lower: Impl::LocalName
§

AttributeInNoNamespace

Fields

§local_name: Impl::LocalName
§value: Impl::AttrValue
§case_sensitivity: ParsedCaseSensitivity
§

AttributeOther(Box<AttrSelectorWithOptionalNamespace<Impl>>)

§

ExplicitUniversalType

§

ExplicitAnyNamespace

§

ExplicitNoNamespace

§

DefaultNamespace(Impl::NamespaceUrl)

§

Namespace(Impl::NamespacePrefix, Impl::NamespaceUrl)

§

Negation(SelectorList<Impl>)

Pseudo-classes

§

Root

§

Empty

§

Scope

§

ParentSelector

§

Nth(NthSelectorData)

§

NthOf(NthOfSelectorData<Impl>)

§

NonTSPseudoClass(Impl::NonTSPseudoClass)

§

Slotted(Selector<Impl>)

The ::slotted() pseudo-element:

https://drafts.csswg.org/css-scoping/#slotted-pseudo

The selector here is a compound selector, that is, no combinators.

NOTE(emilio): This should support a list of selectors, but as of this writing no other browser does, and that allows them to put ::slotted() in the rule hash, so we do that too.

See https://github.com/w3c/csswg-drafts/issues/2158

§

Part(Box<[Impl::Identifier]>)

The ::part pseudo-element. https://drafts.csswg.org/css-shadow-parts/#part

§

Host(Option<Selector<Impl>>)

The :host pseudo-class:

https://drafts.csswg.org/css-scoping/#host-selector

NOTE(emilio): This should support a list of selectors, but as of this writing no other browser does, and that allows them to put :host() in the rule hash, so we do that too.

See https://github.com/w3c/csswg-drafts/issues/2158

§

Where(SelectorList<Impl>)

The :where pseudo-class.

https://drafts.csswg.org/selectors/#zero-matches

The inner argument is conceptually a SelectorList, but we move the selectors to the heap to keep Component small.

§

Is(SelectorList<Impl>)

The :is pseudo-class.

https://drafts.csswg.org/selectors/#matches-pseudo

Same comment as above re. the argument.

§

Has(Box<[RelativeSelector<Impl>]>)

The :has pseudo-class.

https://drafts.csswg.org/selectors/#has-pseudo

Same comment as above re. the argument.

§

Invalid(Arc<String>)

An invalid selector inside :is() / :where().

§

PseudoElement(Impl::PseudoElement)

An implementation-dependent pseudo-element selector.

§

Combinator(Combinator)

§

RelativeSelectorAnchor

Used only for relative selectors, which starts with a combinator (With an implied descendant combinator if not specified).

https://drafts.csswg.org/selectors-4/#typedef-relative-selector

Implementations§

source§

impl<Impl: SelectorImpl> Component<Impl>

source

pub fn is_combinator(&self) -> bool

Returns true if this is a combinator.

source

pub fn is_host(&self) -> bool

Returns true if this is a :host() selector.

source

pub fn matches_featureless_host(&self) -> bool

Returns true if this is a :host() selector.

source

pub fn as_combinator(&self) -> Option<Combinator>

Returns the value as a combinator if applicable, None otherwise.

source

pub fn maybe_allowed_after_pseudo_element(&self) -> bool

Whether this component is valid after a pseudo-element. Only intended for sanity-checking.

source

fn matches_for_stateless_pseudo_element(&self) -> bool

Whether a given selector should match for stateless pseudo-elements.

This is a bit subtle: Only selectors that return true in maybe_allowed_after_pseudo_element should end up here, and NonTSPseudoClass never matches (as it is a stateless pseudo after all).

source

pub fn visit<V>(&self, visitor: &mut V) -> boolwhere V: SelectorVisitor<Impl = Impl>,

source

pub fn has_indexed_selector_in_subject(&self) -> bool

Trait Implementations§

source§

impl<Impl: Clone + SelectorImpl> Clone for Component<Impl>where Impl::Identifier: Clone, Impl::LocalName: Clone, Impl::AttrValue: Clone, Impl::NamespaceUrl: Clone, Impl::NamespacePrefix: Clone, Impl::NonTSPseudoClass: Clone, Impl::PseudoElement: Clone,

source§

fn clone(&self) -> Component<Impl>

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<Impl: SelectorImpl> Debug for Component<Impl>

source§

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

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

impl<Impl: PartialEq + SelectorImpl> PartialEq<Component<Impl>> for Component<Impl>where Impl::Identifier: PartialEq, Impl::LocalName: PartialEq, Impl::AttrValue: PartialEq, Impl::NamespaceUrl: PartialEq, Impl::NamespacePrefix: PartialEq, Impl::NonTSPseudoClass: PartialEq, Impl::PseudoElement: PartialEq,

source§

fn eq(&self, other: &Component<Impl>) -> 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<Impl: SelectorImpl> Push<Component<Impl>> for SelectorBuilder<Impl>

source§

fn push(&mut self, value: Component<Impl>)

Push a value into self.
source§

impl<Impl: SelectorImpl> ToCss for Component<Impl>

source§

fn to_css<W>(&self, dest: &mut W) -> Resultwhere W: Write,

Serialize self in CSS syntax, writing to dest.
source§

fn to_css_string(&self) -> String

Serialize self in CSS syntax and return a string. Read more
source§

impl<Impl: SelectorImpl> ToShmem for Component<Impl>where Impl::Identifier: ToShmem, Impl::LocalName: ToShmem, Impl::AttrValue: ToShmem, Impl::NamespaceUrl: ToShmem, Impl::NamespacePrefix: ToShmem, Impl::NonTSPseudoClass: ToShmem, Box<[Impl::Identifier]>: ToShmem, Impl::PseudoElement: ToShmem,

source§

fn to_shmem(&self, builder: &mut SharedMemoryBuilder) -> Result<Self>

Clones this value into a form suitable for writing into a SharedMemoryBuilder. Read more
source§

impl<Impl: Eq + SelectorImpl> Eq for Component<Impl>where Impl::Identifier: Eq, Impl::LocalName: Eq, Impl::AttrValue: Eq, Impl::NamespaceUrl: Eq, Impl::NamespacePrefix: Eq, Impl::NonTSPseudoClass: Eq, Impl::PseudoElement: Eq,

source§

impl<Impl: SelectorImpl> StructuralEq for Component<Impl>

source§

impl<Impl: SelectorImpl> StructuralPartialEq for Component<Impl>

Auto Trait Implementations§

§

impl<Impl> RefUnwindSafe for Component<Impl>where <Impl as SelectorImpl>::AttrValue: RefUnwindSafe, <Impl as SelectorImpl>::Identifier: RefUnwindSafe, <Impl as SelectorImpl>::LocalName: RefUnwindSafe, <Impl as SelectorImpl>::NamespacePrefix: RefUnwindSafe, <Impl as SelectorImpl>::NamespaceUrl: RefUnwindSafe, <Impl as SelectorImpl>::NonTSPseudoClass: RefUnwindSafe, <Impl as SelectorImpl>::PseudoElement: RefUnwindSafe,

§

impl<Impl> Send for Component<Impl>where <Impl as SelectorImpl>::AttrValue: Send + Sync, <Impl as SelectorImpl>::Identifier: Send + Sync, <Impl as SelectorImpl>::LocalName: Send + Sync, <Impl as SelectorImpl>::NamespacePrefix: Send + Sync, <Impl as SelectorImpl>::NamespaceUrl: Send + Sync, <Impl as SelectorImpl>::NonTSPseudoClass: Send + Sync, <Impl as SelectorImpl>::PseudoElement: Send + Sync,

§

impl<Impl> Sync for Component<Impl>where <Impl as SelectorImpl>::AttrValue: Send + Sync, <Impl as SelectorImpl>::Identifier: Send + Sync, <Impl as SelectorImpl>::LocalName: Send + Sync, <Impl as SelectorImpl>::NamespacePrefix: Send + Sync, <Impl as SelectorImpl>::NamespaceUrl: Send + Sync, <Impl as SelectorImpl>::NonTSPseudoClass: Send + Sync, <Impl as SelectorImpl>::PseudoElement: Send + Sync,

§

impl<Impl> Unpin for Component<Impl>where <Impl as SelectorImpl>::AttrValue: Unpin, <Impl as SelectorImpl>::Identifier: Unpin, <Impl as SelectorImpl>::LocalName: Unpin, <Impl as SelectorImpl>::NamespacePrefix: Unpin, <Impl as SelectorImpl>::NamespaceUrl: Unpin, <Impl as SelectorImpl>::NonTSPseudoClass: Unpin, <Impl as SelectorImpl>::PseudoElement: Unpin,

§

impl<Impl> UnwindSafe for Component<Impl>where <Impl as SelectorImpl>::AttrValue: UnwindSafe + RefUnwindSafe, <Impl as SelectorImpl>::Identifier: UnwindSafe + RefUnwindSafe, <Impl as SelectorImpl>::LocalName: UnwindSafe + RefUnwindSafe, <Impl as SelectorImpl>::NamespacePrefix: UnwindSafe + RefUnwindSafe, <Impl as SelectorImpl>::NamespaceUrl: UnwindSafe + RefUnwindSafe, <Impl as SelectorImpl>::NonTSPseudoClass: UnwindSafe + RefUnwindSafe, <Impl as SelectorImpl>::PseudoElement: UnwindSafe + RefUnwindSafe,

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