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/ng/layout_ng_block_flow.h" | 7 #include "core/layout/ng/layout_ng_block_flow.h" |
8 #include "core/layout/ng/ng_block_layout_algorithm.h" | 8 #include "core/layout/ng/ng_block_layout_algorithm.h" |
9 #include "core/layout/ng/ng_constraint_space.h" | 9 #include "core/layout/ng/ng_constraint_space.h" |
10 #include "core/layout/ng/ng_direction.h" | 10 #include "core/layout/ng/ng_direction.h" |
11 #include "core/layout/ng/ng_fragment.h" | 11 #include "core/layout/ng/ng_fragment.h" |
12 #include "core/layout/ng/ng_fragment_builder.h" | 12 #include "core/layout/ng/ng_fragment_builder.h" |
| 13 #include "core/layout/ng/ng_length_utils.h" |
13 #include "core/layout/ng/ng_writing_mode.h" | 14 #include "core/layout/ng/ng_writing_mode.h" |
14 | 15 |
15 namespace blink { | 16 namespace blink { |
16 NGBox::NGBox(LayoutObject* layout_object) | 17 NGBox::NGBox(LayoutObject* layout_object) |
17 : layout_box_(toLayoutBox(layout_object)) { | 18 : layout_box_(toLayoutBox(layout_object)) { |
18 DCHECK(layout_box_); | 19 DCHECK(layout_box_); |
19 } | 20 } |
20 | 21 |
21 NGBox::NGBox(ComputedStyle* style) : layout_box_(nullptr), style_(style) { | 22 NGBox::NGBox(ComputedStyle* style) : layout_box_(nullptr), style_(style) { |
22 DCHECK(style_); | 23 DCHECK(style_); |
(...skipping 12 matching lines...) Expand all Loading... |
35 FromPlatformWritingMode(Style()->getWritingMode()), constraint_space); | 36 FromPlatformWritingMode(Style()->getWritingMode()), constraint_space); |
36 | 37 |
37 NGPhysicalFragment* fragment = nullptr; | 38 NGPhysicalFragment* fragment = nullptr; |
38 if (!algorithm_->Layout(child_constraint_space, &fragment)) | 39 if (!algorithm_->Layout(child_constraint_space, &fragment)) |
39 return false; | 40 return false; |
40 fragment_ = fragment; | 41 fragment_ = fragment; |
41 | 42 |
42 if (layout_box_) { | 43 if (layout_box_) { |
43 layout_box_->setWidth(fragment_->Width()); | 44 layout_box_->setWidth(fragment_->Width()); |
44 layout_box_->setHeight(fragment_->Height()); | 45 layout_box_->setHeight(fragment_->Height()); |
| 46 NGBoxStrut border_and_padding = |
| 47 computeBorders(*Style()) + |
| 48 computePadding(*constraint_space, *Style()); |
| 49 LayoutUnit intrinsic_logical_height = |
| 50 layout_box_->style()->isHorizontalWritingMode() |
| 51 ? fragment_->HeightOverflow() |
| 52 : fragment_->WidthOverflow(); |
| 53 intrinsic_logical_height -= border_and_padding.BlockSum(); |
| 54 layout_box_->setIntrinsicContentLogicalHeight(intrinsic_logical_height); |
45 | 55 |
46 // Ensure the position of the children are copied across to the | 56 // Ensure the position of the children are copied across to the |
47 // LayoutObject tree. | 57 // LayoutObject tree. |
48 for (NGBox* box = FirstChild(); box; box = box->NextSibling()) { | 58 for (NGBox* box = FirstChild(); box; box = box->NextSibling()) { |
49 if (box->fragment_) | 59 if (box->fragment_) |
50 box->PositionUpdated(); | 60 box->PositionUpdated(); |
51 } | 61 } |
52 | 62 |
53 if (layout_box_->isLayoutBlock()) | 63 if (layout_box_->isLayoutBlock()) |
54 toLayoutBlock(layout_box_)->layoutPositionedObjects(true); | 64 toLayoutBlock(layout_box_)->layoutPositionedObjects(true); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 | 138 |
129 bool NGBox::CanUseNewLayout() { | 139 bool NGBox::CanUseNewLayout() { |
130 if (!layout_box_) | 140 if (!layout_box_) |
131 return true; | 141 return true; |
132 if (!layout_box_->isLayoutBlockFlow()) | 142 if (!layout_box_->isLayoutBlockFlow()) |
133 return false; | 143 return false; |
134 const LayoutBlockFlow* block_flow = toLayoutBlockFlow(layout_box_); | 144 const LayoutBlockFlow* block_flow = toLayoutBlockFlow(layout_box_); |
135 return !block_flow->childrenInline() || !block_flow->firstChild(); | 145 return !block_flow->childrenInline() || !block_flow->firstChild(); |
136 } | 146 } |
137 } // namespace blink | 147 } // namespace blink |
OLD | NEW |