pub enum Component<'i, Impl: SelectorImpl<'i>> {
Show 38 variants Combinator(Combinator), ExplicitAnyNamespace, ExplicitNoNamespace, DefaultNamespace(Impl::NamespaceUrl), Namespace(Impl::NamespacePrefix, Impl::NamespaceUrl), ExplicitUniversalType, LocalName(LocalName<'i, 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, never_matches: bool, }, AttributeOther(Box<AttrSelectorWithOptionalNamespace<'i, Impl>>), Negation(Box<[Selector<'i, Impl>]>), FirstChild, LastChild, OnlyChild, Root, Empty, Scope, NthChild(i32, i32), NthLastChild(i32, i32), NthCol(i32, i32), NthLastCol(i32, i32), NthOfType(i32, i32), NthLastOfType(i32, i32), FirstOfType, LastOfType, OnlyOfType, NonTSPseudoClass(Impl::NonTSPseudoClass), Slotted(Selector<'i, Impl>), Part(Box<[Impl::Identifier]>), Host(Option<Selector<'i, Impl>>), Where(Box<[Selector<'i, Impl>]>), Is(Box<[Selector<'i, Impl>]>), Any(Impl::VendorPrefix, Box<[Selector<'i, Impl>]>), Has(Box<[Selector<'i, Impl>]>), PseudoElement(Impl::PseudoElement), Nesting,
}
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§

§

Combinator(Combinator)

§

ExplicitAnyNamespace

§

ExplicitNoNamespace

§

DefaultNamespace(Impl::NamespaceUrl)

§

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

§

ExplicitUniversalType

§

LocalName(LocalName<'i, 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
§never_matches: bool
§

AttributeOther(Box<AttrSelectorWithOptionalNamespace<'i, Impl>>)

§

Negation(Box<[Selector<'i, Impl>]>)

Pseudo-classes

§

FirstChild

§

LastChild

§

OnlyChild

§

Root

§

Empty

§

Scope

§

NthChild(i32, i32)

§

NthLastChild(i32, i32)

§

NthCol(i32, i32)

§

NthLastCol(i32, i32)

§

NthOfType(i32, i32)

§

NthLastOfType(i32, i32)

§

FirstOfType

§

LastOfType

§

OnlyOfType

§

NonTSPseudoClass(Impl::NonTSPseudoClass)

§

Slotted(Selector<'i, 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<'i, 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(Box<[Selector<'i, 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(Box<[Selector<'i, Impl>]>)

The :is pseudo-class.

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

Same comment as above re. the argument.

§

Any(Impl::VendorPrefix, Box<[Selector<'i, Impl>]>)

§

Has(Box<[Selector<'i, Impl>]>)

The :has pseudo-class.

https://www.w3.org/TR/selectors/#relational

§

PseudoElement(Impl::PseudoElement)

An implementation-dependent pseudo-element selector.

§

Nesting

A nesting selector:

https://drafts.csswg.org/css-nesting-1/#nest-selector

NOTE: This is a lightningcss addition.

Implementations§

source§

impl<'i, Impl: SelectorImpl<'i>> Component<'i, Impl>

source

pub fn is_combinator(&self) -> bool

Returns true if this is a combinator.

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

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

Trait Implementations§

source§

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

source§

fn clone(&self) -> Component<'i, 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<'i, Impl: SelectorImpl<'i>> Debug for Component<'i, Impl>

source§

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

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

impl<'i, Impl: SelectorImpl<'i>> From<Component<'i, Impl>> for Selector<'i, Impl>

source§

fn from(component: Component<'i, Impl>) -> Self

Converts to this type from the input type.
source§

impl<'i, Impl: SelectorImpl<'i>> From<Component<'i, Impl>> for SelectorList<'i, Impl>

source§

fn from(component: Component<'i, Impl>) -> Self

Converts to this type from the input type.
source§

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

source§

fn eq(&self, other: &Component<'i, 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<'i, Impl: SelectorImpl<'i>> ToCss for Component<'i, 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<'i, Impl: SelectorImpl<'i>> StructuralPartialEq for Component<'i, Impl>

Auto Trait Implementations§

§

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

§

impl<'i, Impl> Send for Component<'i, Impl>where <Impl as SelectorImpl<'i>>::AttrValue: Send, <Impl as SelectorImpl<'i>>::Identifier: Send, <Impl as SelectorImpl<'i>>::LocalName: Send, <Impl as SelectorImpl<'i>>::NamespacePrefix: Send, <Impl as SelectorImpl<'i>>::NamespaceUrl: Send, <Impl as SelectorImpl<'i>>::NonTSPseudoClass: Send, <Impl as SelectorImpl<'i>>::PseudoElement: Send, <Impl as SelectorImpl<'i>>::VendorPrefix: Send,

§

impl<'i, Impl> Sync for Component<'i, Impl>where <Impl as SelectorImpl<'i>>::AttrValue: Sync, <Impl as SelectorImpl<'i>>::Identifier: Sync, <Impl as SelectorImpl<'i>>::LocalName: Sync, <Impl as SelectorImpl<'i>>::NamespacePrefix: Sync, <Impl as SelectorImpl<'i>>::NamespaceUrl: Sync, <Impl as SelectorImpl<'i>>::NonTSPseudoClass: Sync, <Impl as SelectorImpl<'i>>::PseudoElement: Sync, <Impl as SelectorImpl<'i>>::VendorPrefix: Sync,

§

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

§

impl<'i, Impl> UnwindSafe for Component<'i, Impl>where <Impl as SelectorImpl<'i>>::AttrValue: UnwindSafe, <Impl as SelectorImpl<'i>>::Identifier: UnwindSafe, <Impl as SelectorImpl<'i>>::LocalName: UnwindSafe, <Impl as SelectorImpl<'i>>::NamespacePrefix: UnwindSafe, <Impl as SelectorImpl<'i>>::NamespaceUrl: UnwindSafe, <Impl as SelectorImpl<'i>>::NonTSPseudoClass: UnwindSafe, <Impl as SelectorImpl<'i>>::PseudoElement: UnwindSafe, <Impl as SelectorImpl<'i>>::VendorPrefix: UnwindSafe,

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,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · 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.
const: unstable · 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.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.