Auto merge of #13056 - KiChjang:transition-event, r=mbrubeck

Implement transition event and infrastructure

Fixes #10245.

<!-- 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/13056)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-10-12 02:08:37 -05:00 committed by GitHub
commit cd2f950de3
23 changed files with 199 additions and 61 deletions

View file

@ -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);