Skip to content

Commit

Permalink
Add Servo_Property_IsShorthand to geckolib/glue.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
jwatt committed Mar 19, 2018
1 parent 794c0d4 commit b8185b4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
6 changes: 6 additions & 0 deletions components/style/properties/properties.mako.rs
Expand Up @@ -1645,6 +1645,12 @@ impl PropertyId {
}
}

/// Returns true if the property is a shorthand or shorthand alias.
#[inline]
pub fn is_shorthand(&self) -> bool {
self.as_shorthand().is_ok()
}

/// Given this property id, get it either as a shorthand or as a
/// `PropertyDeclarationId`.
pub fn as_shorthand(&self) -> Result<ShorthandId, PropertyDeclarationId> {
Expand Down
17 changes: 17 additions & 0 deletions ports/geckolib/glue.rs
Expand Up @@ -933,6 +933,23 @@ pub extern "C" fn Servo_ComputedValues_ExtractAnimationValue(
}
}

#[no_mangle]
pub unsafe extern "C" fn Servo_Property_IsShorthand(
prop_name: *const nsACString,
found: *mut bool
) -> bool {
let prop_id = PropertyId::parse(prop_name.as_ref().unwrap().as_str_unchecked());
let prop_id = match prop_id {
Ok(ref p) if p.enabled_for_all_content() => p,
_ => {
*found = false;
return false;
}
};
*found = true;
prop_id.is_shorthand()
}

#[no_mangle]
pub extern "C" fn Servo_Property_IsAnimatable(property: nsCSSPropertyID) -> bool {
use style::properties::animated_properties;
Expand Down

0 comments on commit b8185b4

Please sign in to comment.