From 799014755ed338753644dea6cd8e3187d603706e Mon Sep 17 00:00:00 2001 From: Josh Matthews Date: Thu, 7 Sep 2017 12:46:24 -0700 Subject: [PATCH] Remove 10k from AnimationValue::animate. --- .../helpers/animated_properties.mako.rs | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/components/style/properties/helpers/animated_properties.mako.rs b/components/style/properties/helpers/animated_properties.mako.rs index 250e2ff6d74..d85337c3593 100644 --- a/components/style/properties/helpers/animated_properties.mako.rs +++ b/components/style/properties/helpers/animated_properties.mako.rs @@ -524,9 +524,17 @@ impl AnimationValue { } } +fn animate_discrete(this: &T, other: &T, procedure: Procedure) -> Result { + if let Procedure::Interpolate { progress } = procedure { + Ok(if progress < 0.5 { this.clone() } else { other.clone() }) + } else { + Err(()) + } +} + impl Animate for AnimationValue { fn animate(&self, other: &Self, procedure: Procedure) -> Result { - match (self, other) { + let value = match (self, other) { % for prop in data.longhands: % if prop.animatable: % if prop.animation_value_type != "discrete": @@ -534,22 +542,18 @@ impl Animate for AnimationValue { &AnimationValue::${prop.camel_case}(ref this), &AnimationValue::${prop.camel_case}(ref other), ) => { - Ok(AnimationValue::${prop.camel_case}( + AnimationValue::${prop.camel_case}( this.animate(other, procedure)?, - )) + ) }, % else: ( &AnimationValue::${prop.camel_case}(ref this), &AnimationValue::${prop.camel_case}(ref other), ) => { - if let Procedure::Interpolate { progress } = procedure { - Ok(AnimationValue::${prop.camel_case}( - if progress < 0.5 { this.clone() } else { other.clone() }, - )) - } else { - Err(()) - } + AnimationValue::${prop.camel_case}( + animate_discrete(this, other, procedure)? + ) }, % endif % endif @@ -557,7 +561,8 @@ impl Animate for AnimationValue { _ => { panic!("Unexpected AnimationValue::animate call, got: {:?}, {:?}", self, other); } - } + }; + Ok(value) } }