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

Unified Diff: third_party/WebKit/Source/core/layout/LayoutTextTest.cpp

Issue 2369963005: Avoid creating consecutive whitespace renderers. (Closed)
Patch Set: Rebased and manually fixed expectations Created 4 years, 3 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/dom/Text.cpp ('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/LayoutTextTest.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutTextTest.cpp b/third_party/WebKit/Source/core/layout/LayoutTextTest.cpp
index 9c551bbcf4df3a69b7405733b165cb34ab898c3b..1a6517c0299cfdb50defbfd214d215de0cdc01a2 100644
--- a/third_party/WebKit/Source/core/layout/LayoutTextTest.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutTextTest.cpp
@@ -85,4 +85,88 @@ TEST_F(LayoutTextTest, WidthLengthBeyondLength)
ASSERT_LE(width, 20.f);
}
+TEST_F(LayoutTextTest, ConsecutiveWhitespaceRenderersInsertAfterWS)
+{
+ setBodyInnerHTML("<span></span> <span id='span'></span>");
+
+ Element* span = document().getElementById("span");
+ Node* whitespace1 = span->previousSibling();
+ EXPECT_TRUE(whitespace1->layoutObject());
+
+ Node* whitespace2 = Text::create(document(), " ");
+ document().body()->insertBefore(whitespace2, span, ASSERT_NO_EXCEPTION);
+ document().view()->updateAllLifecyclePhases();
+
+ EXPECT_TRUE(whitespace1->layoutObject());
+ EXPECT_FALSE(whitespace2->layoutObject());
+}
+
+TEST_F(LayoutTextTest, ConsecutiveWhitespaceRenderersInsertBeforeWS)
+{
+ setBodyInnerHTML("<span id='span'></span> <span></span>");
+
+ Element* span = document().getElementById("span");
+ Node* whitespace2 = span->nextSibling();
+ EXPECT_TRUE(whitespace2->layoutObject());
+
+ Node* whitespace1 = Text::create(document(), " ");
+ document().body()->insertBefore(whitespace1, whitespace2, ASSERT_NO_EXCEPTION);
+ document().view()->updateAllLifecyclePhases();
+
+ EXPECT_TRUE(whitespace1->layoutObject());
+ EXPECT_FALSE(whitespace2->layoutObject());
+}
+
+TEST_F(LayoutTextTest, ConsecutiveWhitespaceRenderersDisplayNone)
+{
+ setBodyInnerHTML("<span></span> <span style='display:none'></span> <span></span>");
+
+ // First <span>
+ Node* child = document().body()->firstChild();
+ ASSERT_TRUE(child);
+
+ // First whitespace node
+ child = child->nextSibling();
+ ASSERT_TRUE(child);
+ EXPECT_TRUE(child->isTextNode());
+ EXPECT_TRUE(child->layoutObject());
+
+ // <span display:none>
+ child = child->nextSibling();
+ ASSERT_TRUE(child);
+ EXPECT_FALSE(child->layoutObject());
+
+ // Second whitespace node
+ child = child->nextSibling();
+ ASSERT_TRUE(child);
+ EXPECT_TRUE(child->isTextNode());
+ EXPECT_FALSE(child->layoutObject());
+}
+
+TEST_F(LayoutTextTest, ConsecutiveWhitespaceRenderersComment)
+{
+ setBodyInnerHTML("<span></span> <!-- --> <span></span>");
+
+ // First <span>
+ Node* child = document().body()->firstChild();
+ ASSERT_TRUE(child);
+
+ // First whitespace node
+ child = child->nextSibling();
+ ASSERT_TRUE(child);
+ EXPECT_TRUE(child->isTextNode());
+ EXPECT_TRUE(child->layoutObject());
+
+ // Comment node
+ child = child->nextSibling();
+ ASSERT_TRUE(child);
+ EXPECT_FALSE(child->layoutObject());
+
+ // Second whitespace node
+ child = child->nextSibling();
+ ASSERT_TRUE(child);
+ EXPECT_TRUE(child->isTextNode());
+ EXPECT_FALSE(child->layoutObject());
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/dom/Text.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698