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_block_layout_algorithm.h" | 5 #include "core/layout/ng/ng_block_layout_algorithm.h" |
6 | 6 |
7 #include "core/layout/ng/ng_absolute_utils.h" | 7 #include "core/layout/ng/ng_absolute_utils.h" |
8 #include "core/layout/ng/ng_block_child_iterator.h" | 8 #include "core/layout/ng/ng_block_child_iterator.h" |
9 #include "core/layout/ng/ng_box_fragment.h" | 9 #include "core/layout/ng/ng_box_fragment.h" |
10 #include "core/layout/ng/ng_constraint_space.h" | 10 #include "core/layout/ng/ng_constraint_space.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 MinMaxContentSize sizes; | 70 MinMaxContentSize sizes; |
71 | 71 |
72 // Size-contained elements don't consider their contents for intrinsic sizing. | 72 // Size-contained elements don't consider their contents for intrinsic sizing. |
73 if (Style().containsSize()) | 73 if (Style().containsSize()) |
74 return sizes; | 74 return sizes; |
75 | 75 |
76 // TODO: handle floats & orthogonal children. | 76 // TODO: handle floats & orthogonal children. |
77 for (NGLayoutInputNode* node = Node()->FirstChild(); node; | 77 for (NGLayoutInputNode* node = Node()->FirstChild(); node; |
78 node = node->NextSibling()) { | 78 node = node->NextSibling()) { |
79 MinMaxContentSize child_sizes; | 79 MinMaxContentSize child_sizes; |
80 if (node->Type() == NGLayoutInputNode::kLegacyInline) { | 80 if (node->IsInline()) { |
81 // From |NGBlockLayoutAlgorithm| perspective, we can handle |NGInlineNode| | 81 // From |NGBlockLayoutAlgorithm| perspective, we can handle |NGInlineNode| |
82 // almost the same as |NGBlockNode|, because an |NGInlineNode| includes | 82 // almost the same as |NGBlockNode|, because an |NGInlineNode| includes |
83 // all inline nodes following |node| and their descendants, and produces | 83 // all inline nodes following |node| and their descendants, and produces |
84 // an anonymous box that contains all line boxes. | 84 // an anonymous box that contains all line boxes. |
85 // |NextSibling| returns the next block sibling, or nullptr, skipping all | 85 // |NextSibling| returns the next block sibling, or nullptr, skipping all |
86 // following inline siblings and descendants. | 86 // following inline siblings and descendants. |
87 child_sizes = toNGInlineNode(node)->ComputeMinMaxContentSize(); | 87 child_sizes = node->ComputeMinMaxContentSize(); |
88 } else { | 88 } else { |
89 Optional<MinMaxContentSize> child_minmax; | 89 Optional<MinMaxContentSize> child_minmax; |
90 NGBlockNode* block_child = toNGBlockNode(node); | 90 if (NeedMinMaxContentSizeForContentContribution(node->Style())) { |
91 if (NeedMinMaxContentSizeForContentContribution(block_child->Style())) { | 91 child_minmax = node->ComputeMinMaxContentSize(); |
92 child_minmax = block_child->ComputeMinMaxContentSize(); | |
93 } | 92 } |
94 | 93 |
95 child_sizes = ComputeMinAndMaxContentContribution(block_child->Style(), | 94 child_sizes = |
96 child_minmax); | 95 ComputeMinAndMaxContentContribution(node->Style(), child_minmax); |
97 } | 96 } |
98 | 97 |
99 sizes.min_content = std::max(sizes.min_content, child_sizes.min_content); | 98 sizes.min_content = std::max(sizes.min_content, child_sizes.min_content); |
100 sizes.max_content = std::max(sizes.max_content, child_sizes.max_content); | 99 sizes.max_content = std::max(sizes.max_content, child_sizes.max_content); |
101 } | 100 } |
102 | 101 |
103 sizes.max_content = std::max(sizes.min_content, sizes.max_content); | 102 sizes.max_content = std::max(sizes.min_content, sizes.max_content); |
104 return sizes; | 103 return sizes; |
105 } | 104 } |
106 | 105 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 DCHECK_EQ(curr_margin_strut_, NGMarginStrut()); | 188 DCHECK_EQ(curr_margin_strut_, NGMarginStrut()); |
190 // TODO(glebl): Uncomment the line below once we add the fragmentation | 189 // TODO(glebl): Uncomment the line below once we add the fragmentation |
191 // support for floats. | 190 // support for floats. |
192 // DCHECK_EQ(builder_.BfcOffset().value(), NGLogicalOffset()); | 191 // DCHECK_EQ(builder_.BfcOffset().value(), NGLogicalOffset()); |
193 curr_bfc_offset_ = {}; | 192 curr_bfc_offset_ = {}; |
194 } | 193 } |
195 | 194 |
196 curr_bfc_offset_.block_offset += content_size_; | 195 curr_bfc_offset_.block_offset += content_size_; |
197 | 196 |
198 while (child) { | 197 while (child) { |
199 if (child->Type() == NGLayoutInputNode::kLegacyBlock) { | 198 if (child->IsBlock()) { |
200 NGBlockNode* current_block_child = toNGBlockNode(child); | 199 EPosition position = child->Style().position(); |
201 EPosition position = current_block_child->Style().position(); | |
202 if (position == EPosition::kAbsolute || position == EPosition::kFixed) { | 200 if (position == EPosition::kAbsolute || position == EPosition::kFixed) { |
203 NGLogicalOffset offset = {border_and_padding_.inline_start, | 201 NGLogicalOffset offset = {border_and_padding_.inline_start, |
204 content_size_ + curr_margin_strut_.Sum()}; | 202 content_size_ + curr_margin_strut_.Sum()}; |
205 builder_.AddOutOfFlowChildCandidate(current_block_child, offset); | 203 builder_.AddOutOfFlowChildCandidate(toNGBlockNode(child), offset); |
206 NGBlockChildIterator::Entry entry = child_iterator.NextChild(); | 204 NGBlockChildIterator::Entry entry = child_iterator.NextChild(); |
207 child = entry.node; | 205 child = entry.node; |
208 child_break_token = entry.token; | 206 child_break_token = entry.token; |
209 continue; | 207 continue; |
210 } | 208 } |
211 } | 209 } |
212 | 210 |
213 PrepareChildLayout(child); | 211 PrepareChildLayout(child); |
214 RefPtr<NGConstraintSpace> child_space = | 212 RefPtr<NGConstraintSpace> child_space = |
215 CreateConstraintSpaceForChild(child); | 213 CreateConstraintSpaceForChild(child); |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 // started handling the fragmentation for floats. | 509 // started handling the fragmentation for floats. |
512 space_builder_.SetBfcOffset(NGLogicalOffset()); | 510 space_builder_.SetBfcOffset(NGLogicalOffset()); |
513 } | 511 } |
514 } | 512 } |
515 space_builder_.SetFragmentainerSpaceAvailable(space_available); | 513 space_builder_.SetFragmentainerSpaceAvailable(space_available); |
516 | 514 |
517 return space_builder_.ToConstraintSpace( | 515 return space_builder_.ToConstraintSpace( |
518 FromPlatformWritingMode(child_style.getWritingMode())); | 516 FromPlatformWritingMode(child_style.getWritingMode())); |
519 } | 517 } |
520 } // namespace blink | 518 } // namespace blink |
OLD | NEW |