Chromium Code Reviews| 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 = | |
|
Gleb Lanbin
2016/09/14 20:54:17
.nit should we use plural nouns here?
const auto b
| |
| 47 computeBorders(*style_) + computePadding(*constraint_space, *style_); | |
| 48 LayoutUnit intrinsic_logical_height = | |
| 49 layout_box_->style()->isHorizontalWritingMode() | |
| 50 ? fragment_->HeightOverflow() | |
| 51 : fragment_->WidthOverflow(); | |
| 52 intrinsic_logical_height -= border_and_padding.BlockSum(); | |
| 53 layout_box_->setIntrinsicContentLogicalHeight(intrinsic_logical_height); | |
| 45 | 54 |
| 46 // Ensure the position of the children are copied across to the | 55 // Ensure the position of the children are copied across to the |
| 47 // LayoutObject tree. | 56 // LayoutObject tree. |
| 48 for (NGBox* box = FirstChild(); box; box = box->NextSibling()) { | 57 for (NGBox* box = FirstChild(); box; box = box->NextSibling()) { |
| 49 if (box->fragment_) | 58 if (box->fragment_) |
| 50 box->PositionUpdated(); | 59 box->PositionUpdated(); |
| 51 } | 60 } |
| 52 | 61 |
| 53 if (layout_box_->isLayoutBlock()) | 62 if (layout_box_->isLayoutBlock()) |
| 54 toLayoutBlock(layout_box_)->layoutPositionedObjects(true); | 63 toLayoutBlock(layout_box_)->layoutPositionedObjects(true); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 128 | 137 |
| 129 bool NGBox::CanUseNewLayout() { | 138 bool NGBox::CanUseNewLayout() { |
| 130 if (!layout_box_) | 139 if (!layout_box_) |
| 131 return true; | 140 return true; |
| 132 if (!layout_box_->isLayoutBlockFlow()) | 141 if (!layout_box_->isLayoutBlockFlow()) |
| 133 return false; | 142 return false; |
| 134 const LayoutBlockFlow* block_flow = toLayoutBlockFlow(layout_box_); | 143 const LayoutBlockFlow* block_flow = toLayoutBlockFlow(layout_box_); |
| 135 return !block_flow->childrenInline() || !block_flow->firstChild(); | 144 return !block_flow->childrenInline() || !block_flow->firstChild(); |
| 136 } | 145 } |
| 137 } // namespace blink | 146 } // namespace blink |
| OLD | NEW |