Commit 3ed7a074 authored by Ian Kilpatrick's avatar Ian Kilpatrick Committed by Commit Bot

[cleanup] Remove NGMinMaxSizeType.

... and places adjustment within:
LayoutNGMixin<Base>::ComputeIntrinsicLogicalWidths

Previously ComputeMinMaxSize could work in two different modes,
one to return the border-box min/max sizes, and one for the content-box.

This was primarily to support ComputeIntrinsicLogicalWidths.

This patch removes this enum, and instead places the adjustment logic
within ComputeIntrinsicLogicalWidths.

Change-Id: I1bf839e5afc5f7a7241749b9e9eeb34d50fc77ce
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2031533Reviewed-by: default avatarChristian Biesinger <cbiesinger@chromium.org>
Reviewed-by: default avatarMorten Stenshorne <mstensho@chromium.org>
Commit-Queue: Ian Kilpatrick <ikilpatrick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#739082}
parent 083daae1
...@@ -77,9 +77,6 @@ base::Optional<MinMaxSize> NGCustomLayoutAlgorithm::ComputeMinMaxSize( ...@@ -77,9 +77,6 @@ base::Optional<MinMaxSize> NGCustomLayoutAlgorithm::ComputeMinMaxSize(
sizes.max_size, LayoutUnit::FromDoubleRound( sizes.max_size, LayoutUnit::FromDoubleRound(
intrinsic_sizes_result_options->minContentSize())); intrinsic_sizes_result_options->minContentSize()));
if (input.size_type == NGMinMaxSizeType::kContentBoxSize)
sizes -= border_scrollbar_padding_.InlineSum();
sizes.min_size.ClampNegativeToZero(); sizes.min_size.ClampNegativeToZero();
sizes.max_size.ClampNegativeToZero(); sizes.max_size.ClampNegativeToZero();
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "third_party/blink/renderer/core/layout/ng/layout_box_utils.h" #include "third_party/blink/renderer/core/layout/ng/layout_box_utils.h"
#include "third_party/blink/renderer/core/layout/ng/ng_box_fragment_builder.h" #include "third_party/blink/renderer/core/layout/ng/ng_box_fragment_builder.h"
#include "third_party/blink/renderer/core/layout/ng/ng_constraint_space.h" #include "third_party/blink/renderer/core/layout/ng/ng_constraint_space.h"
#include "third_party/blink/renderer/core/layout/ng/ng_constraint_space_builder.h"
#include "third_party/blink/renderer/core/layout/ng/ng_layout_result.h" #include "third_party/blink/renderer/core/layout/ng/ng_layout_result.h"
#include "third_party/blink/renderer/core/layout/ng/ng_length_utils.h" #include "third_party/blink/renderer/core/layout/ng/ng_length_utils.h"
#include "third_party/blink/renderer/core/layout/ng/ng_out_of_flow_layout_part.h" #include "third_party/blink/renderer/core/layout/ng/ng_out_of_flow_layout_part.h"
...@@ -75,11 +76,19 @@ void LayoutNGMixin<Base>::ComputeIntrinsicLogicalWidths( ...@@ -75,11 +76,19 @@ void LayoutNGMixin<Base>::ComputeIntrinsicLogicalWidths(
LayoutUnit available_logical_height = LayoutUnit available_logical_height =
LayoutBoxUtils::AvailableLogicalHeight(*this, Base::ContainingBlock()); LayoutBoxUtils::AvailableLogicalHeight(*this, Base::ContainingBlock());
MinMaxSizeInput input(available_logical_height); WritingMode writing_mode = node.Style().GetWritingMode();
MinMaxSize sizes = node.ComputeMinMaxSize(
writing_mode, MinMaxSizeInput(available_logical_height));
NGConstraintSpace space = NGConstraintSpaceBuilder(writing_mode, writing_mode,
/* is_new_fc */ true)
.ToConstraintSpace();
NGBoxStrut border_padding =
ComputeBorders(space, node) + ComputePadding(space, node.Style());
// This function returns content-box plus scrollbar. // This function returns content-box plus scrollbar.
input.size_type = NGMinMaxSizeType::kContentBoxSize; sizes -= border_padding.InlineSum();
MinMaxSize sizes =
node.ComputeMinMaxSize(node.Style().GetWritingMode(), input);
if (Base::IsTableCell()) { if (Base::IsTableCell()) {
// If a table cell, or the column that it belongs to, has a specified fixed // If a table cell, or the column that it belongs to, has a specified fixed
...@@ -95,7 +104,6 @@ void LayoutNGMixin<Base>::ComputeIntrinsicLogicalWidths( ...@@ -95,7 +104,6 @@ void LayoutNGMixin<Base>::ComputeIntrinsicLogicalWidths(
} }
} }
sizes += LayoutUnit(Base::ScrollbarLogicalWidth());
min_logical_width = sizes.min_size; min_logical_width = sizes.min_size;
max_logical_width = sizes.max_size; max_logical_width = sizes.max_size;
} }
......
...@@ -141,8 +141,8 @@ scoped_refptr<const NGLayoutResult> NGMathRowLayoutAlgorithm::Layout() { ...@@ -141,8 +141,8 @@ scoped_refptr<const NGLayoutResult> NGMathRowLayoutAlgorithm::Layout() {
base::Optional<MinMaxSize> NGMathRowLayoutAlgorithm::ComputeMinMaxSize( base::Optional<MinMaxSize> NGMathRowLayoutAlgorithm::ComputeMinMaxSize(
const MinMaxSizeInput& input) const { const MinMaxSizeInput& input) const {
base::Optional<MinMaxSize> sizes = CalculateMinMaxSizesIgnoringChildren( base::Optional<MinMaxSize> sizes =
Node(), border_scrollbar_padding_, input.size_type); CalculateMinMaxSizesIgnoringChildren(Node(), border_scrollbar_padding_);
if (sizes) if (sizes)
return sizes; return sizes;
...@@ -172,10 +172,7 @@ base::Optional<MinMaxSize> NGMathRowLayoutAlgorithm::ComputeMinMaxSize( ...@@ -172,10 +172,7 @@ base::Optional<MinMaxSize> NGMathRowLayoutAlgorithm::ComputeMinMaxSize(
// Due to negative margins, it is possible that we calculated a negative // Due to negative margins, it is possible that we calculated a negative
// intrinsic width. Make sure that we never return a negative width. // intrinsic width. Make sure that we never return a negative width.
sizes->Encompass(LayoutUnit()); sizes->Encompass(LayoutUnit());
*sizes += border_scrollbar_padding_.InlineSum();
if (input.size_type == NGMinMaxSizeType::kBorderBoxSize)
*sizes += border_scrollbar_padding_.InlineSum();
return sizes; return sizes;
} }
......
...@@ -36,8 +36,7 @@ scoped_refptr<const NGLayoutResult> NGMathSpaceLayoutAlgorithm::Layout() { ...@@ -36,8 +36,7 @@ scoped_refptr<const NGLayoutResult> NGMathSpaceLayoutAlgorithm::Layout() {
base::Optional<MinMaxSize> NGMathSpaceLayoutAlgorithm::ComputeMinMaxSize( base::Optional<MinMaxSize> NGMathSpaceLayoutAlgorithm::ComputeMinMaxSize(
const MinMaxSizeInput& input) const { const MinMaxSizeInput& input) const {
return CalculateMinMaxSizesIgnoringChildren(Node(), border_padding_, return CalculateMinMaxSizesIgnoringChildren(Node(), border_padding_);
input.size_type);
} }
} // namespace blink } // namespace blink
...@@ -198,8 +198,8 @@ void NGBlockLayoutAlgorithm::SetBoxType(NGPhysicalFragment::NGBoxType type) { ...@@ -198,8 +198,8 @@ void NGBlockLayoutAlgorithm::SetBoxType(NGPhysicalFragment::NGBoxType type) {
base::Optional<MinMaxSize> NGBlockLayoutAlgorithm::ComputeMinMaxSize( base::Optional<MinMaxSize> NGBlockLayoutAlgorithm::ComputeMinMaxSize(
const MinMaxSizeInput& input) const { const MinMaxSizeInput& input) const {
base::Optional<MinMaxSize> sizes = CalculateMinMaxSizesIgnoringChildren( base::Optional<MinMaxSize> sizes =
node_, border_scrollbar_padding_, input.size_type); CalculateMinMaxSizesIgnoringChildren(node_, border_scrollbar_padding_);
if (sizes) if (sizes)
return sizes; return sizes;
...@@ -332,8 +332,7 @@ base::Optional<MinMaxSize> NGBlockLayoutAlgorithm::ComputeMinMaxSize( ...@@ -332,8 +332,7 @@ base::Optional<MinMaxSize> NGBlockLayoutAlgorithm::ComputeMinMaxSize(
DCHECK_GE(sizes->min_size, LayoutUnit()); DCHECK_GE(sizes->min_size, LayoutUnit());
DCHECK_LE(sizes->min_size, sizes->max_size) << Node().ToString(); DCHECK_LE(sizes->min_size, sizes->max_size) << Node().ToString();
if (input.size_type == NGMinMaxSizeType::kBorderBoxSize) *sizes += border_scrollbar_padding_.InlineSum();
*sizes += border_scrollbar_padding_.InlineSum();
return sizes; return sizes;
} }
......
...@@ -660,12 +660,6 @@ MinMaxSize NGBlockNode::ComputeMinMaxSize( ...@@ -660,12 +660,6 @@ MinMaxSize NGBlockNode::ComputeMinMaxSize(
TextDirection::kLtr, // irrelevant here TextDirection::kLtr, // irrelevant here
To<NGPhysicalBoxFragment>(layout_result->PhysicalFragment())); To<NGPhysicalBoxFragment>(layout_result->PhysicalFragment()));
sizes.min_size = sizes.max_size = fragment.Size().inline_size; sizes.min_size = sizes.max_size = fragment.Size().inline_size;
if (input.size_type == NGMinMaxSizeType::kContentBoxSize) {
sizes -= fragment.Borders().InlineSum() + fragment.Padding().InlineSum() +
box_->ScrollbarLogicalWidth();
DCHECK_GE(sizes.min_size, LayoutUnit());
DCHECK_GE(sizes.max_size, LayoutUnit());
}
return sizes; return sizes;
} }
...@@ -708,13 +702,6 @@ MinMaxSize NGBlockNode::ComputeMinMaxSize( ...@@ -708,13 +702,6 @@ MinMaxSize NGBlockNode::ComputeMinMaxSize(
TextDirection::kLtr, // irrelevant here TextDirection::kLtr, // irrelevant here
To<NGPhysicalBoxFragment>(layout_result->PhysicalFragment())); To<NGPhysicalBoxFragment>(layout_result->PhysicalFragment()));
sizes.max_size = max_fragment.Size().inline_size; sizes.max_size = max_fragment.Size().inline_size;
if (input.size_type == NGMinMaxSizeType::kContentBoxSize) {
sizes -= max_fragment.Borders().InlineSum() +
max_fragment.Padding().InlineSum() + box_->ScrollbarLogicalWidth();
DCHECK_GE(sizes.min_size, LayoutUnit());
DCHECK_GE(sizes.max_size, LayoutUnit());
}
return sizes; return sizes;
} }
...@@ -730,13 +717,7 @@ MinMaxSize NGBlockNode::ComputeMinMaxSizeFromLegacy( ...@@ -730,13 +717,7 @@ MinMaxSize NGBlockNode::ComputeMinMaxSizeFromLegacy(
MinMaxSize sizes; MinMaxSize sizes;
// ComputeIntrinsicLogicalWidths returns content-box + scrollbar. // ComputeIntrinsicLogicalWidths returns content-box + scrollbar.
box_->ComputeIntrinsicLogicalWidths(sizes.min_size, sizes.max_size); box_->ComputeIntrinsicLogicalWidths(sizes.min_size, sizes.max_size);
if (input.size_type == NGMinMaxSizeType::kContentBoxSize) { sizes += box_->BorderAndPaddingLogicalWidth();
sizes -= LayoutUnit(box_->ScrollbarLogicalWidth());
DCHECK_GE(sizes.min_size, LayoutUnit());
DCHECK_GE(sizes.max_size, LayoutUnit());
} else {
sizes += box_->BorderAndPaddingLogicalWidth();
}
if (needs_size_reset) if (needs_size_reset)
box_->ClearOverrideContainingBlockContentSize(); box_->ClearOverrideContainingBlockContentSize();
......
...@@ -195,10 +195,7 @@ base::Optional<MinMaxSize> NGColumnLayoutAlgorithm::ComputeMinMaxSize( ...@@ -195,10 +195,7 @@ base::Optional<MinMaxSize> NGColumnLayoutAlgorithm::ComputeMinMaxSize(
NGFragmentGeometry fragment_geometry = NGFragmentGeometry fragment_geometry =
CalculateInitialMinMaxFragmentGeometry(space, Node()); CalculateInitialMinMaxFragmentGeometry(space, Node());
NGBlockLayoutAlgorithm algorithm({Node(), fragment_geometry, space}); NGBlockLayoutAlgorithm algorithm({Node(), fragment_geometry, space});
MinMaxSizeInput child_input(input); base::Optional<MinMaxSize> min_max_sizes = algorithm.ComputeMinMaxSize(input);
child_input.size_type = NGMinMaxSizeType::kContentBoxSize;
base::Optional<MinMaxSize> min_max_sizes =
algorithm.ComputeMinMaxSize(child_input);
DCHECK(min_max_sizes.has_value()); DCHECK(min_max_sizes.has_value());
MinMaxSize sizes = *min_max_sizes; MinMaxSize sizes = *min_max_sizes;
...@@ -221,10 +218,7 @@ base::Optional<MinMaxSize> NGColumnLayoutAlgorithm::ComputeMinMaxSize( ...@@ -221,10 +218,7 @@ base::Optional<MinMaxSize> NGColumnLayoutAlgorithm::ComputeMinMaxSize(
// TODO(mstensho): Need to include spanners. // TODO(mstensho): Need to include spanners.
if (input.size_type == NGMinMaxSizeType::kBorderBoxSize) { sizes += border_scrollbar_padding_.InlineSum();
sizes += border_scrollbar_padding_.InlineSum();
}
return sizes; return sizes;
} }
......
...@@ -160,12 +160,8 @@ base::Optional<MinMaxSize> NGFieldsetLayoutAlgorithm::ComputeMinMaxSize( ...@@ -160,12 +160,8 @@ base::Optional<MinMaxSize> NGFieldsetLayoutAlgorithm::ComputeMinMaxSize(
const MinMaxSizeInput& input) const { const MinMaxSizeInput& input) const {
MinMaxSize sizes; MinMaxSize sizes;
bool apply_size_containment = node_.ShouldApplySizeContainment();
// TODO(crbug.com/1011842): Need to consider content-size here. // TODO(crbug.com/1011842): Need to consider content-size here.
if (apply_size_containment) { bool apply_size_containment = node_.ShouldApplySizeContainment();
if (input.size_type == NGMinMaxSizeType::kContentBoxSize)
return sizes;
}
// Size containment does not consider the legend for sizing. // Size containment does not consider the legend for sizing.
if (!apply_size_containment) { if (!apply_size_containment) {
......
...@@ -901,8 +901,8 @@ void NGFlexLayoutAlgorithm::PropagateBaselineFromChild( ...@@ -901,8 +901,8 @@ void NGFlexLayoutAlgorithm::PropagateBaselineFromChild(
base::Optional<MinMaxSize> NGFlexLayoutAlgorithm::ComputeMinMaxSize( base::Optional<MinMaxSize> NGFlexLayoutAlgorithm::ComputeMinMaxSize(
const MinMaxSizeInput& input) const { const MinMaxSizeInput& input) const {
base::Optional<MinMaxSize> sizes = CalculateMinMaxSizesIgnoringChildren( base::Optional<MinMaxSize> sizes =
Node(), border_scrollbar_padding_, input.size_type); CalculateMinMaxSizesIgnoringChildren(Node(), border_scrollbar_padding_);
if (sizes) if (sizes)
return sizes; return sizes;
...@@ -948,10 +948,7 @@ base::Optional<MinMaxSize> NGFlexLayoutAlgorithm::ComputeMinMaxSize( ...@@ -948,10 +948,7 @@ base::Optional<MinMaxSize> NGFlexLayoutAlgorithm::ComputeMinMaxSize(
// Due to negative margins, it is possible that we calculated a negative // Due to negative margins, it is possible that we calculated a negative
// intrinsic width. Make sure that we never return a negative width. // intrinsic width. Make sure that we never return a negative width.
sizes->Encompass(LayoutUnit()); sizes->Encompass(LayoutUnit());
*sizes += border_scrollbar_padding_.InlineSum();
if (input.size_type == NGMinMaxSizeType::kBorderBoxSize)
*sizes += border_scrollbar_padding_.InlineSum();
return sizes; return sizes;
} }
......
...@@ -28,8 +28,6 @@ struct MinMaxSize; ...@@ -28,8 +28,6 @@ struct MinMaxSize;
struct LogicalSize; struct LogicalSize;
struct PhysicalSize; struct PhysicalSize;
enum class NGMinMaxSizeType { kContentBoxSize, kBorderBoxSize };
// Input to the min/max inline size calculation algorithm for child nodes. Child // Input to the min/max inline size calculation algorithm for child nodes. Child
// nodes within the same formatting context need to know which floats are beside // nodes within the same formatting context need to know which floats are beside
// them. // them.
...@@ -49,9 +47,6 @@ struct MinMaxSizeInput { ...@@ -49,9 +47,6 @@ struct MinMaxSizeInput {
LayoutUnit float_left_inline_size; LayoutUnit float_left_inline_size;
LayoutUnit float_right_inline_size; LayoutUnit float_right_inline_size;
LayoutUnit percentage_resolution_block_size; LayoutUnit percentage_resolution_block_size;
// Whether to return the size as a content-box size or border-box size.
NGMinMaxSizeType size_type = NGMinMaxSizeType::kBorderBoxSize;
}; };
// Represents the input to a layout algorithm for a given node. The layout // Represents the input to a layout algorithm for a given node. The layout
......
...@@ -1267,11 +1267,9 @@ LayoutUnit ClampIntrinsicBlockSize( ...@@ -1267,11 +1267,9 @@ LayoutUnit ClampIntrinsicBlockSize(
base::Optional<MinMaxSize> CalculateMinMaxSizesIgnoringChildren( base::Optional<MinMaxSize> CalculateMinMaxSizesIgnoringChildren(
const NGBlockNode& node, const NGBlockNode& node,
const NGBoxStrut& border_scrollbar_padding, const NGBoxStrut& border_scrollbar_padding) {
NGMinMaxSizeType type) {
MinMaxSize sizes; MinMaxSize sizes;
if (type == NGMinMaxSizeType::kBorderBoxSize) sizes += border_scrollbar_padding.InlineSum();
sizes += border_scrollbar_padding.InlineSum();
// If intrinsic size was overridden, then use that. // If intrinsic size was overridden, then use that.
const LayoutUnit intrinsic_size_override = const LayoutUnit intrinsic_size_override =
......
...@@ -611,9 +611,7 @@ LayoutUnit ClampIntrinsicBlockSize( ...@@ -611,9 +611,7 @@ LayoutUnit ClampIntrinsicBlockSize(
// itself. // itself.
base::Optional<MinMaxSize> CalculateMinMaxSizesIgnoringChildren( base::Optional<MinMaxSize> CalculateMinMaxSizesIgnoringChildren(
const NGBlockNode&, const NGBlockNode&,
const NGBoxStrut& border_scrollbar_padding, const NGBoxStrut& border_scrollbar_padding);
NGMinMaxSizeType);
} // namespace blink } // namespace blink
......
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