Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: ea6773454c246cb407ca3fd88b08036c1c005071
      
https://github.com/WebKit/WebKit/commit/ea6773454c246cb407ca3fd88b08036c1c005071
  Author: Sammy Gill <[email protected]>
  Date:   2026-10-09 (Fri, 09 Oct 2026)

  Changed paths:
    M Source/WebCore/layout/formattingContexts/grid/GridLayout.cpp
    M Source/WebCore/layout/formattingContexts/grid/GridLayout.h
    M Source/WebCore/layout/formattingContexts/grid/GridLayoutUtils.cpp
    M Source/WebCore/layout/formattingContexts/grid/GridLayoutUtils.h
    M Source/WebCore/layout/integration/LayoutIntegrationUtils.cpp
    M Source/WebCore/layout/integration/LayoutIntegrationUtils.h

  Log Message:
  -----------
  [GFC] Baseline align grid items after they have been sized
https://bugs.webkit.org/show_bug.cgi?id=326747
rdar://problem/189457596

Reviewed by Alan Baradlay.

This is the first step towards supporting baseline self-alignment in GFC.
Once the grid items have been laid out and their baselines are known, the
items of each baseline-sharing group are aligned so that their alignment
baselines line up.

A baseline-sharing group is formed by the items that share an alignment
context (a row for align-self and a column for justify-self) and have
compatible baseline alignment preferences. An item that spans multiple
tracks participates in its start-most track for first baseline alignment
and its end-most track for last baseline alignment. GFC only supports
horizontal-tb grid items for now, so every item has the same block flow
direction and only the first/last preference decides compatibility.

Each group is then aligned in three steps:
1. Find where each item's baseline would be, in the grid container's
   coordinates, if the item were placed at the start of its grid area.
2. Line up the baselines by moving every item down to the lowest one.
3. Position the group according to its fallback alignment. A first
   baseline group is start-aligned, which it already is after step 2. A
   last baseline group is end-aligned, so the whole group is moved down
   until its end-most margin box reaches the end edge that all of its grid
   areas share. The fallback alignment is safe, so a group that does not
   fit stays start-aligned instead of overflowing.

Working in the grid container's coordinates is required because the grid
areas of a last baseline group can start at different lines when items
span multiple rows.

This code is not reachable yet since the coverage check still rejects grid
items with baseline alignment.

* Source/WebCore/layout/formattingContexts/grid/GridLayout.cpp:
(WebCore::Layout::computeBaselineAlignedMarginBoxPositions):
Compute the margin box position, relative to its grid area, of every
baseline-aligned grid item.

(WebCore::Layout::GridLayout::performInlineAxisSelfAlignment):
(WebCore::Layout::GridLayout::performBlockAxisSelfAlignment):
Use the baseline-aligned margin box position when the item has one.

* Source/WebCore/layout/formattingContexts/grid/GridLayoutUtils.cpp:
(WebCore::Layout::GridLayoutUtils::baselineSharingGroups):

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



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

Reply via email to