| 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 <memory> | 7 #include <memory> |
| 8 #include "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
| 9 #include "core/dom/Element.h" | 9 #include "core/dom/Element.h" |
| 10 #include "core/dom/Range.h" | 10 #include "core/dom/Range.h" |
| (...skipping 1390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1401 Controller().FinishComposingText(InputMethodController::kKeepSelection); | 1401 Controller().FinishComposingText(InputMethodController::kKeepSelection); |
| 1402 GetFrame().GetEditor().InsertLineBreak(); | 1402 GetFrame().GetEditor().InsertLineBreak(); |
| 1403 | 1403 |
| 1404 Controller().SetCompositionFromExistingText(underlines, 8, 8); | 1404 Controller().SetCompositionFromExistingText(underlines, 8, 8); |
| 1405 | 1405 |
| 1406 underlines.push_back(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0)); | 1406 underlines.push_back(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0)); |
| 1407 Controller().SetComposition(String("world"), underlines, 0, 0); | 1407 Controller().SetComposition(String("world"), underlines, 0, 0); |
| 1408 ASSERT_EQ(1u, GetDocument().Markers().Markers().size()); | 1408 ASSERT_EQ(1u, GetDocument().Markers().Markers().size()); |
| 1409 | 1409 |
| 1410 // Verify composition underline shows up on the second line, not the first | 1410 // Verify composition underline shows up on the second line, not the first |
| 1411 ASSERT_EQ(0u, GetDocument() | 1411 ASSERT_FALSE(GetDocument().Markers().MarkerAtPosition( |
| 1412 .Markers() | 1412 PlainTextRange(2).CreateRange(*div).StartPosition(), |
| 1413 .MarkersInRange(PlainTextRange(0, 5).CreateRange(*div), | 1413 DocumentMarker::AllMarkers())); |
| 1414 DocumentMarker::AllMarkers()) | 1414 ASSERT_TRUE(GetDocument().Markers().MarkerAtPosition( |
| 1415 .size()); | 1415 PlainTextRange(8).CreateRange(*div).StartPosition(), |
| 1416 ASSERT_EQ(1u, GetDocument() | 1416 DocumentMarker::AllMarkers())); |
| 1417 .Markers() | |
| 1418 .MarkersInRange(PlainTextRange(6, 11).CreateRange(*div), | |
| 1419 DocumentMarker::AllMarkers()) | |
| 1420 .size()); | |
| 1421 | 1417 |
| 1422 // Verify marker has correct start/end offsets (measured from the beginning | 1418 // Verify marker has correct start/end offsets (measured from the beginning |
| 1423 // of the node, which is the beginning of the line) | 1419 // of the node, which is the beginning of the line) |
| 1424 EXPECT_EQ(0u, GetDocument().Markers().Markers()[0]->StartOffset()); | 1420 EXPECT_EQ(0u, GetDocument().Markers().Markers()[0]->StartOffset()); |
| 1425 EXPECT_EQ(5u, GetDocument().Markers().Markers()[0]->EndOffset()); | 1421 EXPECT_EQ(5u, GetDocument().Markers().Markers()[0]->EndOffset()); |
| 1426 } | 1422 } |
| 1427 | 1423 |
| 1428 TEST_F(InputMethodControllerTest, SelectionWhenFocusChangeFinishesComposition) { | 1424 TEST_F(InputMethodControllerTest, SelectionWhenFocusChangeFinishesComposition) { |
| 1429 GetDocument().GetSettings()->SetScriptEnabled(true); | 1425 GetDocument().GetSettings()->SetScriptEnabled(true); |
| 1430 Element* editable = | 1426 Element* editable = |
| (...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1972 // Set selection before BODY(editable). | 1968 // Set selection before BODY(editable). |
| 1973 GetFrame().Selection().SetSelection( | 1969 GetFrame().Selection().SetSelection( |
| 1974 SelectionInDOMTree::Builder() | 1970 SelectionInDOMTree::Builder() |
| 1975 .Collapse(Position(GetDocument().documentElement(), 0)) | 1971 .Collapse(Position(GetDocument().documentElement(), 0)) |
| 1976 .Build()); | 1972 .Build()); |
| 1977 | 1973 |
| 1978 EXPECT_EQ(kWebTextInputTypeContentEditable, Controller().TextInputType()); | 1974 EXPECT_EQ(kWebTextInputTypeContentEditable, Controller().TextInputType()); |
| 1979 } | 1975 } |
| 1980 | 1976 |
| 1981 } // namespace blink | 1977 } // namespace blink |
| OLD | NEW |