Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 4e1820c0d71eb2e9fd942d1645516b49ecfdd57e
      
https://github.com/WebKit/WebKit/commit/4e1820c0d71eb2e9fd942d1645516b49ecfdd57e
  Author: Brent Fulgham <[email protected]>
  Date:   2026-09-16 (Wed, 16 Sep 2026)

  Changed paths:
    M 
LayoutTests/fast/images/inline-image-box-with-no-alt-should-collapse-no-quirks-expected.txt
    A 
LayoutTests/imported/w3c/web-platform-tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/img-empty-alt-replaced-block-expected.txt
    A 
LayoutTests/imported/w3c/web-platform-tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/img-empty-alt-replaced-block.html
    M 
LayoutTests/imported/w3c/web-platform-tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/img-no-alt-replaced-expected.txt
    M Source/WebCore/rendering/RenderImage.cpp
    M Source/WebCore/rendering/RenderImage.h

  Log Message:
  -----------
  transworld-home.com: Strange `block` in front of `Unlimited Downloads` in 
offer carousel
https://bugs.webkit.org/show_bug.cgi?id=324192
rdar://155149701

Reviewed by Alan Baradlay.

An img whose image data cannot be obtained and whose alt attribute is the empty
string represents nothing. Per 
https://html.spec.whatwg.org/multipage/rendering.html#images-3,
such an element has natural dimensions of 0 and no natural aspect ratio, so an 
authored
dimension is honoured and an auto dimension resolves to zero.

WebKit instead gave it the 20x20 natural size of the broken-image icon and an 
invented
1:1 natural aspect ratio, then compensated for that in inline boxes, forcing 
both used
dimensions to zero. Block-level boxes were never handled in this case, so a 
blockified
image with an authored width resolved its height from the 1:1 ratio and painted 
the icon
(the stray square on transworld-home.com).

To fix this, give elements in this scenario a zero natural size and no natural 
aspect ratio.
Ordinary replaced-element sizing then produces the specified result for both 
inline and
block boxes, and an authored dimension is no longer overridden. This has the 
side-effect
of fixing img-no-alt-replaced.html, which always failed in our engine.

The old inline-box compensation was gated on the box being inline, which also 
kept it away
from the block-level `content: url()` replacement path. Dropping that gate 
makes the
element type load-bearing, so the new predicate asks for an img explicitly 
rather than for
an alt attribute on any element: alt carries no meaning on the arbitrary 
elements CSS
`content` can replace with an image, and reading it from the DOM there would 
collapse them.

Test: 
imported/w3c/web-platform-tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/img-empty-alt-replaced-block.html

* 
LayoutTests/fast/images/inline-image-box-with-no-alt-should-collapse-no-quirks-expected.txt:
* 
LayoutTests/imported/w3c/web-platform-tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/img-empty-alt-replaced-block-expected.txt:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/img-empty-alt-replaced-block.html:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/img-no-alt-replaced-expected.txt:
* Source/WebCore/rendering/RenderImage.cpp:
(WebCore::RenderImage::setImageSizeForAltText):
(WebCore::RenderImage::imageRepresentsNothing const):
(WebCore::RenderImage::imageChanged):
(WebCore::RenderImage::preferredAspectRatioAsSize const):
(WebCore::RenderImage::shouldCollapseToEmpty const): Deleted.
(WebCore::RenderImage::computeReplacedLogicalWidth const): Deleted.
(WebCore::RenderImage::computeReplacedLogicalHeight const): Deleted.
* Source/WebCore/rendering/RenderImage.h:

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



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

Reply via email to