Struct css::selectors::parser::Selector
[−]
[src]
pub struct Selector<Impl: SelectorImpl>(_);
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.
We store compound selectors internally right-to-left (in matching order). Additionally, we invert the order of top-level compound selectors so that each one matches left-to-right. This is because matching namespace, local name, id, and class are all relatively cheap, whereas matching pseudo-classes might be expensive (depending on the pseudo-class). Since authors tend to put the pseudo-classes on the right, it's faster to start matching on the left.
This reordering doesn't change the semantics of selector matching, and we handle it in to_css to make it invisible to serialization.
Methods
impl<Impl: SelectorImpl> Selector<Impl>
[src]
fn specificity(&self) -> u32
[src]
fn has_pseudo_element(&self) -> bool
[src]
fn pseudo_element(&self) -> Option<&Impl::PseudoElement>
[src]
fn is_universal(&self) -> bool
[src]
Whether this selector (pseudo-element part excluded) matches every element.
Used for "pre-computed" pseudo-elements in components/style/stylist.rs
fn iter(&self) -> SelectorIter<Impl>
[src]
Returns an iterator over this selector in matching order (right-to-left). When a combinator is reached, the iterator will return None, and next_sequence() may be called to continue to the next sequence.
fn iter_from(&self, offset: usize) -> SelectorIter<Impl>
[src]
Returns an iterator over this selector in matching order (right-to-left), skipping the rightmost |offset| Components.
fn combinator_at(&self, index: usize) -> Combinator
[src]
Returns the combinator at index index
(one-indexed from the right),
or panics if the component is not a combinator.
FIXME(bholley): Use more intuitive indexing.
fn iter_raw_match_order(&self) -> Iter<Component<Impl>>
[src]
Returns an iterator over the entire sequence of simple selectors and combinators, in matching order (from right to left).
fn iter_raw_parse_order_from(
&self,
offset_from_right: usize
) -> Rev<Iter<Component<Impl>>>
[src]
&self,
offset_from_right: usize
) -> Rev<Iter<Component<Impl>>>
Returns an iterator over the sequence of simple selectors and combinators, in parse order (from left to right), starting 'offset_from_right' entries from the past-the-end sentinel on the right. So "0" panics,. "1" iterates nothing, and "len" iterates the entire sequence.
FIXME(bholley): This API is rather unintuive, and should really be changed to accept an offset from the left. Same for combinator_at.
fn from_vec(vec: Vec<Component<Impl>>, specificity_and_flags: u32) -> Self
[src]
Creates a Selector from a vec of Components, specified in parse order. Used in tests.
fn len(&self) -> usize
[src]
Returns count of simple selectors and combinators in the Selector.
fn thin_arc_heap_ptr(&self) -> *const c_void
[src]
Returns the address on the heap of the ThinArc for memory reporting.
impl<Impl: SelectorImpl> Selector<Impl>
[src]
fn parse<'i, 't, P, E>(
parser: &P,
input: &mut CssParser<'i, 't>
) -> Result<Self, ParseError<'i, SelectorParseError<'i, E>>> where
P: Parser<'i, Impl = Impl, Error = E>,
[src]
parser: &P,
input: &mut CssParser<'i, 't>
) -> Result<Self, ParseError<'i, SelectorParseError<'i, E>>> where
P: Parser<'i, Impl = Impl, Error = E>,
Parse a selector, without any pseudo-element.
Trait Implementations
impl<Impl: SelectorImpl> SelectorMethods for Selector<Impl>
[src]
type Impl = Impl
fn visit<V>(&self, visitor: &mut V) -> bool where
V: SelectorVisitor<Impl = Impl>,
[src]
V: SelectorVisitor<Impl = Impl>,
impl<Impl: Clone + SelectorImpl> Clone for Selector<Impl>
[src]
fn clone(&self) -> Selector<Impl>
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<Impl: Eq + SelectorImpl> Eq for Selector<Impl>
[src]
impl<Impl: PartialEq + SelectorImpl> PartialEq for Selector<Impl>
[src]
fn eq(&self, __arg_0: &Selector<Impl>) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Selector<Impl>) -> bool
[src]
This method tests for !=
.