Chromium Code Reviews| 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 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 348 | 348 |
| 349 RefPtr<NGLayoutResult> NGInlineNode::Layout(NGConstraintSpace* constraint_space, | 349 RefPtr<NGLayoutResult> NGInlineNode::Layout(NGConstraintSpace* constraint_space, |
| 350 NGBreakToken* break_token) { | 350 NGBreakToken* break_token) { |
| 351 // TODO(kojii): Invalidate PrepareLayout() more efficiently. | 351 // TODO(kojii): Invalidate PrepareLayout() more efficiently. |
| 352 InvalidatePrepareLayout(); | 352 InvalidatePrepareLayout(); |
| 353 PrepareLayout(); | 353 PrepareLayout(); |
| 354 | 354 |
| 355 NGInlineLayoutAlgorithm algorithm(*this, constraint_space, | 355 NGInlineLayoutAlgorithm algorithm(*this, constraint_space, |
| 356 ToNGInlineBreakToken(break_token)); | 356 ToNGInlineBreakToken(break_token)); |
| 357 RefPtr<NGLayoutResult> result = algorithm.Layout(); | 357 RefPtr<NGLayoutResult> result = algorithm.Layout(); |
| 358 CopyFragmentDataToLayoutBox(*constraint_space, result.Get()); | 358 |
| 359 if (result->Status() == NGLayoutResult::kSuccess && | |
|
eae
2017/07/10 23:27:49
Should we return success even when we failed to po
ikilpatrick
2017/07/11 17:20:41
This does at the moment, we don't want to "abort"
| |
| 360 result->UnpositionedFloats().IsEmpty()) | |
| 361 CopyFragmentDataToLayoutBox(*constraint_space, result.Get()); | |
| 362 | |
| 359 return result; | 363 return result; |
| 360 } | 364 } |
| 361 | 365 |
| 362 enum class ContentSizeMode { Max, Sum }; | 366 enum class ContentSizeMode { Max, Sum }; |
| 363 | 367 |
| 364 static LayoutUnit ComputeContentSize(NGInlineNode node, | 368 static LayoutUnit ComputeContentSize(NGInlineNode node, |
| 365 ContentSizeMode mode, | 369 ContentSizeMode mode, |
| 366 LayoutUnit available_inline_size) { | 370 LayoutUnit available_inline_size) { |
| 367 const ComputedStyle& style = node.Style(); | 371 const ComputedStyle& style = node.Style(); |
| 368 NGWritingMode writing_mode = FromPlatformWritingMode(style.GetWritingMode()); | 372 NGWritingMode writing_mode = FromPlatformWritingMode(style.GetWritingMode()); |
| 369 | 373 |
| 370 RefPtr<NGConstraintSpace> space = | 374 RefPtr<NGConstraintSpace> space = |
| 371 NGConstraintSpaceBuilder(writing_mode) | 375 NGConstraintSpaceBuilder(writing_mode) |
| 372 .SetTextDirection(style.Direction()) | 376 .SetTextDirection(style.Direction()) |
| 373 .SetAvailableSize({available_inline_size, NGSizeIndefinite}) | 377 .SetAvailableSize({available_inline_size, NGSizeIndefinite}) |
| 374 .ToConstraintSpace(writing_mode); | 378 .ToConstraintSpace(writing_mode); |
| 375 | 379 |
| 376 NGFragmentBuilder container_builder( | 380 NGFragmentBuilder container_builder( |
| 377 NGPhysicalFragment::NGFragmentType::kFragmentBox, node); | 381 NGPhysicalFragment::NGFragmentType::kFragmentBox, node); |
| 378 container_builder.SetBfcOffset(NGLogicalOffset{LayoutUnit(), LayoutUnit()}); | 382 container_builder.SetBfcOffset(NGLogicalOffset{LayoutUnit(), LayoutUnit()}); |
| 379 | 383 |
| 380 NGLineBreaker line_breaker(node, space.Get(), &container_builder); | 384 Vector<RefPtr<NGUnpositionedFloat>> unpositioned_floats; |
| 385 NGLineBreaker line_breaker(node, space.Get(), &container_builder, | |
| 386 &unpositioned_floats); | |
| 387 | |
| 381 NGLineInfo line_info; | 388 NGLineInfo line_info; |
| 382 LayoutUnit result; | 389 LayoutUnit result; |
| 383 while (line_breaker.NextLine(&line_info, NGLogicalOffset())) { | 390 while (line_breaker.NextLine(&line_info, NGLogicalOffset())) { |
| 384 LayoutUnit inline_size = line_info.TextIndent(); | 391 LayoutUnit inline_size = line_info.TextIndent(); |
| 385 for (const NGInlineItemResult item_result : line_info.Results()) | 392 for (const NGInlineItemResult item_result : line_info.Results()) |
| 386 inline_size += item_result.inline_size; | 393 inline_size += item_result.inline_size; |
| 387 if (mode == ContentSizeMode::Max) { | 394 if (mode == ContentSizeMode::Max) { |
| 388 result = std::max(inline_size, result); | 395 result = std::max(inline_size, result); |
| 389 } else { | 396 } else { |
| 390 result += inline_size; | 397 result += inline_size; |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 548 item.Style() == item.GetLayoutObject()->Style()); | 555 item.Style() == item.GetLayoutObject()->Style()); |
| 549 } | 556 } |
| 550 #endif | 557 #endif |
| 551 } | 558 } |
| 552 | 559 |
| 553 String NGInlineNode::ToString() const { | 560 String NGInlineNode::ToString() const { |
| 554 return String::Format("NGInlineNode"); | 561 return String::Format("NGInlineNode"); |
| 555 } | 562 } |
| 556 | 563 |
| 557 } // namespace blink | 564 } // namespace blink |
| OLD | NEW |