aboutsummaryrefslogtreecommitdiffstats
path: root/components/style/animation.rs
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <me@emiliocobos.me>2016-06-18 15:52:28 +0200
committerEmilio Cobos Álvarez <me@emiliocobos.me>2016-06-28 15:09:53 +0000
commitf389cf61c46754a94acaac0361427b37d01b8d95 (patch)
tree8040cc1f8a8e40f42c1ff9590d3fb4c41741d1ba /components/style/animation.rs
parent058bfb39aeea823623e646c9bf4d2cc8e3f8a1bb (diff)
downloadservo-f389cf61c46754a94acaac0361427b37d01b8d95.tar.gz
servo-f389cf61c46754a94acaac0361427b37d01b8d95.zip
style: Make animation functions as generic as possible.
Diffstat (limited to 'components/style/animation.rs')
-rw-r--r--components/style/animation.rs24
1 files changed, 12 insertions, 12 deletions
diff --git a/components/style/animation.rs b/components/style/animation.rs
index e6e8a3ac89e..f05a43b3ff2 100644
--- a/components/style/animation.rs
+++ b/components/style/animation.rs
@@ -51,10 +51,10 @@ impl PropertyAnimation {
/// Creates a new property animation for the given transition index and old and new styles.
/// Any number of animations may be returned, from zero (if the property did not animate) to
/// one (for a single transition property) to arbitrarily many (for `all`).
- pub fn from_transition(transition_index: usize,
- old_style: &ServoComputedValues,
- new_style: &mut ServoComputedValues)
- -> Vec<PropertyAnimation> {
+ pub fn from_transition<C: ComputedValues>(transition_index: usize,
+ old_style: &C,
+ new_style: &mut C)
+ -> Vec<PropertyAnimation> {
let mut result = vec![];
let box_style = new_style.as_servo().get_box();
let transition_property = box_style.transition_property.0[transition_index];
@@ -88,12 +88,12 @@ impl PropertyAnimation {
result
}
- fn from_transition_property(transition_property: TransitionProperty,
- timing_function: TransitionTimingFunction,
- duration: Time,
- old_style: &ServoComputedValues,
- new_style: &ServoComputedValues)
- -> Option<PropertyAnimation> {
+ fn from_transition_property<C: ComputedValues>(transition_property: TransitionProperty,
+ timing_function: TransitionTimingFunction,
+ duration: Time,
+ old_style: &C,
+ new_style: &C)
+ -> Option<PropertyAnimation> {
let animated_property = AnimatedProperty::from_transition_property(&transition_property,
old_style,
new_style);
@@ -111,7 +111,7 @@ impl PropertyAnimation {
}
}
- pub fn update(&self, style: &mut ServoComputedValues, time: f64) {
+ pub fn update<C: ComputedValues>(&self, style: &mut C, time: f64) {
let progress = match self.timing_function {
TransitionTimingFunction::CubicBezier(p1, p2) => {
// See `WebCore::AnimationBase::solveEpsilon(double)` in WebKit.
@@ -167,7 +167,7 @@ pub fn start_transitions_if_applicable<C: ComputedValues>(new_animations_sender:
let property_animations = PropertyAnimation::from_transition(i, old_style.as_servo(), new_style.as_servo_mut());
for property_animation in property_animations {
// Set the property to the initial value.
- property_animation.update(new_style.as_servo_mut(), 0.0);
+ property_animation.update(new_style, 0.0);
// Kick off the animation.
let now = time::precise_time_s();