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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
96 } | 96 } |
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(LayoutBox* parent) { |
107 if (layout_box_) { | 107 if (layout_box_) { |
108 layout_box_->setX(fragment_->LeftOffset()); | 108 layout_box_->setX(fragment_->LeftOffset()); |
109 layout_box_->setY(fragment_->TopOffset()); | 109 layout_box_->setY(fragment_->TopOffset()); |
110 } | 110 } |
111 | |
112 if (layout_box_->isFloating() && parent->isLayoutBlockFlow()) { | |
cbiesinger
2016/10/17 21:00:34
You're accessing layout_box_ without a nullcheck h
Gleb Lanbin
2016/10/17 22:13:22
Done.
| |
113 FloatingObject* floating_object = | |
114 toLayoutBlockFlow(parent)->insertFloatingObject(*layout_box_); | |
115 floating_object->setX(fragment_->LeftOffset()); | |
116 floating_object->setY(fragment_->TopOffset()); | |
117 floating_object->setIsPlaced(true); | |
118 } | |
111 } | 119 } |
112 | 120 |
113 bool NGBox::CanUseNewLayout() { | 121 bool NGBox::CanUseNewLayout() { |
114 if (!layout_box_) | 122 if (!layout_box_) |
115 return true; | 123 return true; |
116 if (!layout_box_->isLayoutBlockFlow()) | 124 if (!layout_box_->isLayoutBlockFlow()) |
117 return false; | 125 return false; |
118 const LayoutBlockFlow* block_flow = toLayoutBlockFlow(layout_box_); | 126 const LayoutBlockFlow* block_flow = toLayoutBlockFlow(layout_box_); |
119 return !block_flow->childrenInline() || !block_flow->firstChild(); | 127 return !block_flow->childrenInline() || !block_flow->firstChild(); |
120 } | 128 } |
121 | 129 |
122 void NGBox::CopyFragmentDataToLayoutBox( | 130 void NGBox::CopyFragmentDataToLayoutBox( |
123 const NGConstraintSpace& constraint_space) { | 131 const NGConstraintSpace& constraint_space) { |
124 DCHECK(layout_box_); | 132 DCHECK(layout_box_); |
125 layout_box_->setWidth(fragment_->Width()); | 133 layout_box_->setWidth(fragment_->Width()); |
126 layout_box_->setHeight(fragment_->Height()); | 134 layout_box_->setHeight(fragment_->Height()); |
127 NGBoxStrut border_and_padding = | 135 NGBoxStrut border_and_padding = |
128 computeBorders(*Style()) + computePadding(constraint_space, *Style()); | 136 computeBorders(*Style()) + computePadding(constraint_space, *Style()); |
129 LayoutUnit intrinsic_logical_height = | 137 LayoutUnit intrinsic_logical_height = |
130 layout_box_->style()->isHorizontalWritingMode() | 138 layout_box_->style()->isHorizontalWritingMode() |
131 ? fragment_->HeightOverflow() | 139 ? fragment_->HeightOverflow() |
132 : fragment_->WidthOverflow(); | 140 : fragment_->WidthOverflow(); |
133 intrinsic_logical_height -= border_and_padding.BlockSum(); | 141 intrinsic_logical_height -= border_and_padding.BlockSum(); |
134 layout_box_->setIntrinsicContentLogicalHeight(intrinsic_logical_height); | 142 layout_box_->setIntrinsicContentLogicalHeight(intrinsic_logical_height); |
135 | 143 |
136 // Ensure the position of the children are copied across to the | 144 // Ensure the position of the children are copied across to the |
137 // LayoutObject tree. | 145 // LayoutObject tree. |
138 for (NGBox* box = FirstChild(); box; box = box->NextSibling()) { | 146 for (NGBox* box = FirstChild(); box; box = box->NextSibling()) { |
139 if (box->fragment_) | 147 if (box->fragment_) |
140 box->PositionUpdated(); | 148 box->PositionUpdated(layout_box_); |
141 } | 149 } |
142 | 150 |
143 if (layout_box_->isLayoutBlock()) | 151 if (layout_box_->isLayoutBlock()) |
144 toLayoutBlock(layout_box_)->layoutPositionedObjects(true); | 152 toLayoutBlock(layout_box_)->layoutPositionedObjects(true); |
145 layout_box_->clearNeedsLayout(); | 153 layout_box_->clearNeedsLayout(); |
146 if (layout_box_->isLayoutBlockFlow()) { | 154 if (layout_box_->isLayoutBlockFlow()) { |
147 toLayoutBlockFlow(layout_box_)->updateIsSelfCollapsing(); | 155 toLayoutBlockFlow(layout_box_)->updateIsSelfCollapsing(); |
148 } | 156 } |
149 } | 157 } |
150 | 158 |
(...skipping 18 matching lines...) Expand all Loading... | |
169 .SetBlockSize(layout_box_->logicalHeight()) | 177 .SetBlockSize(layout_box_->logicalHeight()) |
170 .SetDirection(FromPlatformDirection(layout_box_->styleRef().direction())) | 178 .SetDirection(FromPlatformDirection(layout_box_->styleRef().direction())) |
171 .SetWritingMode( | 179 .SetWritingMode( |
172 FromPlatformWritingMode(layout_box_->styleRef().getWritingMode())) | 180 FromPlatformWritingMode(layout_box_->styleRef().getWritingMode())) |
173 .SetInlineOverflow(overflow.width()) | 181 .SetInlineOverflow(overflow.width()) |
174 .SetBlockOverflow(overflow.height()); | 182 .SetBlockOverflow(overflow.height()); |
175 return builder.ToFragment(); | 183 return builder.ToFragment(); |
176 } | 184 } |
177 | 185 |
178 } // namespace blink | 186 } // namespace blink |
OLD | NEW |