mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
style: Add a new Timer structure to the shared style context, and basic infrastructure for controlling animations.
This commit is contained in:
parent
2e68821014
commit
0b67b218d0
20 changed files with 178 additions and 26 deletions
|
@ -38,7 +38,6 @@ smallvec = "0.1"
|
|||
string_cache = {version = "0.2.20", features = ["heap_size"]}
|
||||
style = {path = "../style"}
|
||||
style_traits = {path = "../style_traits"}
|
||||
time = "0.1"
|
||||
unicode-bidi = "0.2"
|
||||
unicode-script = {version = "0.1", features = ["harfbuzz"]}
|
||||
url = {version = "1.0.0", features = ["heap_size"]}
|
||||
|
|
|
@ -14,7 +14,7 @@ use script_traits::{AnimationState, LayoutMsg as ConstellationMsg};
|
|||
use std::collections::HashMap;
|
||||
use std::sync::mpsc::Receiver;
|
||||
use style::animation::{Animation, update_style_for_animation};
|
||||
use time;
|
||||
use style::timer::Timer;
|
||||
|
||||
/// Processes any new animations that were discovered after style recalculation.
|
||||
/// Also expire any old animations that have completed, inserting them into
|
||||
|
@ -23,7 +23,8 @@ pub fn update_animation_state(constellation_chan: &IpcSender<ConstellationMsg>,
|
|||
running_animations: &mut HashMap<OpaqueNode, Vec<Animation>>,
|
||||
expired_animations: &mut HashMap<OpaqueNode, Vec<Animation>>,
|
||||
new_animations_receiver: &Receiver<Animation>,
|
||||
pipeline_id: PipelineId) {
|
||||
pipeline_id: PipelineId,
|
||||
timer: &Timer) {
|
||||
let mut new_running_animations = vec![];
|
||||
while let Ok(animation) = new_animations_receiver.try_recv() {
|
||||
let mut should_push = true;
|
||||
|
@ -37,7 +38,7 @@ pub fn update_animation_state(constellation_chan: &IpcSender<ConstellationMsg>,
|
|||
if let Animation::Keyframes(_, ref anim_name, ref mut anim_state) = *anim {
|
||||
if *name == *anim_name {
|
||||
debug!("update_animation_state: Found other animation {}", name);
|
||||
anim_state.update_from_other(&state);
|
||||
anim_state.update_from_other(&state, timer);
|
||||
should_push = false;
|
||||
break;
|
||||
}
|
||||
|
@ -57,7 +58,7 @@ pub fn update_animation_state(constellation_chan: &IpcSender<ConstellationMsg>,
|
|||
return
|
||||
}
|
||||
|
||||
let now = time::precise_time_s();
|
||||
let now = timer.seconds();
|
||||
// Expire old running animations.
|
||||
//
|
||||
// TODO: Do not expunge Keyframes animations, since we need that state if
|
||||
|
|
|
@ -50,7 +50,6 @@ extern crate smallvec;
|
|||
#[macro_use(atom, ns)] extern crate string_cache;
|
||||
extern crate style;
|
||||
extern crate style_traits;
|
||||
extern crate time;
|
||||
extern crate unicode_bidi;
|
||||
extern crate unicode_script;
|
||||
extern crate url;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue