diff options
author | Keith Yeung <kungfukeith11@gmail.com> | 2016-09-03 07:27:39 -0700 |
---|---|---|
committer | Keith Yeung <kungfukeith11@gmail.com> | 2016-10-11 19:36:06 -0700 |
commit | 668163ec5c4091806b155ef14d3b3522cb4697cd (patch) | |
tree | c392fa270399e7fdf1ae103720ea7b7406ddfc2d /components/layout/animation.rs | |
parent | 752c6e6019f72e6ee1b7ee959e80f588b6714cfd (diff) | |
download | servo-668163ec5c4091806b155ef14d3b3522cb4697cd.tar.gz servo-668163ec5c4091806b155ef14d3b3522cb4697cd.zip |
Emit TransitionEnd events in the layout thread and process it in the script thread
Diffstat (limited to 'components/layout/animation.rs')
-rw-r--r-- | components/layout/animation.rs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/components/layout/animation.rs b/components/layout/animation.rs index 71a388dcf0c..22387dff562 100644 --- a/components/layout/animation.rs +++ b/components/layout/animation.rs @@ -10,7 +10,7 @@ use gfx::display_list::OpaqueNode; use ipc_channel::ipc::IpcSender; use msg::constellation_msg::PipelineId; use script_layout_interface::restyle_damage::RestyleDamage; -use script_traits::{AnimationState, LayoutMsg as ConstellationMsg}; +use script_traits::{AnimationState, ConstellationControlMsg, LayoutMsg as ConstellationMsg}; use std::collections::HashMap; use std::sync::mpsc::Receiver; use style::animation::{Animation, update_style_for_animation}; @@ -21,6 +21,7 @@ use style::timer::Timer; /// Also expire any old animations that have completed, inserting them into /// `expired_animations`. pub fn update_animation_state(constellation_chan: &IpcSender<ConstellationMsg>, + script_chan: &IpcSender<ConstellationControlMsg>, running_animations: &mut HashMap<OpaqueNode, Vec<Animation>>, expired_animations: &mut HashMap<OpaqueNode, Vec<Animation>>, new_animations_receiver: &Receiver<Animation>, @@ -70,7 +71,7 @@ pub fn update_animation_state(constellation_chan: &IpcSender<ConstellationMsg>, let mut animations_still_running = vec![]; for mut running_animation in running_animations.drain(..) { let still_running = !running_animation.is_expired() && match running_animation { - Animation::Transition(_, started_at, ref frame, _expired) => { + Animation::Transition(_, _, started_at, ref frame, _expired) => { now < started_at + frame.duration } Animation::Keyframes(_, _, ref mut state) => { @@ -85,6 +86,13 @@ pub fn update_animation_state(constellation_chan: &IpcSender<ConstellationMsg>, continue } + if let Animation::Transition(_, unsafe_node, _, ref frame, _) = running_animation { + script_chan.send(ConstellationControlMsg::TransitionEnd(unsafe_node, + frame.property_animation.property_name(), + frame.duration)) + .unwrap(); + } + expired_animations.entry(*key) .or_insert_with(Vec::new) .push(running_animation); |