lewp_css/domain/selectors/our_selector_ext.rs
1// This file is part of css. It is subject to the license terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/css/master/COPYRIGHT. No part of predicator, including this file, may be copied, modified, propagated, or distributed except according to the terms contained in the COPYRIGHT file.
2// Copyright © 2017 The developers of css. See the COPYRIGHT file in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/css/master/COPYRIGHT.
3
4use {
5 super::OurSelector,
6 selectors::parser::{Combinator, Component},
7};
8
9pub trait OurSelectorExt {
10 fn is_false_if_any_selector_is_simple_and_only_uses_the_descendant_combinator(
11 &self,
12 ) -> bool;
13}
14
15impl OurSelectorExt for OurSelector {
16 #[inline(always)]
17 fn is_false_if_any_selector_is_simple_and_only_uses_the_descendant_combinator(
18 &self,
19 ) -> bool {
20 for component in self.iter_raw_match_order() {
21 match *component {
22 // Combinators are not allowed except for descendant
23 Component::Combinator(ref combinator) => {
24 if combinator != &Combinator::Descendant {
25 return true;
26 }
27 }
28
29 // Only simple selectors are allowed (http://www.w3.org/TR/css3-selectors/#simple-selectors)
30 Component::PseudoElement(..) => return true,
31
32 _ => {}
33 }
34 }
35
36 false
37 }
38}