mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Auto merge of #26074 - jdm:transition-fix, r=SimonSapin
Avoid infinitely looping CSS transitions. This change addresses the long-standing issue of CSS transitions not ending appropriately. It does not fundamentally change the way we process transitions/animations. --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #20379 - [x] There are tests for these changes
This commit is contained in:
commit
516279e24f
6 changed files with 61 additions and 20 deletions
|
@ -110,6 +110,7 @@ pub fn update_animation_state<E>(
|
|||
.unwrap();
|
||||
}
|
||||
|
||||
debug!("expiring animation for {:?}", running_animation);
|
||||
expired_animations
|
||||
.entry(*key)
|
||||
.or_insert_with(Vec::new)
|
||||
|
|
|
@ -425,6 +425,11 @@ 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.
|
||||
|
@ -852,26 +857,18 @@ pub fn complete_expired_transitions(
|
|||
node: OpaqueNode,
|
||||
style: &mut Arc<ComputedValues>,
|
||||
context: &SharedStyleContext,
|
||||
) -> bool {
|
||||
let had_animations_to_expire;
|
||||
{
|
||||
let all_expired_animations = context.expired_animations.read();
|
||||
let animations_to_expire = all_expired_animations.get(&node);
|
||||
had_animations_to_expire = animations_to_expire.is_some();
|
||||
if let Some(ref animations) = animations_to_expire {
|
||||
for animation in *animations {
|
||||
debug!("Updating expired animation {:?}", animation);
|
||||
// TODO: support animation-fill-mode
|
||||
if let Animation::Transition(_, _, ref frame) = *animation {
|
||||
frame.property_animation.update(Arc::make_mut(style), 1.0);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if had_animations_to_expire {
|
||||
context.expired_animations.write().remove(&node);
|
||||
}
|
||||
|
||||
had_animations_to_expire
|
||||
}
|
||||
|
|
|
@ -607,7 +607,12 @@ trait PrivateMatchMethods: TElement {
|
|||
|
||||
// Finish any expired transitions.
|
||||
let this_opaque = self.as_node().opaque();
|
||||
animation::complete_expired_transitions(this_opaque, style, context);
|
||||
animation::complete_expired_transitions(
|
||||
this_opaque,
|
||||
style,
|
||||
context,
|
||||
possibly_expired_animations,
|
||||
);
|
||||
|
||||
// Merge any running animations into the current style, and cancel them.
|
||||
let had_running_animations = context
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue