Bug 1829430 - Fix @import supports() parsing position r=emilio

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 12:30:30 +00:00
Родитель 08d9f32e0a
Коммит e327a756ba
2 изменённых файлов: 23 добавлений и 15 удалений

Просмотреть файл

@ -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 = 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()
};
let supports = if !static_prefs::pref!("layout.css.import-supports.enabled") {
None
} else {
@ -259,21 +274,6 @@ impl<'a, 'i> AtRuleParser<'i> for TopLevelRuleParser<'a> {
}).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 = Arc::new(self.shared_lock.wrap(media));

Просмотреть файл

@ -99,6 +99,14 @@
importCondition: "supports(font-format(invalid))",
matches: false
},
{
importCondition: "layer(A.B) supports(font-format(opentype))",
matches: true
},
{
importCondition: "layer supports(selector(a))",
matches: true
},
];
let target = document.getElementById("target");
for (let testCase of testCases) {