From 97aacb242e6bc69d11a33d720da5b5e1b48cd170 Mon Sep 17 00:00:00 2001 From: Hiroyuki Ikezoe Date: Thu, 6 Apr 2017 10:29:58 +0900 Subject: [PATCH] Add an FFI function that returns an AnimationValue for a given nsCSSPropertyID from computed values. When we compose style for a given nsCSSPropertyID in the case where we have no specified values in target keyframe, we use this AnimationValue for composition as if it's specified. --- .../helpers/animated_properties.mako.rs | 17 +++++++++++++++++ ports/geckolib/glue.rs | 9 +++++++++ 2 files changed, 26 insertions(+) diff --git a/components/style/properties/helpers/animated_properties.mako.rs b/components/style/properties/helpers/animated_properties.mako.rs index 7ec46e31214..aade71b5493 100644 --- a/components/style/properties/helpers/animated_properties.mako.rs +++ b/components/style/properties/helpers/animated_properties.mako.rs @@ -399,6 +399,23 @@ impl AnimationValue { _ => None // non animatable properties will get included because of shorthands. ignore. } } + + /// Get an AnimationValue for a TransitionProperty from a given computed values. + pub fn from_computed_values(transition_property: &TransitionProperty, + computed_values: &ComputedValues) + -> Self { + match *transition_property { + TransitionProperty::All => panic!("Can't use TransitionProperty::All here."), + % for prop in data.longhands: + % if prop.animatable: + TransitionProperty::${prop.camel_case} => { + AnimationValue::${prop.camel_case}( + computed_values.get_${prop.style_struct.ident.strip("_")}().clone_${prop.ident}()) + } + % endif + % endfor + } + } } impl Interpolate for AnimationValue { diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index b093919462a..3f668cdcbef 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -340,6 +340,15 @@ pub extern "C" fn Servo_StyleSet_GetBaseComputedValuesForElement(raw_data: RawSe .into_strong() } +#[no_mangle] +pub extern "C" fn Servo_ComputedValues_ExtractAnimationValue(computed_values: ServoComputedValuesBorrowed, + property_id: nsCSSPropertyID) + -> RawServoAnimationValueStrong +{ + let computed_values = ComputedValues::as_arc(&computed_values); + Arc::new(AnimationValue::from_computed_values(&property_id.into(), computed_values)).into_strong() +} + #[no_mangle] pub extern "C" fn Servo_StyleWorkerThreadCount() -> u32 { GLOBAL_STYLE_DATA.num_threads as u32