Commit 49290ced authored by Ian Kilpatrick's avatar Ian Kilpatrick Committed by Chromium LUCI CQ

[LayoutNG] Fix %-block-size for ComputeMinMaxSizes.

Previously we had two separate issues.
1) We were using border/padding to determine the %-block-size rather
   than border/scrollbar/padding.
2) For OOF nodes, we weren't subtracting the border/scrollbar/padding
   at all.

This patch fixes both these issues.

Bug: 1060904, 1158406
Change-Id: I266d69725c6cecdb0888e29489e46f1a82ffccc6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2641294
Commit-Queue: Ian Kilpatrick <ikilpatrick@chromium.org>
Reviewed-by: default avatarChristian Biesinger <cbiesinger@chromium.org>
Reviewed-by: default avatarMorten Stenshorne <mstensho@chromium.org>
Cr-Commit-Position: refs/heads/master@{#845906}
parent 16d842a0
......@@ -771,9 +771,9 @@ MinMaxSizesResult NGBlockNode::ComputeMinMaxSizes(
block_size = input.percentage_resolution_block_size;
}
NGFragmentGeometry fragment_geometry =
const NGFragmentGeometry fragment_geometry =
CalculateInitialMinMaxFragmentGeometry(*constraint_space, *this);
NGBoxStrut border_padding =
const NGBoxStrut border_padding =
fragment_geometry.border + fragment_geometry.padding;
LayoutUnit size_from_ar = ComputeInlineSizeFromAspectRatio(
*constraint_space, Style(), border_padding, block_size);
......@@ -801,7 +801,7 @@ MinMaxSizesResult NGBlockNode::ComputeMinMaxSizes(
return {sizes, depends_on_percentage_block_size};
}
NGFragmentGeometry fragment_geometry =
const NGFragmentGeometry fragment_geometry =
CalculateInitialMinMaxFragmentGeometry(*constraint_space, *this);
// Calculate the %-block-size for our children up front. This allows us to
......@@ -811,7 +811,7 @@ MinMaxSizesResult NGBlockNode::ComputeMinMaxSizes(
bool uses_input_percentage_block_size = false;
LayoutUnit child_percentage_resolution_block_size =
CalculateChildPercentageBlockSizeForMinMax(
*constraint_space, *this, border_padding,
*constraint_space, *this, border_padding, fragment_geometry.scrollbar,
input.percentage_resolution_block_size,
&uses_input_percentage_block_size);
......
......@@ -1395,38 +1395,46 @@ LayoutUnit CalculateChildPercentageBlockSizeForMinMax(
const NGConstraintSpace& space,
const NGBlockNode node,
const NGBoxStrut& border_padding,
const NGBoxStrut& scrollbar,
LayoutUnit input_percentage_block_size,
bool* uses_input_percentage_block_size) {
*uses_input_percentage_block_size = false;
// Anonymous block or spaces should pass the percent size straight through.
// If this node is OOF-positioned, our size was pre-calculated and we should
// pass this through to our children.
if (space.IsAnonymous() || node.IsAnonymousBlock() ||
node.IsOutOfFlowPositioned()) {
if (space.IsAnonymous() || node.IsAnonymousBlock()) {
*uses_input_percentage_block_size = true;
return input_percentage_block_size;
}
const ComputedStyle& style = node.Style();
LayoutUnit block_size = ComputeBlockSizeForFragmentInternal(
space, style, border_padding,
CalculateDefaultBlockSize(space, node, border_padding),
/* inline_size */ base::nullopt,
/* available_block_size_adjustment */ LayoutUnit(),
&input_percentage_block_size);
if (style.LogicalMinHeight().IsPercentOrCalc() ||
style.LogicalHeight().IsPercentOrCalc() ||
style.LogicalMaxHeight().IsPercentOrCalc())
const NGBoxStrut& border_scrollbar_padding = border_padding + scrollbar;
LayoutUnit block_size;
if (node.IsOutOfFlowPositioned()) {
// If this node is OOF-positioned, our size was pre-calculated.
block_size = input_percentage_block_size;
*uses_input_percentage_block_size = true;
} else {
block_size = ComputeBlockSizeForFragmentInternal(
space, style, border_padding,
CalculateDefaultBlockSize(space, node, border_scrollbar_padding),
/* inline_size */ base::nullopt,
/* available_block_size_adjustment */ LayoutUnit(),
&input_percentage_block_size);
if (style.LogicalMinHeight().IsPercentOrCalc() ||
style.LogicalHeight().IsPercentOrCalc() ||
style.LogicalMaxHeight().IsPercentOrCalc())
*uses_input_percentage_block_size = true;
}
LayoutUnit child_percentage_block_size =
block_size == kIndefiniteSize
? kIndefiniteSize
: (block_size - border_padding.BlockSum()).ClampNegativeToZero();
: (block_size - border_scrollbar_padding.BlockSum())
.ClampNegativeToZero();
// For OOF-positioned nodes, use the parent (containing-block) size.
// In quirks mode some 'auto' block-size nodes pass the %-block-size through.
if (child_percentage_block_size == kIndefiniteSize &&
node.UseParentPercentageResolutionBlockSizeForChildren()) {
*uses_input_percentage_block_size = true;
......
......@@ -618,6 +618,7 @@ LayoutUnit CalculateChildPercentageBlockSizeForMinMax(
const NGConstraintSpace& constraint_space,
const NGBlockNode node,
const NGBoxStrut& border_padding,
const NGBoxStrut& scrollbar,
LayoutUnit input_percentage_block_size,
bool* uses_input_percentage_block_size);
......
......@@ -548,7 +548,6 @@ crbug.com/417223 external/wpt/css/css-position/position-relative-table-tr-top.ht
crbug.com/1164135 external/wpt/css/css-sizing/aspect-ratio/flex-aspect-ratio-025.html [ Failure ]
crbug.com/1164135 external/wpt/css/css-sizing/aspect-ratio/flex-aspect-ratio-026.html [ Failure ]
crbug.com/1164474 external/wpt/css/css-sizing/aspect-ratio/table-element-001.html [ Failure ]
crbug.com/1158406 external/wpt/css/css-sizing/intrinsic-percent-replaced-009.html [ Failure ]
crbug.com/1008951 external/wpt/css/css-text-decor/text-decoration-subelements-002.html [ Failure ]
crbug.com/1008951 external/wpt/css/css-text-decor/text-decoration-subelements-003.html [ Failure ]
......
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