script: Properly root nodes with animating images (#37689)

This change fixes an issue and makes a few more minor improvements to
the `ImageAnimationState`:

1. Image rooting and unrooted now happens in one step from
   `Window::update_animations_post_reflow`.
2. The `node_to_animating_image_map` is now stored as a shared `RwLock`
   so that it doesn't need to be taken and then replaced in the
`ImageAnimationState` during reflow. This should prevent a hypothetical
issue
   where image animations are restarted during empty reflows.
3. General naming and idiomatic Rust usage improvements.

Testing: This doesn't really have any obvious behavioral changes,
because all
reflows currently trigger a restyle. It becomes a serious problem with
#37677
and this change fixes the failing test there.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Martin Robinson 2025-06-25 15:52:11 +02:00 committed by GitHub
parent b89a44c539
commit a66a257b38
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 107 additions and 118 deletions

View file

@ -2218,9 +2218,7 @@ impl Window {
pending_restyles,
animation_timeline_value: document.current_animation_timeline_value(),
animations: document.animations().sets.clone(),
node_to_image_animation_map: document
.image_animation_manager_mut()
.take_image_animate_set(),
node_to_animating_image_map: document.image_animation_manager().node_to_image_map(),
theme: self.theme.get(),
highlighted_dom_node,
};
@ -2297,9 +2295,6 @@ impl Window {
if !size_messages.is_empty() {
self.send_to_constellation(ScriptToConstellationMessage::IFrameSizes(size_messages));
}
document
.image_animation_manager_mut()
.restore_image_animate_set(results.node_to_image_animation_map);
document.update_animations_post_reflow();
self.update_constellation_epoch();