| Index: third_party/WebKit/Source/core/layout/ng/ng_block_node.cc
|
| diff --git a/third_party/WebKit/Source/core/layout/ng/ng_block_node.cc b/third_party/WebKit/Source/core/layout/ng/ng_block_node.cc
|
| index 7e8127a48780df6ce49966c3c011861e117d73f2..6b9bd6ee9bcf1e12ea98ca4e4cfc52bdb9e75cd4 100644
|
| --- a/third_party/WebKit/Source/core/layout/ng/ng_block_node.cc
|
| +++ b/third_party/WebKit/Source/core/layout/ng/ng_block_node.cc
|
| @@ -14,6 +14,7 @@
|
| #include "core/layout/ng/ng_constraint_space_builder.h"
|
| #include "core/layout/ng/ng_fragment_builder.h"
|
| #include "core/layout/ng/ng_inline_node.h"
|
| +#include "core/layout/ng/ng_layout_result.h"
|
| #include "core/layout/ng/ng_length_utils.h"
|
| #include "core/layout/ng/ng_writing_mode.h"
|
| #include "core/paint/PaintLayer.h"
|
| @@ -24,15 +25,15 @@ namespace blink {
|
| namespace {
|
|
|
| // Copies data back to the legacy layout tree for a given child fragment.
|
| -void FragmentPositionUpdated(const NGPhysicalBoxFragment& box_fragment) {
|
| - LayoutBox* layout_box = toLayoutBox(box_fragment.GetLayoutObject());
|
| +void FragmentPositionUpdated(const NGPhysicalFragment& fragment) {
|
| + LayoutBox* layout_box = toLayoutBox(fragment.GetLayoutObject());
|
| if (!layout_box)
|
| return;
|
|
|
| DCHECK(layout_box->parent()) << "Should be called on children only.";
|
|
|
| - layout_box->setX(box_fragment.LeftOffset());
|
| - layout_box->setY(box_fragment.TopOffset());
|
| + layout_box->setX(fragment.LeftOffset());
|
| + layout_box->setY(fragment.TopOffset());
|
| }
|
|
|
| // Similar to FragmentPositionUpdated but for floats.
|
| @@ -76,23 +77,22 @@ NGBlockNode::NGBlockNode(ComputedStyle* style)
|
| // included from a compilation unit that lacks the ComputedStyle definition.
|
| NGBlockNode::~NGBlockNode() {}
|
|
|
| -RefPtr<NGPhysicalFragment> NGBlockNode::Layout(
|
| +RefPtr<NGLayoutResult> NGBlockNode::Layout(
|
| NGConstraintSpace* constraint_space) {
|
| // Use the old layout code and synthesize a fragment.
|
| if (!CanUseNewLayout()) {
|
| DCHECK(layout_box_);
|
| - fragment_ = RunOldLayout(*constraint_space);
|
| - return fragment_;
|
| + layout_result_ = RunOldLayout(*constraint_space);
|
| + return layout_result_;
|
| }
|
|
|
| - RefPtr<NGPhysicalFragment> fragment =
|
| + layout_result_ =
|
| NGBlockLayoutAlgorithm(GetLayoutObject(), &Style(), FirstChild(),
|
| constraint_space, CurrentBreakToken())
|
| .Layout();
|
|
|
| - fragment_ = toNGPhysicalBoxFragment(fragment.get());
|
| CopyFragmentDataToLayoutBox(*constraint_space);
|
| - return fragment_;
|
| + return layout_result_;
|
| }
|
|
|
| MinAndMaxContentSizes NGBlockNode::ComputeMinAndMaxContentSizes() {
|
| @@ -129,9 +129,11 @@ MinAndMaxContentSizes NGBlockNode::ComputeMinAndMaxContentSizes() {
|
| return *maybe_sizes;
|
|
|
| // Have to synthesize this value.
|
| - RefPtr<NGPhysicalFragment> physical_fragment = Layout(constraint_space);
|
| + RefPtr<NGLayoutResult> layout_result = Layout(constraint_space);
|
| + NGPhysicalFragment* physical_fragment =
|
| + layout_result->PhysicalFragment().get();
|
| NGBoxFragment min_fragment(FromPlatformWritingMode(Style().getWritingMode()),
|
| - toNGPhysicalBoxFragment(physical_fragment.get()));
|
| + toNGPhysicalBoxFragment(physical_fragment));
|
| sizes.min_content = min_fragment.InlineOverflow();
|
|
|
| // Now, redo with infinite space for max_content
|
| @@ -143,9 +145,10 @@ MinAndMaxContentSizes NGBlockNode::ComputeMinAndMaxContentSizes() {
|
| .SetPercentageResolutionSize({LayoutUnit(), LayoutUnit()})
|
| .ToConstraintSpace(FromPlatformWritingMode(Style().getWritingMode()));
|
|
|
| - physical_fragment = Layout(constraint_space);
|
| + layout_result = Layout(constraint_space);
|
| + physical_fragment = layout_result->PhysicalFragment().get();
|
| NGBoxFragment max_fragment(FromPlatformWritingMode(Style().getWritingMode()),
|
| - toNGPhysicalBoxFragment(physical_fragment.get()));
|
| + toNGPhysicalBoxFragment(physical_fragment));
|
| sizes.max_content = max_fragment.InlineOverflow();
|
| return sizes;
|
| }
|
| @@ -194,7 +197,8 @@ void NGBlockNode::SetFirstChild(NGLayoutInputNode* child) {
|
| }
|
|
|
| NGBreakToken* NGBlockNode::CurrentBreakToken() const {
|
| - return fragment_ ? fragment_->BreakToken() : nullptr;
|
| + return layout_result_ ? layout_result_->PhysicalFragment()->BreakToken()
|
| + : nullptr;
|
| }
|
|
|
| DEFINE_TRACE(NGBlockNode) {
|
| @@ -235,14 +239,17 @@ void NGBlockNode::CopyFragmentDataToLayoutBox(
|
| if (!layout_box_)
|
| return;
|
|
|
| - layout_box_->setWidth(fragment_->Width());
|
| - layout_box_->setHeight(fragment_->Height());
|
| + NGPhysicalBoxFragment* fragment =
|
| + toNGPhysicalBoxFragment(layout_result_->PhysicalFragment().get());
|
| +
|
| + layout_box_->setWidth(fragment->Width());
|
| + layout_box_->setHeight(fragment->Height());
|
| NGBoxStrut border_and_padding =
|
| ComputeBorders(Style()) + ComputePadding(constraint_space, Style());
|
| LayoutUnit intrinsic_logical_height =
|
| layout_box_->style()->isHorizontalWritingMode()
|
| - ? fragment_->HeightOverflow()
|
| - : fragment_->WidthOverflow();
|
| + ? fragment->HeightOverflow()
|
| + : fragment->WidthOverflow();
|
| intrinsic_logical_height -= border_and_padding.BlockSum();
|
| layout_box_->setIntrinsicContentLogicalHeight(intrinsic_logical_height);
|
|
|
| @@ -260,11 +267,12 @@ void NGBlockNode::CopyFragmentDataToLayoutBox(
|
| // Ensure the position of the children are copied across to the
|
| // LayoutObject tree.
|
| } else {
|
| - for (const auto& child_fragment : fragment_->Children()) {
|
| + for (const auto& child_fragment : fragment->Children()) {
|
| if (child_fragment->IsPlaced())
|
| FragmentPositionUpdated(toNGPhysicalBoxFragment(*child_fragment));
|
|
|
| - for (const auto& floating_object : child_fragment->PositionedFloats()) {
|
| + for (const auto& floating_object :
|
| + toNGPhysicalBoxFragment(child_fragment.get())->PositionedFloats()) {
|
| FloatingObjectPositionedUpdated(floating_object, layout_box_);
|
| }
|
| }
|
| @@ -278,7 +286,7 @@ void NGBlockNode::CopyFragmentDataToLayoutBox(
|
| }
|
| }
|
|
|
| -RefPtr<NGPhysicalBoxFragment> NGBlockNode::RunOldLayout(
|
| +RefPtr<NGLayoutResult> NGBlockNode::RunOldLayout(
|
| const NGConstraintSpace& constraint_space) {
|
| NGLogicalSize available_size = constraint_space.PercentageResolutionSize();
|
| layout_box_->setOverrideContainingBlockContentLogicalWidth(
|
|
|