mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
CSS-wide keywords parsing in shorthand: use a single code path with IDs
… rather than generating similar code for each shorthand.
This commit is contained in:
parent
3075746edd
commit
a5b80e2d75
1 changed files with 18 additions and 22 deletions
|
@ -1540,30 +1540,26 @@ impl PropertyDeclaration {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PropertyId::Shorthand(id) => {
|
PropertyId::Shorthand(id) => {
|
||||||
match id {
|
if let Ok(keyword) = input.try(|i| CSSWideKeyword::parse(context, i)) {
|
||||||
% for shorthand in data.shorthands:
|
if id == ShorthandId::All {
|
||||||
ShorthandId::${shorthand.camel_case} => {
|
declarations.all_shorthand = AllShorthand::CSSWideKeyword(keyword)
|
||||||
match input.try(|i| CSSWideKeyword::parse(context, i)) {
|
} else {
|
||||||
Ok(keyword) => {
|
for &longhand in id.longhands() {
|
||||||
% if shorthand.name == "all":
|
declarations.push(PropertyDeclaration::CSSWideKeyword(longhand, keyword))
|
||||||
declarations.all_shorthand = AllShorthand::CSSWideKeyword(keyword);
|
|
||||||
% else:
|
|
||||||
% for sub_property in shorthand.sub_properties:
|
|
||||||
declarations.push(PropertyDeclaration::CSSWideKeyword(
|
|
||||||
LonghandId::${sub_property.camel_case},
|
|
||||||
keyword,
|
|
||||||
));
|
|
||||||
% endfor
|
|
||||||
% endif
|
|
||||||
Ok(())
|
|
||||||
},
|
|
||||||
Err(_) => {
|
|
||||||
shorthands::${shorthand.ident}::parse_into(declarations, context, input)
|
|
||||||
.map_err(|_| PropertyDeclarationParseError::InvalidValue("${shorthand.ident}".into()))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
% endfor
|
Ok(())
|
||||||
|
} else {
|
||||||
|
match id {
|
||||||
|
% for shorthand in data.shorthands:
|
||||||
|
ShorthandId::${shorthand.camel_case} => {
|
||||||
|
shorthands::${shorthand.ident}::parse_into(declarations, context, input)
|
||||||
|
.map_err(|_| PropertyDeclarationParseError::InvalidValue(
|
||||||
|
"${shorthand.ident}".into()
|
||||||
|
))
|
||||||
|
}
|
||||||
|
% endfor
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue