| 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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 GetDocument().UpdateStyleAndLayout(); | 195 GetDocument().UpdateStyleAndLayout(); |
| 196 Controller().SetEditableSelectionOffsets(PlainTextRange(2, 2)); | 196 Controller().SetEditableSelectionOffsets(PlainTextRange(2, 2)); |
| 197 EXPECT_EQ(2, GetFrame() | 197 EXPECT_EQ(2, GetFrame() |
| 198 .Selection() | 198 .Selection() |
| 199 .ComputeVisibleSelectionInDOMTreeDeprecated() | 199 .ComputeVisibleSelectionInDOMTreeDeprecated() |
| 200 .Start() | 200 .Start() |
| 201 .ComputeOffsetInContainerNode()); | 201 .ComputeOffsetInContainerNode()); |
| 202 EXPECT_EQ(2, GetFrame() | 202 EXPECT_EQ(2, GetFrame() |
| 203 .Selection() | 203 .Selection() |
| 204 .ComputeVisibleSelectionInDOMTreeDeprecated() | 204 .ComputeVisibleSelectionInDOMTreeDeprecated() |
| 205 .end() | 205 .End() |
| 206 .ComputeOffsetInContainerNode()); | 206 .ComputeOffsetInContainerNode()); |
| 207 | 207 |
| 208 Controller().SetComposition(String("a"), underlines, 1, 1); | 208 Controller().SetComposition(String("a"), underlines, 1, 1); |
| 209 EXPECT_STREQ("\xF0\x9F\x8F\x86\x61", div->innerText().Utf8().data()); | 209 EXPECT_STREQ("\xF0\x9F\x8F\x86\x61", div->innerText().Utf8().data()); |
| 210 | 210 |
| 211 Controller().SetComposition(String("ab"), underlines, 2, 2); | 211 Controller().SetComposition(String("ab"), underlines, 2, 2); |
| 212 EXPECT_STREQ("\xF0\x9F\x8F\x86\x61\x62", div->innerText().Utf8().data()); | 212 EXPECT_STREQ("\xF0\x9F\x8F\x86\x61\x62", div->innerText().Utf8().data()); |
| 213 } | 213 } |
| 214 | 214 |
| 215 TEST_F(InputMethodControllerTest, SetCompositionWithGraphemeCluster) { | 215 TEST_F(InputMethodControllerTest, SetCompositionWithGraphemeCluster) { |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 | 409 |
| 410 Controller().FinishComposingText(InputMethodController::kKeepSelection); | 410 Controller().FinishComposingText(InputMethodController::kKeepSelection); |
| 411 EXPECT_EQ(0, GetFrame() | 411 EXPECT_EQ(0, GetFrame() |
| 412 .Selection() | 412 .Selection() |
| 413 .ComputeVisibleSelectionInDOMTreeDeprecated() | 413 .ComputeVisibleSelectionInDOMTreeDeprecated() |
| 414 .Start() | 414 .Start() |
| 415 .ComputeOffsetInContainerNode()); | 415 .ComputeOffsetInContainerNode()); |
| 416 EXPECT_EQ(0, GetFrame() | 416 EXPECT_EQ(0, GetFrame() |
| 417 .Selection() | 417 .Selection() |
| 418 .ComputeVisibleSelectionInDOMTreeDeprecated() | 418 .ComputeVisibleSelectionInDOMTreeDeprecated() |
| 419 .end() | 419 .End() |
| 420 .ComputeOffsetInContainerNode()); | 420 .ComputeOffsetInContainerNode()); |
| 421 } | 421 } |
| 422 | 422 |
| 423 TEST_F(InputMethodControllerTest, DeleteBySettingEmptyComposition) { | 423 TEST_F(InputMethodControllerTest, DeleteBySettingEmptyComposition) { |
| 424 HTMLInputElement* input = | 424 HTMLInputElement* input = |
| 425 toHTMLInputElement(InsertHTMLElement("<input id='sample'>", "sample")); | 425 toHTMLInputElement(InsertHTMLElement("<input id='sample'>", "sample")); |
| 426 | 426 |
| 427 input->setValue("foo "); | 427 input->setValue("foo "); |
| 428 GetDocument().UpdateStyleAndLayout(); | 428 GetDocument().UpdateStyleAndLayout(); |
| 429 Controller().SetEditableSelectionOffsets(PlainTextRange(4, 4)); | 429 Controller().SetEditableSelectionOffsets(PlainTextRange(4, 4)); |
| (...skipping 1383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1813 // Set selection before BODY(editable). | 1813 // Set selection before BODY(editable). |
| 1814 GetFrame().Selection().SetSelection( | 1814 GetFrame().Selection().SetSelection( |
| 1815 SelectionInDOMTree::Builder() | 1815 SelectionInDOMTree::Builder() |
| 1816 .Collapse(Position(GetDocument().documentElement(), 0)) | 1816 .Collapse(Position(GetDocument().documentElement(), 0)) |
| 1817 .Build()); | 1817 .Build()); |
| 1818 | 1818 |
| 1819 EXPECT_EQ(kWebTextInputTypeContentEditable, Controller().TextInputType()); | 1819 EXPECT_EQ(kWebTextInputTypeContentEditable, Controller().TextInputType()); |
| 1820 } | 1820 } |
| 1821 | 1821 |
| 1822 } // namespace blink | 1822 } // namespace blink |
| OLD | NEW |