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

  Changed paths:
    M Source/WebCore/Sources.txt
    M Source/WebCore/WebCore.xcodeproj/project.pbxproj
    M Source/WebCore/layout/formattingContexts/grid/GridFormattingContext.cpp
    A Source/WebCore/layout/formattingContexts/grid/GridItemPlacer.cpp
    A Source/WebCore/layout/formattingContexts/grid/GridItemPlacer.h
    M Source/WebCore/layout/formattingContexts/grid/GridLayout.cpp
    M Source/WebCore/layout/formattingContexts/grid/GridLayout.h
    M Source/WebCore/layout/formattingContexts/grid/ImplicitGrid.cpp
    M Source/WebCore/layout/formattingContexts/grid/ImplicitGrid.h

  Log Message:
  -----------
  [GFC][Cleanup] Move item placement logic into a dedicated class
https://bugs.webkit.org/show_bug.cgi?id=322447
rdar://problem/185731047

Reviewed by Alan Baradlay.

GridLayout::layout() ran the grid item placement algorithm inline, alongside
track sizing, grid item layout, and alignment. Give placement its own class so
that step 1 of the layout algorithm reads as a single call and GridLayout is
left with only the steps that size and position items.

GridItemPlacer takes the implicit grid rather than building it, so constructing
the initial grid stays the responsibility of ImplicitGrid itself via a new
createInitialGrid() factory. calculateInitialImplicitGridDimensions() moved
there as a file-static helper since it needs no member access, which keeps
GridDimensions out of every header.

Placement only reads the unplaced items -- it writes into the ImplicitGrid --
so placeItems() and GridLayout::layout() now take a const UnplacedGridItems&.
That lets computeIntrinsicWidths() drop the per-scenario clone of the unplaced
items, which was a deep copy of three Vectors per intrinsic width scenario. Its
comment claimed the placement and sizing algorithm consumed them, but nothing
ever mutated them: every ImplicitGrid entry point already took them by const
reference, and the grid cells, grid areas and PlacedGridItems built downstream
all store copies. The clone was not isolating anything, so dropping it leaves
the min-content and max-content scenarios as independent as they already were.

No change in behavior.

* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/layout/formattingContexts/grid/GridFormattingContext.cpp:
(WebCore::Layout::GridFormattingContext::computeIntrinsicWidths):
* Source/WebCore/layout/formattingContexts/grid/GridItemPlacer.cpp: Added.
(WebCore::Layout::GridItemPlacer::GridItemPlacer):
(WebCore::Layout::GridItemPlacer::placeItems const):
* Source/WebCore/layout/formattingContexts/grid/GridItemPlacer.h: Added.
* Source/WebCore/layout/formattingContexts/grid/GridLayout.cpp:
(WebCore::Layout::GridLayout::layout):
(WebCore::Layout::GridLayout::calculateInitialImplicitGridDimensions): Deleted.
(WebCore::Layout::GridLayout::constructInitialImplicitGrid): Deleted.
(WebCore::Layout::GridLayout::placeGridItems): Deleted.
* Source/WebCore/layout/formattingContexts/grid/GridLayout.h:
* Source/WebCore/layout/formattingContexts/grid/ImplicitGrid.cpp:
(WebCore::Layout::calculateInitialImplicitGridDimensions):
(WebCore::Layout::ImplicitGrid::createInitialGrid):
* Source/WebCore/layout/formattingContexts/grid/ImplicitGrid.h:

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



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

Reply via email to