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(
sizes.max_size, LayoutUnit::FromDoubleRound(
intrinsic_sizes_result_options->minContentSize()));
if (input.size_type == NGMinMaxSizeType::kContentBoxSize)
sizes -= border_scrollbar_padding_.InlineSum();
sizes.min_size.ClampNegativeToZero();
sizes.max_size.ClampNegativeToZero();
......
......@@ -11,6 +11,7 @@
#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_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_length_utils.h"
#include "third_party/blink/renderer/core/layout/ng/ng_out_of_flow_layout_part.h"
......@@ -75,11 +76,19 @@ void LayoutNGMixin<Base>::ComputeIntrinsicLogicalWidths(
LayoutUnit available_logical_height =
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.
input.size_type = NGMinMaxSizeType::kContentBoxSize;
MinMaxSize sizes =
node.ComputeMinMaxSize(node.Style().GetWritingMode(), input);
sizes -= border_padding.InlineSum();
if (Base::IsTableCell()) {
// If a table cell, or the column that it belongs to, has a specified fixed
......@@ -95,7 +104,6 @@ void LayoutNGMixin<Base>::ComputeIntrinsicLogicalWidths(
}
}
sizes += LayoutUnit(Base::ScrollbarLogicalWidth());
min_logical_width = sizes.min_size;
max_logical_width = sizes.max_size;
}
......
......@@ -141,8 +141,8 @@ scoped_refptr<const NGLayoutResult> NGMathRowLayoutAlgorithm::Layout() {
base::Optional<MinMaxSize> NGMathRowLayoutAlgorithm::ComputeMinMaxSize(
const MinMaxSizeInput& input) const {
base::Optional<MinMaxSize> sizes = CalculateMinMaxSizesIgnoringChildren(
Node(), border_scrollbar_padding_, input.size_type);
base::Optional<MinMaxSize> sizes =
CalculateMinMaxSizesIgnoringChildren(Node(), border_scrollbar_padding_);
if (sizes)
return sizes;
......@@ -172,10 +172,7 @@ base::Optional<MinMaxSize> NGMathRowLayoutAlgorithm::ComputeMinMaxSize(
// Due to negative margins, it is possible that we calculated a negative
// intrinsic width. Make sure that we never return a negative width.
sizes->Encompass(LayoutUnit());
if (input.size_type == NGMinMaxSizeType::kBorderBoxSize)
*sizes += border_scrollbar_padding_.InlineSum();
*sizes += border_scrollbar_padding_.InlineSum();
return sizes;
}
......
......@@ -36,8 +36,7 @@ scoped_refptr<const NGLayoutResult> NGMathSpaceLayoutAlgorithm::Layout() {
base::Optional<MinMaxSize> NGMathSpaceLayoutAlgorithm::ComputeMinMaxSize(
const MinMaxSizeInput& input) const {
return CalculateMinMaxSizesIgnoringChildren(Node(), border_padding_,
input.size_type);
return CalculateMinMaxSizesIgnoringChildren(Node(), border_padding_);
}
} // namespace blink
......@@ -198,8 +198,8 @@ void NGBlockLayoutAlgorithm::SetBoxType(NGPhysicalFragment::NGBoxType type) {
base::Optional<MinMaxSize> NGBlockLayoutAlgorithm::ComputeMinMaxSize(
const MinMaxSizeInput& input) const {
base::Optional<MinMaxSize> sizes = CalculateMinMaxSizesIgnoringChildren(
node_, border_scrollbar_padding_, input.size_type);
base::Optional<MinMaxSize> sizes =
CalculateMinMaxSizesIgnoringChildren(node_, border_scrollbar_padding_);
if (sizes)
return sizes;
......@@ -332,8 +332,7 @@ base::Optional<MinMaxSize> NGBlockLayoutAlgorithm::ComputeMinMaxSize(
DCHECK_GE(sizes->min_size, LayoutUnit());
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;
}
......
......@@ -660,12 +660,6 @@ MinMaxSize NGBlockNode::ComputeMinMaxSize(
TextDirection::kLtr, // irrelevant here
To<NGPhysicalBoxFragment>(layout_result->PhysicalFragment()));
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;
}
......@@ -708,13 +702,6 @@ MinMaxSize NGBlockNode::ComputeMinMaxSize(
TextDirection::kLtr, // irrelevant here
To<NGPhysicalBoxFragment>(layout_result->PhysicalFragment()));
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;
}
......@@ -730,13 +717,7 @@ MinMaxSize NGBlockNode::ComputeMinMaxSizeFromLegacy(
MinMaxSize sizes;
// ComputeIntrinsicLogicalWidths returns content-box + scrollbar.
box_->ComputeIntrinsicLogicalWidths(sizes.min_size, sizes.max_size);
if (input.size_type == NGMinMaxSizeType::kContentBoxSize) {
sizes -= LayoutUnit(box_->ScrollbarLogicalWidth());
DCHECK_GE(sizes.min_size, LayoutUnit());
DCHECK_GE(sizes.max_size, LayoutUnit());
} else {
sizes += box_->BorderAndPaddingLogicalWidth();
}
sizes += box_->BorderAndPaddingLogicalWidth();
if (needs_size_reset)
box_->ClearOverrideContainingBlockContentSize();
......
......@@ -195,10 +195,7 @@ base::Optional<MinMaxSize> NGColumnLayoutAlgorithm::ComputeMinMaxSize(
NGFragmentGeometry fragment_geometry =
CalculateInitialMinMaxFragmentGeometry(space, Node());
NGBlockLayoutAlgorithm algorithm({Node(), fragment_geometry, space});
MinMaxSizeInput child_input(input);
child_input.size_type = NGMinMaxSizeType::kContentBoxSize;
base::Optional<MinMaxSize> min_max_sizes =
algorithm.ComputeMinMaxSize(child_input);
base::Optional<MinMaxSize> min_max_sizes = algorithm.ComputeMinMaxSize(input);
DCHECK(min_max_sizes.has_value());
MinMaxSize sizes = *min_max_sizes;
......@@ -221,10 +218,7 @@ base::Optional<MinMaxSize> NGColumnLayoutAlgorithm::ComputeMinMaxSize(
// TODO(mstensho): Need to include spanners.
if (input.size_type == NGMinMaxSizeType::kBorderBoxSize) {
sizes += border_scrollbar_padding_.InlineSum();
}
sizes += border_scrollbar_padding_.InlineSum();
return sizes;
}
......
......@@ -160,12 +160,8 @@ base::Optional<MinMaxSize> NGFieldsetLayoutAlgorithm::ComputeMinMaxSize(
const MinMaxSizeInput& input) const {
MinMaxSize sizes;
bool apply_size_containment = node_.ShouldApplySizeContainment();
// TODO(crbug.com/1011842): Need to consider content-size here.
if (apply_size_containment) {
if (input.size_type == NGMinMaxSizeType::kContentBoxSize)
return sizes;
}
bool apply_size_containment = node_.ShouldApplySizeContainment();
// Size containment does not consider the legend for sizing.
if (!apply_size_containment) {
......
......@@ -901,8 +901,8 @@ void NGFlexLayoutAlgorithm::PropagateBaselineFromChild(
base::Optional<MinMaxSize> NGFlexLayoutAlgorithm::ComputeMinMaxSize(
const MinMaxSizeInput& input) const {
base::Optional<MinMaxSize> sizes = CalculateMinMaxSizesIgnoringChildren(
Node(), border_scrollbar_padding_, input.size_type);
base::Optional<MinMaxSize> sizes =
CalculateMinMaxSizesIgnoringChildren(Node(), border_scrollbar_padding_);
if (sizes)
return sizes;
......@@ -948,10 +948,7 @@ base::Optional<MinMaxSize> NGFlexLayoutAlgorithm::ComputeMinMaxSize(
// Due to negative margins, it is possible that we calculated a negative
// intrinsic width. Make sure that we never return a negative width.
sizes->Encompass(LayoutUnit());
if (input.size_type == NGMinMaxSizeType::kBorderBoxSize)
*sizes += border_scrollbar_padding_.InlineSum();
*sizes += border_scrollbar_padding_.InlineSum();
return sizes;
}
......
......@@ -28,8 +28,6 @@ struct MinMaxSize;
struct LogicalSize;
struct PhysicalSize;
enum class NGMinMaxSizeType { kContentBoxSize, kBorderBoxSize };
// 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
// them.
......@@ -49,9 +47,6 @@ struct MinMaxSizeInput {
LayoutUnit float_left_inline_size;
LayoutUnit float_right_inline_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
......
......@@ -1267,11 +1267,9 @@ LayoutUnit ClampIntrinsicBlockSize(
base::Optional<MinMaxSize> CalculateMinMaxSizesIgnoringChildren(
const NGBlockNode& node,
const NGBoxStrut& border_scrollbar_padding,
NGMinMaxSizeType type) {
const NGBoxStrut& border_scrollbar_padding) {
MinMaxSize sizes;
if (type == NGMinMaxSizeType::kBorderBoxSize)
sizes += border_scrollbar_padding.InlineSum();
sizes += border_scrollbar_padding.InlineSum();
// If intrinsic size was overridden, then use that.
const LayoutUnit intrinsic_size_override =
......
......@@ -611,9 +611,7 @@ LayoutUnit ClampIntrinsicBlockSize(
// itself.
base::Optional<MinMaxSize> CalculateMinMaxSizesIgnoringChildren(
const NGBlockNode&,
const NGBoxStrut& border_scrollbar_padding,
NGMinMaxSizeType);
const NGBoxStrut& border_scrollbar_padding);
} // 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