Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 18cf15f731e989435408614b778874c7e1cdf148
      
https://github.com/WebKit/WebKit/commit/18cf15f731e989435408614b778874c7e1cdf148
  Author: Sammy Gill <[email protected]>
  Date:   2026-09-09 (Wed, 09 Sep 2026)

  Changed paths:
    A 
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-definition/fit-content-track-sizing-expected.txt
    A 
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-definition/fit-content-track-sizing.html
    M Source/WebCore/layout/formattingContexts/grid/GridItemSizingFunctions.cpp
    M Source/WebCore/layout/formattingContexts/grid/GridLayout.cpp
    M Source/WebCore/layout/formattingContexts/grid/GridSizer.cpp
    M Source/WebCore/layout/formattingContexts/grid/TrackSizingAlgorithm.cpp
    M Source/WebCore/layout/formattingContexts/grid/TrackSizingFunctions.h

  Log Message:
  -----------
  [GFC] fit-content() tracks should not be stretched and should cap the growth 
limit
https://bugs.webkit.org/show_bug.cgi?id=323704
rdar://problem/186961437

Reviewed by Alan Baradlay.

Setting fit-content() for a track size has a couple of different
implications during track sizing. For the most part this is supposed to
have the same behavior as "auto," for the max track sizing function
(getting treated as max-content). There are some nuances that need to be
taken into consideration during track sizing though since that argument
to fit-content can act as a limit during track sizing.

We currently lose this information and cannot do anything with it since
the max track sizing function is a Style::GridTrackBreadth. Instead, we
need to change the max track sizing function so that is can hold either
a Style::GridTrackBreadth or Style::GridTrackSize::FitContent. We do
this by having MaxTrackSizingFunction just be a variant over these two.

Style::GridTrackSize represents a fit-content() track by leaving both of its 
breadths at their
default value of auto and storing the argument in a separate member, so
GridLayout::convertGridTrackSizeToTrackSizingFunctions() reported such a 
track's max track sizing
function as auto and dropped the argument entirely.

Two things followed from that:

1.) https://drafts.csswg.org/css-grid-1/#algo-stretch only expands
tracks whose max track sizing function is auto. In this case we were
setting the max track sizing function to gridTrackSize.maxTrackBreadth()
which was returning auto in the fit-content case. By now setting
fit-content directly we avoid this.

2.) https://drafts.csswg.org/css-grid-2/#algo-single-span-items says that for 
fit-content() maximums
the growth limit is furthermore clamped by the fit-content() argument, which 
was not reachable at
all once the argument had been dropped.

Test: 
imported/w3c/web-platform-tests/css/css-grid/grid-definition/fit-content-track-sizing.html
Canonical link: https://commits.webkit.org/320780@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to