mirror of
https://github.com/servo/servo.git
synced 2025-08-11 16:35:33 +01:00
Remove 10k from AnimationValue::animate.
This commit is contained in:
parent
13df088201
commit
799014755e
1 changed files with 16 additions and 11 deletions
|
@ -524,9 +524,17 @@ 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":
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue