mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 13:49:16 +00:00
LibWeb: Iterate safely in update_animations_and_send_events()
Make copies of the animation timeline list and animations to dispatch events at before iterating over them. This ensures that they can't be modified during iteration.
This commit is contained in:
parent
32769393a8
commit
59d46af946
Notes:
github-actions[bot]
2025-05-29 01:48:30 +00:00
Author: https://github.com/awesomekling
Commit: 59d46af946
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4899
Reviewed-by: https://github.com/Hendiadyoin1
Reviewed-by: https://github.com/shannonbooth
1 changed files with 6 additions and 3 deletions
|
@ -5240,7 +5240,9 @@ void Document::update_animations_and_send_events(Optional<double> const& timesta
|
|||
// updated.
|
||||
// - Queueing animation events for any such animations.
|
||||
m_last_animation_frame_timestamp = timestamp;
|
||||
for (auto const& timeline : m_associated_animation_timelines)
|
||||
|
||||
auto timelines_to_update = GC::RootVector { heap(), m_associated_animation_timelines.values() };
|
||||
for (auto const& timeline : timelines_to_update)
|
||||
timeline->set_current_time(timestamp);
|
||||
|
||||
// 2. Remove replaced animations for doc.
|
||||
|
@ -5296,8 +5298,9 @@ void Document::update_animations_and_send_events(Optional<double> const& timesta
|
|||
for (auto const& event : events_to_dispatch)
|
||||
event.target->dispatch_event(event.event);
|
||||
|
||||
for (auto& timeline : m_associated_animation_timelines) {
|
||||
for (auto& animation : timeline->associated_animations())
|
||||
for (auto& timeline : timelines_to_update) {
|
||||
auto animations_to_dispatch = GC::RootVector { heap(), timeline->associated_animations().values() };
|
||||
for (auto& animation : animations_to_dispatch)
|
||||
dispatch_events_for_animation_if_necessary(animation);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue