style: Correctly track whether a longhand contains any variable.

This commit is contained in:
Emilio Cobos Álvarez 2017-03-26 17:45:53 +02:00
parent 05b5aabc69
commit 835d95eb41
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
2 changed files with 63 additions and 36 deletions

View file

@ -561,8 +561,8 @@ impl ShorthandId {
///
/// Returns the optional appendable value.
pub fn get_shorthand_appendable_value<'a, I>(self,
declarations: I)
-> Option<AppendableValue<'a, I::IntoIter>>
declarations: I)
-> Option<AppendableValue<'a, I::IntoIter>>
where I: IntoIterator<Item=&'a PropertyDeclaration>,
I::IntoIter: Clone,
{
@ -580,15 +580,21 @@ impl ShorthandId {
// https://drafts.csswg.org/css-variables/#variables-in-shorthands
if let Some(css) = first_declaration.with_variables_from_shorthand(self) {
if declarations2.all(|d| d.with_variables_from_shorthand(self) == Some(css)) {
return Some(AppendableValue::Css(css));
}
return None;
return Some(AppendableValue::Css {
css: css,
with_variables: true,
});
}
return None;
}
// Check whether they are all the same CSS-wide keyword.
if let Some(keyword) = first_declaration.get_css_wide_keyword() {
if declarations2.all(|d| d.get_css_wide_keyword() == Some(keyword)) {
return Some(AppendableValue::Css(keyword.to_str()));
return Some(AppendableValue::Css {
css: keyword.to_str(),
with_variables: false,
});
}
return None;
}