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

Unified Diff: third_party/WebKit/Source/core/layout/ng/ng_layout_inline_items_builder_test.cc

Issue 2749013003: [LayoutNG] Fix whitespace collapsing when a node is a newline (Closed)
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/layout/ng/ng_layout_inline_items_builder.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/layout/ng/ng_layout_inline_items_builder_test.cc
diff --git a/third_party/WebKit/Source/core/layout/ng/ng_layout_inline_items_builder_test.cc b/third_party/WebKit/Source/core/layout/ng/ng_layout_inline_items_builder_test.cc
index b878a5aed1c8f4fdd8430242807260f52f718ae3..3331e7cc004d163de47cd85f0fdceb23404fbb94 100644
--- a/third_party/WebKit/Source/core/layout/ng/ng_layout_inline_items_builder_test.cc
+++ b/third_party/WebKit/Source/core/layout/ng/ng_layout_inline_items_builder_test.cc
@@ -97,15 +97,22 @@ TEST_F(NGLayoutInlineItemsBuilderTest, CollapseTabs) {
}
TEST_F(NGLayoutInlineItemsBuilderTest, CollapseNewLines) {
- String input("text\ntext \n text");
- String collapsed("text text text");
+ String input("text\ntext \n text\n\ntext");
+ String collapsed("text text text text");
TestWhitespaceValue(collapsed, input, EWhiteSpace::kNormal);
TestWhitespaceValue(collapsed, input, EWhiteSpace::kNowrap);
- TestWhitespaceValue("text\ntext\ntext", input, EWhiteSpace::kPreLine);
+ TestWhitespaceValue("text\ntext\ntext\n\ntext", input, EWhiteSpace::kPreLine);
TestWhitespaceValue(input, input, EWhiteSpace::kPre);
TestWhitespaceValue(input, input, EWhiteSpace::kPreWrap);
}
+TEST_F(NGLayoutInlineItemsBuilderTest, CollapseNewlinesAsSpaces) {
+ EXPECT_EQ("text text", TestAppend("text\ntext"));
+ EXPECT_EQ("text text", TestAppend("text\n\ntext"));
+ EXPECT_EQ("text text", TestAppend("text \n\n text"));
+ EXPECT_EQ("text text", TestAppend("text \n \n text"));
+}
+
TEST_F(NGLayoutInlineItemsBuilderTest, CollapseAcrossElements) {
EXPECT_EQ("text text", TestAppend("text ", " text"))
<< "Spaces are collapsed even when across elements.";
@@ -175,9 +182,6 @@ TEST_F(NGLayoutInlineItemsBuilderTest,
}
TEST_F(NGLayoutInlineItemsBuilderTest, CollapseZeroWidthSpaces) {
- EXPECT_EQ("text text", TestAppend("text\ntext"))
- << "Newline is converted to a space.";
-
EXPECT_EQ(String(u"text\u200Btext"), TestAppend(u"text\u200B\ntext"))
<< "Newline is removed if the character before is ZWS.";
EXPECT_EQ(String(u"text\u200Btext"), TestAppend(u"text\n\u200Btext"))
@@ -224,12 +228,16 @@ TEST_F(NGLayoutInlineItemsBuilderTest, CollapseAroundReplacedElement) {
EXPECT_EQ(String(u"Hello \uFFFC World"), builder.ToString());
}
-TEST_F(NGLayoutInlineItemsBuilderTest, AppendAsOpaqueToSpaceCollapsing) {
+TEST_F(NGLayoutInlineItemsBuilderTest, CollapseNewlineAfterObject) {
NGLayoutInlineItemsBuilder builder(&items_);
- builder.Append("Hello ", style_.get());
- builder.AppendAsOpaqueToSpaceCollapsing(firstStrongIsolateCharacter);
- builder.Append(" World", style_.get());
- EXPECT_EQ(String(u"Hello \u2068World"), builder.ToString());
+ builder.Append(objectReplacementCharacter);
+ builder.Append("\n", style_.get());
+ builder.Append(objectReplacementCharacter);
+ EXPECT_EQ(String(u"\uFFFC \uFFFC"), builder.ToString());
+ EXPECT_EQ(3u, items_.size());
+ EXPECT_EQ(nullptr, items_[0].Style());
+ EXPECT_EQ(style_.get(), items_[1].Style());
+ EXPECT_EQ(nullptr, items_[2].Style());
}
TEST_F(NGLayoutInlineItemsBuilderTest, AppendEmptyString) {
« no previous file with comments | « third_party/WebKit/Source/core/layout/ng/ng_layout_inline_items_builder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698