diff options
Diffstat (limited to 'components/style')
-rw-r--r-- | components/style/animation.rs | 23 | ||||
-rw-r--r-- | components/style/dom.rs | 4 | ||||
-rw-r--r-- | components/style/matching.rs | 1 | ||||
-rw-r--r-- | components/style/properties/helpers/animated_properties.mako.rs | 10 |
4 files changed, 26 insertions, 12 deletions
diff --git a/components/style/animation.rs b/components/style/animation.rs index 9e55ca2e52a..bf74fa643f2 100644 --- a/components/style/animation.rs +++ b/components/style/animation.rs @@ -6,7 +6,7 @@ use bezier::Bezier; use context::SharedStyleContext; -use dom::OpaqueNode; +use dom::{OpaqueNode, UnsafeNode}; use euclid::point::Point2D; use keyframes::{KeyframesStep, KeyframesStepValue}; use properties::{self, ComputedValues, Importance}; @@ -186,7 +186,7 @@ pub enum Animation { /// the f64 field is the start time as returned by `time::precise_time_s()`. /// /// The `bool` field is werther this animation should no longer run. - Transition(OpaqueNode, f64, AnimationFrame, bool), + Transition(OpaqueNode, UnsafeNode, f64, AnimationFrame, bool), /// A keyframes animation is identified by a name, and can have a /// node-dependent state (i.e. iteration count, etc.). Keyframes(OpaqueNode, Atom, KeyframesAnimationState), @@ -197,7 +197,7 @@ impl Animation { pub fn mark_as_expired(&mut self) { debug_assert!(!self.is_expired()); match *self { - Animation::Transition(_, _, _, ref mut expired) => *expired = true, + Animation::Transition(_, _, _, _, ref mut expired) => *expired = true, Animation::Keyframes(_, _, ref mut state) => state.expired = true, } } @@ -205,7 +205,7 @@ impl Animation { #[inline] pub fn is_expired(&self) -> bool { match *self { - Animation::Transition(_, _, _, expired) => expired, + Animation::Transition(_, _, _, _, expired) => expired, Animation::Keyframes(_, _, ref state) => state.expired, } } @@ -213,7 +213,7 @@ impl Animation { #[inline] pub fn node(&self) -> &OpaqueNode { match *self { - Animation::Transition(ref node, _, _, _) => node, + Animation::Transition(ref node, _, _, _, _) => node, Animation::Keyframes(ref node, _, _) => node, } } @@ -246,6 +246,10 @@ pub struct PropertyAnimation { } impl PropertyAnimation { + pub fn property_name(&self) -> String { + self.property.name() + } + /// Creates a new property animation for the given transition index and old and new styles. /// Any number of animations may be returned, from zero (if the property did not animate) to /// one (for a single transition property) to arbitrarily many (for `all`). @@ -341,7 +345,8 @@ impl PropertyAnimation { // TODO(emilio): Take rid of this mutex splitting SharedLayoutContex into a // cloneable part and a non-cloneable part.. pub fn start_transitions_if_applicable(new_animations_sender: &Sender<Animation>, - node: OpaqueNode, + opaque_node: OpaqueNode, + unsafe_node: UnsafeNode, old_style: &ComputedValues, new_style: &mut Arc<ComputedValues>, timer: &Timer) @@ -362,7 +367,7 @@ pub fn start_transitions_if_applicable(new_animations_sender: &Sender<Animation> let start_time = now + (box_style.transition_delay_mod(i).seconds() as f64); new_animations_sender - .send(Animation::Transition(node, start_time, AnimationFrame { + .send(Animation::Transition(opaque_node, unsafe_node, start_time, AnimationFrame { duration: box_style.transition_duration_mod(i).seconds() as f64, property_animation: property_animation, }, /* is_expired = */ false)).unwrap(); @@ -499,7 +504,7 @@ pub fn update_style_for_animation(context: &SharedStyleContext, debug_assert!(!animation.is_expired()); match *animation { - Animation::Transition(_, start_time, ref frame, _) => { + Animation::Transition(_, _, start_time, ref frame, _) => { debug!("update_style_for_animation: transition found"); let now = context.timer.seconds(); let mut new_style = (*style).clone(); @@ -673,7 +678,7 @@ pub fn complete_expired_transitions(node: OpaqueNode, style: &mut Arc<ComputedVa if let Some(ref animations) = animations_to_expire { for animation in *animations { // TODO: support animation-fill-mode - if let Animation::Transition(_, _, ref frame, _) = *animation { + if let Animation::Transition(_, _, _, ref frame, _) = *animation { frame.property_animation.update(Arc::make_mut(style), 1.0); } } diff --git a/components/style/dom.rs b/components/style/dom.rs index 5b2bbcb135e..3c61a5533d9 100644 --- a/components/style/dom.rs +++ b/components/style/dom.rs @@ -19,9 +19,7 @@ use std::ops::BitOr; use std::sync::Arc; use string_cache::{Atom, Namespace}; -/// Opaque type stored in type-unsafe work queues for parallel layout. -/// Must be transmutable to and from TNode. -pub type UnsafeNode = (usize, usize); +pub use style_traits::UnsafeNode; /// An opaque handle to a node, which, unlike UnsafeNode, cannot be transformed /// back into a non-opaque representation. The only safe operation that can be diff --git a/components/style/matching.rs b/components/style/matching.rs index 18e45a32ece..35e31b66062 100644 --- a/components/style/matching.rs +++ b/components/style/matching.rs @@ -569,6 +569,7 @@ trait PrivateMatchMethods: TNode { animation::start_transitions_if_applicable( new_animations_sender, this_opaque, + self.to_unsafe(), &**style, &mut this_style, &shared_context.timer); diff --git a/components/style/properties/helpers/animated_properties.mako.rs b/components/style/properties/helpers/animated_properties.mako.rs index 384e5436976..c0f2fbe3b28 100644 --- a/components/style/properties/helpers/animated_properties.mako.rs +++ b/components/style/properties/helpers/animated_properties.mako.rs @@ -101,6 +101,16 @@ pub enum AnimatedProperty { } impl AnimatedProperty { + pub fn name(&self) -> String { + match *self { + % for prop in data.longhands: + % if prop.animatable: + AnimatedProperty::${prop.camel_case}(..) => "${prop.name}".to_owned(), + % endif + % endfor + } + } + pub fn does_animate(&self) -> bool { match *self { % for prop in data.longhands: |