Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: b0467f4a9803fa3ccefe2a38ec9e0678acf30b80
https://github.com/WebKit/WebKit/commit/b0467f4a9803fa3ccefe2a38ec9e0678acf30b80
Author: Sammy Gill <[email protected]>
Date: 2026-02-10 (Tue, 10 Feb 2026)
Changed paths:
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/GridTypeAliases.h
M Source/WebCore/layout/formattingContexts/grid/TrackSizingAlgorithm.cpp
M Source/WebCore/layout/formattingContexts/grid/TrackSizingAlgorithm.h
Log Message:
-----------
[GFC] Pass in constraints from opposite axis to track sizing algorithm
https://bugs.webkit.org/show_bug.cgi?id=307393
rdar://170014799
Reviewed by Alan Baradlay.
During the track sizing algorithm, we may need to get a grid item's
min/max content contributions in a given axis when trying to determine
the sizes of the track. In some cases, we may need to know the
constraint/available space from the opposite dimension in order to
compute this properly. For example, in horizontal-tb content when we
size the rows, the min/max content contributions for the grid item's
block size will depend on the available space in the inline axis.
For each iteration of the track sizing algorithm, the spec defines how
we can compute this available space. Generally, this comes just from
the size of the tracks in the previous steps except for the first step
in which the track sizing algorithm defines some special behavior:
https://drafts.csswg.org/css-grid-1/#algo-grid-sizing
In this patch, we compute the constraints for each grid item for the
first iteration of column/row sizing and pass this into the track sizing
algorithm so that the various sizing APIs can use them. This space will
always be available to the API since the spec defines how to compute
this for each iteration of the algorithm, but it will be up to the API
to determine whether or not it will need to use it to get the grid
item's size.
* Source/WebCore/layout/formattingContexts/grid/GridLayout.cpp:
(WebCore::Layout::rowSizesForFirstIterationColumnSizing):
Determines the "row sizes," that will be used to compute the constraints
from for the first iteration of column sizing. Since we have not run any
sort of row sizing, we cannot use any actual row sizes that were the
output of the track sizing algorithm. Instead, the spec defines a method
in which to compute an alternate set of sizes based on the track sizing
functions.
https://drafts.csswg.org/css-grid-1/#algo-grid-sizing
(WebCore::Layout::oppositeAxisConstraintForTrackSizing):
Computes the available space for a grid item in the opposite dimension
that we will compute track sizing for. The caller will pass in the used
track sizes from the previous step along with the placement of the grid
item which will be used together to compute the space.
* Source/WebCore/layout/formattingContexts/grid/GridLayoutUtils.cpp:
(WebCore::Layout::GridLayoutUtils::inlineAxisMinContentContribution):
(WebCore::Layout::GridLayoutUtils::inlineAxisMaxContentContribution):
(WebCore::Layout::GridLayoutUtils::blockAxisMinContentContribution):
(WebCore::Layout::GridLayoutUtils::blockAxisMaxContentContribution):
Add in the available space as an argument to these sizing functions that
will be passed in during the track sizing algorithm.
* Source/WebCore/layout/formattingContexts/grid/TrackSizingAlgorithm.cpp:
(WebCore::Layout::minContentContributions):
(WebCore::Layout::maxContentContributions):
(WebCore::Layout::minimumContributions):
(WebCore::Layout::sizeTracksToFitNonSpanningItems):
(WebCore::Layout::resolveIntrinsicTrackSizes):
(WebCore::Layout::TrackSizingAlgorithm::sizeTracks):
Pass in the constraints in the opposite axis that were computed by
GridLayout and plumb them all the way to the various sizing functions
that get the different contributions of grid items.
Canonical link: https://commits.webkit.org/307172@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications