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

  Changed paths:
    M Source/WebCore/layout/formattingContexts/grid/ImplicitGrid.cpp
    M Source/WebCore/layout/formattingContexts/grid/ImplicitGrid.h

  Log Message:
  -----------
  [GFC] Fill in remaining bits for multi-spanning item placement.
https://bugs.webkit.org/show_bug.cgi?id=323925
rdar://problem/187159344

Reviewed by Alan Baradlay.

Most of the code related to grid item placement already handled items
that spanned multiple tracks so in this patch we just fill in the
remaining holes in order to support them.

https://drafts.csswg.org/css-grid-1/#auto-placement-algo

1.) Position anything that's not auto-positioned -

If an item is not auto positioned then we already know the size of the
ImplicitGrid should be able to handle it. insertItemInArea is a simple
loop over the associated grid area so inserting this type of item is
already handled.

Step 2: Process the items locked to a given row -

Given the rows the item spans we try to find the first column that can
hold the item depending on sparse/dense packing. This already handled
multi spanning items by taking in the column start and end positions of
the item.

Step 3: Determine the columns in the implicit grid -

This is already handled while the ImplicitGrid is being built so there is
nothing to do here. See determineImplicitGridColumns, which widens the
grid both for the items that have a definite column position and for the
largest column span among the items that do not. That second part exists
purely to serve spanning items and was already written.

Step 4: position the remaining grid items -
Needed no change at all. Both the definite-column and the fully-auto
placement paths already drove isCellRangeEmpty, growRowsToFit and
insertItemInArea over the item's real row and column spans.

What is left is three narrow fixes explained below rather than an
implementation.

* Source/WebCore/layout/formattingContexts/grid/ImplicitGrid.cpp:
(WebCore::Layout::ImplicitGrid::insertUnplacedGridItem):
Bailed when it saw multi spanning items but insertItemIntoArea can be
used both for non-spanning and spanning items.

(WebCore::Layout::ImplicitGrid::gridAreas const):
Rebuilt each item's area from the grid matrix and stopped at the first cell it
found the item in, so every area came back a single cell no matter how many the
item occupied. Placement could have been entirely correct and the spans would
still have been discarded on the way out. Extend the end lines as the sweep
reaches each further cell instead.

(WebCore::Layout::ImplicitGrid::growColumnsForDefiniteRowItem):
Renamed from growGridColumnsToFit() since it now defers the actual widening to
growColumnsToFit(). Tracked the last occupied column across the spanned rows and
had the initial value as 0 which is indistinguishable from column zero being
occupied. An empty row therefore grew by one column more than the item needed,
adding an implicit track and changing the track count. Make the column a
std::optional instead, so rows that hold nothing stay distinguishable from rows
whose first column is occupied.

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



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

Reply via email to