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) } }