Chromium Code Reviews| 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 1151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1162 inputA->setOuterHTML("", ASSERT_NO_EXCEPTION); | 1162 inputA->setOuterHTML("", ASSERT_NO_EXCEPTION); |
| 1163 EXPECT_EQ(WebTextInputTypeNone, controller().textInputType()); | 1163 EXPECT_EQ(WebTextInputTypeNone, controller().textInputType()); |
| 1164 | 1164 |
| 1165 document().getElementById("b")->focus(); | 1165 document().getElementById("b")->focus(); |
| 1166 EXPECT_EQ(WebTextInputTypeTelephone, controller().textInputType()); | 1166 EXPECT_EQ(WebTextInputTypeTelephone, controller().textInputType()); |
| 1167 | 1167 |
| 1168 controller().finishComposingText(InputMethodController::KeepSelection); | 1168 controller().finishComposingText(InputMethodController::KeepSelection); |
| 1169 EXPECT_EQ(WebTextInputTypeTelephone, controller().textInputType()); | 1169 EXPECT_EQ(WebTextInputTypeTelephone, controller().textInputType()); |
| 1170 } | 1170 } |
| 1171 | 1171 |
| 1172 TEST_F(InputMethodControllerTest, ReflectsSpaceWithoutNbspMangling) { | |
| 1173 insertHTMLElement("<div id='sample' contenteditable></div>", "sample"); | |
| 1174 | |
| 1175 Vector<CompositionUnderline> underlines; | |
| 1176 controller().commitText(String(" "), underlines, 0); | |
| 1177 | |
| 1178 // In a contenteditable, multiple spaces or a space at the edge needs to be | |
|
aelias_OOO_until_Jul13
2017/01/25 04:34:09
Done.
| |
| 1179 // nbsp to affect layout properly, but it confuses some IMEs (particularly | |
| 1180 // Vietnamese, see crbug.com/663880) to have their spaces reflected back to | |
| 1181 // them as nbsp. | |
| 1182 EXPECT_EQ(' ', controller().textInputInfo().value.ascii()[0]); | |
| 1183 EXPECT_EQ(' ', controller().textInputInfo().value.ascii()[1]); | |
| 1184 } | |
| 1185 | |
| 1172 TEST_F(InputMethodControllerTest, SetCompositionPlainTextWithUnderline) { | 1186 TEST_F(InputMethodControllerTest, SetCompositionPlainTextWithUnderline) { |
| 1173 insertHTMLElement("<div id='sample' contenteditable></div>", "sample"); | 1187 insertHTMLElement("<div id='sample' contenteditable></div>", "sample"); |
| 1174 | 1188 |
| 1175 Vector<CompositionUnderline> underlines; | 1189 Vector<CompositionUnderline> underlines; |
| 1176 underlines.push_back(CompositionUnderline(0, 1, Color(255, 0, 0), false, 0)); | 1190 underlines.push_back(CompositionUnderline(0, 1, Color(255, 0, 0), false, 0)); |
| 1177 | 1191 |
| 1178 controller().setComposition(" ", underlines, 1, 1); | 1192 controller().setComposition(" ", underlines, 1, 1); |
| 1179 | 1193 |
| 1180 ASSERT_EQ(1u, document().markers().markers().size()); | 1194 ASSERT_EQ(1u, document().markers().markers().size()); |
| 1181 | 1195 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1213 | 1227 |
| 1214 controller().commitText(String("string"), underlines, 0); | 1228 controller().commitText(String("string"), underlines, 0); |
| 1215 | 1229 |
| 1216 ASSERT_EQ(1u, document().markers().markers().size()); | 1230 ASSERT_EQ(1u, document().markers().markers().size()); |
| 1217 | 1231 |
| 1218 EXPECT_EQ(9u, document().markers().markers()[0]->startOffset()); | 1232 EXPECT_EQ(9u, document().markers().markers()[0]->startOffset()); |
| 1219 EXPECT_EQ(15u, document().markers().markers()[0]->endOffset()); | 1233 EXPECT_EQ(15u, document().markers().markers()[0]->endOffset()); |
| 1220 } | 1234 } |
| 1221 | 1235 |
| 1222 } // namespace blink | 1236 } // namespace blink |
| OLD | NEW |