| 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 1178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1189 underlines.push_back(CompositionUnderline(1, 11, Color(255, 0, 0), false, 0)); | 1189 underlines.push_back(CompositionUnderline(1, 11, Color(255, 0, 0), false, 0)); |
| 1190 | 1190 |
| 1191 controller().commitText(String("string"), underlines, 0); | 1191 controller().commitText(String("string"), underlines, 0); |
| 1192 | 1192 |
| 1193 ASSERT_EQ(1u, document().markers().markers().size()); | 1193 ASSERT_EQ(1u, document().markers().markers().size()); |
| 1194 | 1194 |
| 1195 EXPECT_EQ(9u, document().markers().markers()[0]->startOffset()); | 1195 EXPECT_EQ(9u, document().markers().markers()[0]->startOffset()); |
| 1196 EXPECT_EQ(15u, document().markers().markers()[0]->endOffset()); | 1196 EXPECT_EQ(15u, document().markers().markers()[0]->endOffset()); |
| 1197 } | 1197 } |
| 1198 | 1198 |
| 1199 TEST_F(InputMethodControllerTest, |
| 1200 CompositionUnderlineAppearsCorrectlyAfterNewline) { |
| 1201 Element* div = |
| 1202 insertHTMLElement("<div id='sample' contenteditable></div>", "sample"); |
| 1203 |
| 1204 Vector<CompositionUnderline> underlines; |
| 1205 controller().setComposition(String("hello"), underlines, 6, 6); |
| 1206 controller().finishComposingText(InputMethodController::KeepSelection); |
| 1207 frame().editor().insertLineBreak(); |
| 1208 |
| 1209 controller().setCompositionFromExistingText(underlines, 8, 8); |
| 1210 |
| 1211 underlines.push_back(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0)); |
| 1212 controller().setComposition(String("world"), underlines, 0, 0); |
| 1213 ASSERT_EQ(1u, document().markers().markers().size()); |
| 1214 |
| 1215 // Verify composition underline shows up on the second line, not the first |
| 1216 ASSERT_EQ(0u, document() |
| 1217 .markers() |
| 1218 .markersInRange(PlainTextRange(0, 5).createRange(*div), |
| 1219 DocumentMarker::AllMarkers()) |
| 1220 .size()); |
| 1221 ASSERT_EQ(1u, document() |
| 1222 .markers() |
| 1223 .markersInRange(PlainTextRange(6, 11).createRange(*div), |
| 1224 DocumentMarker::AllMarkers()) |
| 1225 .size()); |
| 1226 |
| 1227 // Verify marker has correct start/end offsets (measured from the beginning |
| 1228 // of the node, which is the beginning of the line) |
| 1229 EXPECT_EQ(0u, document().markers().markers()[0]->startOffset()); |
| 1230 EXPECT_EQ(5u, document().markers().markers()[0]->endOffset()); |
| 1231 } |
| 1232 |
| 1199 } // namespace blink | 1233 } // namespace blink |
| OLD | NEW |