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

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

Issue 2870413005: [LayoutNG] Add "Control" NGInlineItemType for newlines and tabs (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « third_party/WebKit/Source/core/layout/ng/inline/ng_inline_items_builder_test.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/inline/ng_inline_node.h" 5 #include "core/layout/ng/inline/ng_inline_node.h"
6 6
7 #include "core/layout/LayoutTestHelper.h" 7 #include "core/layout/LayoutTestHelper.h"
8 #include "core/layout/ng/inline/ng_inline_layout_algorithm.h" 8 #include "core/layout/ng/inline/ng_inline_layout_algorithm.h"
9 #include "core/layout/ng/inline/ng_physical_line_box_fragment.h" 9 #include "core/layout/ng/inline/ng_physical_line_box_fragment.h"
10 #include "core/layout/ng/inline/ng_physical_text_fragment.h" 10 #include "core/layout/ng/inline/ng_physical_text_fragment.h"
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 node->CollectInlines(layout_object_, layout_block_flow_); 137 node->CollectInlines(layout_object_, layout_block_flow_);
138 Vector<NGInlineItem>& items = node->Items(); 138 Vector<NGInlineItem>& items = node->Items();
139 TEST_ITEM_TYPE_OFFSET(items[0], kText, 0u, 6u); 139 TEST_ITEM_TYPE_OFFSET(items[0], kText, 0u, 6u);
140 TEST_ITEM_TYPE_OFFSET(items[1], kOpenTag, 6u, 6u); 140 TEST_ITEM_TYPE_OFFSET(items[1], kOpenTag, 6u, 6u);
141 TEST_ITEM_TYPE_OFFSET(items[2], kText, 6u, 12u); 141 TEST_ITEM_TYPE_OFFSET(items[2], kText, 6u, 12u);
142 TEST_ITEM_TYPE_OFFSET(items[3], kCloseTag, 12u, 12u); 142 TEST_ITEM_TYPE_OFFSET(items[3], kCloseTag, 12u, 12u);
143 TEST_ITEM_TYPE_OFFSET(items[4], kText, 12u, 19u); 143 TEST_ITEM_TYPE_OFFSET(items[4], kText, 12u, 19u);
144 EXPECT_EQ(5u, items.size()); 144 EXPECT_EQ(5u, items.size());
145 } 145 }
146 146
147 TEST_F(NGInlineNodeTest, CollectInlinesBR) {
148 SetupHtml("t", u"<div id=t>Hello<br>World</div>");
149 NGInlineNodeForTest* node = CreateInlineNode();
150 node->CollectInlines(layout_object_, layout_block_flow_);
151 EXPECT_EQ("Hello\nWorld", node->Text());
152 Vector<NGInlineItem>& items = node->Items();
153 TEST_ITEM_TYPE_OFFSET(items[0], kText, 0u, 5u);
154 TEST_ITEM_TYPE_OFFSET(items[1], kControl, 5u, 6u);
155 TEST_ITEM_TYPE_OFFSET(items[2], kText, 6u, 11u);
156 EXPECT_EQ(3u, items.size());
157 }
158
147 TEST_F(NGInlineNodeTest, CollectInlinesRtlText) { 159 TEST_F(NGInlineNodeTest, CollectInlinesRtlText) {
148 SetupHtml("t", u"<div id=t dir=rtl>\u05E2 <span>\u05E2</span> \u05E2</div>"); 160 SetupHtml("t", u"<div id=t dir=rtl>\u05E2 <span>\u05E2</span> \u05E2</div>");
149 NGInlineNodeForTest* node = CreateInlineNode(); 161 NGInlineNodeForTest* node = CreateInlineNode();
150 node->CollectInlines(layout_object_, layout_block_flow_); 162 node->CollectInlines(layout_object_, layout_block_flow_);
151 EXPECT_TRUE(node->IsBidiEnabled()); 163 EXPECT_TRUE(node->IsBidiEnabled());
152 node->SegmentText(); 164 node->SegmentText();
153 EXPECT_TRUE(node->IsBidiEnabled()); 165 EXPECT_TRUE(node->IsBidiEnabled());
154 Vector<NGInlineItem>& items = node->Items(); 166 Vector<NGInlineItem>& items = node->Items();
155 TEST_ITEM_TYPE_OFFSET_LEVEL(items[0], kText, 0u, 2u, 1u); 167 TEST_ITEM_TYPE_OFFSET_LEVEL(items[0], kText, 0u, 2u, 1u);
156 TEST_ITEM_TYPE_OFFSET_LEVEL(items[1], kOpenTag, 2u, 2u, 1u); 168 TEST_ITEM_TYPE_OFFSET_LEVEL(items[1], kOpenTag, 2u, 2u, 1u);
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 MinMaxContentSize sizes = node->ComputeMinMaxContentSize(); 343 MinMaxContentSize sizes = node->ComputeMinMaxContentSize();
332 // |min_content| should be the width of "BC" because there is an element 344 // |min_content| should be the width of "BC" because there is an element
333 // boundary between "B" and "C" but no break opportunities. 345 // boundary between "B" and "C" but no break opportunities.
334 // TODO(kojii): min_content should be 20, but is 30 until 346 // TODO(kojii): min_content should be 20, but is 30 until
335 // NGInlineLayoutAlgorithm implements trailing spaces correctly. 347 // NGInlineLayoutAlgorithm implements trailing spaces correctly.
336 EXPECT_EQ(30, sizes.min_content); 348 EXPECT_EQ(30, sizes.min_content);
337 EXPECT_EQ(60, sizes.max_content); 349 EXPECT_EQ(60, sizes.max_content);
338 } 350 }
339 351
340 } // namespace blink 352 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/ng/inline/ng_inline_items_builder_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698