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