Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 20da9872141e117fb9f839f4e5571102f62c8e0a
https://github.com/WebKit/WebKit/commit/20da9872141e117fb9f839f4e5571102f62c8e0a
Author: Alan Baradlay <[email protected]>
Date: 2026-05-14 (Thu, 14 May 2026)
Changed paths:
A
LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/flex-aspect-ratio-cross-size-001-expected.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/flex-aspect-ratio-cross-size-001-ref.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/flex-aspect-ratio-cross-size-001.html
M Source/WebCore/rendering/RenderFlexibleBox.cpp
M Source/WebCore/rendering/RenderFlexibleBox.h
Log Message:
-----------
[Flex] Flex container with aspect-ratio-derived height does not provide
definite cross size to flex items
https://bugs.webkit.org/show_bug.cgi?id=314734
Reviewed by Antti Koivisto.
<div style="display: flex; width: 400px; aspect-ratio: 2/1">
<img src="1x1.png" style="display: block">
</div>
The image should be 200x200 (flex container height = 400/2 = 200, image
stretches to 200, aspect ratio 1:1 gives width 200). Instead it was 1x200
because the flex algorithm didn't recognize the container's height as definite.
hasDefiniteCrossSizeForFlexItem only checked fixed heights and percentages.
It missed the case where height is auto but determinable from aspect-ratio
- the height says auto but we have an aspect ratio and we know the width,
so we can figure out the height.
This is only safe during layout (when the container's width is set from
recomputeLogicalWidth). During intrinsic sizing the width isn't final yet
so aspect-ratio can't resolve the height. The fix uses m_inLayout to
distinguish the two phases.
Extract canResolveCrossSizeFromAspectRatioDuringLayout() as a named check
used by both hasDefiniteCrossSizeForFlexItem and innerCrossSizeForFlexItem.
Tests:
imported/w3c/web-platform-tests/css/css-flexbox/flex-aspect-ratio-cross-size-001-ref.html
imported/w3c/web-platform-tests/css/css-flexbox/flex-aspect-ratio-cross-size-001.html
*
LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/flex-aspect-ratio-cross-size-001-expected.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/flex-aspect-ratio-cross-size-001-ref.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/flex-aspect-ratio-cross-size-001.html:
Added.
* Source/WebCore/rendering/RenderFlexibleBox.cpp:
(WebCore::RenderFlexibleBox::hasDefiniteCrossSizeForFlexItem const):
(WebCore::RenderFlexibleBox::canResolveCrossSizeFromAspectRatioDuringLayout
const):
(WebCore::RenderFlexibleBox::innerCrossSizeForFlexItem const):
* Source/WebCore/rendering/RenderFlexibleBox.h:
Canonical link: https://commits.webkit.org/313256@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications