Changeset 290096 in webkit
- Timestamp:
- Feb 17, 2022 4:54:41 PM (5 months ago)
- Location:
- trunk
- Files:
-
- 14 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/TestExpectations (modified) (1 diff)
-
LayoutTests/imported/w3c/ChangeLog (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/subgrid/abs-pos-002-expected.html (modified) (2 diffs)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/subgrid/abs-pos-003-expected.html (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/subgrid/line-names-008.html (modified) (2 diffs)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/subgrid/parent-repeat-auto-fit-001.html (modified) (2 diffs)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/subgrid/parent-repeat-auto-fit-002.html (modified) (2 diffs)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/rendering/GridLayoutFunctions.cpp (modified) (1 diff)
-
Source/WebCore/rendering/GridTrackSizingAlgorithm.cpp (modified) (6 diffs)
-
Source/WebCore/rendering/RenderGrid.cpp (modified) (4 diffs)
-
Source/WebCore/rendering/RenderGrid.h (modified) (5 diffs)
-
Source/WebCore/rendering/style/GridPositionsResolver.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r290087 r290096 1 2022-02-17 Matt Woodrow <mattwoodrow@apple.com> 2 3 Account for subgrid MBP when sizing 4 https://bugs.webkit.org/show_bug.cgi?id=236338 5 6 Reviewed by Dean Jackson. 7 8 Account for subgrid MBP when sizing 9 10 * TestExpectations: 11 1 12 2022-02-17 Matt Woodrow <mattwoodrow@apple.com> 2 13 -
trunk/LayoutTests/TestExpectations
r290077 r290096 1396 1396 1397 1397 imported/w3c/web-platform-tests/css/css-grid/subgrid/auto-track-sizing-001.html [ ImageOnlyFailure ] 1398 imported/w3c/web-platform-tests/css/css-grid/subgrid/abs-pos-002.html [ ImageOnlyFailure ]1399 imported/w3c/web-platform-tests/css/css-grid/subgrid/abs-pos-003.html [ ImageOnlyFailure ]1400 imported/w3c/web-platform-tests/css/css-grid/subgrid/abs-pos-004.html [ ImageOnlyFailure ]1401 1398 imported/w3c/web-platform-tests/css/css-grid/subgrid/baseline-001.html [ ImageOnlyFailure ] 1402 imported/w3c/web-platform-tests/css/css-grid/subgrid/grid-gap-001.html [ ImageOnlyFailure ]1403 imported/w3c/web-platform-tests/css/css-grid/subgrid/grid-gap-002.html [ ImageOnlyFailure ]1404 1399 imported/w3c/web-platform-tests/css/css-grid/subgrid/grid-gap-003.html [ ImageOnlyFailure ] 1405 imported/w3c/web-platform-tests/css/css-grid/subgrid/grid-gap-004.html [ ImageOnlyFailure ]1406 1400 imported/w3c/web-platform-tests/css/css-grid/subgrid/grid-gap-007.html [ ImageOnlyFailure ] 1407 imported/w3c/web-platform-tests/css/css-grid/subgrid/grid-gap-larger-001.html [ ImageOnlyFailure ]1408 imported/w3c/web-platform-tests/css/css-grid/subgrid/grid-gap-larger-002.html [ ImageOnlyFailure ]1409 imported/w3c/web-platform-tests/css/css-grid/subgrid/grid-gap-smaller-001.html [ ImageOnlyFailure ]1410 imported/w3c/web-platform-tests/css/css-grid/subgrid/item-percentage-height-001.html [ ImageOnlyFailure ]1411 1401 imported/w3c/web-platform-tests/css/css-grid/subgrid/line-names-007.html [ ImageOnlyFailure ] 1412 imported/w3c/web-platform-tests/css/css-grid/subgrid/line-names-008.html [ ImageOnlyFailure ]1413 imported/w3c/web-platform-tests/css/css-grid/subgrid/orthogonal-writing-mode-001.html [ ImageOnlyFailure ]1414 1402 imported/w3c/web-platform-tests/css/css-grid/subgrid/orthogonal-writing-mode-002.html [ ImageOnlyFailure ] 1415 1403 imported/w3c/web-platform-tests/css/css-grid/subgrid/orthogonal-writing-mode-003.html [ ImageOnlyFailure ] 1416 1404 imported/w3c/web-platform-tests/css/css-grid/subgrid/orthogonal-writing-mode-004.html [ ImageOnlyFailure ] 1417 imported/w3c/web-platform-tests/css/css-grid/subgrid/parent-repeat-auto-fit-001.html [ ImageOnlyFailure ]1418 imported/w3c/web-platform-tests/css/css-grid/subgrid/parent-repeat-auto-fit-002.html [ ImageOnlyFailure ]1419 1405 imported/w3c/web-platform-tests/css/css-grid/subgrid/repeat-auto-fill-003.html [ ImageOnlyFailure ] 1420 imported/w3c/web-platform-tests/css/css-grid/subgrid/repeat-auto-fill-004.html [ ImageOnlyFailure ]1421 1406 imported/w3c/web-platform-tests/css/css-grid/subgrid/subgrid-mbp-overflow-001.html [ ImageOnlyFailure ] 1422 1407 imported/w3c/web-platform-tests/css/css-grid/subgrid/subgrid-mbp-overflow-002.html [ ImageOnlyFailure ] -
trunk/LayoutTests/imported/w3c/ChangeLog
r290080 r290096 1 2022-02-17 Matt Woodrow <mattwoodrow@apple.com> 2 3 Account for subgrid MBP when sizing 4 https://bugs.webkit.org/show_bug.cgi?id=236338 5 6 Reviewed by Dean Jackson. 7 8 * web-platform-tests/css/css-grid/subgrid/abs-pos-002-expected.html: 9 * web-platform-tests/css/css-grid/subgrid/abs-pos-003-expected.html: 10 * web-platform-tests/css/css-grid/subgrid/line-names-008.html: 11 * web-platform-tests/css/css-grid/subgrid/parent-repeat-auto-fit-001.html: 12 * web-platform-tests/css/css-grid/subgrid/parent-repeat-auto-fit-002.html: 13 1 14 2022-02-17 Noam Rosenthal <noam@webkit.org> 2 15 -
trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/subgrid/abs-pos-002-expected.html
r262056 r290096 62 62 <i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i> 63 63 <div class="subgrid"> 64 <x style="grid-column:3; right: 27px">x</x>64 <x style="grid-column:3; right:33px">x</x> 65 65 </div> 66 66 </div> … … 118 118 <i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i> 119 119 <div class="subgrid hr"> 120 <x style="grid-column:auto/1; left:- 27px">x</x>120 <x style="grid-column:auto/1; left:-33px">x</x> 121 121 </div> 122 122 </div> -
trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/subgrid/abs-pos-003-expected.html
r262056 r290096 39 39 inset: 0; 40 40 background: purple; 41 }42 43 .a > .t1 > x {44 margin: -10px 0 0 -10px;45 }46 .a > .t2 > x,47 .c > .t2 > x,48 .c > .t1 > x {49 margin: 0 0 0 -10px;50 41 } 51 42 -
trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/subgrid/line-names-008.html
r262056 r290096 147 147 </div> 148 148 149 <div class="grid" style="grid-template-columns: repeat(3,30px) [a] 30px repeat(7,30px)">149 <div class="grid" style="grid-template-columns: 30px [a] repeat(2,30px) [a] 30px repeat(7,30px)"> 150 150 <n></n><n></n><n></n><n></n><n></n><n></n><n></n><n></n><n></n><n></n> 151 151 <div class="hr" style="grid-template-columns: subgrid [] [] [] [] [a]; grid-column:2/span 6"> … … 154 154 </div> 155 155 156 <div class="grid" style="grid-template-columns: repeat(3,30px) [a] 30px repeat(7,30px)">156 <div class="grid" style="grid-template-columns: 30px [a] repeat(2,30px) [a] 30px repeat(7,30px)"> 157 157 <n></n><n></n><n></n><n></n><n></n><n></n><n></n><n></n><n></n><n></n> 158 158 <div class="hr" style="grid-template-columns: subgrid [] [] [] [] [a]; grid-column:2/span 6"> -
trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/subgrid/parent-repeat-auto-fit-001.html
r262056 r290096 436 436 <script> 437 437 const expectedResults = [ 438 "[y] 0px [z] 1px [z] 1px [z] 1px [z] 1px [z] ",439 "[x y] 0px [z] 1px [z] 1px [z] 1px [z] ",438 "[y] 0px [z] 1px [z] 1px [z] 1px [z] 1px [z] 46px", 439 "[x y] 0px [z] 1px [z] 1px [z] 1px [z] 23.5px 23.5px", 440 440 "[x] 1px [x y] 0px [y] 10px [y] 10px [y] 10px [z] 1px [z] 1px [z]", 441 441 "[x] 2px [x] 2px [x y] 10px [y] 10px [y] 10px [y] 10px [z] 1px [z]", … … 455 455 "[x] 2px [x] 2px [x] 2px [x y] 10px [y] 10px [y] 10px [y] 0px", 456 456 "[y] 0px [y] 0px [y] 10px [y] 10px [z] 1px [z] 1px [z]", 457 "[x y] 0px [y] 0px [y] 10px [y] 10px [z] 1px [z] ",458 "[x] 2px [x y] 0px [y] 10px [y] 10px [y] 10px [z] ",457 "[x y] 0px [y] 0px [y] 10px [y] 10px [z] 1px [z] 29px", 458 "[x] 2px [x y] 0px [y] 10px [y] 10px [y] 10px [z] 18px", 459 459 "[x] 2px [x] 2px [x y] 10px [y] 10px [y] 10px [y] 10px", 460 "[y] 0px [y] 0px [y] 10px [y] 10px [z] 1px [z] ",461 "[x y] 0px [y] 0px [y] 10px [y] 10px [y] 10px [z] ",462 "[x] 2px [x y] 0px [y] 10px [y] 10px [y] 10px ",463 "[y] 0px [y] 0px [y] 10px [y] 10px [y] 10px [z] ",464 "[x y] 0px [y] 0px [y] 10px [y] 10px [y] 10px ",465 "[y] 0px [y] 0px [y] 10px [y] 10px [y] 10px ",460 "[y] 0px [y] 0px [y] 10px [y] 10px [z] 1px [z] 29px", 461 "[x y] 0px [y] 0px [y] 10px [y] 10px [y] 10px [z] 20px", 462 "[x] 2px [x y] 0px [y] 10px [y] 10px [y] 10px 18px", 463 "[y] 0px [y] 0px [y] 10px [y] 10px [y] 10px [z] 20px", 464 "[x y] 0px [y] 0px [y] 10px [y] 10px [y] 10px 20px", 465 "[y] 0px [y] 0px [y] 10px [y] 10px [y] 10px 20px", 466 466 ]; 467 467 [...document.querySelectorAll('.grid')].forEach(function(grid, i) { -
trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/subgrid/parent-repeat-auto-fit-002.html
r262056 r290096 440 440 <script> 441 441 const expectedResults = [ 442 "[y] 0px [z] 1px [z] 1px [z] 1px [z] 1px [z] ",443 "[x y] 0px [z] 1px [z] 1px [z] 1px [z] ",442 "[y] 0px [z] 1px [z] 1px [z] 1px [z] 1px [z] 46px", 443 "[x y] 0px [z] 1px [z] 1px [z] 1px [z] 23.5px 23.5px", 444 444 "[x] 1px [x y] 0px [y] 10px [y] 10px [y] 10px [z] 1px [z] 1px [z]", 445 445 "[x] 2px [x] 2px [x y] 10px [y] 10px [y] 10px [y] 10px [z] 1px [z]", … … 459 459 "[x] 2px [x] 2px [x] 2px [x y] 10px [y] 10px [y] 10px [y] 0px", 460 460 "[y] 0px [y] 0px [y] 10px [y] 10px [z] 1px [z] 1px [z]", 461 "[x y] 0px [y] 0px [y] 10px [y] 10px [z] 1px [z] ",462 "[x] 2px [x y] 0px [y] 10px [y] 10px [y] 10px [z] ",461 "[x y] 0px [y] 0px [y] 10px [y] 10px [z] 1px [z] 29px", 462 "[x] 2px [x y] 0px [y] 10px [y] 10px [y] 10px [z] 18px", 463 463 "[x] 2px [x] 2px [x y] 10px [y] 10px [y] 10px [y] 10px", 464 "[y] 0px [y] 0px [y] 10px [y] 10px [z] 1px [z] ",465 "[x y] 0px [y] 0px [y] 10px [y] 10px [y] 10px [z] ",466 "[x] 2px [x y] 0px [y] 10px [y] 10px [y] 10px ",467 "[y] 0px [y] 0px [y] 10px [y] 10px [y] 10px [z] ",468 "[x y] 0px [y] 0px [y] 10px [y] 10px [y] 10px ",469 "[y] 0px [y] 0px [y] 10px [y] 10px [y] 10px ",464 "[y] 0px [y] 0px [y] 10px [y] 10px [z] 1px [z] 29px", 465 "[x y] 0px [y] 0px [y] 10px [y] 10px [y] 10px [z] 20px", 466 "[x] 2px [x y] 0px [y] 10px [y] 10px [y] 10px 18px", 467 "[y] 0px [y] 0px [y] 10px [y] 10px [y] 10px [z] 20px", 468 "[x y] 0px [y] 0px [y] 10px [y] 10px [y] 10px 20px", 469 "[y] 0px [y] 0px [y] 10px [y] 10px [y] 10px 20px", 470 470 ]; 471 471 [...document.querySelectorAll('.grid')].forEach(function(grid, i) { -
trunk/Source/WebCore/ChangeLog
r290089 r290096 1 2022-02-17 Matt Woodrow <mattwoodrow@apple.com> 2 3 Account for subgrid MBP when sizing 4 https://bugs.webkit.org/show_bug.cgi?id=236338 5 6 Reviewed by Dean Jackson. 7 8 Adds extra margin to subgrid items participating in the sizing of an outer 9 grid's tracks to account for the margin/border/padding of the intermediate 10 subgrid item itself. 11 Also contributes the subgrid's m/b/p to the edge tracks it cover, even 12 if no inner items occupy that track. 13 14 * rendering/GridLayoutFunctions.cpp: 15 (WebCore::GridLayoutFunctions::directionFromSide): 16 (WebCore::GridLayoutFunctions::hasRelativeOrIntrinsicSizeForChild): 17 (WebCore::GridLayoutFunctions::extraMarginForSubgridChild): 18 (WebCore::GridLayoutFunctions::gapDifferenceForSubgridChild): 19 (WebCore::GridLayoutFunctions::marginLogicalSizeForChild): 20 * rendering/GridTrackSizingAlgorithm.cpp: 21 (WebCore::setOverridingContainingBlockContentSizeForChild): 22 (WebCore::GridTrackSizingAlgorithmStrategy::logicalHeightForChild const): 23 (WebCore::GridTrackSizingAlgorithmStrategy::updateOverridingContainingBlockContentSizeForChild const): 24 (WebCore::DefiniteSizeStrategy::minLogicalSizeForChild const): 25 (WebCore::DefiniteSizeStrategy::minContentForChild const): 26 (WebCore::addSubgridMarginBorderPadding): 27 (WebCore::GridTrackSizingAlgorithm::accumulateIntrinsicSizesForTrack): 28 * rendering/RenderGrid.cpp: 29 (WebCore::RenderGrid::isSubgrid const): 30 (WebCore::RenderGrid::mayBeSubgridExcludingAbsPos const): 31 (WebCore::RenderGrid::gridSpanCoversRealTracks const): 32 (WebCore::RenderGrid::gridAreaBreadthForOutOfFlowChild): 33 (WebCore::RenderGrid::computeContentPositionAndDistributionOffset): 34 (WebCore::RenderGrid::gridSpanForChild const): 35 * rendering/RenderGrid.h: 36 * rendering/style/GridPositionsResolver.cpp: 37 (WebCore::adjustGridPositionsFromStyle): 38 1 39 2022-02-17 J Pascoe <j_pascoe@apple.com> 2 40 -
trunk/Source/WebCore/rendering/GridLayoutFunctions.cpp
r290007 r290096 67 67 } 68 68 69 static inline GridTrackSizingDirection directionFromSide(GridPositionSide side) 70 { 71 return side == ColumnStartSide || side == ColumnEndSide ? ForColumns : ForRows; 72 } 73 74 static bool hasRelativeOrIntrinsicSizeForChild(const RenderBox& child, GridTrackSizingDirection direction) 75 { 76 if (direction == ForColumns) 77 return child.hasRelativeLogicalWidth() || child.style().logicalWidth().isIntrinsicOrAuto(); 78 return child.hasRelativeLogicalHeight() || child.style().logicalHeight().isIntrinsicOrAuto(); 79 } 80 81 static LayoutUnit extraMarginForSubgrid(const RenderGrid& parent, unsigned startLine, unsigned endLine, GridTrackSizingDirection direction) 82 { 83 unsigned numTracks = parent.numTracks(direction); 84 if (!numTracks || !parent.isSubgrid(direction)) 85 return 0_lu; 86 87 std::optional<LayoutUnit> availableSpace; 88 if (!hasRelativeOrIntrinsicSizeForChild(parent, direction)) 89 availableSpace = parent.availableSpaceForGutters(direction); 90 91 RenderGrid& grandParent = downcast<RenderGrid>(*parent.parent()); 92 LayoutUnit mbp; 93 if (!startLine) 94 mbp += (direction == ForColumns) ? parent.marginAndBorderAndPaddingStart() : parent.marginAndBorderAndPaddingBefore(); 95 else 96 mbp += (parent.gridGap(direction, availableSpace) - grandParent.gridGap(direction)) / 2; 97 98 if (endLine == numTracks) 99 mbp += (direction == ForColumns) ? parent.marginAndBorderAndPaddingEnd() : parent.marginAndBorderAndPaddingAfter(); 100 else 101 mbp += (parent.gridGap(direction, availableSpace) - grandParent.gridGap(direction)) / 2; 102 103 return mbp; 104 } 105 106 static LayoutUnit extraMarginForSubgridAncestors(GridTrackSizingDirection direction, const RenderBox& child) 107 { 108 const RenderGrid* grid = downcast<RenderGrid>(child.parent()); 109 LayoutUnit mbp; 110 111 while (grid->isSubgrid(direction)) { 112 GridSpan span = grid->gridSpanForChild(child, direction); 113 114 mbp += extraMarginForSubgrid(*grid, span.startLine(), span.endLine(), direction); 115 116 const RenderElement* parent = grid->parent(); 117 if (!parent || !is<RenderGrid>(parent)) 118 break; 119 120 const RenderGrid* parentGrid = downcast<RenderGrid>(parent); 121 direction = flowAwareDirectionForParent(*grid, *parentGrid, direction); 122 123 grid = parentGrid; 124 } 125 126 return mbp; 127 } 128 69 129 LayoutUnit marginLogicalSizeForChild(const RenderGrid& grid, GridTrackSizingDirection direction, const RenderBox& child) 70 130 { 131 LayoutUnit margin; 71 132 if (child.needsLayout()) 72 return computeMarginLogicalSizeForChild(grid, direction, child); 73 GridTrackSizingDirection flowAwareDirection = flowAwareDirectionForChild(grid, child, direction); 74 bool isRowAxis = flowAwareDirection == ForColumns; 75 LayoutUnit marginStart = marginStartIsAuto(child, flowAwareDirection) ? 0_lu : isRowAxis ? child.marginStart() : child.marginBefore(); 76 LayoutUnit marginEnd = marginEndIsAuto(child, flowAwareDirection) ? 0_lu : isRowAxis ? child.marginEnd() : child.marginAfter(); 77 return marginStart + marginEnd; 133 margin = computeMarginLogicalSizeForChild(grid, direction, child); 134 else { 135 GridTrackSizingDirection flowAwareDirection = flowAwareDirectionForChild(grid, child, direction); 136 bool isRowAxis = flowAwareDirection == ForColumns; 137 LayoutUnit marginStart = marginStartIsAuto(child, flowAwareDirection) ? 0_lu : isRowAxis ? child.marginStart() : child.marginBefore(); 138 LayoutUnit marginEnd = marginEndIsAuto(child, flowAwareDirection) ? 0_lu : isRowAxis ? child.marginEnd() : child.marginAfter(); 139 margin = marginStart + marginEnd; 140 } 141 142 if (&grid != child.parent()) 143 margin += extraMarginForSubgridAncestors(direction, child); 144 145 return margin; 78 146 } 79 147 -
trunk/Source/WebCore/rendering/GridTrackSizingAlgorithm.cpp
r290077 r290096 126 126 } 127 127 128 static void setOverridingContainingBlockContentSizeForChild(RenderBox& child, GridTrackSizingDirection direction, std::optional<LayoutUnit> size) 129 { 128 static void setOverridingContainingBlockContentSizeForChild(const RenderGrid& grid, RenderBox& child, GridTrackSizingDirection direction, std::optional<LayoutUnit> size) 129 { 130 // This function sets the dimension based on the writing mode of the containing block. 131 // For subgrids, this might not be the outermost grid, but could be a subgrid. If the 132 // writing mode of the CB and the grid for which we're doing sizing don't match, swap 133 // the directions. 134 direction = GridLayoutFunctions::flowAwareDirectionForChild(grid, *child.containingBlock(), direction); 130 135 if (direction == ForColumns) 131 136 child.setOverridingContainingBlockContentLogicalWidth(size); … … 795 800 // what we are interested in here. Thus we need to set the block-axis override size to nullopt (no possible resolution). 796 801 if (shouldClearOverridingContainingBlockContentSizeForChild(child, ForRows)) { 797 setOverridingContainingBlockContentSizeForChild( child, childBlockDirection, std::nullopt);802 setOverridingContainingBlockContentSizeForChild(*renderGrid(), child, childBlockDirection, std::nullopt); 798 803 child.setNeedsLayout(MarkOnlyThis); 799 804 } … … 960 965 if (!overrideSize) 961 966 overrideSize = m_algorithm.gridAreaBreadthForChild(child, direction); 967 962 968 if (GridLayoutFunctions::hasOverridingContainingBlockContentSizeForChild(child, direction) && GridLayoutFunctions::overridingContainingBlockContentSizeForChild(child, direction) == overrideSize) 963 969 return false; 964 970 965 setOverridingContainingBlockContentSizeForChild( child, direction, overrideSize);971 setOverridingContainingBlockContentSizeForChild(*renderGrid(), child, direction, overrideSize); 966 972 return true; 967 973 } … … 1123 1129 if (hasRelativeMarginOrPaddingForChild(child, flowAwareDirection) || (direction() != childInlineDirection && hasRelativeOrIntrinsicSizeForChild(child, flowAwareDirection))) { 1124 1130 auto indefiniteSize = direction() == childInlineDirection ? std::make_optional(0_lu) : std::nullopt; 1125 setOverridingContainingBlockContentSizeForChild( child, direction(), indefiniteSize);1131 setOverridingContainingBlockContentSizeForChild(*renderGrid(), child, direction(), indefiniteSize); 1126 1132 } 1127 1133 return GridTrackSizingAlgorithmStrategy::minLogicalSizeForChild(child, childMinSize, availableSize); … … 1168 1174 GridTrackSizingDirection childInlineDirection = GridLayoutFunctions::flowAwareDirectionForChild(*renderGrid(), child, ForColumns); 1169 1175 if (direction() == childInlineDirection && child.needsLayout() && shouldClearOverridingContainingBlockContentSizeForChild(child, ForColumns)) 1170 setOverridingContainingBlockContentSizeForChild( child, childInlineDirection, LayoutUnit());1176 setOverridingContainingBlockContentSizeForChild(*renderGrid(), child, childInlineDirection, LayoutUnit()); 1171 1177 return GridTrackSizingAlgorithmStrategy::minContentForChild(child); 1172 1178 } … … 1223 1229 } 1224 1230 1231 static LayoutUnit marginAndBorderAndPaddingForEdge(const RenderGrid& grid, GridTrackSizingDirection direction, bool startEdge) 1232 { 1233 if (direction == ForColumns) 1234 return startEdge ? grid.marginAndBorderAndPaddingStart() : grid.marginAndBorderAndPaddingEnd(); 1235 return startEdge ? grid.marginAndBorderAndPaddingBefore() : grid.marginAndBorderAndPaddingAfter(); 1236 } 1237 1238 // https://drafts.csswg.org/css-grid-2/#subgrid-edge-placeholders 1239 // FIXME: This is a simplification of the specified behaviour, where we add the hypothetical 1240 // items directly to the edge tracks as if they had a span of 1. This matches the current Gecko 1241 // behavior. 1242 static void addSubgridMarginBorderPadding(const RenderGrid* outermost, GridTrackSizingDirection outermostDirection, Vector<GridTrack>& allTracks, GridSpan& span, RenderGrid* subgrid) 1243 { 1244 // Convert the direction into the coordinate space of subgrid (which may not be a direct child 1245 // of the outermost grid for which we're running the track sizing algorithm). 1246 GridTrackSizingDirection direction = GridLayoutFunctions::flowAwareDirectionForChild(*outermost, *subgrid, outermostDirection); 1247 bool reversed = GridLayoutFunctions::isSubgridReversedDirection(*outermost, outermostDirection, *subgrid); 1248 1249 if (allTracks[span.startLine()].cachedTrackSize().hasIntrinsicMinTrackBreadth()) { 1250 // If the subgrid has a reversed flow direction relative to the outermost grid, then 1251 // we want the MBP from the end edge in its local coordinate space. 1252 LayoutUnit mbpStart = marginAndBorderAndPaddingForEdge(*subgrid, direction, !reversed); 1253 allTracks[span.startLine()].setBaseSize(std::max(allTracks[span.startLine()].baseSize(), mbpStart)); 1254 } 1255 if (allTracks[span.endLine() - 1].cachedTrackSize().hasIntrinsicMinTrackBreadth()) { 1256 LayoutUnit mbpEnd = marginAndBorderAndPaddingForEdge(*subgrid, direction, reversed); 1257 allTracks[span.endLine() - 1].setBaseSize(std::max(allTracks[span.endLine() - 1].baseSize(), mbpEnd)); 1258 } 1259 } 1260 1225 1261 void GridTrackSizingAlgorithm::accumulateIntrinsicSizesForTrack(GridTrack& track, GridIterator& iterator, Vector<GridItemWithSpan>& itemsSortedByIncreasingSpan, Vector<GridItemWithSpan>& itemsCrossingFlexibleTracks, HashSet<RenderBox*>& itemsSet) 1226 1262 { 1263 Vector<GridTrack>& allTracks = tracks(m_direction); 1264 1227 1265 while (auto* gridItem = iterator.nextGridItem()) { 1228 1266 bool isNewEntry = itemsSet.add(gridItem).isNewEntry; 1229 1267 if (is<RenderGrid>(gridItem) && downcast<RenderGrid>(gridItem)->isSubgridInParentDirection(iterator.direction())) { 1268 // Contribute the mbp of wrapper to the first and last tracks that we span. 1230 1269 RenderGrid* inner = downcast<RenderGrid>(gridItem); 1270 if (isNewEntry) { 1271 GridSpan span = m_renderGrid->gridSpanForChild(*gridItem, m_direction); 1272 addSubgridMarginBorderPadding(m_renderGrid, m_direction, allTracks, span, inner); 1273 } 1231 1274 1232 1275 GridIterator childIterator = GridIterator::createForSubgrid(*inner, iterator); -
trunk/Source/WebCore/rendering/RenderGrid.cpp
r290077 r290096 1654 1654 bool RenderGrid::isSubgrid(GridTrackSizingDirection direction) const 1655 1655 { 1656 if ( isOutOfFlowPositioned() || isExcludedFromNormalLayout())1656 if (!mayBeSubgridExcludingAbsPos(direction)) 1657 1657 return false; 1658 if ((direction == ForColumns) ? !style().gridSubgridColumns() : !style().gridSubgridRows()) 1659 return false; 1660 return is<RenderGrid>(parent()); 1658 return downcast<RenderGrid>(parent())->gridSpanCoversRealTracks(*this, direction); 1661 1659 } 1662 1660 … … 1667 1665 GridTrackSizingDirection direction = GridLayoutFunctions::flowAwareDirectionForChild(*downcast<RenderGrid>(parent()), *this, parentDirection); 1668 1666 return isSubgrid(direction); 1667 } 1668 1669 bool RenderGrid::mayBeSubgridExcludingAbsPos(GridTrackSizingDirection direction) const 1670 { 1671 // Should exclude cases where we establish an IFC, like contain layout. 1672 if (isExcludedFromNormalLayout()) 1673 return false; 1674 if (direction == ForColumns ? !style().gridSubgridColumns() : !style().gridSubgridRows()) 1675 return false; 1676 if (!is<RenderGrid>(parent())) 1677 return false; 1678 return true; 1669 1679 } 1670 1680 … … 1853 1863 auto& offset = 1854 1864 isRowAxis ? m_offsetBetweenColumns : m_offsetBetweenRows; 1865 if (isRowAxis ? isSubgridColumns() : isSubgridRows()) { 1866 offset.positionOffset = 0_lu; 1867 offset.distributionOffset = 0_lu; 1868 return; 1869 } 1855 1870 auto contentAlignmentData = contentAlignment(direction); 1856 1871 auto position = contentAlignmentData.position(); … … 2096 2111 } 2097 2112 2113 bool RenderGrid::gridSpanCoversRealTracks(const RenderBox& child, GridTrackSizingDirection direction) const 2114 { 2115 // Only out of flow positioned items can span to the special line that covers 2116 // the padding area. 2117 if (!child.isOutOfFlowPositioned()) 2118 return true; 2119 2120 int lastLine = numTracks(direction, m_grid); 2121 int startLine, endLine; 2122 bool startIsAuto, endIsAuto; 2123 if (!computeGridPositionsForOutOfFlowChild(child, direction, startLine, startIsAuto, endLine, endIsAuto)) 2124 return lastLine > 0; 2125 2126 // If the resulting span covers only the padding area, then it's not a real 2127 // track that could be used for a subgrid. 2128 if (startIsAuto && !endLine) 2129 return false; 2130 if (endIsAuto && startLine == lastLine) 2131 return false; 2132 return true; 2133 } 2134 2098 2135 } // namespace WebCore -
trunk/Source/WebCore/rendering/RenderGrid.h
r290077 r290096 97 97 } 98 98 bool isSubgridInParentDirection(GridTrackSizingDirection parentDirection) const; 99 bool mayBeSubgridExcludingAbsPos(GridTrackSizingDirection) const; 99 100 100 101 const Grid& currentGrid() const … … 109 110 110 111 void placeItems(); 112 113 std::optional<LayoutUnit> availableSpaceForGutters(GridTrackSizingDirection) const; 114 LayoutUnit gridGap(GridTrackSizingDirection) const; 115 LayoutUnit gridGap(GridTrackSizingDirection, std::optional<LayoutUnit> availableSize) const; 111 116 112 117 private: … … 125 130 bool selfAlignmentChangedToStretch(GridAxis, const RenderStyle& oldStyle, const RenderStyle& newStyle, const RenderBox&) const; 126 131 bool selfAlignmentChangedFromStretch(GridAxis, const RenderStyle& oldStyle, const RenderStyle& newStyle, const RenderBox&) const; 127 128 std::optional<LayoutUnit> availableSpaceForGutters(GridTrackSizingDirection) const;129 132 130 133 bool explicitGridDidResize(const RenderStyle&) const; … … 207 210 LayoutUnit rowAxisBaselineOffsetForChild(const RenderBox&) const; 208 211 209 LayoutUnit gridGap(GridTrackSizingDirection) const;210 LayoutUnit gridGap(GridTrackSizingDirection, std::optional<LayoutUnit> availableSize) const;211 212 212 unsigned nonCollapsedTracks(GridTrackSizingDirection) const; 213 213 unsigned numTracks(GridTrackSizingDirection, const Grid&) const; … … 223 223 224 224 GridSpan gridSpanForOutOfFlowChild(const RenderBox&, GridTrackSizingDirection) const; 225 225 226 bool computeGridPositionsForOutOfFlowChild(const RenderBox&, GridTrackSizingDirection, int&, bool&, int&, bool&) const; 227 bool gridSpanCoversRealTracks(const RenderBox&, GridTrackSizingDirection) const; 226 228 227 229 Grid m_grid; -
trunk/Source/WebCore/rendering/style/GridPositionsResolver.cpp
r289998 r290096 381 381 initialPosition.setSpanPosition(1, String()); 382 382 383 if (isIndefiniteSpan(initialPosition, finalPosition) && is<RenderGrid>(gridItem) && downcast<RenderGrid>(gridItem).isSubgrid(direction)) { 383 // Absolutely positioned items specifying subgrid might not actually be a subgrid if their grid 384 // span doesn't cover any tracks and only the padding area. We don't know if that is the case until 385 // we've figured out their grid position though, which is what we're trying to do now. 386 if (isIndefiniteSpan(initialPosition, finalPosition) && is<RenderGrid>(gridItem) && downcast<RenderGrid>(gridItem).mayBeSubgridExcludingAbsPos(direction)) { 384 387 // Indefinite span for an item that is subgridded in this axis. 385 388 int lineCount = (isForColumns ? gridItem.style().orderedNamedGridColumnLines() : gridItem.style().orderedNamedGridRowLines()).size();
Note: See TracChangeset
for help on using the changeset viewer.