| // Copyright 2016 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 "core/layout/ng/layout_ng_block_flow.h" |
| |
| #include "core/layout/LayoutAnalyzer.h" |
| #include "core/layout/ng/ng_constraint_space.h" |
| #include "core/layout/ng/ng_fragment.h" |
| #include "core/layout/ng/ng_layout_result.h" |
| |
| namespace blink { |
| |
| LayoutNGBlockFlow::LayoutNGBlockFlow(Element* element) |
| : LayoutBlockFlow(element) {} |
| |
| bool LayoutNGBlockFlow::IsOfType(LayoutObjectType type) const { |
| return type == kLayoutObjectNGBlockFlow || LayoutBlockFlow::IsOfType(type); |
| } |
| |
| void LayoutNGBlockFlow::UpdateBlockLayout(bool relayout_children) { |
| LayoutAnalyzer::BlockScope analyzer(*this); |
| |
| RefPtr<NGConstraintSpace> constraint_space = |
| NGConstraintSpace::CreateFromLayoutObject(*this); |
| RefPtr<NGLayoutResult> result = |
| NGBlockNode(this).Layout(constraint_space.Get()); |
| |
| if (IsOutOfFlowPositioned()) { |
| // In legacy layout, abspos differs from regular blocks in that abspos |
| // blocks position themselves in their own layout, instead of getting |
| // positioned by their parent. So it we are a positioned block in a legacy- |
| // layout containing block, we have to emulate this positioning. |
| // Additionally, until we natively support abspos in LayoutNG, this code |
| // will also be reached though the layoutPositionedObjects call in |
| // NGBlockNode::CopyFragmentDataToLayoutBox. |
| LogicalExtentComputedValues computed_values; |
| ComputeLogicalWidth(computed_values); |
| SetLogicalLeft(computed_values.position_); |
| ComputeLogicalHeight(LogicalHeight(), LogicalTop(), computed_values); |
| SetLogicalTop(computed_values.position_); |
| } |
| |
| for (NGOutOfFlowPositionedDescendant descendant : |
| result->OutOfFlowPositionedDescendants()) |
| descendant.node.UseOldOutOfFlowPositioning(); |
| } |
| |
| NGInlineNodeData& LayoutNGBlockFlow::GetNGInlineNodeData() const { |
| DCHECK(ng_inline_node_data_); |
| return *ng_inline_node_data_.get(); |
| } |
| |
| void LayoutNGBlockFlow::ResetNGInlineNodeData() { |
| ng_inline_node_data_ = WTF::MakeUnique<NGInlineNodeData>(); |
| } |
| |
| } // namespace blink |