Commit 1c8b6637 authored by Ian Kilpatrick's avatar Ian Kilpatrick Committed by Commit Bot

[LayoutNG] Introduce NGConstraintSpace::RareData.

This moves fields relating to:
 - Floats clearance
 - Fragmentation
 - Margin struts
 - Weird percentages

... to a rare data member. This decreases partition alloc usage on
system_health.memory_desktop by approximately 6-7%, at the cost of
0-6% on most benchmarks.

Change-Id: Ifaeaf5d874efcd13ce9eff785d8093d24637de86
Bug: 635619
Reviewed-on: https://chromium-review.googlesource.com/c/1323803
Commit-Queue: Ian Kilpatrick <ikilpatrick@chromium.org>
Reviewed-by: default avatarMorten Stenshorne <mstensho@chromium.org>
Reviewed-by: default avatarChristian Biesinger <cbiesinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#609030}
parent 20ef032a
......@@ -424,6 +424,7 @@ blink_core_sources("layout") {
"ng/ng_column_layout_algorithm.h",
"ng/ng_constraint_space.cc",
"ng/ng_constraint_space.h",
"ng/ng_constraint_space_builder.cc",
"ng/ng_constraint_space_builder.h",
"ng/ng_container_fragment_builder.cc",
"ng/ng_container_fragment_builder.h",
......
......@@ -32,6 +32,9 @@ struct CORE_EXPORT NGLogicalSize {
return std::tie(other.inline_size, other.block_size) ==
std::tie(inline_size, block_size);
}
bool operator!=(const NGLogicalSize& other) const {
return !(*this == other);
}
bool IsEmpty() const {
return inline_size == LayoutUnit() || block_size == LayoutUnit();
......
......@@ -36,6 +36,7 @@ bool NGMarginStrut::operator==(const NGMarginStrut& other) const {
return positive_margin == other.positive_margin &&
negative_margin == other.negative_margin &&
quirky_positive_margin == other.quirky_positive_margin &&
discard_margins == other.discard_margins &&
is_quirky_container_start == other.is_quirky_container_start;
}
......
......@@ -158,8 +158,11 @@ void ComputeAbsoluteHorizontal(const NGConstraintSpace& space,
const WritingMode container_writing_mode,
const TextDirection container_direction,
NGAbsolutePhysicalPosition* position) {
NGPhysicalSize percentage_physical = ToNGPhysicalSize(
space.PercentageResolutionSize(), space.GetWritingMode());
LayoutUnit percentage_width =
LIKELY(space.GetWritingMode() == WritingMode::kHorizontalTb)
? space.PercentageResolutionInlineSize()
: space.PercentageResolutionBlockSize();
base::Optional<LayoutUnit> margin_left;
if (!style.MarginLeft().IsAuto())
margin_left = ResolveMarginPaddingLength(space, style.MarginLeft());
......@@ -168,10 +171,10 @@ void ComputeAbsoluteHorizontal(const NGConstraintSpace& space,
margin_right = ResolveMarginPaddingLength(space, style.MarginRight());
base::Optional<LayoutUnit> left;
if (!style.Left().IsAuto())
left = ValueForLength(style.Left(), percentage_physical.width);
left = ValueForLength(style.Left(), percentage_width);
base::Optional<LayoutUnit> right;
if (!style.Right().IsAuto())
right = ValueForLength(style.Right(), percentage_physical.width);
right = ValueForLength(style.Right(), percentage_width);
base::Optional<LayoutUnit> width = incoming_width;
NGPhysicalSize container_size =
ToNGPhysicalSize(space.AvailableSize(), space.GetWritingMode());
......@@ -320,8 +323,10 @@ void ComputeAbsoluteVertical(const NGConstraintSpace& space,
const WritingMode container_writing_mode,
const TextDirection container_direction,
NGAbsolutePhysicalPosition* position) {
NGPhysicalSize percentage_physical = ToNGPhysicalSize(
space.PercentageResolutionSize(), space.GetWritingMode());
LayoutUnit percentage_height =
LIKELY(space.GetWritingMode() == WritingMode::kHorizontalTb)
? space.PercentageResolutionBlockSize()
: space.PercentageResolutionInlineSize();
base::Optional<LayoutUnit> margin_top;
if (!style.MarginTop().IsAuto())
......@@ -331,10 +336,10 @@ void ComputeAbsoluteVertical(const NGConstraintSpace& space,
margin_bottom = ResolveMarginPaddingLength(space, style.MarginBottom());
base::Optional<LayoutUnit> top;
if (!style.Top().IsAuto())
top = ValueForLength(style.Top(), percentage_physical.height);
top = ValueForLength(style.Top(), percentage_height);
base::Optional<LayoutUnit> bottom;
if (!style.Bottom().IsAuto())
bottom = ValueForLength(style.Bottom(), percentage_physical.height);
bottom = ValueForLength(style.Bottom(), percentage_height);
LayoutUnit border_padding = VerticalBorderPadding(space, style);
base::Optional<LayoutUnit> height = incoming_height;
......
......@@ -2091,12 +2091,12 @@ NGConstraintSpace NGBlockLayoutAlgorithm::CreateConstraintSpaceForChild(
// to bother to check whether we're actually at the start).
space_builder.SetSeparateLeadingFragmentainerMargins(
ConstraintSpace().HasSeparateLeadingFragmentainerMargins());
space_builder.SetFragmentainerBlockSize(
ConstraintSpace().FragmentainerBlockSize());
space_builder.SetFragmentainerSpaceAtBfcStart(space_available);
space_builder.SetFragmentationType(
ConstraintSpace().BlockFragmentationType());
}
space_builder.SetFragmentainerBlockSize(
ConstraintSpace().FragmentainerBlockSize());
space_builder.SetFragmentainerSpaceAtBfcStart(space_available);
space_builder.SetFragmentationType(
ConstraintSpace().BlockFragmentationType());
return space_builder.ToConstraintSpace();
}
......
......@@ -148,9 +148,9 @@ LayoutUnit CalculateAvailableInlineSizeForLegacy(
const NGConstraintSpace& space) {
if (box.StyleRef().LogicalWidth().IsPercent()) {
if (box.ShouldComputeSizeAsReplaced())
return space.ReplacedPercentageResolutionSize().inline_size;
return space.ReplacedPercentageResolutionInlineSize();
return space.PercentageResolutionSize().inline_size;
return space.PercentageResolutionInlineSize();
}
return space.AvailableSize().inline_size;
......@@ -161,9 +161,9 @@ LayoutUnit CalculateAvailableBlockSizeForLegacy(
const NGConstraintSpace& space) {
if (box.StyleRef().LogicalHeight().IsPercent()) {
if (box.ShouldComputeSizeAsReplaced())
return space.ReplacedPercentageResolutionSize().block_size;
return space.ReplacedPercentageResolutionBlockSize();
return space.PercentageResolutionSize().block_size;
return space.PercentageResolutionBlockSize();
}
return space.AvailableSize().block_size;
......@@ -193,8 +193,7 @@ scoped_refptr<NGLayoutResult> NGBlockNode::Layout(
// TODO(layoutng): Figure out why these two call can't be inside the
// !constraint_space.IsIntermediateLayout() block below.
UpdateShapeOutsideInfoIfNeeded(
*layout_result,
constraint_space.PercentageResolutionSize().inline_size);
*layout_result, constraint_space.PercentageResolutionInlineSize());
// We may need paint invalidation even if we can reuse layout, as our
// paint offset/visual rect may have changed due to relative
// positioning changes. Otherwise we fail fast/css/
......@@ -278,7 +277,7 @@ scoped_refptr<NGLayoutResult> NGBlockNode::Layout(
// TODO(ikilpatrick): This should be fixed by moving the shape-outside data
// to the NGLayoutResult, removing this "side" data-structure.
UpdateShapeOutsideInfoIfNeeded(
*layout_result, constraint_space.PercentageResolutionSize().inline_size);
*layout_result, constraint_space.PercentageResolutionInlineSize());
return layout_result;
}
......@@ -893,7 +892,7 @@ scoped_refptr<NGLayoutResult> NGBlockNode::RunOldLayout(
scoped_refptr<NGLayoutResult> layout_result = builder.ToBoxFragment();
UpdateShapeOutsideInfoIfNeeded(
*layout_result, constraint_space.PercentageResolutionSize().inline_size);
*layout_result, constraint_space.PercentageResolutionInlineSize());
return layout_result;
}
......
......@@ -18,14 +18,14 @@ namespace blink {
namespace {
struct SameSizeAsNGConstraintSpace {
NGLogicalSize logical_sizes[3];
NGPhysicalSize physical_sizes[1];
NGMarginStrut margin_strut;
NGBfcOffset bfc_offset;
NGLogicalSize available_size;
NGPhysicalSize initial_containing_block_size;
union {
NGBfcOffset bfc_offset;
void* rare_data;
};
NGExclusionSpace exclusion_space;
base::Optional<LayoutUnit> optional_layout_unit;
LayoutUnit layout_units[3];
unsigned flags[1];
unsigned bitfields[1];
};
static_assert(sizeof(NGConstraintSpace) == sizeof(SameSizeAsNGConstraintSpace),
......@@ -33,16 +33,6 @@ static_assert(sizeof(NGConstraintSpace) == sizeof(SameSizeAsNGConstraintSpace),
} // namespace
NGConstraintSpace::NGConstraintSpace(WritingMode out_writing_mode,
NGPhysicalSize icb_size)
: initial_containing_block_size_(icb_size),
block_direction_fragmentation_type_(static_cast<unsigned>(kFragmentNone)),
table_cell_child_layout_phase_(static_cast<unsigned>(kNotTableCellChild)),
adjoining_floats_(static_cast<unsigned>(kFloatTypeNone)),
writing_mode_(static_cast<unsigned>(out_writing_mode)),
direction_(static_cast<unsigned>(TextDirection::kLtr)),
flags_(kFixedSizeBlockIsDefinite) {}
NGConstraintSpace NGConstraintSpace::CreateFromLayoutObject(
const LayoutBox& box) {
auto writing_mode = box.StyleRef().GetWritingMode();
......@@ -155,11 +145,20 @@ NGConstraintSpace NGConstraintSpace::CreateFromLayoutObject(
}
bool NGConstraintSpace::operator==(const NGConstraintSpace& other) const {
return AreSizesEqual(other) &&
bfc_offset_.block_offset == other.bfc_offset_.block_offset &&
initial_containing_block_size_ ==
other.initial_containing_block_size_ &&
MaySkipLayout(other);
if (!AreSizesEqual(other))
return false;
if (!MaySkipLayout(other))
return false;
if (initial_containing_block_size_ != other.initial_containing_block_size_)
return false;
if (!HasRareData() && !other.HasRareData() &&
bfc_offset_.block_offset != other.bfc_offset_.block_offset)
return false;
return true;
}
String NGConstraintSpace::ToString() const {
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "third_party/blink/renderer/core/layout/ng/ng_constraint_space_builder.h"
#include "third_party/blink/renderer/core/layout/ng/ng_constraint_space.h"
namespace blink {
namespace {
NGPercentageStorage GetPercentageStorage(LayoutUnit percentage_size,
LayoutUnit available_size) {
if (percentage_size == available_size)
return kSameAsAvailable;
if (percentage_size == NGSizeIndefinite)
return kIndefinite;
if (percentage_size == LayoutUnit())
return kZero;
return kRareDataPercentage;
}
} // namespace
NGConstraintSpaceBuilder& NGConstraintSpaceBuilder::SetPercentageResolutionSize(
NGLogicalSize percentage_resolution_size) {
#if DCHECK_IS_ON()
DCHECK(is_available_size_set_);
#endif
if (LIKELY(is_in_parallel_flow_)) {
space_.bitfields_.percentage_inline_storage =
GetPercentageStorage(percentage_resolution_size.inline_size,
space_.available_size_.inline_size);
if (UNLIKELY(space_.bitfields_.percentage_inline_storage ==
kRareDataPercentage)) {
space_.EnsureRareData()->percentage_resolution_size.inline_size =
percentage_resolution_size.inline_size;
}
space_.bitfields_.percentage_block_storage =
GetPercentageStorage(percentage_resolution_size.block_size,
space_.available_size_.block_size);
if (space_.bitfields_.percentage_block_storage == kRareDataPercentage) {
space_.EnsureRareData()->percentage_resolution_size.block_size =
percentage_resolution_size.block_size;
}
} else {
AdjustInlineSizeIfNeeded(&percentage_resolution_size.block_size);
space_.bitfields_.percentage_inline_storage =
GetPercentageStorage(percentage_resolution_size.block_size,
space_.available_size_.inline_size);
if (space_.bitfields_.percentage_inline_storage == kRareDataPercentage) {
space_.EnsureRareData()->percentage_resolution_size.inline_size =
percentage_resolution_size.block_size;
}
space_.bitfields_.percentage_block_storage =
GetPercentageStorage(percentage_resolution_size.inline_size,
space_.available_size_.block_size);
if (space_.bitfields_.percentage_block_storage == kRareDataPercentage) {
space_.EnsureRareData()->percentage_resolution_size.block_size =
percentage_resolution_size.inline_size;
}
}
return *this;
}
NGConstraintSpaceBuilder&
NGConstraintSpaceBuilder::SetReplacedPercentageResolutionSize(
NGLogicalSize replaced_percentage_resolution_size) {
#if DCHECK_IS_ON()
DCHECK(is_available_size_set_);
#endif
if (LIKELY(is_in_parallel_flow_)) {
space_.bitfields_.replaced_percentage_inline_storage =
GetPercentageStorage(replaced_percentage_resolution_size.inline_size,
space_.available_size_.inline_size);
if (UNLIKELY(space_.bitfields_.replaced_percentage_inline_storage ==
kRareDataPercentage)) {
space_.EnsureRareData()->replaced_percentage_resolution_size.inline_size =
replaced_percentage_resolution_size.inline_size;
}
space_.bitfields_.replaced_percentage_block_storage =
GetPercentageStorage(replaced_percentage_resolution_size.block_size,
space_.available_size_.block_size);
if (space_.bitfields_.replaced_percentage_block_storage ==
kRareDataPercentage) {
space_.EnsureRareData()->replaced_percentage_resolution_size.block_size =
replaced_percentage_resolution_size.block_size;
}
} else {
AdjustInlineSizeIfNeeded(&replaced_percentage_resolution_size.block_size);
space_.bitfields_.replaced_percentage_inline_storage =
GetPercentageStorage(replaced_percentage_resolution_size.block_size,
space_.available_size_.inline_size);
if (space_.bitfields_.replaced_percentage_inline_storage ==
kRareDataPercentage) {
space_.EnsureRareData()->replaced_percentage_resolution_size.inline_size =
replaced_percentage_resolution_size.block_size;
}
space_.bitfields_.replaced_percentage_block_storage =
GetPercentageStorage(replaced_percentage_resolution_size.inline_size,
space_.available_size_.block_size);
if (space_.bitfields_.replaced_percentage_block_storage ==
kRareDataPercentage) {
space_.EnsureRareData()->replaced_percentage_resolution_size.block_size =
replaced_percentage_resolution_size.inline_size;
}
}
return *this;
}
} // namespace blink
......@@ -32,7 +32,7 @@ class CORE_EXPORT NGConstraintSpaceBuilder final {
is_new_fc) {
// Propagate the intermediate layout bit to the child constraint space.
if (parent_space.IsIntermediateLayout())
space_.flags_ |= NGConstraintSpace::kIntermediateLayout;
space_.bitfields_.flags |= NGConstraintSpace::kIntermediateLayout;
}
// The setters on this builder are in the writing mode of parent_writing_mode.
......@@ -54,10 +54,10 @@ class CORE_EXPORT NGConstraintSpaceBuilder final {
force_orthogonal_writing_mode_root_(
force_orthogonal_writing_mode_root) {
if (is_new_fc_)
space_.flags_ |= NGConstraintSpace::kNewFormattingContext;
space_.bitfields_.flags |= NGConstraintSpace::kNewFormattingContext;
if (!is_in_parallel_flow_ || force_orthogonal_writing_mode_root_)
space_.flags_ |= NGConstraintSpace::kOrthogonalWritingModeRoot;
space_.bitfields_.flags |= NGConstraintSpace::kOrthogonalWritingModeRoot;
}
// If inline size is indefinite, use size of initial containing block.
......@@ -68,7 +68,7 @@ class CORE_EXPORT NGConstraintSpaceBuilder final {
if (*inline_size != NGSizeIndefinite)
return;
if (static_cast<WritingMode>(space_.writing_mode_) ==
if (static_cast<WritingMode>(space_.bitfields_.writing_mode) ==
WritingMode::kHorizontalTb)
*inline_size = space_.initial_containing_block_size_.width;
else
......@@ -76,6 +76,9 @@ class CORE_EXPORT NGConstraintSpaceBuilder final {
}
NGConstraintSpaceBuilder& SetAvailableSize(NGLogicalSize available_size) {
#if DCHECK_IS_ON()
is_available_size_set_ = true;
#endif
space_.available_size_ = available_size;
if (UNLIKELY(!is_in_parallel_flow_)) {
......@@ -87,43 +90,33 @@ class CORE_EXPORT NGConstraintSpaceBuilder final {
}
NGConstraintSpaceBuilder& SetPercentageResolutionSize(
NGLogicalSize percentage_resolution_size) {
space_.percentage_resolution_size_ = percentage_resolution_size;
if (UNLIKELY(!is_in_parallel_flow_)) {
space_.percentage_resolution_size_.Flip();
AdjustInlineSizeIfNeeded(&space_.percentage_resolution_size_.inline_size);
}
return *this;
}
NGLogicalSize percentage_resolution_size);
NGConstraintSpaceBuilder& SetReplacedPercentageResolutionSize(
NGLogicalSize replaced_percentage_resolution_size) {
space_.replaced_percentage_resolution_size_ =
replaced_percentage_resolution_size;
if (UNLIKELY(!is_in_parallel_flow_)) {
space_.replaced_percentage_resolution_size_.Flip();
AdjustInlineSizeIfNeeded(
&space_.replaced_percentage_resolution_size_.inline_size);
}
return *this;
}
NGLogicalSize replaced_percentage_resolution_size);
NGConstraintSpaceBuilder& SetFragmentainerBlockSize(LayoutUnit size) {
space_.fragmentainer_block_size_ = size;
#if DCHECK_IS_ON()
DCHECK(!is_fragmentainer_block_size_set_);
is_fragmentainer_block_size_set_ = true;
#endif
if (size != NGSizeIndefinite)
space_.EnsureRareData()->fragmentainer_block_size = size;
return *this;
}
NGConstraintSpaceBuilder& SetFragmentainerSpaceAtBfcStart(LayoutUnit space) {
space_.fragmentainer_space_at_bfc_start_ = space;
#if DCHECK_IS_ON()
DCHECK(!is_fragmentainer_space_at_bfc_start_set_);
is_fragmentainer_space_at_bfc_start_set_ = true;
#endif
if (space != NGSizeIndefinite)
space_.EnsureRareData()->fragmentainer_space_at_bfc_start = space;
return *this;
}
NGConstraintSpaceBuilder& SetTextDirection(TextDirection direction) {
space_.direction_ = static_cast<unsigned>(direction);
space_.bitfields_.direction = static_cast<unsigned>(direction);
return *this;
}
......@@ -164,7 +157,14 @@ class CORE_EXPORT NGConstraintSpaceBuilder final {
NGConstraintSpaceBuilder& SetFragmentationType(
NGFragmentationType fragmentation_type) {
space_.block_direction_fragmentation_type_ = fragmentation_type;
#if DCHECK_IS_ON()
DCHECK(!is_block_direction_fragmentation_type_set_);
is_block_direction_fragmentation_type_set_ = true;
#endif
if (fragmentation_type != NGFragmentationType::kFragmentNone) {
space_.EnsureRareData()->block_direction_fragmentation_type =
fragmentation_type;
}
return *this;
}
......@@ -185,35 +185,53 @@ class CORE_EXPORT NGConstraintSpaceBuilder final {
NGConstraintSpaceBuilder& SetAdjoiningFloatTypes(NGFloatTypes floats) {
if (!is_new_fc_)
space_.adjoining_floats_ = static_cast<unsigned>(floats);
space_.bitfields_.adjoining_floats = static_cast<unsigned>(floats);
return *this;
}
NGConstraintSpaceBuilder& SetMarginStrut(const NGMarginStrut& margin_strut) {
if (!is_new_fc_)
space_.margin_strut_ = margin_strut;
#if DCHECK_IS_ON()
DCHECK(!is_margin_strut_set_);
is_margin_strut_set_ = true;
#endif
if (!is_new_fc_ && margin_strut != NGMarginStrut())
space_.EnsureRareData()->margin_strut = margin_strut;
return *this;
}
NGConstraintSpaceBuilder& SetBfcOffset(const NGBfcOffset& bfc_offset) {
if (!is_new_fc_)
space_.bfc_offset_ = bfc_offset;
if (!is_new_fc_) {
if (space_.HasRareData())
space_.rare_data_->bfc_offset = bfc_offset;
else
space_.bfc_offset_ = bfc_offset;
}
return *this;
}
NGConstraintSpaceBuilder& SetFloatsBfcBlockOffset(
const base::Optional<LayoutUnit>& floats_bfc_block_offset) {
if (!is_new_fc_)
space_.floats_bfc_block_offset_ = floats_bfc_block_offset;
#if DCHECK_IS_ON()
DCHECK(!is_floats_bfc_block_offset_set_);
is_floats_bfc_block_offset_set_ = true;
#endif
if (LIKELY(!is_new_fc_ && floats_bfc_block_offset != base::nullopt)) {
space_.EnsureRareData()->floats_bfc_block_offset =
floats_bfc_block_offset;
}
return *this;
}
NGConstraintSpaceBuilder& SetClearanceOffset(LayoutUnit clearance_offset) {
if (!is_new_fc_)
space_.clearance_offset_ = clearance_offset;
#if DCHECK_IS_ON()
DCHECK(!is_clearance_offset_set_);
is_clearance_offset_set_ = true;
#endif
if (!is_new_fc_ && clearance_offset != LayoutUnit::Min())
space_.EnsureRareData()->clearance_offset = clearance_offset;
return *this;
}
......@@ -225,7 +243,8 @@ class CORE_EXPORT NGConstraintSpaceBuilder final {
NGConstraintSpaceBuilder& SetTableCellChildLayoutPhase(
NGTableCellChildLayoutPhase table_cell_child_layout_phase) {
space_.table_cell_child_layout_phase_ = table_cell_child_layout_phase;
space_.bitfields_.table_cell_child_layout_phase =
table_cell_child_layout_phase;
return *this;
}
......@@ -255,7 +274,7 @@ class CORE_EXPORT NGConstraintSpaceBuilder final {
to_constraint_space_called_ = true;
#endif
DCHECK(!is_new_fc_ || !space_.adjoining_floats_);
DCHECK(!is_new_fc_ || !space_.bitfields_.adjoining_floats);
DCHECK_EQ(space_.HasFlag(NGConstraintSpace::kOrthogonalWritingModeRoot),
!is_in_parallel_flow_ || force_orthogonal_writing_mode_root_);
......@@ -264,14 +283,15 @@ class CORE_EXPORT NGConstraintSpaceBuilder final {
"simultaneously. Inferred means the constraints are in parent "
"writing mode, forced means they are in child writing mode.";
space_.baseline_requests_ = baseline_requests_.Serialize();
space_.bitfields_.baseline_requests = baseline_requests_.Serialize();
return std::move(space_);
}
private:
void SetFlag(NGConstraintSpace::ConstraintSpaceFlags mask, bool value) {
space_.flags_ = (space_.flags_ & ~static_cast<unsigned>(mask)) |
(-(int32_t)value & static_cast<unsigned>(mask));
space_.bitfields_.flags =
(space_.bitfields_.flags & ~static_cast<unsigned>(mask)) |
(-(int32_t)value & static_cast<unsigned>(mask));
}
NGConstraintSpace space_;
......@@ -280,6 +300,14 @@ class CORE_EXPORT NGConstraintSpaceBuilder final {
bool force_orthogonal_writing_mode_root_;
#if DCHECK_IS_ON()
bool is_available_size_set_ = false;
bool is_fragmentainer_block_size_set_ = false;
bool is_fragmentainer_space_at_bfc_start_set_ = false;
bool is_block_direction_fragmentation_type_set_ = false;
bool is_margin_strut_set_ = false;
bool is_floats_bfc_block_offset_set_ = false;
bool is_clearance_offset_set_ = false;
bool to_constraint_space_called_ = false;
#endif
......
......@@ -35,7 +35,7 @@ TEST(NGConstraintSpaceBuilderTest, AvailableSizeFromHorizontalICB) {
NGConstraintSpace space = vertical_builder.ToConstraintSpace();
EXPECT_EQ(space.AvailableSize().inline_size, icb_size.height);
EXPECT_EQ(space.PercentageResolutionSize().inline_size, icb_size.height);
EXPECT_EQ(space.PercentageResolutionInlineSize(), icb_size.height);
};
// Asserts that indefinite inline length becomes initial containing
......@@ -62,7 +62,7 @@ TEST(NGConstraintSpaceBuilderTest, AvailableSizeFromVerticalICB) {
NGConstraintSpace space = vertical_builder.ToConstraintSpace();
EXPECT_EQ(space.AvailableSize().inline_size, icb_size.width);
EXPECT_EQ(space.PercentageResolutionSize().inline_size, icb_size.width);
EXPECT_EQ(space.PercentageResolutionInlineSize(), icb_size.width);
};
} // namespace
......
......@@ -214,9 +214,9 @@ NGFieldsetLayoutAlgorithm::CreateConstraintSpaceForFieldsetContent(
NGConstraintSpaceBuilder builder(ConstraintSpace(),
ConstraintSpace().GetWritingMode(),
/* is_new_fc */ true);
builder.SetAvailableSize(padding_box_size);
builder.SetPercentageResolutionSize(
ConstraintSpace().PercentageResolutionSize());
builder.SetAvailableSize(padding_box_size);
builder.SetIsFixedSizeBlock(padding_box_size.block_size != NGSizeIndefinite);
return builder.ToConstraintSpace();
}
......
......@@ -85,8 +85,8 @@ NGConstraintSpace CreateConstraintSpaceForFloat(
builder.SetFragmentationType(NGFragmentationType::kFragmentNone);
}
return builder.SetPercentageResolutionSize(float_percentage_size)
.SetAvailableSize(float_available_size)
return builder.SetAvailableSize(float_available_size)
.SetPercentageResolutionSize(float_percentage_size)
.SetReplacedPercentageResolutionSize(float_replaced_percentage_size)
.SetIsShrinkToFit(style.LogicalWidth().IsAuto())
.SetTextDirection(style.Direction())
......
......@@ -65,8 +65,8 @@ inline bool InlineLengthMayChange(Length length,
return true;
}
if (is_unspecified || length.IsPercentOrCalc()) {
if (new_space.PercentageResolutionSize().inline_size !=
old_space.PercentageResolutionSize().inline_size)
if (new_space.PercentageResolutionInlineSize() !=
old_space.PercentageResolutionInlineSize())
return true;
}
return false;
......@@ -84,11 +84,11 @@ inline bool BlockLengthMayChange(Length length,
// (in addition to percent values). The reason is that percentage resolution
// block sizes may be passed through auto-sized blocks, in some cases,
// e.g. for anonymous blocks, and also in quirks mode.
if (new_space.PercentageResolutionSize().block_size !=
old_space.PercentageResolutionSize().block_size)
if (new_space.PercentageResolutionBlockSize() !=
old_space.PercentageResolutionBlockSize())
return true;
if (new_space.ReplacedPercentageResolutionSize().block_size !=
old_space.ReplacedPercentageResolutionSize().block_size)
if (new_space.ReplacedPercentageResolutionBlockSize() !=
old_space.ReplacedPercentageResolutionBlockSize())
return true;
}
return false;
......@@ -123,8 +123,7 @@ LayoutUnit ResolveInlineLength(
LengthResolvePhase phase,
const base::Optional<NGBoxStrut>& opt_border_padding) {
DCHECK_GE(constraint_space.AvailableSize().inline_size, LayoutUnit());
DCHECK_GE(constraint_space.PercentageResolutionSize().inline_size,
LayoutUnit());
DCHECK_GE(constraint_space.PercentageResolutionInlineSize(), LayoutUnit());
DCHECK_EQ(constraint_space.GetWritingMode(), style.GetWritingMode());
if (constraint_space.IsAnonymous())
......@@ -168,7 +167,7 @@ LayoutUnit ResolveInlineLength(
case kFixed:
case kCalculated: {
LayoutUnit percentage_resolution_size =
constraint_space.PercentageResolutionSize().inline_size;
constraint_space.PercentageResolutionInlineSize();
LayoutUnit value = ValueForLength(length, percentage_resolution_size);
if (style.BoxSizing() == EBoxSizing::kContentBox) {
value += border_and_padding.InlineSum();
......@@ -251,8 +250,7 @@ LayoutUnit ResolveBlockLength(
if (length.IsPercentOrCalc()) {
size_is_unresolvable =
phase == LengthResolvePhase::kIntrinsic ||
constraint_space.PercentageResolutionSize().block_size ==
NGSizeIndefinite;
constraint_space.PercentageResolutionBlockSize() == NGSizeIndefinite;
} else if (length.GetType() == kFillAvailable) {
size_is_unresolvable =
phase == LengthResolvePhase::kIntrinsic ||
......@@ -283,7 +281,7 @@ LayoutUnit ResolveBlockLength(
case kFixed:
case kCalculated: {
LayoutUnit percentage_resolution_size =
constraint_space.PercentageResolutionSize().block_size;
constraint_space.PercentageResolutionBlockSize();
LayoutUnit value = ValueForLength(length, percentage_resolution_size);
// Percentage-sized children of table cells, in the table "layout" phase,
......@@ -699,8 +697,8 @@ bool SizeMayChange(const ComputedStyle& style,
return true;
}
if (new_space.PercentageResolutionSize().inline_size !=
old_space.PercentageResolutionSize().inline_size) {
if (new_space.PercentageResolutionInlineSize() !=
old_space.PercentageResolutionInlineSize()) {
// Percentage-based padding is resolved against the inline content box size
// of the containing block.
if (style.PaddingTop().IsPercentOrCalc() ||
......@@ -1104,7 +1102,7 @@ NGLogicalSize CalculateChildPercentageSize(
return AdjustChildPercentageSizeForQuirksAndFlex(
space, node, child_percentage_size,
space.PercentageResolutionSize().block_size);
space.PercentageResolutionBlockSize());
}
NGLogicalSize CalculateReplacedChildPercentageSize(
......@@ -1139,7 +1137,7 @@ NGLogicalSize CalculateReplacedChildPercentageSize(
return AdjustChildPercentageSizeForQuirksAndFlex(
space, node, child_percentage_size,
space.ReplacedPercentageResolutionSize().block_size);
space.ReplacedPercentageResolutionBlockSize());
}
} // 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