diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2016-07-20 13:38:31 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-20 13:38:31 -0500 |
commit | 14aeccc33ab44d706df86fbce67339218efe710c (patch) | |
tree | 623b24534550a56755d440d48f5a89cff6171ded /components/style/animation.rs | |
parent | 46db988b906fbec0286fa07387bb34e76a5b3a94 (diff) | |
parent | 0b67b218d0c8dc48a5301227802296aff98af6d7 (diff) | |
download | servo-14aeccc33ab44d706df86fbce67339218efe710c.tar.gz servo-14aeccc33ab44d706df86fbce67339218efe710c.zip |
Auto merge of #12392 - emilio:test-animations, r=SimonSapin
style: Add support to test animations programatically.
<!-- Please describe your changes on the following line: -->
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #12120
<!-- Either: -->
- [x] There are tests for these changes OR
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
r? @SimonSapin for the style changes, @Ms2ger or @jdm for the dom and test changes
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12392)
<!-- Reviewable:end -->
Diffstat (limited to 'components/style/animation.rs')
-rw-r--r-- | components/style/animation.rs | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/components/style/animation.rs b/components/style/animation.rs index c9529f7b99f..c36cde3caea 100644 --- a/components/style/animation.rs +++ b/components/style/animation.rs @@ -20,7 +20,7 @@ use selectors::matching::DeclarationBlock; use std::sync::Arc; use std::sync::mpsc::Sender; use string_cache::Atom; -use time; +use timer::Timer; use values::computed::Time; /// This structure represents a keyframes animation current iteration state. @@ -122,7 +122,9 @@ 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) { + pub fn update_from_other(&mut self, + other: &Self, + timer: &Timer) { use self::KeyframesRunningState::*; debug!("KeyframesAnimationState::update_from_other({:?}, {:?})", self, other); @@ -146,11 +148,11 @@ impl KeyframesAnimationState { // If we're pausing the animation, compute the progress value. match (&mut self.running_state, old_running_state) { (&mut Running, Paused(progress)) - => new_started_at = time::precise_time_s() - (self.duration * progress), + => new_started_at = timer.seconds() - (self.duration * progress), (&mut Paused(ref mut new), Paused(old)) => *new = old, (&mut Paused(ref mut progress), Running) - => *progress = (time::precise_time_s() - old_started_at) / old_duration, + => *progress = (timer.seconds() - old_started_at) / old_duration, _ => {}, } @@ -341,7 +343,8 @@ impl PropertyAnimation { pub fn start_transitions_if_applicable(new_animations_sender: &Sender<Animation>, node: OpaqueNode, old_style: &ComputedValues, - new_style: &mut Arc<ComputedValues>) + new_style: &mut Arc<ComputedValues>, + timer: &Timer) -> bool { let mut had_animations = false; for i in 0..new_style.get_box().transition_property_count() { @@ -355,7 +358,7 @@ pub fn start_transitions_if_applicable(new_animations_sender: &Sender<Animation> // Kick off the animation. let box_style = new_style.get_box(); - let now = time::precise_time_s(); + let now = timer.seconds(); let start_time = now + (box_style.transition_delay_mod(i).seconds() as f64); new_animations_sender @@ -424,7 +427,7 @@ pub fn maybe_start_animations(context: &SharedStyleContext, } let delay = box_style.animation_delay_mod(i).seconds(); - let now = time::precise_time_s(); + let now = context.timer.seconds(); let animation_start = now + delay as f64; let duration = box_style.animation_duration_mod(i).seconds(); let iteration_state = match box_style.animation_iteration_count_mod(i) { @@ -497,7 +500,7 @@ where Damage: TRestyleDamage { match *animation { Animation::Transition(_, start_time, ref frame, _) => { debug!("update_style_for_animation: transition found"); - let now = time::precise_time_s(); + let now = context.timer.seconds(); let mut new_style = (*style).clone(); let updated_style = update_style_for_animation_frame(&mut new_style, now, start_time, @@ -516,7 +519,7 @@ where Damage: TRestyleDamage { let started_at = state.started_at; let now = match state.running_state { - KeyframesRunningState::Running => time::precise_time_s(), + KeyframesRunningState::Running => context.timer.seconds(), KeyframesRunningState::Paused(progress) => started_at + duration * progress, }; |