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 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1988 // Set selection before BODY(editable). | 1984 // Set selection before BODY(editable). |
1989 GetFrame().Selection().SetSelection( | 1985 GetFrame().Selection().SetSelection( |
1990 SelectionInDOMTree::Builder() | 1986 SelectionInDOMTree::Builder() |
1991 .Collapse(Position(GetDocument().documentElement(), 0)) | 1987 .Collapse(Position(GetDocument().documentElement(), 0)) |
1992 .Build()); | 1988 .Build()); |
1993 | 1989 |
1994 EXPECT_EQ(kWebTextInputTypeContentEditable, Controller().TextInputType()); | 1990 EXPECT_EQ(kWebTextInputTypeContentEditable, Controller().TextInputType()); |
1995 } | 1991 } |
1996 | 1992 |
1997 } // namespace blink | 1993 } // namespace blink |
OLD | NEW |