From 28db6788b1455949f40b649d4e100e9fb0ef801b Mon Sep 17 00:00:00 2001 From: Boris Chiou Date: Wed, 12 Apr 2017 16:32:11 +0800 Subject: [PATCH] Bug 1343753 - Add Servo_Property_IsDiscreteAnimatable. MozReview-Commit-ID: 5pMw7Wynv2q --- components/style/gecko_bindings/bindings.rs | 4 ++++ .../properties/helpers/animated_properties.mako.rs | 12 ++++++++++++ ports/geckolib/glue.rs | 6 ++++++ 3 files changed, 22 insertions(+) diff --git a/components/style/gecko_bindings/bindings.rs b/components/style/gecko_bindings/bindings.rs index 6c118e92bdc..e65e3ce76c5 100644 --- a/components/style/gecko_bindings/bindings.rs +++ b/components/style/gecko_bindings/bindings.rs @@ -1684,6 +1684,10 @@ extern "C" { nsCSSPropertyID) -> RawServoAnimationValueStrong; } +extern "C" { + pub fn Servo_Property_IsDiscreteAnimatable(property: nsCSSPropertyID) + -> bool; +} extern "C" { pub fn Servo_AnimationValues_Interpolate(from: RawServoAnimationValueBorrowed, diff --git a/components/style/properties/helpers/animated_properties.mako.rs b/components/style/properties/helpers/animated_properties.mako.rs index 98214519290..b38cd04db72 100644 --- a/components/style/properties/helpers/animated_properties.mako.rs +++ b/components/style/properties/helpers/animated_properties.mako.rs @@ -104,6 +104,18 @@ impl TransitionProperty { _ => None, } } + + /// Returns true if this TransitionProperty is one of the discrete animatable properties. + pub fn is_discrete(&self) -> bool { + match *self { + % for prop in data.longhands: + % if prop.animation_type == "discrete": + TransitionProperty::${prop.camel_case} => true, + % endif + % endfor + _ => false + } + } } impl ToCss for TransitionProperty { diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index bb7267cd175..d1205a0f574 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -461,6 +461,12 @@ pub extern "C" fn Servo_ComputedValues_ExtractAnimationValue(computed_values: Se Arc::new(AnimationValue::from_computed_values(&property_id.into(), computed_values)).into_strong() } +#[no_mangle] +pub extern "C" fn Servo_Property_IsDiscreteAnimatable(property: nsCSSPropertyID) -> bool { + let property: TransitionProperty = property.into(); + property.is_discrete() +} + #[no_mangle] pub extern "C" fn Servo_StyleWorkerThreadCount() -> u32 { GLOBAL_STYLE_DATA.num_threads as u32