style: Disallow forgiving selector-parsing in @supports

As per spec, see https://github.com/w3c/csswg-drafts/issues/7280

Differential Revision: https://phabricator.services.mozilla.com/D156468
This commit is contained in:
Emilio Cobos Álvarez 2022-09-06 17:00:33 +00:00 committed by Martin Robinson
parent ab36c8a39b
commit 9f6341b83a
6 changed files with 25 additions and 23 deletions

View file

@ -785,6 +785,7 @@ impl<'a, 'b, 'i> QualifiedRuleParser<'i> for NestedRuleParser<'a, 'b> {
stylesheet_origin: self.context.stylesheet_origin,
namespaces: self.namespaces,
url_data: self.context.url_data,
for_supports_rule: false,
};
let selectors = SelectorList::parse(&selector_parser, input)?;
if self.context.error_reporting_enabled() {

View file

@ -385,29 +385,12 @@ impl RawSelector {
namespaces,
stylesheet_origin: context.stylesheet_origin,
url_data: context.url_data,
for_supports_rule: true,
};
#[allow(unused_variables)]
let selector = Selector::<SelectorImpl>::parse(&parser, input)
Selector::<SelectorImpl>::parse(&parser, input)
.map_err(|_| input.new_custom_error(()))?;
#[cfg(feature = "gecko")]
{
use crate::selector_parser::PseudoElement;
use selectors::parser::Component;
let has_any_unknown_webkit_pseudo = selector.has_pseudo_element() &&
selector.iter_raw_match_order().any(|component| {
matches!(
*component,
Component::PseudoElement(PseudoElement::UnknownWebkit(..))
)
});
if has_any_unknown_webkit_pseudo {
return Err(input.new_custom_error(()));
}
}
Ok(())
})
.is_ok()