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_base_layout_algorithm_test.h" | 5 #include "core/layout/ng/ng_base_layout_algorithm_test.h" |
6 | 6 |
7 #include "core/layout/ng/inline/ng_inline_layout_algorithm.h" | 7 #include "core/layout/ng/inline/ng_inline_layout_algorithm.h" |
8 #include "core/layout/ng/inline/ng_inline_node.h" | 8 #include "core/layout/ng/inline/ng_inline_node.h" |
9 #include "core/layout/ng/inline/ng_line_breaker.h" | 9 #include "core/layout/ng/inline/ng_line_breaker.h" |
10 #include "core/layout/ng/layout_ng_block_flow.h" | 10 #include "core/layout/ng/layout_ng_block_flow.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 if (!node.IsPrepareLayoutFinished()) | 31 if (!node.IsPrepareLayoutFinished()) |
32 node.PrepareLayout(); | 32 node.PrepareLayout(); |
33 | 33 |
34 RefPtr<NGConstraintSpace> space = | 34 RefPtr<NGConstraintSpace> space = |
35 NGConstraintSpaceBuilder(NGWritingMode::kHorizontalTopBottom) | 35 NGConstraintSpaceBuilder(NGWritingMode::kHorizontalTopBottom) |
36 .SetAvailableSize({available_width, NGSizeIndefinite}) | 36 .SetAvailableSize({available_width, NGSizeIndefinite}) |
37 .ToConstraintSpace(NGWritingMode::kHorizontalTopBottom); | 37 .ToConstraintSpace(NGWritingMode::kHorizontalTopBottom); |
38 NGLineBreaker line_breaker(node, space.Get()); | 38 NGLineBreaker line_breaker(node, space.Get()); |
39 NGInlineLayoutAlgorithm algorithm(node, space.Get()); | 39 NGInlineLayoutAlgorithm algorithm(node, space.Get()); |
40 Vector<NGInlineItemResults> lines; | 40 Vector<NGInlineItemResults> lines; |
41 while (true) { | 41 NGLineInfo line_info; |
42 NGInlineItemResults item_results; | 42 while (line_breaker.NextLine(&line_info, &algorithm)) |
43 line_breaker.NextLine(&item_results, &algorithm); | 43 lines.push_back(std::move(line_info.Results())); |
44 if (item_results.IsEmpty()) | |
45 break; | |
46 lines.push_back(item_results); | |
47 } | |
48 return lines; | 44 return lines; |
49 } | 45 } |
50 }; | 46 }; |
51 | 47 |
52 namespace { | 48 namespace { |
53 | 49 |
54 String ToString(NGInlineItemResults line, NGInlineNode node) { | 50 String ToString(NGInlineItemResults line, NGInlineNode node) { |
55 StringBuilder builder; | 51 StringBuilder builder; |
56 for (const auto& item_result : line) { | 52 for (const auto& item_result : line) { |
57 builder.Append(node.Text(item_result.start_offset, item_result.end_offset)); | 53 builder.Append(node.Text(item_result.start_offset, item_result.end_offset)); |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 EXPECT_EQ("789", ToString(lines[1], node)); | 257 EXPECT_EQ("789", ToString(lines[1], node)); |
262 | 258 |
263 lines = BreakLines(node, LayoutUnit(20)); | 259 lines = BreakLines(node, LayoutUnit(20)); |
264 EXPECT_EQ(2u, lines.size()); | 260 EXPECT_EQ(2u, lines.size()); |
265 EXPECT_EQ("123456", ToString(lines[0], node)); | 261 EXPECT_EQ("123456", ToString(lines[0], node)); |
266 EXPECT_EQ("789", ToString(lines[1], node)); | 262 EXPECT_EQ("789", ToString(lines[1], node)); |
267 } | 263 } |
268 | 264 |
269 } // namespace | 265 } // namespace |
270 } // namespace blink | 266 } // namespace blink |
OLD | NEW |