style: Fix @import supports() parsing position

Fixed @import supports() being parsed in the incorrect position as per spec.

Also added more WPT tests for layer and supports in one @import.

Differential Revision: https://phabricator.services.mozilla.com/D176193
This commit is contained in:
CanadaHonk 2023-04-22 21:46:15 +00:00 committed by Martin Robinson
parent 0c246b0b7c
commit 5671b9f025

View file

@ -241,6 +241,21 @@ impl<'a, 'i> AtRuleParser<'i> for TopLevelRuleParser<'a> {
let url_string = input.expect_url_or_string()?.as_ref().to_owned(); let url_string = input.expect_url_or_string()?.as_ref().to_owned();
let url = CssUrl::parse_from_string(url_string, &self.context, CorsMode::None); let url = CssUrl::parse_from_string(url_string, &self.context, CorsMode::None);
let layer = if input.try_parse(|input| input.expect_ident_matching("layer")).is_ok() {
Some(ImportLayer {
name: None,
})
} else {
input.try_parse(|input| {
input.expect_function_matching("layer")?;
input.parse_nested_block(|input| {
LayerName::parse(&self.context, input)
}).map(|name| ImportLayer {
name: Some(name),
})
}).ok()
};
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
let supports_enabled = static_prefs::pref!("layout.css.import-supports.enabled"); let supports_enabled = static_prefs::pref!("layout.css.import-supports.enabled");
#[cfg(feature = "servo")] #[cfg(feature = "servo")]
@ -264,21 +279,6 @@ impl<'a, 'i> AtRuleParser<'i> for TopLevelRuleParser<'a> {
}).ok() }).ok()
}; };
let layer = if input.try_parse(|input| input.expect_ident_matching("layer")).is_ok() {
Some(ImportLayer {
name: None,
})
} else {
input.try_parse(|input| {
input.expect_function_matching("layer")?;
input.parse_nested_block(|input| {
LayerName::parse(&self.context, input)
}).map(|name| ImportLayer {
name: Some(name),
})
}).ok()
};
let media = MediaList::parse(&self.context, input); let media = MediaList::parse(&self.context, input);
let media = Arc::new(self.shared_lock.wrap(media)); let media = Arc::new(self.shared_lock.wrap(media));