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/LayoutTestHelper.h" | 7 #include "core/layout/LayoutTestHelper.h" |
8 #include "core/layout/ng/ng_constraint_space.h" | 8 #include "core/layout/ng/ng_constraint_space.h" |
9 #include "core/layout/ng/ng_constraint_space_builder.h" | 9 #include "core/layout/ng/ng_constraint_space_builder.h" |
10 #include "core/layout/ng/ng_fragment_builder.h" | 10 #include "core/layout/ng/ng_fragment_builder.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 // Get Ahem from document. Loading "Ahem.woff" using |createTestFont| fails | 71 // Get Ahem from document. Loading "Ahem.woff" using |createTestFont| fails |
72 // on linux_chromium_asan_rel_ng. | 72 // on linux_chromium_asan_rel_ng. |
73 loadAhem(); | 73 loadAhem(); |
74 setBodyInnerHTML("<div id=t style='font:10px Ahem'></div>"); | 74 setBodyInnerHTML("<div id=t style='font:10px Ahem'></div>"); |
75 LayoutObject* layout_object = getLayoutObjectByElementId("t"); | 75 LayoutObject* layout_object = getLayoutObjectByElementId("t"); |
76 style_->setFont(layout_object->style()->font()); | 76 style_->setFont(layout_object->style()->font()); |
77 } | 77 } |
78 | 78 |
79 void CreateLine(NGInlineNode* node, | 79 void CreateLine(NGInlineNode* node, |
80 Vector<RefPtr<const NGPhysicalTextFragment>>* fragments_out) { | 80 Vector<RefPtr<const NGPhysicalTextFragment>>* fragments_out) { |
81 NGConstraintSpace* constraint_space = | 81 RefPtr<NGConstraintSpace> constraint_space = |
82 NGConstraintSpaceBuilder(kHorizontalTopBottom) | 82 NGConstraintSpaceBuilder(kHorizontalTopBottom) |
83 .ToConstraintSpace(kHorizontalTopBottom); | 83 .ToConstraintSpace(kHorizontalTopBottom); |
84 NGLineBuilder line_builder(node, constraint_space); | 84 NGLineBuilder line_builder(node, constraint_space.get()); |
85 | 85 |
86 NGTextLayoutAlgorithm algorithm(node, constraint_space); | 86 NGTextLayoutAlgorithm algorithm(node, constraint_space.get()); |
87 algorithm.LayoutInline(&line_builder); | 87 algorithm.LayoutInline(&line_builder); |
88 | 88 |
89 NGFragmentBuilder fragment_builder(NGPhysicalFragment::kFragmentBox, node); | 89 NGFragmentBuilder fragment_builder(NGPhysicalFragment::kFragmentBox, node); |
90 line_builder.CreateFragments(&fragment_builder); | 90 line_builder.CreateFragments(&fragment_builder); |
91 RefPtr<NGLayoutResult> result = fragment_builder.ToBoxFragment(); | 91 RefPtr<NGLayoutResult> result = fragment_builder.ToBoxFragment(); |
92 for (const auto& child : | 92 for (const auto& child : |
93 toNGPhysicalBoxFragment(result->PhysicalFragment().get()) | 93 toNGPhysicalBoxFragment(result->PhysicalFragment().get()) |
94 ->Children()) { | 94 ->Children()) { |
95 fragments_out->push_back(toNGPhysicalTextFragment(child.get())); | 95 fragments_out->push_back(toNGPhysicalTextFragment(child.get())); |
96 } | 96 } |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 MinAndMaxContentSizes sizes = node->ComputeMinAndMaxContentSizes(); | 237 MinAndMaxContentSizes sizes = node->ComputeMinAndMaxContentSizes(); |
238 // |min_content| should be the width of "BC" because there is an element | 238 // |min_content| should be the width of "BC" because there is an element |
239 // boundary between "B" and "C" but no break opportunities. | 239 // boundary between "B" and "C" but no break opportunities. |
240 // TODO(kojii): min_content should be 20, but is 30 until NGLineBuilder | 240 // TODO(kojii): min_content should be 20, but is 30 until NGLineBuilder |
241 // implements trailing spaces correctly. | 241 // implements trailing spaces correctly. |
242 EXPECT_EQ(30, sizes.min_content); | 242 EXPECT_EQ(30, sizes.min_content); |
243 EXPECT_EQ(60, sizes.max_content); | 243 EXPECT_EQ(60, sizes.max_content); |
244 } | 244 } |
245 | 245 |
246 } // namespace blink | 246 } // namespace blink |
OLD | NEW |