Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 32309d175884210b8f289aa7c567903b31afa137
https://github.com/WebKit/WebKit/commit/32309d175884210b8f289aa7c567903b31afa137
Author: Sammy Gill <[email protected]>
Date: 2026-04-24 (Fri, 24 Apr 2026)
Changed paths:
A
LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/flex-grow-009-expected.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/flex-grow-009.html
M Source/WebCore/rendering/RenderFlexibleBox.cpp
Log Message:
-----------
Flexbox: calc(infinity) flex-grow factor fails to stretch item to 100% width.
https://bugs.webkit.org/show_bug.cgi?id=312477
rdar://175431146
Reviewed by Alan Baradlay.
The CSS Flexbox spec (Section 9.7, "Resolve Flexible Lengths") says to
distribute
remaining free space proportionally: compute the ratio of each item's flex grow
factor to the sum of all flex grow factors, then multiply remaining free space
by
that ratio.
For example, given a 100px wide flex container with two items:
- Item A: flex: calc(infinity) 0 0px (flex-grow: FLT_MAX)
- Item B: flex: 1 0 0px (flex-grow: 1)
Item A should receive essentially all 100px of free space, and Item B ~0px.
However, resolveFlexibleLengths computed the expression left-to-right:
remainingFreeSpace * flexGrow / totalFlexGrow. The LayoutUnit * float
multiplication
returns a float, so remainingFreeSpace (100) * flexGrow (FLT_MAX) computes the
result to infinity. Then infinity / totalFlexGrow produces NaN. The existing
std::isfinite guard then discards the result, leaving both items stuck at their
flex
basis with no free space distributed.
Fix this by computing the ratio first: remainingFreeSpace * (flexGrow /
totalFlexGrow).
This gives a ratio of 1 for item A and ~0 for item B.
Test: imported/w3c/web-platform-tests/css/css-flexbox/flex-grow-009.html
Canonical link: https://commits.webkit.org/311956@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications