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" |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 | 97 |
98 void NGBox::SetNextSibling(NGBox* sibling) { | 98 void NGBox::SetNextSibling(NGBox* sibling) { |
99 next_sibling_ = sibling; | 99 next_sibling_ = sibling; |
100 } | 100 } |
101 | 101 |
102 void NGBox::SetFirstChild(NGBox* child) { | 102 void NGBox::SetFirstChild(NGBox* child) { |
103 first_child_ = child; | 103 first_child_ = child; |
104 } | 104 } |
105 | 105 |
106 void NGBox::PositionUpdated() { | 106 void NGBox::PositionUpdated() { |
107 if (layout_box_) { | 107 if (!layout_box_) |
108 layout_box_->setX(fragment_->LeftOffset()); | 108 return; |
109 layout_box_->setY(fragment_->TopOffset()); | 109 DCHECK(layout_box_->parent()) << "Should be called on children only."; |
| 110 |
| 111 layout_box_->setX(fragment_->LeftOffset()); |
| 112 layout_box_->setY(fragment_->TopOffset()); |
| 113 |
| 114 if (layout_box_->isFloating() && layout_box_->parent()->isLayoutBlockFlow()) { |
| 115 FloatingObject* floating_object = toLayoutBlockFlow(layout_box_->parent()) |
| 116 ->insertFloatingObject(*layout_box_); |
| 117 floating_object->setX(fragment_->LeftOffset()); |
| 118 floating_object->setY(fragment_->TopOffset()); |
| 119 floating_object->setIsPlaced(true); |
110 } | 120 } |
111 } | 121 } |
112 | 122 |
113 bool NGBox::CanUseNewLayout() { | 123 bool NGBox::CanUseNewLayout() { |
114 if (!layout_box_) | 124 if (!layout_box_) |
115 return true; | 125 return true; |
116 if (!layout_box_->isLayoutBlockFlow()) | 126 if (!layout_box_->isLayoutBlockFlow()) |
117 return false; | 127 return false; |
118 const LayoutBlockFlow* block_flow = toLayoutBlockFlow(layout_box_); | 128 const LayoutBlockFlow* block_flow = toLayoutBlockFlow(layout_box_); |
119 return !block_flow->childrenInline() || !block_flow->firstChild(); | 129 return !block_flow->childrenInline() || !block_flow->firstChild(); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 .SetBlockSize(layout_box_->logicalHeight()) | 179 .SetBlockSize(layout_box_->logicalHeight()) |
170 .SetDirection(FromPlatformDirection(layout_box_->styleRef().direction())) | 180 .SetDirection(FromPlatformDirection(layout_box_->styleRef().direction())) |
171 .SetWritingMode( | 181 .SetWritingMode( |
172 FromPlatformWritingMode(layout_box_->styleRef().getWritingMode())) | 182 FromPlatformWritingMode(layout_box_->styleRef().getWritingMode())) |
173 .SetInlineOverflow(overflow.width()) | 183 .SetInlineOverflow(overflow.width()) |
174 .SetBlockOverflow(overflow.height()); | 184 .SetBlockOverflow(overflow.height()); |
175 return builder.ToFragment(); | 185 return builder.ToFragment(); |
176 } | 186 } |
177 | 187 |
178 } // namespace blink | 188 } // namespace blink |
OLD | NEW |