Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: d166513e8cf28fb3cc4e03f03a078d562ac084c4
      
https://github.com/WebKit/WebKit/commit/d166513e8cf28fb3cc4e03f03a078d562ac084c4
  Author: Ahmad Saleem <[email protected]>
  Date:   2026-05-25 (Mon, 25 May 2026)

  Changed paths:
    A LayoutTests/http/tests/preload/picture-source-loading-lazy-expected.txt
    A LayoutTests/http/tests/preload/picture-source-loading-lazy.html
    M 
LayoutTests/imported/w3c/web-platform-tests/html/syntax/speculative-parsing/generated/page-load/picture-source-no-img.tentative-expected.txt
    M Source/WebCore/html/parser/HTMLPreloadScanner.cpp
    M Source/WebCore/html/parser/HTMLPreloadScanner.h

  Log Message:
  -----------
  <picture> <source> candidates are speculatively preloaded even when the inner 
<img> has loading="lazy"
https://bugs.webkit.org/show_bug.cgi?id=315466
rdar://177833110

Reviewed by Chris Dumez.

This patch aligns WebKit with Gecko / Firefox and Blink / Chromium.

The preload scanner emits a fetch for a matched <source> inside a
<picture> as soon as it is selected, without consulting the inner
<img>'s loading attribute. Because <source> appears before <img> in
source order, the lazy-load short-circuit in
StartTagScanner::createPreloadRequest never sees loading="lazy", and
alternative-format / srcset candidates for off-screen lazy images are
fetched up front — then fetched again when the image approaches the
viewport.

Defer the matched <source> preload in per-<picture> state instead of
emitting it immediately. Flush it when the inner <img> is seen and is
not loading="lazy"; drop it if the <img> is lazy or if the <picture>
closes without an <img>. Also read the <img>'s loading attribute even
when a sibling <source> already matched (the previous code bailed out
on alreadyMatchedSource before reaching it).

* 
LayoutTests/imported/w3c/web-platform-tests/html/syntax/speculative-parsing/generated/page-load/picture-source-no-img.tentative-expected.txt:
 Progression
* Source/WebCore/html/parser/HTMLPreloadScanner.cpp:
(WebCore::TokenPreloadScanner::StartTagScanner::processAttributes):
(WebCore::TokenPreloadScanner::StartTagScanner::isLazyloadingImage const):
(WebCore::TokenPreloadScanner::StartTagScanner::processAttribute):
(WebCore::TokenPreloadScanner::scan):
* Source/WebCore/html/parser/HTMLPreloadScanner.h:
* LayoutTests/http/tests/preload/picture-source-loading-lazy-expected.txt
* LayoutTests/http/tests/preload/picture-source-loading-lazy.html:

Canonical link: https://commits.webkit.org/313833@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to