Commit d0918983 authored by Alison Maher's avatar Alison Maher Committed by Commit Bot

[LayoutNG] Refactor the fieldset Layout() function

Refactor the fieldset Layout() function to increase readability. This
CL should have no functional change.

Bug: 875235
Change-Id: Ie9081f419fd06f99a50c3def3747b48d08471c9d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2102765
Commit-Queue: Alison Maher <almaher@microsoft.com>
Reviewed-by: default avatarMorten Stenshorne <mstensho@chromium.org>
Cr-Commit-Position: refs/heads/master@{#750623}
parent f6a95dd5
......@@ -12,6 +12,7 @@
namespace blink {
enum class NGBreakStatus;
class NGBlockBreakToken;
class NGConstraintSpace;
......@@ -28,6 +29,15 @@ class CORE_EXPORT NGFieldsetLayoutAlgorithm
const MinMaxSizesInput&) const override;
private:
NGBreakStatus LayoutChildren();
NGBreakStatus LayoutLegend(
NGBlockNode& legend,
scoped_refptr<const NGBlockBreakToken> legend_break_token);
NGBreakStatus LayoutFieldsetContent(
NGBlockNode& fieldset_content,
scoped_refptr<const NGBlockBreakToken> content_break_token,
const LogicalSize adjusted_padding_box_size);
const NGConstraintSpace CreateConstraintSpaceForLegend(
NGBlockNode legend,
LogicalSize available_size,
......@@ -38,7 +48,30 @@ class CORE_EXPORT NGFieldsetLayoutAlgorithm
LogicalSize padding_box_size,
LayoutUnit block_offset);
const WritingMode writing_mode_;
const NGBoxStrut border_padding_;
NGBoxStrut borders_;
NGBoxStrut padding_;
// The border and padding after adjusting to ensure that the leading border
// and padding are only applied to the first fragment.
NGBoxStrut adjusted_border_padding_;
// The result of borders_ after positioning the fieldset's legend element.
NGBoxStrut borders_with_legend_;
LayoutUnit block_start_padding_edge_;
LayoutUnit intrinsic_block_size_;
LogicalSize border_box_size_;
// If true, this indicates the block_start_padding_edge_ had changed from its
// initial value during the current layout pass.
bool block_start_padding_edge_adjusted_ = false;
// If true, this indicates that either the entire legend or part of the
// legend needs to be laid out during the current layout pass.
bool legend_needs_layout_ = false;
};
} // namespace blink
......
......@@ -38,7 +38,8 @@ class NGFieldsetLayoutAlgorithmTest
MinMaxSizes RunComputeMinMaxSizes(NGBlockNode node) {
NGConstraintSpace space = ConstructBlockLayoutTestConstraintSpace(
WritingMode::kHorizontalTb, TextDirection::kLtr,
LogicalSize(LayoutUnit(), LayoutUnit()));
LogicalSize(LayoutUnit(), LayoutUnit()), false,
node.CreatesNewFormattingContext());
NGFragmentGeometry fragment_geometry =
CalculateInitialMinMaxFragmentGeometry(space, node);
......
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