Add a function that checks PropertyDeclarationBlock has a CSSWideKeyword for a given property.

It will be used to check whether the PropertyDeclarationBlock has 'inherit',
'initial' or 'unset'.
This commit is contained in:
Hiroyuki Ikezoe 2017-04-14 23:36:50 +09:00
parent c57b24c468
commit 39d3c22edc
2 changed files with 24 additions and 0 deletions

View file

@ -359,6 +359,21 @@ impl PropertyDeclarationBlock {
longhands: longhands,
}
}
/// Returns true if the declaration block has a CSSWideKeyword for the given
/// property.
#[cfg(feature = "gecko")]
pub fn has_css_wide_keyword(&self, property: &PropertyId) -> bool {
if let PropertyId::Longhand(id) = *property {
if !self.longhands.contains(id) {
return false
}
}
self.declarations.iter().any(|&&(ref decl, _)|
decl.id().is_or_is_longhand_of(property) &&
decl.get_css_wide_keyword().is_some()
)
}
}
impl ToCss for PropertyDeclarationBlock {