Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: third_party/WebKit/Source/core/layout/ng/ng_inline_node_test.cc

Issue 2764753007: [LayoutNG] Add NGLineBoxFragment (Closed)
Patch Set: Rebase again as other CLs landed faster Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "core/layout/ng/ng_line_builder.h" 11 #include "core/layout/ng/ng_line_builder.h"
12 #include "core/layout/ng/ng_physical_box_fragment.h" 12 #include "core/layout/ng/ng_physical_box_fragment.h"
13 #include "core/layout/ng/ng_physical_line_box_fragment.h"
13 #include "core/layout/ng/ng_physical_text_fragment.h" 14 #include "core/layout/ng/ng_physical_text_fragment.h"
14 #include "core/layout/ng/ng_text_fragment.h" 15 #include "core/layout/ng/ng_text_fragment.h"
15 #include "core/layout/ng/ng_text_layout_algorithm.h" 16 #include "core/layout/ng/ng_text_layout_algorithm.h"
16 #include "core/style/ComputedStyle.h" 17 #include "core/style/ComputedStyle.h"
17 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
18 19
19 namespace blink { 20 namespace blink {
20 21
21 class NGInlineNodeForTest : public NGInlineNode { 22 class NGInlineNodeForTest : public NGInlineNode {
22 public: 23 public:
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 Vector<RefPtr<const NGPhysicalTextFragment>>* fragments_out) { 92 Vector<RefPtr<const NGPhysicalTextFragment>>* fragments_out) {
92 RefPtr<NGConstraintSpace> constraint_space = 93 RefPtr<NGConstraintSpace> constraint_space =
93 NGConstraintSpaceBuilder(kHorizontalTopBottom) 94 NGConstraintSpaceBuilder(kHorizontalTopBottom)
94 .ToConstraintSpace(kHorizontalTopBottom); 95 .ToConstraintSpace(kHorizontalTopBottom);
95 NGLineBuilder line_builder(node, constraint_space.get()); 96 NGLineBuilder line_builder(node, constraint_space.get());
96 97
97 NGTextLayoutAlgorithm algorithm(node); 98 NGTextLayoutAlgorithm algorithm(node);
98 algorithm.LayoutInline(&line_builder); 99 algorithm.LayoutInline(&line_builder);
99 100
100 RefPtr<NGLayoutResult> result = line_builder.CreateFragments(); 101 RefPtr<NGLayoutResult> result = line_builder.CreateFragments();
101 for (const auto& child : 102 const NGPhysicalBoxFragment* container =
102 toNGPhysicalBoxFragment(result->PhysicalFragment().get()) 103 toNGPhysicalBoxFragment(result->PhysicalFragment().get());
103 ->Children()) { 104 EXPECT_EQ(container->Children().size(), 1u);
105 const NGPhysicalLineBoxFragment* line =
106 toNGPhysicalLineBoxFragment(container->Children()[0].get());
107 for (const auto& child : line->Children()) {
104 fragments_out->push_back(toNGPhysicalTextFragment(child.get())); 108 fragments_out->push_back(toNGPhysicalTextFragment(child.get()));
105 } 109 }
106 } 110 }
107 111
108 RefPtr<const ComputedStyle> style_; 112 RefPtr<const ComputedStyle> style_;
109 LayoutBlockFlow* layout_block_flow_ = nullptr; 113 LayoutBlockFlow* layout_block_flow_ = nullptr;
110 LayoutObject* layout_object_ = nullptr; 114 LayoutObject* layout_object_ = nullptr;
111 FontCachePurgePreventer purge_preventer_; 115 FontCachePurgePreventer purge_preventer_;
112 }; 116 };
113 117
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 MinMaxContentSize sizes = node->ComputeMinMaxContentSize(); 331 MinMaxContentSize sizes = node->ComputeMinMaxContentSize();
328 // |min_content| should be the width of "BC" because there is an element 332 // |min_content| should be the width of "BC" because there is an element
329 // boundary between "B" and "C" but no break opportunities. 333 // boundary between "B" and "C" but no break opportunities.
330 // TODO(kojii): min_content should be 20, but is 30 until NGLineBuilder 334 // TODO(kojii): min_content should be 20, but is 30 until NGLineBuilder
331 // implements trailing spaces correctly. 335 // implements trailing spaces correctly.
332 EXPECT_EQ(30, sizes.min_content); 336 EXPECT_EQ(30, sizes.min_content);
333 EXPECT_EQ(60, sizes.max_content); 337 EXPECT_EQ(60, sizes.max_content);
334 } 338 }
335 339
336 } // namespace blink 340 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698