mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2026-04-18 18:00:31 +00:00
LibWeb: Reset animated frame index when loading new img element src
When an img element is changed from animated image to static image, the animation briefly continues into the new image, even if the new image has only a single frame (static image). Could also impact when going from animated image to another animated image, but the new image has less frames versus the previously animated image. In some cases a newly loaded static image would continue to be animated, so that is also stopped. fixes: #7879 fixes: #7945
This commit is contained in:
parent
8867f95f41
commit
7eb0bb7c70
Notes:
github-actions[bot]
2026-02-19 09:52:43 +00:00
Author: https://github.com/rcorsi
Commit: 7eb0bb7c70
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/8021
1 changed files with 3 additions and 1 deletions
|
|
@ -656,6 +656,7 @@ void HTMLImageElement::update_the_image_data_impl(bool restart_animations, bool
|
|||
m_current_request = ImageRequest::create(realm(), document().page());
|
||||
m_current_request->set_image_data(entry->image_data);
|
||||
m_current_request->set_state(ImageRequest::State::CompletelyAvailable);
|
||||
m_current_frame_index = 0;
|
||||
|
||||
// 5. Prepare the current request for presentation given the img element.
|
||||
m_current_request->prepare_for_presentation(*this);
|
||||
|
|
@ -918,8 +919,9 @@ void HTMLImageElement::add_callbacks_to_image_request(GC::Ref<ImageRequest> imag
|
|||
if (!maybe_omit_events || previous_url != url_string)
|
||||
dispatch_event(DOM::Event::create(realm(), HTML::EventNames::load));
|
||||
|
||||
m_current_frame_index = 0;
|
||||
m_animation_timer->stop();
|
||||
if (image_data->is_animated() && image_data->frame_count() > 1) {
|
||||
m_current_frame_index = 0;
|
||||
m_animation_timer->set_interval(image_data->frame_duration(0));
|
||||
m_animation_timer->start();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue