Skip to content

Commit

Permalink
Remove 10k from AnimationValue::animate.
Browse files Browse the repository at this point in the history
  • Loading branch information
jdm committed Oct 3, 2017
1 parent 13df088 commit 7990147
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions components/style/properties/helpers/animated_properties.mako.rs
Expand Up @@ -524,40 +524,45 @@ impl AnimationValue {
}
}

fn animate_discrete<T: Clone>(this: &T, other: &T, procedure: Procedure) -> Result<T, ()> {
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<Self, ()> {
match (self, other) {
let value = match (self, other) {
% for prop in data.longhands:
% if prop.animatable:
% if prop.animation_value_type != "discrete":
(
&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
% endfor
_ => {
panic!("Unexpected AnimationValue::animate call, got: {:?}, {:?}", self, other);
}
}
};
Ok(value)
}
}

Expand Down

0 comments on commit 7990147

Please sign in to comment.