Chromium Code Reviews| 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/LayoutText.h" | 5 #include "core/layout/LayoutText.h" |
| 6 | 6 |
| 7 #include "core/layout/LayoutTestHelper.h" | 7 #include "core/layout/LayoutTestHelper.h" |
| 8 #include "core/layout/line/InlineTextBox.h" | 8 #include "core/layout/line/InlineTextBox.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 78 | 78 |
| 79 TEST_F(LayoutTextTest, WidthLengthBeyondLength) | 79 TEST_F(LayoutTextTest, WidthLengthBeyondLength) |
| 80 { | 80 { |
| 81 setBasicBody("x"); | 81 setBasicBody("x"); |
| 82 // Width may vary by platform and we just want to make sure it's something r oughly reasonable. | 82 // Width may vary by platform and we just want to make sure it's something r oughly reasonable. |
| 83 float width = getBasicText()->width(0u, 2u, LayoutUnit(), LTR, false); | 83 float width = getBasicText()->width(0u, 2u, LayoutUnit(), LTR, false); |
| 84 ASSERT_GE(width, 4.f); | 84 ASSERT_GE(width, 4.f); |
| 85 ASSERT_LE(width, 20.f); | 85 ASSERT_LE(width, 20.f); |
| 86 } | 86 } |
| 87 | 87 |
| 88 TEST_F(LayoutTextTest, ConsecutiveWhitespaceRenderers) | |
| 89 { | |
| 90 setBodyInnerHTML("<span></span> <span id='span'></span>"); | |
| 91 | |
| 92 Element* span = document().getElementById("span"); | |
| 93 Node* whitespace1 = span->previousSibling(); | |
| 94 Node* whitespace2 = Text::create(document(), " "); | |
| 95 document().body()->insertBefore(whitespace2, span, ASSERT_NO_EXCEPTION); | |
| 96 document().view()->updateAllLifecyclePhases(); | |
| 97 | |
| 98 EXPECT_TRUE(whitespace1->layoutObject()); | |
| 99 EXPECT_FALSE(whitespace2->layoutObject()); | |
| 100 } | |
|
mstensho (USE GERRIT)
2016/09/28 11:19:09
How about a test similar to this one, except that
| |
| 101 | |
| 102 TEST_F(LayoutTextTest, ConsecutiveWhitespaceRenderersDisplayNone) | |
| 103 { | |
| 104 setBodyInnerHTML("<span></span> <span style='display:none'></span> <span></s pan>"); | |
| 105 | |
| 106 // First <span> | |
| 107 Node* child = document().body()->firstChild(); | |
| 108 ASSERT_TRUE(child); | |
| 109 | |
| 110 // First whitespace node | |
| 111 child = child->nextSibling(); | |
| 112 ASSERT_TRUE(child); | |
| 113 EXPECT_TRUE(child->isTextNode()); | |
| 114 EXPECT_TRUE(child->layoutObject()); | |
| 115 | |
| 116 // <span display:none> | |
| 117 child = child->nextSibling(); | |
| 118 ASSERT_TRUE(child); | |
| 119 EXPECT_FALSE(child->layoutObject()); | |
| 120 | |
| 121 // Second whitespace node | |
| 122 child = child->nextSibling(); | |
| 123 ASSERT_TRUE(child); | |
| 124 EXPECT_TRUE(child->isTextNode()); | |
| 125 EXPECT_FALSE(child->layoutObject()); | |
| 126 } | |
| 127 | |
| 128 TEST_F(LayoutTextTest, ConsecutiveWhitespaceRenderersComment) | |
| 129 { | |
| 130 setBodyInnerHTML("<span></span> <!-- --> <span></span>"); | |
| 131 | |
| 132 // First <span> | |
| 133 Node* child = document().body()->firstChild(); | |
| 134 ASSERT_TRUE(child); | |
| 135 | |
| 136 // First whitespace node | |
| 137 child = child->nextSibling(); | |
| 138 ASSERT_TRUE(child); | |
| 139 EXPECT_TRUE(child->isTextNode()); | |
| 140 EXPECT_TRUE(child->layoutObject()); | |
| 141 | |
| 142 // <span display:none> | |
|
rune
2016/09/27 13:54:14
This should be the comment <!-- -->
rune
2016/09/28 12:13:10
Fixed.
| |
| 143 child = child->nextSibling(); | |
| 144 ASSERT_TRUE(child); | |
| 145 EXPECT_FALSE(child->layoutObject()); | |
| 146 | |
| 147 // Second whitespace node | |
| 148 child = child->nextSibling(); | |
| 149 ASSERT_TRUE(child); | |
| 150 EXPECT_TRUE(child->isTextNode()); | |
| 151 EXPECT_FALSE(child->layoutObject()); | |
| 152 } | |
| 153 | |
| 88 } // namespace blink | 154 } // namespace blink |
| OLD | NEW |