mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
LibWeb: Mark image elements for layout before firing their load event
This removes a long-standing source of flakiness seen for example in WPT's /referrer-policy/ tests.
This commit is contained in:
parent
f638f84185
commit
063cd68bf4
Notes:
github-actions[bot]
2024-11-20 18:05:33 +00:00
Author: https://github.com/awesomekling Commit: https://github.com/LadybirdBrowser/ladybird/commit/063cd68bf47 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2461 Reviewed-by: https://github.com/gmta ✅
3 changed files with 17 additions and 3 deletions
|
@ -703,13 +703,13 @@ void HTMLImageElement::add_callbacks_to_image_request(GC::Ref<ImageRequest> imag
|
|||
// 3. Add the image to the list of available images using the key key, with the ignore higher-layer caching flag set.
|
||||
document().list_of_available_images().add(key, *image_data, true);
|
||||
|
||||
set_needs_style_update(true);
|
||||
document().set_needs_layout();
|
||||
|
||||
// 4. If maybe omit events is not set or previousURL is not equal to urlString, then fire an event named load at the img element.
|
||||
if (!maybe_omit_events || previous_url != url_string)
|
||||
dispatch_event(DOM::Event::create(realm(), HTML::EventNames::load));
|
||||
|
||||
set_needs_style_update(true);
|
||||
document().set_needs_layout();
|
||||
|
||||
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));
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
image is 400x400
|
|
@ -0,0 +1,13 @@
|
|||
<script src="../include.js"></script>
|
||||
<script>
|
||||
asyncTest((done) => {
|
||||
let img = document.createElement("img");
|
||||
img.src = "../../../Layout/input/400.png";
|
||||
document.body.appendChild(img);
|
||||
img.onload = function() {
|
||||
println("image is " + img.clientWidth + "x" + img.clientHeight);
|
||||
img.remove();
|
||||
done();
|
||||
};
|
||||
});
|
||||
</script>
|
Loading…
Reference in a new issue