From b8185b474434410f64749b2427a19754d71af793 Mon Sep 17 00:00:00 2001 From: Jonathan Watt Date: Mon, 19 Mar 2018 14:55:39 +0000 Subject: [PATCH] Add Servo_Property_IsShorthand to geckolib/glue.rs --- components/style/properties/properties.mako.rs | 6 ++++++ ports/geckolib/glue.rs | 17 +++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index 283e8dd1fec..99922dacf61 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -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 { diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index 4168c089fe2..c0231be9ca8 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -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;