Skip to content

Commit ddc412d

Browse files
webkit-commit-queueSaid Abou-Hallawa
authored andcommitted
Unreviewed, reverting r254127@main.
https://bugs.webkit.org/show_bug.cgi?id=247297 Causes some images with loading=lazy to not load Reverted changeset: "Fix image-loading-lazy-multiple-times.html" https://bugs.webkit.org/show_bug.cgi?id=216979 https://commits.webkit.org/254127@main Canonical link: https://commits.webkit.org/256175@main
1 parent ca201a7 commit ddc412d

File tree

3 files changed

+14
-19
lines changed

3 files changed

+14
-19
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11

22

3-
PASS Images with loading='lazy' can be lazy loaded multiple times
3+
FAIL Images with loading='lazy' can be lazy loaded multiple times assert_unreached: The loading=lazy below-viewport image should lazily load its second image, and not load it eagerly when the `src` attribute is changed Reached unreachable code
44

LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/image-loading-lazy-multiple-times.html

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,24 +37,19 @@
3737
function changeImageSourceAndScrollToTop() {
3838
top_div.scrollIntoView();
3939

40-
// Allow some time for scroll back to top, since we don't
41-
// want the image to still be in the viewport and trigger a
42-
// load due to the scroll being slow.
40+
// Lazily load a "different" image.
41+
image.src = 'resources/image.png?image-loading-lazy-multiple-times-second';
42+
image.onload =
43+
t.unreached_func("The loading=lazy below-viewport image should lazily " +
44+
"load its second image, and not load it eagerly when " +
45+
"the `src` attribute is changed");
46+
47+
// In 1s, scroll the image *back* into view, and record that it loads
48+
// successfully.
4349
t.step_timeout(() => {
44-
// Lazily load a "different" image.
45-
image.src = 'resources/image.png?image-loading-lazy-multiple-times-second';
46-
image.onload =
47-
t.unreached_func("The loading=lazy below-viewport image should lazily " +
48-
"load its second image, and not load it eagerly when " +
49-
"the `src` attribute is changed");
50-
51-
// In 1s, scroll the image *back* into view, and record that it loads
52-
// successfully.
53-
t.step_timeout(() => {
54-
image.onload = t.step_func_done();
55-
image.scrollIntoView();
56-
}, 1000);
57-
}, 500);
50+
image.onload = t.step_func_done();
51+
image.scrollIntoView();
52+
}, 1000);
5853
}
5954
</script>
6055
</body>

Source/WebCore/loader/ImageLoader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ void ImageLoader::updateFromElement(RelevantMutation relevantMutation)
251251
#if !LOG_DISABLED
252252
auto oldState = m_lazyImageLoadState;
253253
#endif
254-
if (!isDeferred() && isImageElement) {
254+
if (m_lazyImageLoadState == LazyImageLoadState::None && isImageElement) {
255255
auto& imageElement = downcast<HTMLImageElement>(element());
256256
if (imageElement.isLazyLoadable() && document.settings().lazyImageLoadingEnabled()) {
257257
m_lazyImageLoadState = LazyImageLoadState::Deferred;

0 commit comments

Comments
 (0)