Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: a9d16998cc6d8cc75e33ee75602f22ede9b70bc1
https://github.com/WebKit/WebKit/commit/a9d16998cc6d8cc75e33ee75602f22ede9b70bc1
Author: Ahmad Saleem <[email protected]>
Date: 2026-09-25 (Fri, 25 Sep 2026)
Changed paths:
M
LayoutTests/imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/replaced-element-036-expected.txt
A
LayoutTests/imported/w3c/web-platform-tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/img-aspect-ratio-alt-text-expected.txt
A
LayoutTests/imported/w3c/web-platform-tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/img-aspect-ratio-alt-text.html
M Source/WebCore/rendering/RenderBox.cpp
M Source/WebCore/rendering/RenderImage.cpp
Log Message:
-----------
Broken <img> with alt text is given a square aspect ratio, overflowing a
definite CSS Grid area
https://bugs.webkit.org/show_bug.cgi?id=321082
rdar://184712865
Reviewed by Alan Baradlay.
RenderImage::preferredAspectRatioAsSize() fabricated a 1:1 preferred aspect
ratio for
any image in the broken state, and discarded the ratio derived from the
width/height
attributes whenever alt text was rendered. With a square ratio the used block
size
follows the used inline size, so for
.media { display: grid; width: 420px; height: 236.25px }
.media > img { width: 100%; height: 100% }
the grid item's automatic minimum size in the block axis resolved through the
ratio to
420 (the column size divided by 1), the implicit auto row grew to 420, and
height:100%
then resolved against that row, overflowing the container by ~184px.
min-height:0
skipped the automatic minimum size and hid it. Outside grid the same square
showed up
directly: width:100% in a 300px block laid out 300x300 instead of taking its
block size
from the alt text box.
An <img> rendering alt text is not sized as a replaced element, so it has no
preferred
aspect ratio and the "auto <ratio>" from the dimension attributes does not
apply. An
explicit aspect-ratio still applies unless the box is an inline box. This
matches
Chromium and Firefox: replaced-element-036.html now passes (explicit ratio
applies for
block and inline-block) and replaced-element-028.html keeps passing (it does
not apply
for inline).
Also guard the one consumer that divided by the preferred ratio without
checking it
exists, now reachable for images with no ratio at all.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/replaced-element-036-expected.txt:
Progression
*
LayoutTests/imported/w3c/web-platform-tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/img-aspect-ratio-alt-text-expected.txt:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/img-aspect-ratio-alt-text.html:
Added.
* Source/WebCore/rendering/RenderBox.cpp:
(WebCore::RenderBox::computeSizingKeywordLogicalContentHeightUsingGeneric
const):
* Source/WebCore/rendering/RenderImage.cpp:
(WebCore::RenderImage::preferredAspectRatioAsSize const):
Canonical link: https://commits.webkit.org/321907@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications