Move "is universal" logic from stylist.rs to selectors/parser.rs

This commit is contained in:
Simon Sapin 2017-05-16 17:07:49 +02:00
parent 390e688058
commit 685b9efed6
3 changed files with 16 additions and 15 deletions

View file

@ -182,6 +182,18 @@ pub struct Selector<Impl: SelectorImpl> {
pub specificity: u32,
}
impl<Impl: SelectorImpl> Selector<Impl> {
/// Whether this selector (pseudo-element part excluded) matches every element.
///
/// Used for "pre-computed" pseudo-elements in components/style/stylist.rs
pub fn is_universal(&self) -> bool {
self.inner.complex.iter_raw().all(|c| matches!(*c,
Component::ExplicitUniversalType |
Component::ExplicitAnyNamespace
))
}
}
pub trait SelectorMethods {
type Impl: SelectorImpl;