style: Move the code to parse a list of compound selectors.

I'll need this for ::slotted().
This commit is contained in:
Emilio Cobos Álvarez 2017-12-09 16:45:06 +01:00
parent 051a715721
commit b1f25a2b1f
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
2 changed files with 35 additions and 11 deletions

View file

@ -11,7 +11,7 @@ use gecko_bindings::structs::RawServoSelectorList;
use gecko_bindings::sugar::ownership::{HasBoxFFI, HasFFI, HasSimpleFFI};
use selector_parser::{Direction, SelectorParser, PseudoElementCascadeType};
use selectors::SelectorList;
use selectors::parser::{Selector, SelectorMethods, SelectorParseErrorKind};
use selectors::parser::{self as selector_parser, Selector, SelectorMethods, SelectorParseErrorKind};
use selectors::visitor::SelectorVisitor;
use std::fmt;
use string_cache::{Atom, Namespace, WeakAtom, WeakNamespace};
@ -399,16 +399,12 @@ impl<'a, 'i> ::selectors::Parser<'i> for SelectorParser<'a> {
NonTSPseudoClass::Dir(Box::new(direction))
},
"-moz-any" => {
let selectors = parser.parse_comma_separated(|input| {
Selector::parse(self, input)
})?;
// Selectors inside `:-moz-any` may not include combinators.
if selectors.iter().flat_map(|x| x.iter_raw_match_order()).any(|s| s.is_combinator()) {
return Err(parser.new_custom_error(
SelectorParseErrorKind::UnexpectedIdent("-moz-any".into())
))
}
NonTSPseudoClass::MozAny(selectors.into_boxed_slice())
NonTSPseudoClass::MozAny(
selector_parser::parse_compound_selector_list(
self,
parser,
)?
)
}
_ => return Err(parser.new_custom_error(
SelectorParseErrorKind::UnsupportedPseudoClassOrElement(name.clone())