| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/layout/ng/ng_block_node.h" | 5 #include "core/layout/ng/ng_block_node.h" |
| 6 | 6 |
| 7 #include "core/layout/LayoutBlockFlow.h" | 7 #include "core/layout/LayoutBlockFlow.h" |
| 8 #include "core/layout/api/LineLayoutAPIShim.h" | 8 #include "core/layout/api/LineLayoutAPIShim.h" |
| 9 #include "core/layout/line/InlineIterator.h" | 9 #include "core/layout/line/InlineIterator.h" |
| 10 #include "core/layout/ng/layout_ng_block_flow.h" | 10 #include "core/layout/ng/layout_ng_block_flow.h" |
| 11 #include "core/layout/ng/ng_block_layout_algorithm.h" | 11 #include "core/layout/ng/ng_block_layout_algorithm.h" |
| 12 #include "core/layout/ng/ng_constraint_space_builder.h" | 12 #include "core/layout/ng/ng_constraint_space_builder.h" |
| 13 #include "core/layout/ng/ng_constraint_space.h" | 13 #include "core/layout/ng/ng_constraint_space.h" |
| 14 #include "core/layout/ng/ng_inline_layout_algorithm.h" | 14 #include "core/layout/ng/ng_inline_layout_algorithm.h" |
| 15 #include "core/layout/ng/ng_fragment.h" | 15 #include "core/layout/ng/ng_fragment.h" |
| 16 #include "core/layout/ng/ng_fragment_builder.h" | 16 #include "core/layout/ng/ng_fragment_builder.h" |
| 17 #include "core/layout/ng/ng_layout_coordinator.h" | 17 #include "core/layout/ng/ng_layout_coordinator.h" |
| 18 #include "core/layout/ng/ng_length_utils.h" | 18 #include "core/layout/ng/ng_length_utils.h" |
| 19 #include "core/layout/ng/ng_writing_mode.h" | 19 #include "core/layout/ng/ng_writing_mode.h" |
| 20 #include "platform/RuntimeEnabledFeatures.h" | 20 #include "platform/RuntimeEnabledFeatures.h" |
| 21 #include "platform/text/TextDirection.h" | 21 #include "platform/text/TextDirection.h" |
| 22 | 22 |
| 23 namespace blink { | 23 namespace blink { |
| 24 | 24 |
| 25 NGBlockNode::NGBlockNode(LayoutObject* layout_object) | 25 NGBlockNode::NGBlockNode(LayoutObject* layout_object) |
| 26 : NGLayoutInputNode(NGLayoutInputNodeType::LegacyBlock), | 26 : NGLayoutInputNode(NGLayoutInputNodeType::kLegacyBlock), |
| 27 layout_box_(toLayoutBox(layout_object)) { | 27 layout_box_(toLayoutBox(layout_object)) { |
| 28 DCHECK(layout_box_); | 28 DCHECK(layout_box_); |
| 29 } | 29 } |
| 30 | 30 |
| 31 NGBlockNode::NGBlockNode(ComputedStyle* style) | 31 NGBlockNode::NGBlockNode(ComputedStyle* style) |
| 32 : NGLayoutInputNode(NGLayoutInputNodeType::LegacyBlock), | 32 : NGLayoutInputNode(NGLayoutInputNodeType::kLegacyBlock), |
| 33 layout_box_(nullptr), | 33 layout_box_(nullptr), |
| 34 style_(style) { | 34 style_(style) { |
| 35 DCHECK(style_); | 35 DCHECK(style_); |
| 36 } | 36 } |
| 37 | 37 |
| 38 bool NGBlockNode::Layout(const NGConstraintSpace* constraint_space, | 38 bool NGBlockNode::Layout(const NGConstraintSpace* constraint_space, |
| 39 NGFragmentBase** out) { | 39 NGFragmentBase** out) { |
| 40 DCHECK(!minmax_algorithm_) | 40 DCHECK(!minmax_algorithm_) |
| 41 << "Can't interleave Layout and ComputeMinAndMaxContentSizes"; | 41 << "Can't interleave Layout and ComputeMinAndMaxContentSizes"; |
| 42 if (layout_box_ && layout_box_->isOutOfFlowPositioned()) | 42 if (layout_box_ && layout_box_->isOutOfFlowPositioned()) |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 NGConstraintSpace* constraint_space = new NGConstraintSpace( | 103 NGConstraintSpace* constraint_space = new NGConstraintSpace( |
| 104 FromPlatformWritingMode(Style()->getWritingMode()), | 104 FromPlatformWritingMode(Style()->getWritingMode()), |
| 105 Style()->direction(), builder.ToConstraintSpace()); | 105 Style()->direction(), builder.ToConstraintSpace()); |
| 106 | 106 |
| 107 minmax_algorithm_ = new NGBlockLayoutAlgorithm( | 107 minmax_algorithm_ = new NGBlockLayoutAlgorithm( |
| 108 Style(), toNGBlockNode(FirstChild()), constraint_space); | 108 Style(), toNGBlockNode(FirstChild()), constraint_space); |
| 109 } | 109 } |
| 110 // TODO(cbiesinger): For orthogonal children, we need to always synthesize. | 110 // TODO(cbiesinger): For orthogonal children, we need to always synthesize. |
| 111 NGLayoutAlgorithm::MinAndMaxState state = | 111 NGLayoutAlgorithm::MinAndMaxState state = |
| 112 minmax_algorithm_->ComputeMinAndMaxContentSizes(sizes); | 112 minmax_algorithm_->ComputeMinAndMaxContentSizes(sizes); |
| 113 if (state == NGLayoutAlgorithm::Success) | 113 if (state == NGLayoutAlgorithm::kSuccess) |
| 114 return true; | 114 return true; |
| 115 if (state == NGLayoutAlgorithm::Pending) | 115 if (state == NGLayoutAlgorithm::kPending) |
| 116 return false; | 116 return false; |
| 117 DCHECK_EQ(state, NGLayoutAlgorithm::NotImplemented); | 117 DCHECK_EQ(state, NGLayoutAlgorithm::kNotImplemented); |
| 118 | 118 |
| 119 // TODO(cbiesinger): Replace the loops below with a state machine like in | 119 // TODO(cbiesinger): Replace the loops below with a state machine like in |
| 120 // Layout. | 120 // Layout. |
| 121 | 121 |
| 122 // Have to synthesize this value. | 122 // Have to synthesize this value. |
| 123 NGPhysicalFragmentBase* physical_fragment; | 123 NGPhysicalFragmentBase* physical_fragment; |
| 124 while (!minmax_algorithm_->Layout(nullptr, &physical_fragment, nullptr)) | 124 while (!minmax_algorithm_->Layout(nullptr, &physical_fragment, nullptr)) |
| 125 continue; | 125 continue; |
| 126 NGFragment* fragment = new NGFragment( | 126 NGFragment* fragment = new NGFragment( |
| 127 FromPlatformWritingMode(Style()->getWritingMode()), Style()->direction(), | 127 FromPlatformWritingMode(Style()->getWritingMode()), Style()->direction(), |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 layout_box_->setOverrideContainingBlockContentLogicalHeight( | 302 layout_box_->setOverrideContainingBlockContentLogicalHeight( |
| 303 available_size.block_size); | 303 available_size.block_size); |
| 304 if (layout_box_->isLayoutNGBlockFlow() && layout_box_->needsLayout()) { | 304 if (layout_box_->isLayoutNGBlockFlow() && layout_box_->needsLayout()) { |
| 305 toLayoutNGBlockFlow(layout_box_)->LayoutBlockFlow::layoutBlock(true); | 305 toLayoutNGBlockFlow(layout_box_)->LayoutBlockFlow::layoutBlock(true); |
| 306 } else { | 306 } else { |
| 307 layout_box_->forceLayout(); | 307 layout_box_->forceLayout(); |
| 308 } | 308 } |
| 309 LayoutRect overflow = layout_box_->layoutOverflowRect(); | 309 LayoutRect overflow = layout_box_->layoutOverflowRect(); |
| 310 // TODO(layout-ng): This does not handle writing modes correctly (for | 310 // TODO(layout-ng): This does not handle writing modes correctly (for |
| 311 // overflow) | 311 // overflow) |
| 312 NGFragmentBuilder builder(NGPhysicalFragmentBase::FragmentBox); | 312 NGFragmentBuilder builder(NGPhysicalFragmentBase::kFragmentBox); |
| 313 builder.SetInlineSize(layout_box_->logicalWidth()) | 313 builder.SetInlineSize(layout_box_->logicalWidth()) |
| 314 .SetBlockSize(layout_box_->logicalHeight()) | 314 .SetBlockSize(layout_box_->logicalHeight()) |
| 315 .SetDirection(layout_box_->styleRef().direction()) | 315 .SetDirection(layout_box_->styleRef().direction()) |
| 316 .SetWritingMode( | 316 .SetWritingMode( |
| 317 FromPlatformWritingMode(layout_box_->styleRef().getWritingMode())) | 317 FromPlatformWritingMode(layout_box_->styleRef().getWritingMode())) |
| 318 .SetInlineOverflow(overflow.width()) | 318 .SetInlineOverflow(overflow.width()) |
| 319 .SetBlockOverflow(overflow.height()); | 319 .SetBlockOverflow(overflow.height()); |
| 320 return builder.ToFragment(); | 320 return builder.ToFragment(); |
| 321 } | 321 } |
| 322 | 322 |
| 323 } // namespace blink | 323 } // namespace blink |
| OLD | NEW |