Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 582f8821c289135365d3a011413f0b50a3b08cda
https://github.com/WebKit/WebKit/commit/582f8821c289135365d3a011413f0b50a3b08cda
Author: Karl Dubost <[email protected]>
Date: 2026-09-19 (Sat, 19 Sep 2026)
Changed paths:
A
LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/svg-root-as-flex-item-007-expected.txt
A
LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/svg-root-as-flex-item-007.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-sizing/svg-intrinsic-size-011-expected.txt
A
LayoutTests/imported/w3c/web-platform-tests/css/css-sizing/svg-intrinsic-size-011.html
M Source/WebCore/rendering/RenderBox.cpp
M Source/WebCore/rendering/RenderReplaced.cpp
M Source/WebCore/rendering/svg/RenderSVGRoot.cpp
M Source/WebCore/rendering/svg/legacy/LegacyRenderSVGRoot.cpp
Log Message:
-----------
REGRESSION (313091@main): SVG with no viewBox gets zero width as a flex item
https://bugs.webkit.org/show_bug.cgi?id=324552
rdar://187794543
Reviewed by Sammy Gill.
An <svg> with no width, no height and no viewBox has no aspect ratio.
FloatSize::aspectRatioDouble() divides the two components, so it returns
NaN. RenderReplaced::preferredAspectRatio() put that NaN in an optional.
The optional holds a value, so every check for a ratio passed.
Two places use the ratio to get a width from a height. One turns a
max-height into a maximum width. The other handles width: max-content.
A height times NaN is NaN, and LayoutUnit turns NaN into 0. So the
width becomes 0.
The fix is to return nothing when there is no ratio. One caller in
RenderBox did the division itself, so it now calls
preferredAspectRatio() too.
hasIntrinsicAspectRatio() on the two SVG roots had the same problem.
NaN is not zero, so it returned true. Flex layout asks it. Fixed the
same way.
The NaN is old. What changed is which widths reach it. 313091@main sent
auto and the intrinsic keywords through the max-height transfer, and
that is this bug. The width: max-content case came earlier, in
310885@main. Before those, only a percentage width was transferred.
The six existing svg-root-as-flex-item tests all carry a viewBox, so
they all have an aspect ratio. The new tests cover the case without one,
in flex layout and for the intrinsic width keywords.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/svg-root-as-flex-item-007-expected.txt:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/svg-root-as-flex-item-007.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-sizing/svg-intrinsic-size-011-expected.txt:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-sizing/svg-intrinsic-size-011.html:
Added.
* Source/WebCore/rendering/RenderBox.cpp:
(WebCore::RenderBox::computeIntrinsicKeywordLogicalWidths const):
* Source/WebCore/rendering/RenderReplaced.cpp:
(WebCore::RenderReplaced::preferredAspectRatio const):
* Source/WebCore/rendering/svg/RenderSVGRoot.cpp:
(WebCore::RenderSVGRoot::hasIntrinsicAspectRatio const):
* Source/WebCore/rendering/svg/legacy/LegacyRenderSVGRoot.cpp:
(WebCore::LegacyRenderSVGRoot::hasIntrinsicAspectRatio const):
Canonical link: https://commits.webkit.org/321446@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications