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_inline_node.h" | 5 #include "core/layout/ng/ng_inline_node.h" |
6 | 6 |
7 #include "core/layout/ng/ng_constraint_space.h" | 7 #include "core/layout/ng/ng_constraint_space.h" |
8 #include "core/layout/ng/ng_constraint_space_builder.h" | 8 #include "core/layout/ng/ng_constraint_space_builder.h" |
9 #include "core/layout/ng/ng_fragment_builder.h" | 9 #include "core/layout/ng/ng_fragment_builder.h" |
10 #include "core/layout/ng/ng_line_builder.h" | 10 #include "core/layout/ng/ng_line_builder.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 NGConstraintSpace* constraint_space = | 68 NGConstraintSpace* constraint_space = |
69 NGConstraintSpaceBuilder(kHorizontalTopBottom) | 69 NGConstraintSpaceBuilder(kHorizontalTopBottom) |
70 .ToConstraintSpace(kHorizontalTopBottom); | 70 .ToConstraintSpace(kHorizontalTopBottom); |
71 NGLineBuilder line_builder(node, constraint_space); | 71 NGLineBuilder line_builder(node, constraint_space); |
72 | 72 |
73 NGTextLayoutAlgorithm algorithm(node, constraint_space); | 73 NGTextLayoutAlgorithm algorithm(node, constraint_space); |
74 algorithm.LayoutInline(&line_builder); | 74 algorithm.LayoutInline(&line_builder); |
75 | 75 |
76 NGFragmentBuilder fragment_builder(NGPhysicalFragment::kFragmentBox, node); | 76 NGFragmentBuilder fragment_builder(NGPhysicalFragment::kFragmentBox, node); |
77 line_builder.CreateFragments(&fragment_builder); | 77 line_builder.CreateFragments(&fragment_builder); |
78 RefPtr<NGPhysicalBoxFragment> fragment = fragment_builder.ToBoxFragment(); | 78 RefPtr<NGLayoutResult> result = fragment_builder.ToBoxFragment(); |
79 for (const auto& child : fragment->Children()) { | 79 for (const auto& child : |
| 80 toNGPhysicalBoxFragment(result->PhysicalFragment().get()) |
| 81 ->Children()) { |
80 fragments_out->push_back(toNGPhysicalTextFragment(child.get())); | 82 fragments_out->push_back(toNGPhysicalTextFragment(child.get())); |
81 } | 83 } |
82 } | 84 } |
83 | 85 |
84 RefPtr<ComputedStyle> style_; | 86 RefPtr<ComputedStyle> style_; |
85 }; | 87 }; |
86 | 88 |
87 #define TEST_ITEM_OFFSET_DIR(item, start, end, direction) \ | 89 #define TEST_ITEM_OFFSET_DIR(item, start, end, direction) \ |
88 EXPECT_EQ(start, item.StartOffset()); \ | 90 EXPECT_EQ(start, item.StartOffset()); \ |
89 EXPECT_EQ(end, item.EndOffset()); \ | 91 EXPECT_EQ(end, item.EndOffset()); \ |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 CreateLine(node, &fragments); | 196 CreateLine(node, &fragments); |
195 ASSERT_EQ(5u, fragments.size()); | 197 ASSERT_EQ(5u, fragments.size()); |
196 TEST_TEXT_FRAGMENT(fragments[0], node, 0u, 0u, 6u, TextDirection::kLtr); | 198 TEST_TEXT_FRAGMENT(fragments[0], node, 0u, 0u, 6u, TextDirection::kLtr); |
197 TEST_TEXT_FRAGMENT(fragments[1], node, 6u, 16u, 21u, TextDirection::kRtl); | 199 TEST_TEXT_FRAGMENT(fragments[1], node, 6u, 16u, 21u, TextDirection::kRtl); |
198 TEST_TEXT_FRAGMENT(fragments[2], node, 4u, 14u, 15u, TextDirection::kLtr); | 200 TEST_TEXT_FRAGMENT(fragments[2], node, 4u, 14u, 15u, TextDirection::kLtr); |
199 TEST_TEXT_FRAGMENT(fragments[3], node, 2u, 7u, 13u, TextDirection::kRtl); | 201 TEST_TEXT_FRAGMENT(fragments[3], node, 2u, 7u, 13u, TextDirection::kRtl); |
200 TEST_TEXT_FRAGMENT(fragments[4], node, 8u, 22u, 28u, TextDirection::kLtr); | 202 TEST_TEXT_FRAGMENT(fragments[4], node, 8u, 22u, 28u, TextDirection::kLtr); |
201 } | 203 } |
202 | 204 |
203 } // namespace blink | 205 } // namespace blink |
OLD | NEW |