Commit 02fbf24b authored by Kurt Catti-Schmidt (SCHMIDT)'s avatar Kurt Catti-Schmidt (SCHMIDT) Committed by Commit Bot

[GridNG] 'auto' grid block sizing

This change completes a TODO for auto-sizing the grid container for
the block direction. This is implemented by using the resolved
row/column definitions to determine the total intrinsic grid
block size.

'auto' inline sizes for the grid block will be addressed separately,
as that will be calculated in ComputeMinMaxSizes and will require
some refactoring to maintain const-ness.

After this change, the grid-gutters (gap) WPT tests mostly pass.
The only remaining failures have to do with % and calc sized gutters,
which these changes will also be a prerequisite for. A number of other
TestExpectations failures were able to be removed as well.

Bug: 1045599
Change-Id: I6136c8daa6501facac67281ac5cb493bb07a34d1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2488665Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Commit-Queue: Ian Kilpatrick <ikilpatrick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#821571}
parent 0c59d7a7
......@@ -89,17 +89,16 @@ scoped_refptr<const NGLayoutResult> NGGridLayoutAlgorithm::Layout() {
}
}
// TODO(ansollan): Calculate the intrinsic-block-size from the tracks.
LayoutUnit intrinsic_block_size = BorderScrollbarPadding().BlockSum();
intrinsic_block_size =
intrinsic_block_size_ =
ClampIntrinsicBlockSize(ConstraintSpace(), Node(),
BorderScrollbarPadding(), intrinsic_block_size);
BorderScrollbarPadding(), intrinsic_block_size_);
container_builder_.SetIntrinsicBlockSize(intrinsic_block_size_);
LayoutUnit block_size = ComputeBlockSizeForFragment(
ConstraintSpace(), Style(), BorderPadding(), intrinsic_block_size,
ConstraintSpace(), Style(), BorderPadding(), intrinsic_block_size_,
border_box_size_.inline_size);
container_builder_.SetIntrinsicBlockSize(intrinsic_block_size);
container_builder_.SetFragmentsTotalBlockSize(block_size);
NGOutOfFlowLayoutPart(Node(), ConstraintSpace(), &container_builder_).Run();
return container_builder_.ToBoxFragment();
}
......@@ -1129,6 +1128,11 @@ void NGGridLayoutAlgorithm::PlaceGridItems() {
row_set_offsets.push_back(row_set_offset);
}
// Store the total size of row definitions (summed with
// BorderScrollbarPadding) as the intrinsic block size.
intrinsic_block_size_ = BorderScrollbarPadding().BlockSum() +
(row_set_offsets.back() - row_grid_gap);
for (GridItemData& grid_item : grid_items_) {
wtf_size_t column_start_index = grid_item.columns_begin_set_index;
wtf_size_t column_end_index = grid_item.columns_end_set_index;
......
......@@ -194,6 +194,7 @@ class CORE_EXPORT NGGridLayoutAlgorithm
GridLayoutAlgorithmState state_;
LogicalSize border_box_size_;
LogicalSize child_percentage_size_;
LayoutUnit intrinsic_block_size_;
Vector<GridItemData> grid_items_;
Vector<GridItemData> out_of_flow_items_;
......
......@@ -1517,8 +1517,8 @@ TEST_F(NGGridLayoutAlgorithmTest, AutoSizedGridWithGap) {
String dump = DumpFragmentTree(GetElementById("wrapper"));
String expectation = R"DUMP(.:: LayoutNG Physical Fragment Tree ::.
offset:unplaced size:1000x0
offset:0,0 size:1000x0
offset:unplaced size:1000x275
offset:0,0 size:1000x275
offset:0,0 size:100x100
offset:0,0 size:10x10
offset:150,0 size:200x100
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment