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_physical_fragment.h" | 10 #include "core/layout/ng/ng_physical_box_fragment.h" |
11 #include "core/layout/ng/ng_physical_text_fragment.h" | 11 #include "core/layout/ng/ng_physical_text_fragment.h" |
12 #include "core/layout/ng/ng_text_fragment.h" | 12 #include "core/layout/ng/ng_text_fragment.h" |
13 #include "core/layout/ng/ng_text_layout_algorithm.h" | 13 #include "core/layout/ng/ng_text_layout_algorithm.h" |
14 #include "core/layout/ng/ng_line_builder.h" | 14 #include "core/layout/ng/ng_line_builder.h" |
15 #include "core/style/ComputedStyle.h" | 15 #include "core/style/ComputedStyle.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
17 | 17 |
18 namespace blink { | 18 namespace blink { |
19 | 19 |
20 class NGInlineNodeForTest : public NGInlineNode { | 20 class NGInlineNodeForTest : public NGInlineNode { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 void CreateLine( | 61 void CreateLine( |
62 NGInlineNode* node, | 62 NGInlineNode* node, |
63 HeapVector<Member<const NGPhysicalTextFragment>>* fragments_out) { | 63 HeapVector<Member<const NGPhysicalTextFragment>>* fragments_out) { |
64 NGConstraintSpace* constraint_space = | 64 NGConstraintSpace* constraint_space = |
65 NGConstraintSpaceBuilder(kHorizontalTopBottom).ToConstraintSpace(); | 65 NGConstraintSpaceBuilder(kHorizontalTopBottom).ToConstraintSpace(); |
66 NGLineBuilder line_builder(node, constraint_space); | 66 NGLineBuilder line_builder(node, constraint_space); |
67 NGTextLayoutAlgorithm* algorithm = | 67 NGTextLayoutAlgorithm* algorithm = |
68 new NGTextLayoutAlgorithm(node, constraint_space); | 68 new NGTextLayoutAlgorithm(node, constraint_space); |
69 algorithm->LayoutInline(&line_builder); | 69 algorithm->LayoutInline(&line_builder); |
70 | 70 |
71 NGFragmentBuilder fragment_builder(NGPhysicalFragmentBase::kFragmentBox); | 71 NGFragmentBuilder fragment_builder(NGPhysicalFragment::kFragmentBox); |
72 line_builder.CreateFragments(&fragment_builder); | 72 line_builder.CreateFragments(&fragment_builder); |
73 NGPhysicalFragment* fragment = fragment_builder.ToFragment(); | 73 NGPhysicalBoxFragment* fragment = fragment_builder.ToBoxFragment(); |
74 for (const NGPhysicalFragmentBase* child : fragment->Children()) { | 74 for (const NGPhysicalFragment* child : fragment->Children()) { |
75 fragments_out->append(toNGPhysicalTextFragment(child)); | 75 fragments_out->append(toNGPhysicalTextFragment(child)); |
76 } | 76 } |
77 } | 77 } |
78 | 78 |
79 RefPtr<ComputedStyle> style_; | 79 RefPtr<ComputedStyle> style_; |
80 }; | 80 }; |
81 | 81 |
82 #define TEST_ITEM_OFFSET_DIR(item, start, end, direction) \ | 82 #define TEST_ITEM_OFFSET_DIR(item, start, end, direction) \ |
83 EXPECT_EQ(start, item.StartOffset()); \ | 83 EXPECT_EQ(start, item.StartOffset()); \ |
84 EXPECT_EQ(end, item.EndOffset()); \ | 84 EXPECT_EQ(end, item.EndOffset()); \ |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 CreateLine(node, &fragments); | 185 CreateLine(node, &fragments); |
186 ASSERT_EQ(5u, fragments.size()); | 186 ASSERT_EQ(5u, fragments.size()); |
187 TEST_TEXT_FRAGMENT(fragments[0], node, 0u, 1u, TextDirection::Ltr); | 187 TEST_TEXT_FRAGMENT(fragments[0], node, 0u, 1u, TextDirection::Ltr); |
188 TEST_TEXT_FRAGMENT(fragments[1], node, 6u, 7u, TextDirection::Rtl); | 188 TEST_TEXT_FRAGMENT(fragments[1], node, 6u, 7u, TextDirection::Rtl); |
189 TEST_TEXT_FRAGMENT(fragments[2], node, 4u, 5u, TextDirection::Ltr); | 189 TEST_TEXT_FRAGMENT(fragments[2], node, 4u, 5u, TextDirection::Ltr); |
190 TEST_TEXT_FRAGMENT(fragments[3], node, 2u, 3u, TextDirection::Rtl); | 190 TEST_TEXT_FRAGMENT(fragments[3], node, 2u, 3u, TextDirection::Rtl); |
191 TEST_TEXT_FRAGMENT(fragments[4], node, 8u, 9u, TextDirection::Ltr); | 191 TEST_TEXT_FRAGMENT(fragments[4], node, 8u, 9u, TextDirection::Ltr); |
192 } | 192 } |
193 | 193 |
194 } // namespace blink | 194 } // namespace blink |
OLD | NEW |