| OLD | NEW |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/dom/Text.h" | 5 #include "core/dom/Text.h" |
| 6 | 6 |
| 7 #include "core/dom/Range.h" | 7 #include "core/dom/Range.h" |
| 8 #include "core/editing/EditingTestBase.h" | 8 #include "core/editing/EditingTestBase.h" |
| 9 #include "core/html/HTMLPreElement.h" | 9 #include "core/html/HTMLPreElement.h" |
| 10 #include "core/layout/LayoutText.h" | 10 #include "core/layout/LayoutText.h" |
| 11 | 11 |
| 12 namespace blink { | 12 namespace blink { |
| 13 | 13 |
| 14 // TODO(xiaochengh): Use a new testing base class. | 14 // TODO(xiaochengh): Use a new testing base class. |
| 15 class TextTest : public EditingTestBase { | 15 class TextTest : public EditingTestBase { |
| 16 }; | 16 }; |
| 17 | 17 |
| 18 TEST_F(TextTest, SetDataToChangeFirstLetterTextNode) |
| 19 { |
| 20 setBodyContent("<style>pre::first-letter {color:red;}</style><pre id=sample>
a<span>b</span></pre>"); |
| 21 |
| 22 Node* sample = document().getElementById("sample"); |
| 23 Text* text = toText(sample->firstChild()); |
| 24 text->setData(" "); |
| 25 updateAllLifecyclePhases(); |
| 26 |
| 27 EXPECT_FALSE(text->layoutObject()->isTextFragment()); |
| 28 } |
| 29 |
| 18 TEST_F(TextTest, RemoveFirstLetterPseudoElementWhenNoLetter) | 30 TEST_F(TextTest, RemoveFirstLetterPseudoElementWhenNoLetter) |
| 19 { | 31 { |
| 20 setBodyContent("<style>*::first-letter{font:icon;}</style><pre>AB\n</pre>"); | 32 setBodyContent("<style>*::first-letter{font:icon;}</style><pre>AB\n</pre>"); |
| 21 | 33 |
| 22 Element* pre = document().querySelector("pre", ASSERT_NO_EXCEPTION); | 34 Element* pre = document().querySelector("pre", ASSERT_NO_EXCEPTION); |
| 23 Text* text = toText(pre->firstChild()); | 35 Text* text = toText(pre->firstChild()); |
| 24 | 36 |
| 25 Range* range = Range::create(document(), text, 0, text, 2); | 37 Range* range = Range::create(document(), text, 0, text, 2); |
| 26 range->deleteContents(ASSERT_NO_EXCEPTION); | 38 range->deleteContents(ASSERT_NO_EXCEPTION); |
| 27 updateAllLifecyclePhases(); | 39 updateAllLifecyclePhases(); |
| 28 | 40 |
| 29 EXPECT_FALSE(text->layoutObject()->isTextFragment()); | 41 EXPECT_FALSE(text->layoutObject()->isTextFragment()); |
| 30 } | 42 } |
| 31 | 43 |
| 32 } // namespace blink | 44 } // namespace blink |
| OLD | NEW |