Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: eeeb01ce5ab8258304a1a878667b1b2ec548bec6
https://github.com/WebKit/WebKit/commit/eeeb01ce5ab8258304a1a878667b1b2ec548bec6
Author: Ahmad Saleem <[email protected]>
Date: 2026-08-04 (Tue, 04 Aug 2026)
Changed paths:
M
LayoutTests/imported/w3c/web-platform-tests/preload/preload-imagesrcset-in-markup-expected.txt
M Source/WebCore/html/parser/HTMLPreloadScanner.cpp
Log Message:
-----------
imagesrcset does not override href for <link rel="preload" as="image">
https://bugs.webkit.org/show_bug.cgi?id=320786
rdar://183945535
Reviewed by Frédéric Wang Nélar and Chris Dumez.
The preload scanner read srcset/sizes only for <img> and <source>. For
<link rel=preload as=image> it took href verbatim, so the speculative fetch went
to href while LinkLoader::preloadIfNeeded selected an image source from the
source set and fetched that instead — two downloads for one preload. Step 2 of
the "preload" algorithm [1] requires selecting from the source set when the
destination is "image".
Mirror the <img> resolution in the link branch: buffer imagesrcset/imagesizes
(first value wins, as with srcset/sizes) and run
bestFitSourceForImageAttributes() over href + imagesrcset, gated on rel=preload
resolving to an image resource so it matches LinkLoader::preloadIfNeeded. href
is
passed as the default source, so it is still selected when it legitimately joins
the source set as the 1x candidate.
dynamic-adding-preload-imagesrcset.html already passed because script-created
links never reach the scanner; preload-imagesrcset-in-markup.html goes from 2
FAIL to 2 PASS.
[1] https://html.spec.whatwg.org/multipage/links.html#preload
*
LayoutTests/imported/w3c/web-platform-tests/preload/preload-imagesrcset-in-markup-expected.txt:
Progression
* Source/WebCore/html/parser/HTMLPreloadScanner.cpp:
(WebCore::TokenPreloadScanner::StartTagScanner::processAttributes):
(WebCore::TokenPreloadScanner::StartTagScanner::processAttribute):
Canonical link: https://commits.webkit.org/318544@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications