pub enum Component<Impl: SelectorImpl> {
Show 30 variants Combinator(Combinator), ExplicitAnyNamespace, ExplicitNoNamespace, DefaultNamespace(Impl::NamespaceUrl), Namespace(Impl::NamespacePrefix, Impl::NamespaceUrl), ExplicitUniversalType, LocalName(LocalName<Impl>), ID(Impl::Identifier), Class(Impl::ClassName), 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<Impl>>), Negation(ThinBoxedSlice<Component<Impl>>), FirstChild, LastChild, OnlyChild, Root, Empty, Scope, NthChild(i32i32), NthLastChild(i32i32), NthOfType(i32i32), NthLastOfType(i32i32), FirstOfType, LastOfType, OnlyOfType, NonTSPseudoClass(Impl::NonTSPseudoClass), Slotted(Selector<Impl>), Host(Option<Selector<Impl>>), PseudoElement(Impl::PseudoElement),
}
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<Impl>)

§

ID(Impl::Identifier)

§

Class(Impl::ClassName)

§

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<Impl>>)

§

Negation(ThinBoxedSlice<Component<Impl>>)

Pseudo-classes

CSS3 Negation only takes a simple simple selector, but we still need to treat it as a compound selector because it might be a type selector which we represent as a namespace and a localname.

Note: if/when we upgrade this to CSS4, which supports combinators, we need to think about how this should interact with visit_complex_selector, and what the consumers of those APIs should do about the presence of combinators in negation.

§

FirstChild

§

LastChild

§

OnlyChild

§

Root

§

Empty

§

Scope

§

NthChild(i32i32)

§

NthLastChild(i32i32)

§

NthOfType(i32i32)

§

NthLastOfType(i32i32)

§

FirstOfType

§

LastOfType

§

OnlyOfType

§

NonTSPseudoClass(Impl::NonTSPseudoClass)

§

Slotted(Selector<Impl>)

The ::slotted() pseudo-element (which isn’t actually a pseudo-element, and probably should be a pseudo-class):

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

§

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

§

PseudoElement(Impl::PseudoElement)

Implementations§

Returns true if this is a combinator.

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

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
Serialize self in CSS syntax, writing to dest.
Serialize self in CSS syntax and return a string. Read more
The type parameter of selector component types.
Traverse selector components inside self. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.