aboutsummaryrefslogtreecommitdiffstats
path: root/components/style/animation.rs
diff options
context:
space:
mode:
authorMartin Robinson <mrobinson@igalia.com>2018-05-05 18:27:38 +0200
committerMartin Robinson <mrobinson@igalia.com>2020-04-14 13:40:43 +0200
commit304b2838110ed462ff327c66dc6761f2b91976ec (patch)
treed46ed12577e2d01df44aca42b2505992ed00993c /components/style/animation.rs
parent7b5ec99d25be61a7a3ec2f630c31a9f02c7b849b (diff)
downloadservo-304b2838110ed462ff327c66dc6761f2b91976ec.tar.gz
servo-304b2838110ed462ff327c66dc6761f2b91976ec.zip
style: Refactor some animations code
This change modifies the names of some methods to make it clearer what they are doing. It also adds some clarifying comments to explain some confusing behavior.
Diffstat (limited to 'components/style/animation.rs')
-rw-r--r--components/style/animation.rs42
1 files changed, 9 insertions, 33 deletions
diff --git a/components/style/animation.rs b/components/style/animation.rs
index d98cc901b6a..d734acd6d7b 100644
--- a/components/style/animation.rs
+++ b/components/style/animation.rs
@@ -328,8 +328,8 @@ impl PropertyAnimation {
let property_animation = PropertyAnimation {
property: animated_property,
- timing_function: timing_function,
- duration: duration,
+ timing_function,
+ duration,
};
if property_animation.does_animate() {
@@ -411,7 +411,7 @@ pub fn start_transitions_if_applicable(
old_style: &ComputedValues,
new_style: &mut Arc<ComputedValues>,
timer: &Timer,
- possibly_expired_animations: &[PropertyAnimation],
+ running_and_expired_transitions: &[PropertyAnimation],
) -> bool {
let mut had_animations = false;
for i in 0..new_style.get_box().transition_property_count() {
@@ -425,17 +425,16 @@ pub fn start_transitions_if_applicable(
// above.
property_animation.update(Arc::get_mut(new_style).unwrap(), 0.0);
- debug!(
- "checking {:?} for matching end value",
- possibly_expired_animations
- );
-
// Per [1], don't trigger a new transition if the end state for that
// transition is the same as that of a transition that's already
// running on the same node.
//
// [1]: https://drafts.csswg.org/css-transitions/#starting
- if possibly_expired_animations
+ debug!(
+ "checking {:?} for matching end value",
+ running_and_expired_transitions
+ );
+ if running_and_expired_transitions
.iter()
.any(|animation| animation.has_the_same_end_value_as(&property_animation))
{
@@ -447,9 +446,8 @@ pub fn start_transitions_if_applicable(
continue;
}
- debug!("Kicking off transition of {:?}", property_animation);
-
// Kick off the animation.
+ debug!("Kicking off transition of {:?}", property_animation);
let box_style = new_style.get_box();
let now = timer.seconds();
let start_time = now + (box_style.transition_delay_mod(i).seconds() as f64);
@@ -850,25 +848,3 @@ where
},
}
}
-
-/// Update the style in the node when it finishes.
-#[cfg(feature = "servo")]
-pub fn complete_expired_transitions(
- node: OpaqueNode,
- style: &mut Arc<ComputedValues>,
- context: &SharedStyleContext,
- expired_animations: &mut Vec<crate::animation::PropertyAnimation>,
-) {
- let mut all_expired_animations = context.expired_animations.write();
- if let Some(animations) = all_expired_animations.remove(&node) {
- debug!("removing expired animations for {:?}", node);
- for animation in animations {
- debug!("Updating expired animation {:?}", animation);
- // TODO: support animation-fill-mode
- if let Animation::Transition(_, _, frame) = animation {
- frame.property_animation.update(Arc::make_mut(style), 1.0);
- expired_animations.push(frame.property_animation);
- }
- }
- }
-}