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

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

Issue 2709343002: Fix bug on Android causing composition underlines to appear in the wrong place (Closed)
Patch Set: Created 3 years, 9 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 1164 matching lines...) Expand 10 before | Expand all | Expand 10 after
1175 underlines.push_back(CompositionUnderline(1, 11, Color(255, 0, 0), false, 0)); 1175 underlines.push_back(CompositionUnderline(1, 11, Color(255, 0, 0), false, 0));
1176 1176
1177 controller().commitText(String("string"), underlines, 0); 1177 controller().commitText(String("string"), underlines, 0);
1178 1178
1179 ASSERT_EQ(1u, document().markers().markers().size()); 1179 ASSERT_EQ(1u, document().markers().markers().size());
1180 1180
1181 EXPECT_EQ(9u, document().markers().markers()[0]->startOffset()); 1181 EXPECT_EQ(9u, document().markers().markers()[0]->startOffset());
1182 EXPECT_EQ(15u, document().markers().markers()[0]->endOffset()); 1182 EXPECT_EQ(15u, document().markers().markers()[0]->endOffset());
1183 } 1183 }
1184 1184
1185 TEST_F(InputMethodControllerTest,
1186 CompositionUnderlineAppearsCorrectlyAfterNewline) {
1187 Element* div =
1188 insertHTMLElement("<div id='sample' contenteditable></div>", "sample");
1189
1190 Vector<CompositionUnderline> underlines;
1191 controller().setComposition(String("hello"), underlines, 6, 6);
1192 controller().finishComposingText(InputMethodController::KeepSelection);
1193 frame().editor().insertLineBreak();
1194
1195 controller().setCompositionFromExistingText(underlines, 8, 8);
1196
1197 underlines.push_back(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0));
1198 controller().setComposition(String("world"), underlines, 0, 0);
1199 ASSERT_EQ(1u, document().markers().markers().size());
1200
1201 // Verify composition underline shows up on the second line, not the first
1202 ASSERT_EQ(0u, document()
1203 .markers()
1204 .markersInRange(PlainTextRange(0, 5).createRange(*div),
1205 DocumentMarker::AllMarkers())
1206 .size());
1207 ASSERT_EQ(1u, document()
1208 .markers()
1209 .markersInRange(PlainTextRange(6, 11).createRange(*div),
1210 DocumentMarker::AllMarkers())
1211 .size());
1212
1213 // Verify marker has correct start/end offsets (measured from the beginning
1214 // of the node, which is the beginning of the line)
1215 EXPECT_EQ(0u, document().markers().markers()[0]->startOffset());
1216 EXPECT_EQ(5u, document().markers().markers()[0]->endOffset());
1217 }
1218
1185 } // namespace blink 1219 } // 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