Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 1665f4bc90084a86cd9463d60553211b8a79a77b
      
https://github.com/WebKit/WebKit/commit/1665f4bc90084a86cd9463d60553211b8a79a77b
  Author: Sammy Gill <[email protected]>
  Date:   2026-07-22 (Wed, 22 Jul 2026)

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

  Log Message:
  -----------
  [GFC][Cleanup] Remove some code duplication for resolving margins
https://bugs.webkit.org/show_bug.cgi?id=319942
rdar://problem/182860702

Reviewed by Cole Carley.

After track sizing is finished, we attempt to resolve the margins for
grid items in two different places: once during the final sizing of the
item and then when we want to align them. The logic to do this is
exactly the same and we do it in two different ways in both scenarios
when we do not need to. Instead, let's just use the static helper
function that we already have during item sizing and remove the lambdas
that were basically just duplicate code.

This change requires us to compute a list of the margins for each grid
item rather than resolve the margins one at a time, but this is
basically just a matter of plumbing the values to the right place.

* Source/WebCore/layout/formattingContexts/grid/GridLayout.cpp:
Remove the local UsedMargins definition now that it lives in
GridLayoutUtils.h.

(WebCore::Layout::GridLayout::layoutGridItems const):
Resolve each grid item's used margins with computeMarginsForAxis and pass
them into the sizing functions.

* Source/WebCore/layout/formattingContexts/grid/GridLayoutUtils.cpp:
(WebCore::Layout::GridLayoutUtils::stretchFitSize):
(WebCore::Layout::GridLayoutUtils::inlinePreferredSize):
(WebCore::Layout::GridLayoutUtils::blockPreferredSize):
(WebCore::Layout::GridLayoutUtils::inlineUsedSize):
(WebCore::Layout::GridLayoutUtils::blockUsedSize):
Aforementioned plumbing from GridLayout::layoutGridItems to the spots
where we were manually resolving them in the lambdas.

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



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

Reply via email to