From 793de6dff270ce111773e7ce2e6637c4cbe10658 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Tue, 28 Jun 2016 10:29:12 +0000 Subject: [PATCH] style: Remove an unsound where clause, and don't reset the iteration count on restyle. --- components/style/animation.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/components/style/animation.rs b/components/style/animation.rs index 4c8bfdc9bf4..b2a64a5fa5e 100644 --- a/components/style/animation.rs +++ b/components/style/animation.rs @@ -123,8 +123,7 @@ impl KeyframesAnimationState { /// /// There are some bits of state we can't just replace, over all taking in /// account times, so here's that logic. - pub fn update_from_other(&mut self, other: &Self) - where Self: Clone { + pub fn update_from_other(&mut self, other: &Self) { use self::KeyframesRunningState::*; debug!("KeyframesAnimationState::update_from_other({:?}, {:?})", self, other); @@ -135,6 +134,7 @@ impl KeyframesAnimationState { let old_duration = self.duration; let old_direction = self.current_direction; let old_running_state = self.running_state.clone(); + let old_iteration_state = self.iteration_state.clone(); *self = other.clone(); let mut new_started_at = old_started_at; @@ -155,6 +155,15 @@ impl KeyframesAnimationState { _ => {}, } + // Don't update the iteration count, just the iteration limit. + // TODO: see how changing the limit affects rendering in other browsers. + // We might need to keep the iteration count even when it's infinite. + match (&mut self.iteration_state, old_iteration_state) { + (&mut KeyframesIterationState::Finite(ref mut iters, _), KeyframesIterationState::Finite(old_iters, _)) + => *iters = old_iters, + _ => {} + } + self.current_direction = old_direction; self.started_at = new_started_at; }