Add comments for shorthand alias property logic

This commit is contained in:
Nazım Can Altınova 2017-05-09 14:14:19 +03:00
parent e1053f2c71
commit 936fa7c90b
No known key found for this signature in database
GPG key ID: AF9BCD7CE6449954

View file

@ -1263,6 +1263,9 @@ impl ToCss for PropertyDeclaration {
PropertyDeclaration::WithVariables(_, ref with_variables) => { PropertyDeclaration::WithVariables(_, ref with_variables) => {
// https://drafts.csswg.org/css-variables/#variables-in-shorthands // https://drafts.csswg.org/css-variables/#variables-in-shorthands
match with_variables.from_shorthand { match with_variables.from_shorthand {
// Normally, we shouldn't be printing variables here if they came from
// shorthands. But we should allow properties that came from shorthand
// aliases. That also matches with the Gecko behavior.
Some(shorthand) if shorthand.flags().contains(SHORTHAND_ALIAS_PROPERTY) => Some(shorthand) if shorthand.flags().contains(SHORTHAND_ALIAS_PROPERTY) =>
dest.write_str(&*with_variables.css)?, dest.write_str(&*with_variables.css)?,
None => dest.write_str(&*with_variables.css)?, None => dest.write_str(&*with_variables.css)?,
@ -1345,6 +1348,10 @@ impl PropertyDeclaration {
Some(&*with_variables.css) Some(&*with_variables.css)
} else { None } } else { None }
} else { } else {
// Normally, longhand property that doesn't come from a shorthand
// should return None here. But we return Some to longhands if they
// came from a shorthand alias. Because for example, we should be able to
// get -moz-transform's value from transform.
if shorthand.flags().contains(SHORTHAND_ALIAS_PROPERTY) { if shorthand.flags().contains(SHORTHAND_ALIAS_PROPERTY) {
return Some(&*with_variables.css); return Some(&*with_variables.css);
} }