Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 25f9a54701a9457c5acfc8347221a0297a06ba1b
https://github.com/WebKit/WebKit/commit/25f9a54701a9457c5acfc8347221a0297a06ba1b
Author: Sammy Gill <[email protected]>
Date: 2026-07-21 (Tue, 21 Jul 2026)
Changed paths:
M Source/WebCore/layout/formattingContexts/grid/GridLayoutUtils.cpp
M Source/WebCore/layout/formattingContexts/grid/GridLayoutUtils.h
M
Source/WebCore/layout/integration/LayoutIntegrationFormattingContextLayout.h
M Source/WebCore/layout/integration/LayoutIntegrationUtils.cpp
M Source/WebCore/layout/integration/LayoutIntegrationUtils.h
Log Message:
-----------
[GFC] Implement fit-content sizing for non-replaced elements.
https://bugs.webkit.org/show_bug.cgi?id=319914
rdar://problem/182834140
Reviewed by Elika Etemad.
https://drafts.csswg.org/css-grid-1/#grid-item-sizing
Here we implement the case where we have a non-replaced element without
a preferred aspect ratio and an alignment that is not normal or stretch.
In this case the automatic size for that grid item is the fit-content
size. We can simply expand the preferred size functions to detect this,
compute each of the sizes that goes into the fit-content size, and then
return the result.
* Source/WebCore/layout/formattingContexts/grid/GridLayoutUtils.cpp:
(WebCore::Layout::GridLayoutUtils::stretchFitSize):
This is a pretty common operation at this point that is used in a few
different scenarios so we might as well move it over to a helper
function.
(WebCore::Layout::GridLayoutUtils::stretchedBlockSize): Deleted.
Folded into the generic stretch fit size function since the logic is the
same for both inline and block version.
* Source/WebCore/layout/integration/LayoutIntegrationUtils.cpp:
(WebCore::Layout::IntegrationUtils::maxContentWidth const):
We already used the respective minContentWidth integration function to
get the min content width of a grid item so now that we do the same with
the max content width we need to update this assert.
(WebCore::Layout::blockSizeForGridItem):
(WebCore::Layout::IntegrationUtils::maxContentHeightForGridItem const):
* Source/WebCore/layout/integration/LayoutIntegrationUtils.h:
This new integration API mirrors the one that we have to get the min
content height for a grid item. This ends up calling into
blockSizeForGridItem with the type of height we are querying for the
grid item.
Canonical link: https://commits.webkit.org/317674@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications