| 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/inline/ng_inline_node.h" | 5 #include "core/layout/ng/inline/ng_inline_node.h" |
| 6 | 6 |
| 7 #include "core/layout/BidiRun.h" | 7 #include "core/layout/BidiRun.h" |
| 8 #include "core/layout/LayoutBlockFlow.h" | 8 #include "core/layout/LayoutBlockFlow.h" |
| 9 #include "core/layout/LayoutObject.h" | 9 #include "core/layout/LayoutObject.h" |
| 10 #include "core/layout/LayoutText.h" | 10 #include "core/layout/LayoutText.h" |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 | 347 |
| 348 RefPtr<NGLayoutResult> NGInlineNode::Layout(NGConstraintSpace* constraint_space, | 348 RefPtr<NGLayoutResult> NGInlineNode::Layout(NGConstraintSpace* constraint_space, |
| 349 NGBreakToken* break_token) { | 349 NGBreakToken* break_token) { |
| 350 // TODO(kojii): Invalidate PrepareLayout() more efficiently. | 350 // TODO(kojii): Invalidate PrepareLayout() more efficiently. |
| 351 InvalidatePrepareLayout(); | 351 InvalidatePrepareLayout(); |
| 352 PrepareLayout(); | 352 PrepareLayout(); |
| 353 | 353 |
| 354 NGInlineLayoutAlgorithm algorithm(*this, constraint_space, | 354 NGInlineLayoutAlgorithm algorithm(*this, constraint_space, |
| 355 ToNGInlineBreakToken(break_token)); | 355 ToNGInlineBreakToken(break_token)); |
| 356 RefPtr<NGLayoutResult> result = algorithm.Layout(); | 356 RefPtr<NGLayoutResult> result = algorithm.Layout(); |
| 357 CopyFragmentDataToLayoutBox(*constraint_space, result.Get()); | 357 |
| 358 if (result->Status() == NGLayoutResult::kSuccess && |
| 359 result->UnpositionedFloats().IsEmpty()) |
| 360 CopyFragmentDataToLayoutBox(*constraint_space, result.Get()); |
| 361 |
| 358 return result; | 362 return result; |
| 359 } | 363 } |
| 360 | 364 |
| 361 static LayoutUnit ComputeContentSize(NGInlineNode node, | 365 static LayoutUnit ComputeContentSize(NGInlineNode node, |
| 362 LayoutUnit available_inline_size) { | 366 LayoutUnit available_inline_size) { |
| 363 const ComputedStyle& style = node.Style(); | 367 const ComputedStyle& style = node.Style(); |
| 364 NGWritingMode writing_mode = FromPlatformWritingMode(style.GetWritingMode()); | 368 NGWritingMode writing_mode = FromPlatformWritingMode(style.GetWritingMode()); |
| 365 | 369 |
| 366 RefPtr<NGConstraintSpace> space = | 370 RefPtr<NGConstraintSpace> space = |
| 367 NGConstraintSpaceBuilder(writing_mode) | 371 NGConstraintSpaceBuilder(writing_mode) |
| 368 .SetTextDirection(style.Direction()) | 372 .SetTextDirection(style.Direction()) |
| 369 .SetAvailableSize({available_inline_size, NGSizeIndefinite}) | 373 .SetAvailableSize({available_inline_size, NGSizeIndefinite}) |
| 370 .ToConstraintSpace(writing_mode); | 374 .ToConstraintSpace(writing_mode); |
| 371 | 375 |
| 372 NGFragmentBuilder container_builder( | 376 NGFragmentBuilder container_builder( |
| 373 NGPhysicalFragment::NGFragmentType::kFragmentBox, node); | 377 NGPhysicalFragment::NGFragmentType::kFragmentBox, node); |
| 374 container_builder.SetBfcOffset(NGLogicalOffset{LayoutUnit(), LayoutUnit()}); | 378 container_builder.SetBfcOffset(NGLogicalOffset{LayoutUnit(), LayoutUnit()}); |
| 375 | 379 |
| 376 NGLineBreaker line_breaker(node, space.Get(), &container_builder); | 380 Vector<RefPtr<NGUnpositionedFloat>> unpositioned_floats; |
| 381 NGLineBreaker line_breaker(node, space.Get(), &container_builder, |
| 382 &unpositioned_floats); |
| 383 |
| 377 NGLineInfo line_info; | 384 NGLineInfo line_info; |
| 378 LayoutUnit result; | 385 LayoutUnit result; |
| 379 while (line_breaker.NextLine(&line_info, NGLogicalOffset())) { | 386 while (line_breaker.NextLine(&line_info, NGLogicalOffset())) { |
| 380 LayoutUnit inline_size = line_info.TextIndent(); | 387 LayoutUnit inline_size = line_info.TextIndent(); |
| 381 for (const NGInlineItemResult item_result : line_info.Results()) | 388 for (const NGInlineItemResult item_result : line_info.Results()) |
| 382 inline_size += item_result.inline_size; | 389 inline_size += item_result.inline_size; |
| 383 result = std::max(inline_size, result); | 390 result = std::max(inline_size, result); |
| 384 } | 391 } |
| 385 return result; | 392 return result; |
| 386 } | 393 } |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 item.Style() == item.GetLayoutObject()->Style()); | 548 item.Style() == item.GetLayoutObject()->Style()); |
| 542 } | 549 } |
| 543 #endif | 550 #endif |
| 544 } | 551 } |
| 545 | 552 |
| 546 String NGInlineNode::ToString() const { | 553 String NGInlineNode::ToString() const { |
| 547 return String::Format("NGInlineNode"); | 554 return String::Format("NGInlineNode"); |
| 548 } | 555 } |
| 549 | 556 |
| 550 } // namespace blink | 557 } // namespace blink |
| OLD | NEW |