| 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_break_token.h" | 8 #include "core/layout/ng/ng_block_break_token.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_column_mapper.h" | 10 #include "core/layout/ng/ng_column_mapper.h" |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 sizes->max_content = LayoutUnit(); | 201 sizes->max_content = LayoutUnit(); |
| 202 | 202 |
| 203 // Size-contained elements don't consider their contents for intrinsic sizing. | 203 // Size-contained elements don't consider their contents for intrinsic sizing. |
| 204 if (Style().containsSize()) | 204 if (Style().containsSize()) |
| 205 return true; | 205 return true; |
| 206 | 206 |
| 207 // TODO: handle floats & orthogonal children. | 207 // TODO: handle floats & orthogonal children. |
| 208 for (NGBlockNode* node = first_child_; node; node = node->NextSibling()) { | 208 for (NGBlockNode* node = first_child_; node; node = node->NextSibling()) { |
| 209 Optional<MinAndMaxContentSizes> child_minmax; | 209 Optional<MinAndMaxContentSizes> child_minmax; |
| 210 if (NeedMinAndMaxContentSizesForContentContribution(*node->Style())) { | 210 if (NeedMinAndMaxContentSizesForContentContribution(*node->Style())) { |
| 211 child_minmax = node->ComputeMinAndMaxContentSizesSync(); | 211 child_minmax = node->ComputeMinAndMaxContentSizes(); |
| 212 } | 212 } |
| 213 | 213 |
| 214 MinAndMaxContentSizes child_sizes = | 214 MinAndMaxContentSizes child_sizes = |
| 215 ComputeMinAndMaxContentContribution(*node->Style(), child_minmax); | 215 ComputeMinAndMaxContentContribution(*node->Style(), child_minmax); |
| 216 | 216 |
| 217 sizes->min_content = std::max(sizes->min_content, child_sizes.min_content); | 217 sizes->min_content = std::max(sizes->min_content, child_sizes.min_content); |
| 218 sizes->max_content = std::max(sizes->max_content, child_sizes.max_content); | 218 sizes->max_content = std::max(sizes->max_content, child_sizes.max_content); |
| 219 } | 219 } |
| 220 | 220 |
| 221 sizes->max_content = std::max(sizes->min_content, sizes->max_content); | 221 sizes->max_content = std::max(sizes->min_content, sizes->max_content); |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 builder_->SetMarginStrutBlockEnd(from); | 607 builder_->SetMarginStrutBlockEnd(from); |
| 608 } | 608 } |
| 609 | 609 |
| 610 NGBoxStrut NGBlockLayoutAlgorithm::CalculateMargins( | 610 NGBoxStrut NGBlockLayoutAlgorithm::CalculateMargins( |
| 611 const NGConstraintSpace& space, | 611 const NGConstraintSpace& space, |
| 612 const ComputedStyle& style) { | 612 const ComputedStyle& style) { |
| 613 WTF::Optional<MinAndMaxContentSizes> sizes; | 613 WTF::Optional<MinAndMaxContentSizes> sizes; |
| 614 if (NeedMinAndMaxContentSizes(space, style)) { | 614 if (NeedMinAndMaxContentSizes(space, style)) { |
| 615 // TODO(ikilpatrick): Change ComputeMinAndMaxContentSizes to return | 615 // TODO(ikilpatrick): Change ComputeMinAndMaxContentSizes to return |
| 616 // MinAndMaxContentSizes. | 616 // MinAndMaxContentSizes. |
| 617 sizes = current_child_->ComputeMinAndMaxContentSizesSync(); | 617 sizes = current_child_->ComputeMinAndMaxContentSizes(); |
| 618 } | 618 } |
| 619 LayoutUnit child_inline_size = | 619 LayoutUnit child_inline_size = |
| 620 ComputeInlineSizeForFragment(space, style, sizes); | 620 ComputeInlineSizeForFragment(space, style, sizes); |
| 621 NGBoxStrut margins = | 621 NGBoxStrut margins = |
| 622 ComputeMargins(space, style, space.WritingMode(), space.Direction()); | 622 ComputeMargins(space, style, space.WritingMode(), space.Direction()); |
| 623 if (!style.isFloating()) { | 623 if (!style.isFloating()) { |
| 624 ApplyAutoMargins(space, style, child_inline_size, &margins); | 624 ApplyAutoMargins(space, style, child_inline_size, &margins); |
| 625 } | 625 } |
| 626 return margins; | 626 return margins; |
| 627 } | 627 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 662 visitor->trace(constraint_space_); | 662 visitor->trace(constraint_space_); |
| 663 visitor->trace(break_token_); | 663 visitor->trace(break_token_); |
| 664 visitor->trace(builder_); | 664 visitor->trace(builder_); |
| 665 visitor->trace(space_builder_); | 665 visitor->trace(space_builder_); |
| 666 visitor->trace(space_for_current_child_); | 666 visitor->trace(space_for_current_child_); |
| 667 visitor->trace(current_child_); | 667 visitor->trace(current_child_); |
| 668 visitor->trace(fragmentainer_mapper_); | 668 visitor->trace(fragmentainer_mapper_); |
| 669 } | 669 } |
| 670 | 670 |
| 671 } // namespace blink | 671 } // namespace blink |
| OLD | NEW |