Auto merge of #20592 - upsuper:is-inherited, r=emilio

Use Servo code to check whether a property is inherited

This is the Servo side change of [bug 1452534](https://bugzilla.mozilla.org/show_bug.cgi?id=1452534).

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/20592)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2018-04-09 05:19:48 -04:00 committed by GitHub
commit 0f20e82690
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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)} ${static_longhand_id_set("INHERITED", lambda p: p.style_struct.inherited)}
INHERITED.contains(*self) INHERITED.contains(*self)
} }

View file

@ -952,6 +952,25 @@ pub unsafe extern "C" fn Servo_Property_IsShorthand(
prop_id.is_shorthand() 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] #[no_mangle]
pub extern "C" fn Servo_Property_IsAnimatable(property: nsCSSPropertyID) -> bool { pub extern "C" fn Servo_Property_IsAnimatable(property: nsCSSPropertyID) -> bool {
use style::properties::animated_properties; use style::properties::animated_properties;