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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 break; | 53 break; |
54 case EClear::ClearBoth: | 54 case EClear::ClearBoth: |
55 *content_size = std::max(left_block_end_offset, right_block_end_offset); | 55 *content_size = std::max(left_block_end_offset, right_block_end_offset); |
56 break; | 56 break; |
57 default: | 57 default: |
58 ASSERT_NOT_REACHED(); | 58 ASSERT_NOT_REACHED(); |
59 } | 59 } |
60 } | 60 } |
61 | 61 |
62 LayoutUnit ComputeCollapsedMarginBlockStart( | 62 LayoutUnit ComputeCollapsedMarginBlockStart( |
63 const NGMarginStrut& prev_margin_strut, | 63 const NGDeprecatedMarginStrut& prev_margin_strut, |
64 const NGMarginStrut& curr_margin_strut) { | 64 const NGDeprecatedMarginStrut& curr_margin_strut) { |
65 return std::max(prev_margin_strut.margin_block_end, | 65 return std::max(prev_margin_strut.margin_block_end, |
66 curr_margin_strut.margin_block_start) - | 66 curr_margin_strut.margin_block_start) - |
67 std::max(prev_margin_strut.negative_margin_block_end.abs(), | 67 std::max(prev_margin_strut.negative_margin_block_end.abs(), |
68 curr_margin_strut.negative_margin_block_start.abs()); | 68 curr_margin_strut.negative_margin_block_start.abs()); |
69 } | 69 } |
70 | 70 |
71 // Creates an exclusion from the fragment that will be placed in the provided | 71 // Creates an exclusion from the fragment that will be placed in the provided |
72 // layout opportunity. | 72 // layout opportunity. |
73 NGExclusion CreateExclusion(const NGFragment& fragment, | 73 NGExclusion CreateExclusion(const NGFragment& fragment, |
74 const NGLayoutOpportunity& opportunity, | 74 const NGLayoutOpportunity& opportunity, |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 return space_left; | 511 return space_left; |
512 } | 512 } |
513 | 513 |
514 NGBoxStrut NGBlockLayoutAlgorithm::CollapseMargins( | 514 NGBoxStrut NGBlockLayoutAlgorithm::CollapseMargins( |
515 const NGBoxStrut& margins, | 515 const NGBoxStrut& margins, |
516 const NGBoxFragment& fragment) { | 516 const NGBoxFragment& fragment) { |
517 bool is_zero_height_box = !fragment.BlockSize() && margins.IsEmpty() && | 517 bool is_zero_height_box = !fragment.BlockSize() && margins.IsEmpty() && |
518 fragment.MarginStrut().IsEmpty(); | 518 fragment.MarginStrut().IsEmpty(); |
519 // Create the current child's margin strut from its children's margin strut or | 519 // Create the current child's margin strut from its children's margin strut or |
520 // use margin strut from the the last non-empty child. | 520 // use margin strut from the the last non-empty child. |
521 NGMarginStrut curr_margin_strut = | 521 NGDeprecatedMarginStrut curr_margin_strut = |
522 is_zero_height_box ? prev_child_margin_strut_ : fragment.MarginStrut(); | 522 is_zero_height_box ? prev_child_margin_strut_ : fragment.MarginStrut(); |
523 | 523 |
524 // Calculate borders and padding for the current child. | 524 // Calculate borders and padding for the current child. |
525 NGBoxStrut border_and_padding = | 525 NGBoxStrut border_and_padding = |
526 ComputeBorders(CurrentChildStyle()) + | 526 ComputeBorders(CurrentChildStyle()) + |
527 ComputePadding(ConstraintSpace(), CurrentChildStyle()); | 527 ComputePadding(ConstraintSpace(), CurrentChildStyle()); |
528 | 528 |
529 // Collapse BLOCK-START margins if there is no padding or border between | 529 // Collapse BLOCK-START margins if there is no padding or border between |
530 // parent (current child) and its first in-flow child. | 530 // parent (current child) and its first in-flow child. |
531 if (border_and_padding.block_start) { | 531 if (border_and_padding.block_start) { |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 | 622 |
623 // Add the float as an exclusion. | 623 // Add the float as an exclusion. |
624 const NGExclusion exclusion = CreateExclusion( | 624 const NGExclusion exclusion = CreateExclusion( |
625 fragment, opportunity, float_offset, margins, exclusion_type); | 625 fragment, opportunity, float_offset, margins, exclusion_type); |
626 constraint_space_->AddExclusion(exclusion); | 626 constraint_space_->AddExclusion(exclusion); |
627 | 627 |
628 return CalculateLogicalOffsetForOpportunity(opportunity, float_offset, | 628 return CalculateLogicalOffsetForOpportunity(opportunity, float_offset, |
629 margins); | 629 margins); |
630 } | 630 } |
631 | 631 |
632 void NGBlockLayoutAlgorithm::UpdateMarginStrut(const NGMarginStrut& from) { | 632 void NGBlockLayoutAlgorithm::UpdateMarginStrut( |
| 633 const NGDeprecatedMarginStrut& from) { |
633 if (!is_fragment_margin_strut_block_start_updated_) { | 634 if (!is_fragment_margin_strut_block_start_updated_) { |
634 builder_->SetMarginStrutBlockStart(from); | 635 builder_->SetMarginStrutBlockStart(from); |
635 is_fragment_margin_strut_block_start_updated_ = true; | 636 is_fragment_margin_strut_block_start_updated_ = true; |
636 } | 637 } |
637 builder_->SetMarginStrutBlockEnd(from); | 638 builder_->SetMarginStrutBlockEnd(from); |
638 } | 639 } |
639 | 640 |
640 NGBoxStrut NGBlockLayoutAlgorithm::CalculateMargins( | 641 NGBoxStrut NGBlockLayoutAlgorithm::CalculateMargins( |
641 const NGConstraintSpace& space, | 642 const NGConstraintSpace& space, |
642 const ComputedStyle& style) { | 643 const ComputedStyle& style) { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
692 visitor->trace(constraint_space_); | 693 visitor->trace(constraint_space_); |
693 visitor->trace(break_token_); | 694 visitor->trace(break_token_); |
694 visitor->trace(builder_); | 695 visitor->trace(builder_); |
695 visitor->trace(space_builder_); | 696 visitor->trace(space_builder_); |
696 visitor->trace(space_for_current_child_); | 697 visitor->trace(space_for_current_child_); |
697 visitor->trace(current_child_); | 698 visitor->trace(current_child_); |
698 visitor->trace(fragmentainer_mapper_); | 699 visitor->trace(fragmentainer_mapper_); |
699 } | 700 } |
700 | 701 |
701 } // namespace blink | 702 } // namespace blink |
OLD | NEW |