style: Implement @supports selector() syntax.

This implements the selector(<complex-selector>) syntax for @supports.

See https://github.com/w3c/csswg-drafts/issues/3207 for explainer and
discussion.

Probably would should wait for that to be sorted out to land this, or maybe we
should put it behind a pref to get the code landed and change our
implementation if the discussion there leads to a change.

Differential Revision: https://phabricator.services.mozilla.com/D8864
This commit is contained in:
Emilio Cobos Álvarez 2018-10-17 12:08:14 +00:00
parent 4e356b4bb9
commit edc40ce320
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
5 changed files with 157 additions and 65 deletions

View file

@ -259,8 +259,13 @@ where
Impl: SelectorImpl,
{
let location = input.current_source_location();
let selector = Selector::parse(parser, input)?;
// Ensure they're actually all compound selectors.
let selector = parse_selector(parser, input)?;
// Ensure they're actually all compound selectors without pseudo-elements.
if selector.has_pseudo_element() {
return Err(location.new_custom_error(SelectorParseErrorKind::PseudoElementInComplexSelector));
}
if selector.iter_raw_match_order().any(|s| s.is_combinator()) {
return Err(location.new_custom_error(SelectorParseErrorKind::NonCompoundSelector));
}
@ -1397,6 +1402,7 @@ where
impl<Impl: SelectorImpl> Selector<Impl> {
/// Parse a selector, without any pseudo-element.
#[inline]
pub fn parse<'i, 't, P>(
parser: &P,
input: &mut CssParser<'i, 't>,
@ -1404,12 +1410,7 @@ impl<Impl: SelectorImpl> Selector<Impl> {
where
P: Parser<'i, Impl = Impl>,
{
let selector = parse_selector(parser, input)?;
if selector.has_pseudo_element() {
let e = SelectorParseErrorKind::PseudoElementInComplexSelector;
return Err(input.new_custom_error(e));
}
Ok(selector)
parse_selector(parser, input)
}
}