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_layout_opportunity_iterator.h" | 5 #include "core/layout/ng/ng_layout_opportunity_iterator.h" |
6 #include "core/layout/ng/ng_constraint_space.h" | 6 #include "core/layout/ng/ng_constraint_space.h" |
7 #include "core/layout/ng/ng_exclusion.h" | 7 #include "core/layout/ng/ng_exclusion.h" |
8 #include "platform/wtf/NonCopyingSort.h" | 8 #include "platform/wtf/NonCopyingSort.h" |
9 #include "platform/wtf/text/StringBuilder.h" | 9 #include "platform/wtf/text/StringBuilder.h" |
10 | 10 |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 const NGLogicalSize& available_size, | 264 const NGLogicalSize& available_size, |
265 const NGLogicalOffset& origin_point, | 265 const NGLogicalOffset& origin_point, |
266 const NGBoxStrut& margins, | 266 const NGBoxStrut& margins, |
267 const NGFragment& fragment) { | 267 const NGFragment& fragment) { |
268 NGLayoutOpportunityIterator opportunity_iter(exclusions, available_size, | 268 NGLayoutOpportunityIterator opportunity_iter(exclusions, available_size, |
269 origin_point); | 269 origin_point); |
270 NGLayoutOpportunity opportunity; | 270 NGLayoutOpportunity opportunity; |
271 NGLayoutOpportunity opportunity_candidate = opportunity_iter.Next(); | 271 NGLayoutOpportunity opportunity_candidate = opportunity_iter.Next(); |
272 while (!opportunity_candidate.IsEmpty()) { | 272 while (!opportunity_candidate.IsEmpty()) { |
273 opportunity = opportunity_candidate; | 273 opportunity = opportunity_candidate; |
274 // Checking opportunity's block size is not necessary as a float cannot be | |
275 // positioned on top of another float inside of the same constraint space. | |
276 auto fragment_inline_size = fragment.InlineSize() + margins.InlineSum(); | 274 auto fragment_inline_size = fragment.InlineSize() + margins.InlineSum(); |
277 if (opportunity.size.inline_size >= fragment_inline_size) | 275 auto fragment_block_size = fragment.BlockSize() + margins.BlockSum(); |
| 276 if (opportunity.size.inline_size >= fragment_inline_size && |
| 277 opportunity.size.block_size >= fragment_block_size) |
278 break; | 278 break; |
279 opportunity_candidate = opportunity_iter.Next(); | 279 opportunity_candidate = opportunity_iter.Next(); |
280 } | 280 } |
281 return opportunity; | 281 return opportunity; |
282 } | 282 } |
283 | 283 |
284 NGLayoutOpportunityIterator::NGLayoutOpportunityIterator( | 284 NGLayoutOpportunityIterator::NGLayoutOpportunityIterator( |
285 const NGExclusions* exclusions, | 285 const NGExclusions* exclusions, |
286 const NGLogicalSize& available_size, | 286 const NGLogicalSize& available_size, |
287 const NGLogicalOffset& offset) | 287 const NGLogicalOffset& offset) |
(...skipping 30 matching lines...) Expand all Loading... |
318 #ifndef NDEBUG | 318 #ifndef NDEBUG |
319 void NGLayoutOpportunityIterator::ShowLayoutOpportunityTree() const { | 319 void NGLayoutOpportunityIterator::ShowLayoutOpportunityTree() const { |
320 StringBuilder string_builder; | 320 StringBuilder string_builder; |
321 string_builder.Append("\n.:: LayoutOpportunity Tree ::.\n\nRoot Node: "); | 321 string_builder.Append("\n.:: LayoutOpportunity Tree ::.\n\nRoot Node: "); |
322 AppendNodeToString(opportunity_tree_root_.get(), &string_builder); | 322 AppendNodeToString(opportunity_tree_root_.get(), &string_builder); |
323 fprintf(stderr, "%s\n", string_builder.ToString().Utf8().data()); | 323 fprintf(stderr, "%s\n", string_builder.ToString().Utf8().data()); |
324 } | 324 } |
325 #endif | 325 #endif |
326 | 326 |
327 } // namespace blink | 327 } // namespace blink |
OLD | NEW |