Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 385c9c629c84a067b47ed966c0d3d96e50819349
https://github.com/WebKit/WebKit/commit/385c9c629c84a067b47ed966c0d3d96e50819349
Author: Sammy Gill <[email protected]>
Date: 2026-07-29 (Wed, 29 Jul 2026)
Changed paths:
M Source/WebCore/layout/formattingContexts/grid/GridFormattingContext.cpp
M Source/WebCore/layout/formattingContexts/grid/UnplacedGridItem.cpp
M Source/WebCore/layout/formattingContexts/grid/UnplacedGridItem.h
Log Message:
-----------
[GFC] Resolve negative grid lines against the explicit grid track count
https://bugs.webkit.org/show_bug.cgi?id=320511
rdar://problem/183473145
Reviewed by Alan Baradlay.
A negative grid line counts backward from the end edge of the explicit grid: for
a grid with N explicit tracks, -1 is the last line and -(N+1) is the first line,
with more-negative values counting past the start edge into the leading implicit
grid. Previously explicitLineToIndex() passed negative lines through unchanged
(e.g. -1 stayed -1), which is not quite how they are supposed to get
resolved.
To fix this we can just thread in the number of explicit tracks through
the code that computes the UnplacedGridItem's GridPosition so that it
takes the number of explicit tracks into account. For example, if you
have three expliti columns with lines L1 L2 L3 L4, then -1 will map to
L4 and -5 will map to the first implicit track that is created right
before the first explicit one.
* Source/WebCore/layout/formattingContexts/grid/GridFormattingContext.cpp:
(WebCore::Layout::GridFormattingContext::constructUnplacedGridItems const):
* Source/WebCore/layout/formattingContexts/grid/UnplacedGridItem.cpp:
(WebCore::Layout::explicitLineToIndex):
This is what does the mapping as described above. This means that this
may still return a negative number for those lines that are part of the
implicit grid that is part of the beginning. That is ok though since
those will be translated and be relative to the implicit grid when we
actually create the GridPosition itself.
(WebCore::Layout::UnplacedGridItem::GridPosition::create):
This is where the line numbers will get transformed to be relative to
the implicit grid. So here -5 from the example above would be fed in as
-1 but then transformed into 0 since it is the first line in the
implicit grid.
(WebCore::Layout::UnplacedGridItem::resolveDefinitePosition):
Plumb the number of explicit tracks to explicitLineToIndex so that the
values take them into consideration like described above in the
explanation of the function.
Canonical link: https://commits.webkit.org/318175@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications