| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/editing/InputMethodController.h" | 5 #include "core/editing/InputMethodController.h" |
| 6 | 6 |
| 7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
| 8 #include "core/dom/Element.h" | 8 #include "core/dom/Element.h" |
| 9 #include "core/dom/Range.h" | 9 #include "core/dom/Range.h" |
| 10 #include "core/editing/Editor.h" | 10 #include "core/editing/Editor.h" |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 controller().setComposition(String::fromUTF8("\xE0\xB0\x83\xE0\xB0\x83"), | 180 controller().setComposition(String::fromUTF8("\xE0\xB0\x83\xE0\xB0\x83"), |
| 181 underlines, 2, 2); | 181 underlines, 2, 2); |
| 182 EXPECT_STREQ("<b>\xE0\xB0\x83\xE0\xB0\x83</b>", | 182 EXPECT_STREQ("<b>\xE0\xB0\x83\xE0\xB0\x83</b>", |
| 183 div->innerHTML().utf8().data()); | 183 div->innerHTML().utf8().data()); |
| 184 | 184 |
| 185 controller().setComposition(String::fromUTF8("\xE0\xB0\x83"), underlines, 1, | 185 controller().setComposition(String::fromUTF8("\xE0\xB0\x83"), underlines, 1, |
| 186 1); | 186 1); |
| 187 EXPECT_STREQ("<b>\xE0\xB0\x83</b>", div->innerHTML().utf8().data()); | 187 EXPECT_STREQ("<b>\xE0\xB0\x83</b>", div->innerHTML().utf8().data()); |
| 188 } | 188 } |
| 189 | 189 |
| 190 TEST_F(InputMethodControllerTest, FinishComposingTextKeepingStyle) { |
| 191 Element* div = insertHTMLElement( |
| 192 "<div id='sample' " |
| 193 "contenteditable='true'>k<b>i</b>d</div>", |
| 194 "sample"); |
| 195 |
| 196 Vector<CompositionUnderline> underlines; |
| 197 underlines.append(CompositionUnderline(0, 3, Color(255, 0, 0), false, 0)); |
| 198 controller().setCompositionFromExistingText(underlines, 0, 3); |
| 199 |
| 200 // Append a character. |
| 201 controller().setComposition(String("kids"), underlines, 4, 4); |
| 202 EXPECT_STREQ("k<b>i</b>ds", div->innerHTML().utf8().data()); |
| 203 |
| 204 controller().finishComposingText(InputMethodController::KeepSelection); |
| 205 EXPECT_STREQ("k<b>i</b>ds", div->innerHTML().utf8().data()); |
| 206 } |
| 207 |
| 190 TEST_F(InputMethodControllerTest, SelectionOnConfirmExistingText) { | 208 TEST_F(InputMethodControllerTest, SelectionOnConfirmExistingText) { |
| 191 insertHTMLElement("<div id='sample' contenteditable='true'>hello world</div>", | 209 insertHTMLElement("<div id='sample' contenteditable='true'>hello world</div>", |
| 192 "sample"); | 210 "sample"); |
| 193 | 211 |
| 194 Vector<CompositionUnderline> underlines; | 212 Vector<CompositionUnderline> underlines; |
| 195 underlines.append(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0)); | 213 underlines.append(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0)); |
| 196 controller().setCompositionFromExistingText(underlines, 0, 5); | 214 controller().setCompositionFromExistingText(underlines, 0, 5); |
| 197 | 215 |
| 198 controller().finishComposingText(InputMethodController::KeepSelection); | 216 controller().finishComposingText(InputMethodController::KeepSelection); |
| 199 EXPECT_EQ(0, frame().selection().start().computeOffsetInContainerNode()); | 217 EXPECT_EQ(0, frame().selection().start().computeOffsetInContainerNode()); |
| (...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 872 EXPECT_STREQ("beforeinput.data:i;input.data:i;", | 890 EXPECT_STREQ("beforeinput.data:i;input.data:i;", |
| 873 document().title().utf8().data()); | 891 document().title().utf8().data()); |
| 874 | 892 |
| 875 document().setTitle(emptyString()); | 893 document().setTitle(emptyString()); |
| 876 controller().finishComposingText(InputMethodController::KeepSelection); | 894 controller().finishComposingText(InputMethodController::KeepSelection); |
| 877 EXPECT_STREQ("beforeinput.data:ni;input.data:ni;", | 895 EXPECT_STREQ("beforeinput.data:ni;input.data:ni;", |
| 878 document().title().utf8().data()); | 896 document().title().utf8().data()); |
| 879 } | 897 } |
| 880 | 898 |
| 881 } // namespace blink | 899 } // namespace blink |
| OLD | NEW |