| Index: third_party/WebKit/Source/core/layout/ng/inline/ng_inline_node.cc
|
| diff --git a/third_party/WebKit/Source/core/layout/ng/inline/ng_inline_node.cc b/third_party/WebKit/Source/core/layout/ng/inline/ng_inline_node.cc
|
| index 7c048de1350880c5663a48df6b6fc11c6512572a..99d716ae00b40a65ec02fc84b289e7e452335cdb 100644
|
| --- a/third_party/WebKit/Source/core/layout/ng/inline/ng_inline_node.cc
|
| +++ b/third_party/WebKit/Source/core/layout/ng/inline/ng_inline_node.cc
|
| @@ -16,6 +16,7 @@
|
| #include "core/layout/ng/inline/ng_inline_items_builder.h"
|
| #include "core/layout/ng/inline/ng_inline_layout_algorithm.h"
|
| #include "core/layout/ng/inline/ng_line_box_fragment.h"
|
| +#include "core/layout/ng/inline/ng_line_breaker.h"
|
| #include "core/layout/ng/inline/ng_physical_line_box_fragment.h"
|
| #include "core/layout/ng/inline/ng_physical_text_fragment.h"
|
| #include "core/layout/ng/inline/ng_text_fragment.h"
|
| @@ -204,22 +205,60 @@ RefPtr<NGLayoutResult> NGInlineNode::Layout(NGConstraintSpace* constraint_space,
|
| return result;
|
| }
|
|
|
| +static LayoutUnit ComputeContentSize(NGInlineNode* node,
|
| + NGConstraintSpace* space,
|
| + bool compute_min_content) {
|
| + NGLineBreaker line_breaker(node, space);
|
| + NGInlineLayoutAlgorithm algorithm(node, space);
|
| + NGInlineItemResults item_results;
|
| + LayoutUnit result;
|
| + while (true) {
|
| + line_breaker.NextLine(&item_results, &algorithm);
|
| + if (item_results.IsEmpty())
|
| + break;
|
| + LayoutUnit inline_size;
|
| + for (const NGInlineItemResult item_result : item_results)
|
| + inline_size += item_result.inline_size;
|
| + if (compute_min_content) {
|
| + result = std::max(inline_size, result);
|
| + } else {
|
| + result += inline_size;
|
| + }
|
| + item_results.clear();
|
| + }
|
| + return result;
|
| +}
|
| +
|
| MinMaxContentSize NGInlineNode::ComputeMinMaxContentSize() {
|
| if (!IsPrepareLayoutFinished())
|
| PrepareLayout();
|
|
|
| + // Run line breaking with 0 and indefinite available width.
|
| + // TODO(kojii): There are several ways to make this more efficient and faster
|
| + // than runnning two line breaking.
|
| +
|
| // Compute the max of inline sizes of all line boxes with 0 available inline
|
| - // size. This gives the min-content, the width where lines wrap at every break
|
| - // opportunity.
|
| - NGWritingMode writing_mode =
|
| - FromPlatformWritingMode(Style().GetWritingMode());
|
| - RefPtr<NGConstraintSpace> constraint_space =
|
| - NGConstraintSpaceBuilder(writing_mode)
|
| - .SetTextDirection(Style().Direction())
|
| - .SetAvailableSize({LayoutUnit(), NGSizeIndefinite})
|
| - .ToConstraintSpace(writing_mode);
|
| - NGInlineLayoutAlgorithm algorithm(this, constraint_space.Get());
|
| - return algorithm.ComputeMinMaxContentSizeByLayout();
|
| + // size. This gives the min-content, the width where lines wrap at every
|
| + // break opportunity.
|
| + const ComputedStyle& style = Style();
|
| + NGWritingMode writing_mode = FromPlatformWritingMode(style.GetWritingMode());
|
| + NGConstraintSpaceBuilder space_builder(writing_mode);
|
| + space_builder.SetTextDirection(style.Direction());
|
| + MinMaxContentSize sizes;
|
| + space_builder.SetAvailableSize({LayoutUnit(), NGSizeIndefinite});
|
| + RefPtr<NGConstraintSpace> space =
|
| + space_builder.ToConstraintSpace(writing_mode);
|
| + sizes.min_content = ComputeContentSize(this, space.Get(), true);
|
| +
|
| + // Compute the sum of inline sizes of all inline boxes with no line breaks.
|
| + // TODO(kojii): NGConstraintSpaceBuilder does not allow NGSizeIndefinite
|
| + // inline available size. We can allow it, or make this more efficient
|
| + // without using NGLineBreaker.
|
| + space_builder.SetAvailableSize({LayoutUnit::Max(), NGSizeIndefinite});
|
| + space = space_builder.ToConstraintSpace(writing_mode);
|
| + sizes.max_content = ComputeContentSize(this, space.Get(), false);
|
| +
|
| + return sizes;
|
| }
|
|
|
| NGLayoutInputNode* NGInlineNode::NextSibling() {
|
|
|