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_column_mapper.h" | 9 #include "core/layout/ng/ng_column_mapper.h" |
10 #include "core/layout/ng/ng_constraint_space.h" | 10 #include "core/layout/ng/ng_constraint_space.h" |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 // @param margins Margins of the fragment. | 124 // @param margins Margins of the fragment. |
125 // @return Layout opportunity for the fragment. | 125 // @return Layout opportunity for the fragment. |
126 const NGLayoutOpportunity FindLayoutOpportunityForFragment( | 126 const NGLayoutOpportunity FindLayoutOpportunityForFragment( |
127 NGConstraintSpace* space, | 127 NGConstraintSpace* space, |
128 const NGFragment& fragment, | 128 const NGFragment& fragment, |
129 const NGLogicalOffset& origin_point, | 129 const NGLogicalOffset& origin_point, |
130 const NGBoxStrut& margins) { | 130 const NGBoxStrut& margins) { |
131 NGLogicalOffset adjusted_origin_point = | 131 NGLogicalOffset adjusted_origin_point = |
132 AdjustToTopEdgeAlignmentRule(*space, origin_point); | 132 AdjustToTopEdgeAlignmentRule(*space, origin_point); |
133 | 133 |
134 NGLayoutOpportunityIterator* opportunity_iter = | 134 NGLayoutOpportunityIterator opportunity_iter(space, adjusted_origin_point); |
135 space->LayoutOpportunities(adjusted_origin_point); | |
136 NGLayoutOpportunity opportunity; | 135 NGLayoutOpportunity opportunity; |
137 NGLayoutOpportunity opportunity_candidate = opportunity_iter->Next(); | 136 NGLayoutOpportunity opportunity_candidate = opportunity_iter.Next(); |
138 | 137 |
139 while (!opportunity_candidate.IsEmpty()) { | 138 while (!opportunity_candidate.IsEmpty()) { |
140 opportunity = opportunity_candidate; | 139 opportunity = opportunity_candidate; |
141 // Checking opportunity's block size is not necessary as a float cannot be | 140 // Checking opportunity's block size is not necessary as a float cannot be |
142 // positioned on top of another float inside of the same constraint space. | 141 // positioned on top of another float inside of the same constraint space. |
143 auto fragment_inline_size = fragment.InlineSize() + margins.InlineSum(); | 142 auto fragment_inline_size = fragment.InlineSize() + margins.InlineSum(); |
144 if (opportunity.size.inline_size >= fragment_inline_size) | 143 if (opportunity.size.inline_size >= fragment_inline_size) |
145 break; | 144 break; |
146 opportunity_candidate = opportunity_iter->Next(); | 145 |
| 146 opportunity_candidate = opportunity_iter.Next(); |
147 } | 147 } |
148 return opportunity; | 148 return opportunity; |
149 } | 149 } |
150 | 150 |
151 // Calculates the logical offset for opportunity. | 151 // Calculates the logical offset for opportunity. |
152 NGLogicalOffset CalculateLogicalOffsetForOpportunity( | 152 NGLogicalOffset CalculateLogicalOffsetForOpportunity( |
153 const NGLayoutOpportunity& opportunity, | 153 const NGLayoutOpportunity& opportunity, |
154 const LayoutUnit float_offset, | 154 const LayoutUnit float_offset, |
155 const NGBoxStrut& margins, | 155 const NGBoxStrut& margins, |
156 const NGLogicalOffset& space_offset) { | 156 const NGLogicalOffset& space_offset) { |
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
712 curr_bfc_offset_.inline_offset += border_and_padding_.inline_start; | 712 curr_bfc_offset_.inline_offset += border_and_padding_.inline_start; |
713 if (ConstraintSpace().IsNewFormattingContext()) { | 713 if (ConstraintSpace().IsNewFormattingContext()) { |
714 curr_bfc_offset_.inline_offset += curr_child_margins_.inline_start; | 714 curr_bfc_offset_.inline_offset += curr_child_margins_.inline_start; |
715 } | 715 } |
716 space_builder_->SetBfcOffset(curr_bfc_offset_); | 716 space_builder_->SetBfcOffset(curr_bfc_offset_); |
717 | 717 |
718 return space_builder_->ToConstraintSpace(); | 718 return space_builder_->ToConstraintSpace(); |
719 } | 719 } |
720 | 720 |
721 } // namespace blink | 721 } // namespace blink |
OLD | NEW |