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

  Changed paths:
    M LayoutTests/fast/preloader/image-with-incorrect-tag-expected.txt
    M LayoutTests/fast/preloader/image-with-incorrect-tag.html
    M 
LayoutTests/imported/w3c/web-platform-tests/html/syntax/speculative-parsing/generated/document-write/image-src.tentative.sub-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/html/syntax/speculative-parsing/generated/page-load/image-src.tentative-expected.txt
    M Source/WebCore/html/parser/HTMLPreloadScanner.cpp

  Log Message:
  -----------
  HTMLPreloadScanner does not preload <image> tag
https://bugs.webkit.org/show_bug.cgi?id=314497
rdar://176712749

Reviewed by Chris Dumez.

This patch aligns WebKit with Gecko / Firefox.

Per the HTML parsing spec [1]:

  "An image start tag token is handled by the tree builder, but it
  is not in this list because it is not an element; it gets turned
  into an img element."

And in the "in body" insertion mode [2]:

  "A start tag whose tag name is 'image':
    Parse error. Change the token's tag name to 'img' and reprocess
    it. (Don't ask.)"

That is, the tree builder rewrites <image> to <img> and reprocesses
it. The speculative preload scanner did not perform this aliasing,
so <image src="..."> was bucketed as TagId::Unknown and produced no
preload, even though the document parser then materializes a real
<img> element that fetches the resource.

Teach tagIdFor() to map "image" to TagId::Img. Because <image> is
not in the HTML "break out of foreign content" list (while <img>
is), inside SVG foreign content <image> stays as the SVG image
element, which uses href/xlink:href rather than src. Guard scan()
so the preload is skipped in that case to avoid regressing
svg-image-src.tentative.

[1] https://html.spec.whatwg.org/multipage/parsing.html#special
[2] https://html.spec.whatwg.org/multipage/parsing.html#parsing-main-inbody

* 
LayoutTests/imported/w3c/web-platform-tests/html/syntax/speculative-parsing/generated/document-write/image-src.tentative.sub-expected.txt:
 Progression
* 
LayoutTests/imported/w3c/web-platform-tests/html/syntax/speculative-parsing/generated/page-load/image-src.tentative-expected.txt:
 Ditto
* Source/WebCore/html/parser/HTMLPreloadScanner.cpp:
(WebCore::TokenPreloadScanner::tagIdFor):
(WebCore::TokenPreloadScanner::scan):

Replace <image> with <imagex> so the test actually uses an unknown tag.
<image> is a legacy alias the HTML parser (and now the preload scanner)
rewrites to <img>, which defeats the test's purpose: confirming the
nested-template preload fix does not preload an unrecognized tag.

* LayoutTests/fast/preloader/image-with-incorrect-tag-expected.txt: Updated.
* LayoutTests/fast/preloader/image-with-incorrect-tag.html: Updated.

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



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

Reply via email to