Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: a64300296c7752fbd4ae85a9621f2f277a4ebb59
      
https://github.com/WebKit/WebKit/commit/a64300296c7752fbd4ae85a9621f2f277a4ebb59
  Author: Sammy Gill <[email protected]>
  Date:   2026-08-03 (Mon, 03 Aug 2026)

  Changed paths:
    M Source/WebCore/layout/formattingContexts/grid/GridFormattingContext.cpp
    M Source/WebCore/layout/formattingContexts/grid/GridFormattingContext.h
    M Source/WebCore/layout/formattingContexts/grid/GridLayout.cpp
    M Source/WebCore/layout/formattingContexts/grid/GridLayout.h
    M Source/WebCore/layout/formattingContexts/grid/GridTypeAliases.h
    M Source/WebCore/layout/formattingContexts/grid/UnplacedGridItem.cpp
    M Source/WebCore/layout/formattingContexts/grid/UnplacedGridItem.h

  Log Message:
  -----------
  [GFC] Generate leading implicit tracks for negative line placements
https://bugs.webkit.org/show_bug.cgi?id=320680
rdar://problem/183664987

Reviewed by Alan Baradlay.

When a grid item is placed with a negative line that resolves before the start 
of
the explicit grid, leading implicit tracks must be generated before the explicit
grid. GridFormattingContext already computes a count of those tracks and shifts
every item's line forward so that its DefinitePosition, if it has one,
is non-negative during layout (relative to the implicit grid). However,
grid layout does not know how many of those leading implicit tracks
there are which is an additional piece of information that it will need
to keep track of.

In GridFormattingContext we compute the number of implicit tracks and
pass that as input to GridLayout just like how the number of explicit
tracks is already a part of the input. It can then use those when
creating the ImplicitGrid and also generate the track sizing functions
for them.

* Source/WebCore/layout/formattingContexts/grid/GridFormattingContext.cpp:
(WebCore::Layout::GridFormattingContext::computeLeadingImplicitTracks const):
Refactor out the logic that computes the number of leading implicit
tracks into a dedicated function since it does not really belong to
unplaced grid item construction. Also rename the values from 
columnNegativeLineOffset
to LeadingImplicitColumns with a column/track count since that is a bit
more descriptive of what it represents.

* Source/WebCore/layout/formattingContexts/grid/GridLayout.cpp:
(WebCore::Layout::GridLayout::calculateInitialImplicitGridDimensions):
Now the initial dimensions of the ImplicitGrid will be the number of
explicit tracks + the number of leading implicit tracks instead of it
just being the explicit ones.

(WebCore::Layout::GridLayout::constructInitialImplicitGrid):
(WebCore::Layout::GridLayout::placeGridItems):
(WebCore::Layout::GridLayout::layout):
(WebCore::Layout::GridLayout::generateImplicitTrackSizingFunctions):
Takes in the number of implicit tracks directly rather then computing it
itself based off the number of total tracks and explicit ones. This
currently is really only correct when grid-auto-columns/rows contains a
single value (e.g. grid-auto-columns: 100px rather than grid-auto-columns: 
100px min-content)
but we gate taking GFC on this anyways so it isn't a problem. Before we
relax that condition we will need to implement this to handle that case.

(WebCore::Layout::GridLayout::trackSizingFunctions):
* Source/WebCore/layout/formattingContexts/grid/GridLayout.h:
* Source/WebCore/layout/formattingContexts/grid/UnplacedGridItem.cpp:
(WebCore::Layout::UnplacedGridItem::GridPosition::create):
(WebCore::Layout::UnplacedGridItem::UnplacedGridItem):
* Source/WebCore/layout/formattingContexts/grid/UnplacedGridItem.h:
Basically just making sure we are consistent and are using the new
"leading implicit columns/rows," term rather than "negative line offset."

Canonical link: https://commits.webkit.org/318485@main



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

Reply via email to