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

Side by Side Diff: third_party/WebKit/Source/core/editing/InputMethodControllerTest.cpp

Issue 2644623003: Revert 'Make "compositionend" event fired after setting caret position' (Closed)
Patch Set: Add updateStyleAndLayoutIgnorePendingStylesheets Created 3 years, 11 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/editing/InputMethodController.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1053 matching lines...) Expand 10 before | Expand all | Expand 10 after
1064 document().title().utf8().data()); 1064 document().title().utf8().data());
1065 1065
1066 // Insert empty text with previous composition. 1066 // Insert empty text with previous composition.
1067 document().setTitle(emptyString()); 1067 document().setTitle(emptyString());
1068 document().updateStyleAndLayout(); 1068 document().updateStyleAndLayout();
1069 controller().commitText("", underlines, 1); 1069 controller().commitText("", underlines, 1);
1070 EXPECT_STREQ("beforeinput.data:;compositionend.data:;", 1070 EXPECT_STREQ("beforeinput.data:;compositionend.data:;",
1071 document().title().utf8().data()); 1071 document().title().utf8().data());
1072 } 1072 }
1073 1073
1074 TEST_F(InputMethodControllerTest, CompositionEndEventForConfirm) {
1075 createHTMLWithCompositionEndEventListener(CaretSelection);
1076
1077 // Simulate composition in the |contentEditable|.
1078 Vector<CompositionUnderline> underlines;
1079 underlines.push_back(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0));
1080
1081 controller().setComposition("hello", underlines, 1, 1);
1082 document().updateStyleAndLayout();
1083 EXPECT_EQ(1u, controller().getSelectionOffsets().start());
1084 EXPECT_EQ(1u, controller().getSelectionOffsets().end());
1085
1086 // Confirm the ongoing composition. Note that it moves the caret to the end of
1087 // text [5,5] before firing 'compositonend' event.
1088 controller().finishComposingText(InputMethodController::DoNotKeepSelection);
1089 document().updateStyleAndLayout();
1090 EXPECT_EQ(3u, controller().getSelectionOffsets().start());
1091 EXPECT_EQ(3u, controller().getSelectionOffsets().end());
1092 }
1093
1094 TEST_F(InputMethodControllerTest, CompositionEndEventForInsert) {
1095 createHTMLWithCompositionEndEventListener(CaretSelection);
1096
1097 // Simulate composition in the |contentEditable|.
1098 Vector<CompositionUnderline> underlines;
1099 underlines.push_back(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0));
1100
1101 controller().setComposition("n", underlines, 1, 1);
1102
1103 // Insert new text with previous composition. Note that it moves the caret to
1104 // [4,4] before firing 'compositonend' event.
1105 document().updateStyleAndLayout();
1106 controller().commitText("hello", underlines, -1);
1107 document().updateStyleAndLayout();
1108 EXPECT_EQ(3u, controller().getSelectionOffsets().start());
1109 EXPECT_EQ(3u, controller().getSelectionOffsets().end());
1110 }
1111
1112 TEST_F(InputMethodControllerTest, CompositionEndEventWithRangeSelection) {
1113 createHTMLWithCompositionEndEventListener(RangeSelection);
1114
1115 // Simulate composition in the |contentEditable|.
1116 Vector<CompositionUnderline> underlines;
1117 underlines.push_back(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0));
1118
1119 controller().setComposition("hello", underlines, 1, 1);
1120 document().updateStyleAndLayout();
1121 EXPECT_EQ(1u, controller().getSelectionOffsets().start());
1122 EXPECT_EQ(1u, controller().getSelectionOffsets().end());
1123
1124 // Confirm the ongoing composition. Note that it moves the caret to the end of
1125 // text [5,5] before firing 'compositonend' event.
1126 controller().finishComposingText(InputMethodController::DoNotKeepSelection);
1127 document().updateStyleAndLayout();
1128 EXPECT_EQ(2u, controller().getSelectionOffsets().start());
1129 EXPECT_EQ(4u, controller().getSelectionOffsets().end());
1130 }
1131
1132 TEST_F(InputMethodControllerTest, CompositionEndEventWithNoSelection) { 1074 TEST_F(InputMethodControllerTest, CompositionEndEventWithNoSelection) {
1133 createHTMLWithCompositionEndEventListener(NoSelection); 1075 createHTMLWithCompositionEndEventListener(NoSelection);
1134 1076
1135 // Simulate composition in the |contentEditable|. 1077 // Simulate composition in the |contentEditable|.
1136 Vector<CompositionUnderline> underlines; 1078 Vector<CompositionUnderline> underlines;
1137 underlines.push_back(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0)); 1079 underlines.push_back(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0));
1138 1080
1139 controller().setComposition("hello", underlines, 1, 1); 1081 controller().setComposition("hello", underlines, 1, 1);
1140 document().updateStyleAndLayout(); 1082 document().updateStyleAndLayout();
1141 EXPECT_EQ(1u, controller().getSelectionOffsets().start()); 1083 EXPECT_EQ(1u, controller().getSelectionOffsets().start());
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1213 1155
1214 controller().commitText(String("string"), underlines, 0); 1156 controller().commitText(String("string"), underlines, 0);
1215 1157
1216 ASSERT_EQ(1u, document().markers().markers().size()); 1158 ASSERT_EQ(1u, document().markers().markers().size());
1217 1159
1218 EXPECT_EQ(9u, document().markers().markers()[0]->startOffset()); 1160 EXPECT_EQ(9u, document().markers().markers()[0]->startOffset());
1219 EXPECT_EQ(15u, document().markers().markers()[0]->endOffset()); 1161 EXPECT_EQ(15u, document().markers().markers()[0]->endOffset());
1220 } 1162 }
1221 1163
1222 } // namespace blink 1164 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/InputMethodController.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698