Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 9bb7a30a2ff78ca1732dd096e6c14c054677f615
https://github.com/WebKit/WebKit/commit/9bb7a30a2ff78ca1732dd096e6c14c054677f615
Author: Ahmad Saleem <[email protected]>
Date: 2026-07-27 (Mon, 27 Jul 2026)
Changed paths:
A
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/subgrid/subgrid-own-column-gap-does-not-inflate-intrinsic-width-expected.txt
A
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/subgrid/subgrid-own-column-gap-does-not-inflate-intrinsic-width.html
M Source/WebCore/rendering/RenderGrid.cpp
Log Message:
-----------
Subgrid with large column-gap overflows max-width-constrained parent
https://bugs.webkit.org/show_bug.cgi?id=280613
rdar://137422489
Reviewed by Sammy Gill.
This patch aligns WebKit with Blink / Chromium.
Per CSS Grid Level 2 [1], a subgrid "acts as if it was completely empty
for track sizing purposes in the subgridded dimension" and "its track
sizes are governed by the parent grid." So a subgrid must not contribute
its own gap to that axis. WebKit did, twice, overflowing a
max-width-constrained parent and any item spanning the subgrid:
parent grid (max-width) |--------------|
+---------------------------------------+
| subgrid [t0].gap.[t1].gap.[t2]... ----+--> overflow: + 12 x 10rem
+---------------------------------------+ (subgrid's own gap, wrongly
tracks governed by parent --+ added on top of parent tracks)
1. computeTrackSizesForIndefiniteSize() unconditionally added
guttersSize() to the container's min/max-content width. In a
subgridded axis this injected the subgrid's own gap (13 inherited
tracks, gap: 10rem -> +12 x 10rem), forcing the parent wider than its
containing block. Fix: skip gutters when isSubgrid(direction).
2. gridAreaBreadthForGridItemIncludingAlignmentOffsets() used
tracks[end-1]->baseSize(). To realize [1]'s rule that "half the
difference between the subgrid's gutters and its parent grid's
gutters is applied as an extra layer of (potentially negative)
margin," copyUsedTrackSizesForSubgrid() stores negative base sizes;
baseSize() clamps them to zero, overstating the breadth. Fix: use
unclampedBaseSize(), matching populateGridPositionsForDirection().
[1] https://drafts.csswg.org/css-grid-2/#subgrids
Test:
imported/w3c/web-platform-tests/css/css-grid/subgrid/subgrid-own-column-gap-does-not-inflate-intrinsic-width.html
*
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/subgrid/subgrid-own-column-gap-does-not-inflate-intrinsic-width-expected.txt:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/subgrid/subgrid-own-column-gap-does-not-inflate-intrinsic-width.html:
Added.
* Source/WebCore/rendering/RenderGrid.cpp:
(WebCore::RenderGrid::computeTrackSizesForIndefiniteSize const):
(WebCore::RenderGrid::gridAreaBreadthForGridItemIncludingAlignmentOffsets
const):
Canonical link: https://commits.webkit.org/318009@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications