From a2307adf46e92c2364f50110aa88a206747b900d Mon Sep 17 00:00:00 2001 From: Brian Birtles Date: Thu, 15 Jun 2017 10:18:55 +0900 Subject: [PATCH] Convert AnimationValue::from_computed_values to take an AnimatableLonghand --- components/style/gecko/wrapper.rs | 9 +++++---- .../properties/helpers/animated_properties.mako.rs | 10 ++++------ ports/geckolib/glue.rs | 7 ++++++- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs index 539cb492adc..f1e84c2129c 100644 --- a/components/style/gecko/wrapper.rs +++ b/components/style/gecko/wrapper.rs @@ -1135,18 +1135,19 @@ impl<'le> TElement for GeckoElement<'le> { return false; } + // |property| should be an animatable longhand + let animatable_longhand = AnimatableLonghand::from_transition_property(property).unwrap(); + if existing_transitions.contains_key(property) { // If there is an existing transition, update only if the end value differs. // If the end value has not changed, we should leave the currently running // transition as-is since we don't want to interrupt its timing function. let after_value = - Arc::new(AnimationValue::from_computed_values(property, after_change_style)); + Arc::new(AnimationValue::from_computed_values(&animatable_longhand, + after_change_style)); return existing_transitions.get(property).unwrap() != &after_value; } - // |property| should be an animatable longhand - let animatable_longhand = AnimatableLonghand::from_transition_property(property).unwrap(); - combined_duration > 0.0f32 && AnimatedProperty::from_animatable_longhand(&animatable_longhand, before_change_style, diff --git a/components/style/properties/helpers/animated_properties.mako.rs b/components/style/properties/helpers/animated_properties.mako.rs index 1f03bd4c071..57b5cd1138e 100644 --- a/components/style/properties/helpers/animated_properties.mako.rs +++ b/components/style/properties/helpers/animated_properties.mako.rs @@ -621,15 +621,14 @@ impl AnimationValue { } } - /// Get an AnimationValue for a TransitionProperty from a given computed values. - pub fn from_computed_values(transition_property: &TransitionProperty, + /// Get an AnimationValue for an AnimatableLonghand from a given computed values. + pub fn from_computed_values(property: &AnimatableLonghand, computed_values: &ComputedValues) -> Self { - match *transition_property { - TransitionProperty::All => panic!("Can't use TransitionProperty::All here."), + match *property { % for prop in data.longhands: % if prop.animatable: - TransitionProperty::${prop.camel_case} => { + AnimatableLonghand::${prop.camel_case} => { AnimationValue::${prop.camel_case}( % if prop.is_animatable_with_computed_value: computed_values.get_${prop.style_struct.ident.strip("_")}().clone_${prop.ident}()) @@ -640,7 +639,6 @@ impl AnimationValue { } % endif % endfor - ref other => panic!("Can't use TransitionProperty::{:?} here.", other), } } } diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index 81445b52022..dc9d7417266 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -688,8 +688,13 @@ pub extern "C" fn Servo_ComputedValues_ExtractAnimationValue(computed_values: Se property_id: nsCSSPropertyID) -> RawServoAnimationValueStrong { + let property = match AnimatableLonghand::from_nscsspropertyid(property_id) { + Some(longhand) => longhand, + None => { return Strong::null(); } + }; + let computed_values = ComputedValues::as_arc(&computed_values); - Arc::new(AnimationValue::from_computed_values(&property_id.into(), computed_values)).into_strong() + Arc::new(AnimationValue::from_computed_values(&property, computed_values)).into_strong() } #[no_mangle]