Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 104ad1e0ccbc36f500c659c46fd183e1489142ff
https://github.com/WebKit/WebKit/commit/104ad1e0ccbc36f500c659c46fd183e1489142ff
Author: Yulun Wu <[email protected]>
Date: 2026-07-24 (Fri, 24 Jul 2026)
Changed paths:
M Source/WebCore/layout/formattingContexts/grid/GridFormattingContext.cpp
M Source/WebCore/layout/formattingContexts/grid/GridItemSizingFunctions.cpp
M Source/WebCore/layout/formattingContexts/grid/GridLayout.cpp
M Source/WebCore/layout/formattingContexts/grid/GridLayoutUtils.cpp
M Source/WebCore/layout/formattingContexts/grid/GridLayoutUtils.h
M Source/WebCore/layout/formattingContexts/grid/PlacedGridItem.cpp
M Source/WebCore/layout/formattingContexts/grid/PlacedGridItem.h
M
Source/WebCore/layout/integration/LayoutIntegrationFormattingContextLayout.cpp
M
Source/WebCore/layout/integration/LayoutIntegrationFormattingContextLayout.h
M Source/WebCore/layout/integration/LayoutIntegrationUtils.cpp
M Source/WebCore/layout/integration/LayoutIntegrationUtils.h
Log Message:
-----------
[GFC] Resolve percentage/calc padding for grid items on grid area
https://bugs.webkit.org/show_bug.cgi?id=319913
<rdar://182833826>
Reviewed by Sammy Gill.
Resolve a grid item's percentage/calc() padding against the inline size of the
grid
item when available, and 0px when it is not, such as during intrinsic sizing.
The biggest change here is that grid items are now laid out with
layoutGridItemWithFormattingContext() which sets the grid area inline size on
the
renderer.
This PR updates PlacedGridItem to stop resolving and caching the border and
padding at
construction time. The grid area's inline size is not knowable at this time and
cannot
be resolved. Border and padding have been updated to be computed on demand.
The intrinsic GridItemSizingFunctions have been updated to correctly resolve
cyclic padding against 0px during intrinsic column track sizing.
minContentWidth() for grid items is now handled by minContentWidthForGridItem()
which now correctly resolves the item's min content width against the grid
area's
inline size instead of the grid container's block size.
borderAndPaddingForGridItem() is a new helper function to resolve the inline and
block border/padding for grid items against the inlineSize. This is fed into
track sizing and used-size calculation.
No change in behavior: percentage/calc()-padded grid items are still routed to
the legacy grid layout by the GridItemHasPercentOrCalcPadding avoidance reason.
* Source/WebCore/layout/formattingContexts/grid/GridFormattingContext.cpp:
(WebCore::Layout::GridFormattingContext::constructPlacedGridItems const):
* Source/WebCore/layout/formattingContexts/grid/GridItemSizingFunctions.cpp:
(WebCore::Layout::GridItemSizingFunctions::inlineAxis):
* Source/WebCore/layout/formattingContexts/grid/GridLayout.cpp:
(WebCore::Layout::GridLayout::sizeColumnTracks const):
(WebCore::Layout::GridLayout::sizeRowTracks const):
(WebCore::Layout::GridLayout::layoutGridItems const):
* Source/WebCore/layout/formattingContexts/grid/GridLayoutUtils.cpp:
(WebCore::Layout::GridLayoutUtils::inlineContentSizeSuggestion):
(WebCore::Layout::GridLayoutUtils::automaticMinimumInlineSize):
(WebCore::Layout::GridLayoutUtils::inlineMinimumSize):
(WebCore::Layout::GridLayoutUtils::inlineUsedSize):
(WebCore::Layout::GridLayoutUtils::inlinePreferredSize):
* Source/WebCore/layout/formattingContexts/grid/GridLayoutUtils.h:
* Source/WebCore/layout/formattingContexts/grid/PlacedGridItem.cpp:
(WebCore::Layout::PlacedGridItem::PlacedGridItem):
(WebCore::Layout::m_blockAxisSizes):
* Source/WebCore/layout/formattingContexts/grid/PlacedGridItem.h:
(WebCore::Layout::PlacedGridItem::usedInlineBorderAndPadding const): Deleted.
(WebCore::Layout::PlacedGridItem::usedBlockBorderAndPadding const): Deleted.
*
Source/WebCore/layout/integration/LayoutIntegrationFormattingContextLayout.cpp:
(WebCore::LayoutIntegration::layoutBoxWithOverridingBorderBoxSize):
(WebCore::LayoutIntegration::layoutWithFormattingContextForBox):
(WebCore::LayoutIntegration::layoutGridItemWithFormattingContext):
* Source/WebCore/layout/integration/LayoutIntegrationFormattingContextLayout.h:
* Source/WebCore/layout/integration/LayoutIntegrationUtils.cpp:
(WebCore::Layout::inlineWidthForGridItemWithGridArea):
(WebCore::Layout::IntegrationUtils::borderAndPaddingForGridItem const):
(WebCore::Layout::IntegrationUtils::layoutGridItem const):
(WebCore::Layout::IntegrationUtils::minContentWidth const):
(WebCore::Layout::IntegrationUtils::minContentWidthForGridItem const):
(WebCore::Layout::IntegrationUtils::minContentLogicalWidthContribution const):
(WebCore::Layout::IntegrationUtils::maxContentLogicalWidthContribution const):
(WebCore::Layout::IntegrationUtils::maxContentWidth const):
(WebCore::Layout::IntegrationUtils::maxContentWidthForGridItem const):
* Source/WebCore/layout/integration/LayoutIntegrationUtils.h:
Canonical link: https://commits.webkit.org/317895@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications