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 {

View file

@ -1235,6 +1235,15 @@ pub extern "C" fn Servo_MediaList_Matches(list: RawServoMediaListBorrowed,
})
}
#[no_mangle]
pub extern "C" fn Servo_DeclarationBlock_HasCSSWideKeyword(declarations: RawServoDeclarationBlockBorrowed,
property: nsCSSPropertyID) -> bool {
let property_id = get_property_id_from_nscsspropertyid!(property, false);
read_locked_arc(declarations, |decls: &PropertyDeclarationBlock| {
decls.has_css_wide_keyword(&property_id)
})
}
#[no_mangle]
pub extern "C" fn Servo_MediaList_GetText(list: RawServoMediaListBorrowed, result: *mut nsAString) {
read_locked_arc(list, |list: &MediaList| {