| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_floats_utils.h" | 5 #include "core/layout/ng/ng_floats_utils.h" |
| 6 | 6 |
| 7 #include "core/layout/ng/ng_box_fragment.h" | 7 #include "core/layout/ng/ng_box_fragment.h" |
| 8 | 8 |
| 9 namespace blink { | 9 namespace blink { |
| 10 namespace { | 10 namespace { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 // @param floating_object Floating object for which we need to find a layout | 39 // @param floating_object Floating object for which we need to find a layout |
| 40 // opportunity. | 40 // opportunity. |
| 41 // @return Layout opportunity for the fragment. | 41 // @return Layout opportunity for the fragment. |
| 42 const NGLayoutOpportunity FindLayoutOpportunityForFragment( | 42 const NGLayoutOpportunity FindLayoutOpportunityForFragment( |
| 43 const NGConstraintSpace* space, | 43 const NGConstraintSpace* space, |
| 44 const NGFragment& fragment, | 44 const NGFragment& fragment, |
| 45 const NGFloatingObject* floating_object) { | 45 const NGFloatingObject* floating_object) { |
| 46 NGLogicalOffset adjusted_origin_point = | 46 NGLogicalOffset adjusted_origin_point = |
| 47 AdjustToTopEdgeAlignmentRule(*space, floating_object->origin_offset); | 47 AdjustToTopEdgeAlignmentRule(*space, floating_object->origin_offset); |
| 48 | 48 |
| 49 NGLayoutOpportunityIterator opportunity_iter( | 49 NGLayoutOpportunityIterator opportunity_iter(space->Exclusions().get(), |
| 50 space, floating_object->available_size, adjusted_origin_point); | 50 floating_object->available_size, |
| 51 adjusted_origin_point); |
| 51 NGLayoutOpportunity opportunity; | 52 NGLayoutOpportunity opportunity; |
| 52 NGLayoutOpportunity opportunity_candidate = opportunity_iter.Next(); | 53 NGLayoutOpportunity opportunity_candidate = opportunity_iter.Next(); |
| 53 | 54 |
| 54 NGBoxStrut margins = floating_object->margins; | 55 NGBoxStrut margins = floating_object->margins; |
| 55 while (!opportunity_candidate.IsEmpty()) { | 56 while (!opportunity_candidate.IsEmpty()) { |
| 56 opportunity = opportunity_candidate; | 57 opportunity = opportunity_candidate; |
| 57 // Checking opportunity's block size is not necessary as a float cannot be | 58 // Checking opportunity's block size is not necessary as a float cannot be |
| 58 // positioned on top of another float inside of the same constraint space. | 59 // positioned on top of another float inside of the same constraint space. |
| 59 auto fragment_inline_size = fragment.InlineSize() + margins.InlineSum(); | 60 auto fragment_inline_size = fragment.InlineSize() + margins.InlineSum(); |
| 60 if (opportunity.size.inline_size >= fragment_inline_size) | 61 if (opportunity.size.inline_size >= fragment_inline_size) |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 floating_object->origin_offset.block_offset = origin_block_offset; | 174 floating_object->origin_offset.block_offset = origin_block_offset; |
| 174 floating_object->from_offset.block_offset = bfc_block_offset; | 175 floating_object->from_offset.block_offset = bfc_block_offset; |
| 175 | 176 |
| 176 NGLogicalOffset offset = PositionFloat(floating_object.Get(), space); | 177 NGLogicalOffset offset = PositionFloat(floating_object.Get(), space); |
| 177 builder->AddFloatingObject(floating_object, offset); | 178 builder->AddFloatingObject(floating_object, offset); |
| 178 } | 179 } |
| 179 builder->MutableUnpositionedFloats().Clear(); | 180 builder->MutableUnpositionedFloats().Clear(); |
| 180 } | 181 } |
| 181 | 182 |
| 182 } // namespace blink | 183 } // namespace blink |
| OLD | NEW |