Use Servo code to check whether a property is inherited.

This commit is contained in:
Xidorn Quan 2018-04-09 19:10:44 +10:00
parent e460b4ab8a
commit 22cf429c35
2 changed files with 21 additions and 1 deletions

View file

@ -826,7 +826,8 @@ impl LonghandId {
}
}
fn inherited(&self) -> bool {
/// Returns whether the longhand property is inherited by default.
pub fn inherited(&self) -> bool {
${static_longhand_id_set("INHERITED", lambda p: p.style_struct.inherited)}
INHERITED.contains(*self)
}

View file

@ -952,6 +952,25 @@ pub unsafe extern "C" fn Servo_Property_IsShorthand(
prop_id.is_shorthand()
}
#[no_mangle]
pub unsafe extern "C" fn Servo_Property_IsInherited(
prop_name: *const nsACString,
) -> bool {
let prop_name = prop_name.as_ref().unwrap().as_str_unchecked();
let prop_id = match PropertyId::parse(prop_name) {
Ok(id) => id,
Err(_) => return false,
};
let longhand_id = match prop_id {
PropertyId::Custom(_) => return true,
PropertyId::Longhand(id) |
PropertyId::LonghandAlias(id, _) => id,
PropertyId::Shorthand(id) |
PropertyId::ShorthandAlias(id, _) => id.longhands().next().unwrap(),
};
longhand_id.inherited()
}
#[no_mangle]
pub extern "C" fn Servo_Property_IsAnimatable(property: nsCSSPropertyID) -> bool {
use style::properties::animated_properties;