| 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_box.h" | 5 #include "core/layout/ng/ng_box.h" |
| 6 | 6 |
| 7 #include "core/layout/LayoutBlockFlow.h" | 7 #include "core/layout/LayoutBlockFlow.h" |
| 8 #include "core/layout/ng/layout_ng_block_flow.h" | 8 #include "core/layout/ng/layout_ng_block_flow.h" |
| 9 #include "core/layout/ng/ng_block_layout_algorithm.h" | 9 #include "core/layout/ng/ng_block_layout_algorithm.h" |
| 10 #include "core/layout/ng/ng_constraint_space.h" | 10 #include "core/layout/ng/ng_constraint_space.h" |
| 11 #include "core/layout/ng/ng_direction.h" | 11 #include "core/layout/ng/ng_direction.h" |
| 12 #include "core/layout/ng/ng_fragment.h" | 12 #include "core/layout/ng/ng_fragment.h" |
| 13 #include "core/layout/ng/ng_fragment_builder.h" | 13 #include "core/layout/ng/ng_fragment_builder.h" |
| 14 #include "core/layout/ng/ng_length_utils.h" | 14 #include "core/layout/ng/ng_length_utils.h" |
| 15 #include "core/layout/ng/ng_writing_mode.h" | 15 #include "core/layout/ng/ng_writing_mode.h" |
| 16 | 16 |
| 17 namespace blink { | 17 namespace blink { |
| 18 NGBox::NGBox(LayoutObject* layout_object) | 18 NGBox::NGBox(LayoutObject* layout_object) |
| 19 : layout_box_(toLayoutBox(layout_object)) { | 19 : layout_box_(toLayoutBox(layout_object)) { |
| 20 DCHECK(layout_box_); | 20 DCHECK(layout_box_); |
| 21 } | 21 } |
| 22 | 22 |
| 23 NGBox::NGBox(ComputedStyle* style) : layout_box_(nullptr), style_(style) { | 23 NGBox::NGBox(ComputedStyle* style) : layout_box_(nullptr), style_(style) { |
| 24 DCHECK(style_); | 24 DCHECK(style_); |
| 25 } | 25 } |
| 26 | 26 |
| 27 bool NGBox::Layout(const NGConstraintSpace* constraint_space, | 27 bool NGBox::Layout(const NGConstraintSpace* constraint_space, |
| 28 NGFragment** out) { | 28 NGFragment** out) { |
| 29 if (layout_box_ && layout_box_->isOutOfFlowPositioned()) |
| 30 layout_box_->containingBlock()->insertPositionedObject(layout_box_); |
| 29 // We can either use the new layout code to do the layout and then copy the | 31 // We can either use the new layout code to do the layout and then copy the |
| 30 // resulting size to the LayoutObject, or use the old layout code and | 32 // resulting size to the LayoutObject, or use the old layout code and |
| 31 // synthesize a fragment. | 33 // synthesize a fragment. |
| 32 if (CanUseNewLayout()) { | 34 if (CanUseNewLayout()) { |
| 33 if (!algorithm_) | 35 if (!algorithm_) |
| 34 algorithm_ = new NGBlockLayoutAlgorithm(Style(), FirstChild()); | 36 algorithm_ = new NGBlockLayoutAlgorithm(Style(), FirstChild()); |
| 35 // Change the coordinate system of the constraint space. | 37 // Change the coordinate system of the constraint space. |
| 36 NGConstraintSpace* child_constraint_space = new NGConstraintSpace( | 38 NGConstraintSpace* child_constraint_space = new NGConstraintSpace( |
| 37 FromPlatformWritingMode(Style()->getWritingMode()), constraint_space); | 39 FromPlatformWritingMode(Style()->getWritingMode()), constraint_space); |
| 38 | 40 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 | 144 |
| 143 bool NGBox::CanUseNewLayout() { | 145 bool NGBox::CanUseNewLayout() { |
| 144 if (!layout_box_) | 146 if (!layout_box_) |
| 145 return true; | 147 return true; |
| 146 if (!layout_box_->isLayoutBlockFlow()) | 148 if (!layout_box_->isLayoutBlockFlow()) |
| 147 return false; | 149 return false; |
| 148 const LayoutBlockFlow* block_flow = toLayoutBlockFlow(layout_box_); | 150 const LayoutBlockFlow* block_flow = toLayoutBlockFlow(layout_box_); |
| 149 return !block_flow->childrenInline() || !block_flow->firstChild(); | 151 return !block_flow->childrenInline() || !block_flow->firstChild(); |
| 150 } | 152 } |
| 151 } // namespace blink | 153 } // namespace blink |
| OLD | NEW |