Commit f787b55c authored by Morten Stenshorne's avatar Morten Stenshorne Committed by Commit Bot

[LayoutNG] Get ComputedStyle from the node.

Removed redundant parameter from CalculateBorderScrollbarPadding() and
ConstrainColumnBlockSize().

Cq-Include-Trybots: master.tryserver.chromium.linux:linux_layout_tests_layout_ng
Change-Id: If828121f1ab3582d2c97d9ea1d85ca0b51ed10c9
Reviewed-on: https://chromium-review.googlesource.com/946096Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Reviewed-by: default avatarEmil A Eklund <eae@chromium.org>
Commit-Queue: Morten Stenshorne <mstensho@chromium.org>
Cr-Commit-Position: refs/heads/master@{#541767}
parent 36c75814
...@@ -236,8 +236,7 @@ Optional<MinMaxSize> NGBlockLayoutAlgorithm::ComputeMinMaxSize( ...@@ -236,8 +236,7 @@ Optional<MinMaxSize> NGBlockLayoutAlgorithm::ComputeMinMaxSize(
DCHECK_GE(sizes.max_size, sizes.min_size); DCHECK_GE(sizes.max_size, sizes.min_size);
sizes += sizes +=
CalculateBorderScrollbarPadding(ConstraintSpace(), node_.Style(), node_) CalculateBorderScrollbarPadding(ConstraintSpace(), node_).InlineSum();
.InlineSum();
return sizes; return sizes;
} }
...@@ -279,7 +278,7 @@ scoped_refptr<NGLayoutResult> NGBlockLayoutAlgorithm::Layout() { ...@@ -279,7 +278,7 @@ scoped_refptr<NGLayoutResult> NGBlockLayoutAlgorithm::Layout() {
} }
border_scrollbar_padding_ = border_scrollbar_padding_ =
CalculateBorderScrollbarPadding(ConstraintSpace(), Style(), Node()); CalculateBorderScrollbarPadding(ConstraintSpace(), Node());
NGLogicalSize size = CalculateBorderBoxSize( NGLogicalSize size = CalculateBorderBoxSize(
ConstraintSpace(), Style(), min_max_size, CalculateDefaultBlockSize()); ConstraintSpace(), Style(), min_max_size, CalculateDefaultBlockSize());
......
...@@ -96,7 +96,7 @@ void UpdateLegacyMultiColumnFlowThread( ...@@ -96,7 +96,7 @@ void UpdateLegacyMultiColumnFlowThread(
if (LayoutMultiColumnSet* column_set = flow_thread->FirstMultiColumnSet()) { if (LayoutMultiColumnSet* column_set = flow_thread->FirstMultiColumnSet()) {
NGFragment logical_fragment(writing_mode, fragment); NGFragment logical_fragment(writing_mode, fragment);
auto border_scrollbar_padding = auto border_scrollbar_padding =
CalculateBorderScrollbarPadding(constraint_space, node.Style(), node); CalculateBorderScrollbarPadding(constraint_space, node);
column_set->SetLogicalLeft(border_scrollbar_padding.inline_start); column_set->SetLogicalLeft(border_scrollbar_padding.inline_start);
column_set->SetLogicalTop(border_scrollbar_padding.block_start); column_set->SetLogicalTop(border_scrollbar_padding.block_start);
......
...@@ -27,8 +27,7 @@ inline bool NeedsColumnBalancing(LayoutUnit block_size, ...@@ -27,8 +27,7 @@ inline bool NeedsColumnBalancing(LayoutUnit block_size,
// container. // container.
LayoutUnit ConstrainColumnBlockSize(LayoutUnit size, LayoutUnit ConstrainColumnBlockSize(LayoutUnit size,
NGBlockNode node, NGBlockNode node,
const NGConstraintSpace& space, const NGConstraintSpace& space) {
const ComputedStyle& style) {
// The {,max-}{height,width} properties are specified on the multicol // The {,max-}{height,width} properties are specified on the multicol
// container, but here we're calculating the column block sizes inside the // container, but here we're calculating the column block sizes inside the
// multicol container, which isn't exactly the same. We may shrink the column // multicol container, which isn't exactly the same. We may shrink the column
...@@ -41,11 +40,12 @@ LayoutUnit ConstrainColumnBlockSize(LayoutUnit size, ...@@ -41,11 +40,12 @@ LayoutUnit ConstrainColumnBlockSize(LayoutUnit size,
// against the resolved properties on the multicol container. That means that // against the resolved properties on the multicol container. That means that
// we have to convert the value from content-box to border-box. // we have to convert the value from content-box to border-box.
NGBoxStrut border_scrollbar_padding = NGBoxStrut border_scrollbar_padding =
CalculateBorderScrollbarPadding(space, style, node); CalculateBorderScrollbarPadding(space, node);
LayoutUnit extra = border_scrollbar_padding.BlockSum(); LayoutUnit extra = border_scrollbar_padding.BlockSum();
size += extra; size += extra;
Optional<LayoutUnit> max_length; Optional<LayoutUnit> max_length;
const ComputedStyle& style = node.Style();
Length logical_max_height = style.LogicalMaxHeight(); Length logical_max_height = style.LogicalMaxHeight();
if (!logical_max_height.IsMaxSizeNone()) { if (!logical_max_height.IsMaxSizeNone()) {
max_length = ResolveBlockLength(space, style, logical_max_height, size, max_length = ResolveBlockLength(space, style, logical_max_height, size,
...@@ -79,7 +79,7 @@ scoped_refptr<NGLayoutResult> NGColumnLayoutAlgorithm::Layout() { ...@@ -79,7 +79,7 @@ scoped_refptr<NGLayoutResult> NGColumnLayoutAlgorithm::Layout() {
if (NeedMinMaxSize(ConstraintSpace(), Style())) if (NeedMinMaxSize(ConstraintSpace(), Style()))
min_max_size = ComputeMinMaxSize(MinMaxSizeInput()); min_max_size = ComputeMinMaxSize(MinMaxSizeInput());
NGBoxStrut border_scrollbar_padding = NGBoxStrut border_scrollbar_padding =
CalculateBorderScrollbarPadding(ConstraintSpace(), Style(), Node()); CalculateBorderScrollbarPadding(ConstraintSpace(), Node());
NGLogicalSize border_box_size = NGLogicalSize border_box_size =
CalculateBorderBoxSize(ConstraintSpace(), Style(), min_max_size); CalculateBorderBoxSize(ConstraintSpace(), Style(), min_max_size);
NGLogicalSize content_box_size = NGLogicalSize content_box_size =
...@@ -217,9 +217,9 @@ Optional<MinMaxSize> NGColumnLayoutAlgorithm::ComputeMinMaxSize( ...@@ -217,9 +217,9 @@ Optional<MinMaxSize> NGColumnLayoutAlgorithm::ComputeMinMaxSize(
sizes.max_size *= column_count; sizes.max_size *= column_count;
LayoutUnit column_gap = ResolveUsedColumnGap(LayoutUnit(), Style()); LayoutUnit column_gap = ResolveUsedColumnGap(LayoutUnit(), Style());
LayoutUnit gap_extra = column_gap * (column_count - 1); LayoutUnit gap_extra = column_gap * (column_count - 1);
sizes += gap_extra + CalculateBorderScrollbarPadding(ConstraintSpace(), LayoutUnit border_scrollbar_padding =
node_.Style(), node_) CalculateBorderScrollbarPadding(ConstraintSpace(), node_).InlineSum();
.InlineSum(); sizes += gap_extra + border_scrollbar_padding;
return sizes; return sizes;
} }
...@@ -269,8 +269,7 @@ LayoutUnit NGColumnLayoutAlgorithm::CalculateBalancedColumnBlockSize( ...@@ -269,8 +269,7 @@ LayoutUnit NGColumnLayoutAlgorithm::CalculateBalancedColumnBlockSize(
single_strip_block_size.ToFloat() / static_cast<float>(column_count)); single_strip_block_size.ToFloat() / static_cast<float>(column_count));
// Finally, honor {,min-,max-}{height,width} properties. // Finally, honor {,min-,max-}{height,width} properties.
return ConstrainColumnBlockSize(block_size, Node(), ConstraintSpace(), return ConstrainColumnBlockSize(block_size, Node(), ConstraintSpace());
Style());
} }
LayoutUnit NGColumnLayoutAlgorithm::StretchColumnBlockSize( LayoutUnit NGColumnLayoutAlgorithm::StretchColumnBlockSize(
...@@ -281,7 +280,7 @@ LayoutUnit NGColumnLayoutAlgorithm::StretchColumnBlockSize( ...@@ -281,7 +280,7 @@ LayoutUnit NGColumnLayoutAlgorithm::StretchColumnBlockSize(
return current_column_size; return current_column_size;
LayoutUnit length = current_column_size + minimal_space_shortage; LayoutUnit length = current_column_size + minimal_space_shortage;
// Honor {,min-,max-}{height,width} properties. // Honor {,min-,max-}{height,width} properties.
return ConstrainColumnBlockSize(length, Node(), ConstraintSpace(), Style()); return ConstrainColumnBlockSize(length, Node(), ConstraintSpace());
} }
scoped_refptr<NGConstraintSpace> scoped_refptr<NGConstraintSpace>
......
...@@ -641,8 +641,9 @@ LayoutUnit ConstrainByMinMax(LayoutUnit length, ...@@ -641,8 +641,9 @@ LayoutUnit ConstrainByMinMax(LayoutUnit length,
NGBoxStrut CalculateBorderScrollbarPadding( NGBoxStrut CalculateBorderScrollbarPadding(
const NGConstraintSpace& constraint_space, const NGConstraintSpace& constraint_space,
const ComputedStyle& style,
const NGBlockNode node) { const NGBlockNode node) {
const ComputedStyle& style = node.Style();
// If we are producing an anonymous fragment (e.g. a column), it has no // If we are producing an anonymous fragment (e.g. a column), it has no
// borders, padding or scrollbars. Using the ones from the container can only // borders, padding or scrollbars. Using the ones from the container can only
// cause trouble. // cause trouble.
......
...@@ -158,7 +158,6 @@ CORE_EXPORT LayoutUnit ConstrainByMinMax(LayoutUnit length, ...@@ -158,7 +158,6 @@ CORE_EXPORT LayoutUnit ConstrainByMinMax(LayoutUnit length,
NGBoxStrut CalculateBorderScrollbarPadding( NGBoxStrut CalculateBorderScrollbarPadding(
const NGConstraintSpace& constraint_space, const NGConstraintSpace& constraint_space,
const ComputedStyle& style,
const NGBlockNode node); const NGBlockNode node);
inline NGLogicalSize CalculateBorderBoxSize( inline NGLogicalSize CalculateBorderBoxSize(
......
...@@ -25,7 +25,7 @@ scoped_refptr<NGLayoutResult> NGPageLayoutAlgorithm::Layout() { ...@@ -25,7 +25,7 @@ scoped_refptr<NGLayoutResult> NGPageLayoutAlgorithm::Layout() {
if (NeedMinMaxSize(ConstraintSpace(), Style())) if (NeedMinMaxSize(ConstraintSpace(), Style()))
min_max_size = ComputeMinMaxSize(MinMaxSizeInput()); min_max_size = ComputeMinMaxSize(MinMaxSizeInput());
NGBoxStrut border_scrollbar_padding = NGBoxStrut border_scrollbar_padding =
CalculateBorderScrollbarPadding(ConstraintSpace(), Style(), Node()); CalculateBorderScrollbarPadding(ConstraintSpace(), Node());
NGLogicalSize border_box_size = NGLogicalSize border_box_size =
CalculateBorderBoxSize(ConstraintSpace(), Style(), min_max_size); CalculateBorderBoxSize(ConstraintSpace(), Style(), min_max_size);
NGLogicalSize content_box_size = NGLogicalSize content_box_size =
......
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