| 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 "ui/base/ime/input_method_chromeos.h" | 5 #include "ui/base/ime/input_method_chromeos.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cstring> | 8 #include <cstring> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 client->ClearCompositionText(); | 547 client->ClearCompositionText(); |
| 548 SendFakeProcessKeyEvent(false); | 548 SendFakeProcessKeyEvent(false); |
| 549 } | 549 } |
| 550 composition_changed_ = false; | 550 composition_changed_ = false; |
| 551 } | 551 } |
| 552 } | 552 } |
| 553 | 553 |
| 554 void InputMethodChromeOS::DeleteSurroundingText(int32 offset, uint32 length) { | 554 void InputMethodChromeOS::DeleteSurroundingText(int32 offset, uint32 length) { |
| 555 if (!composition_.text.empty()) | 555 if (!composition_.text.empty()) |
| 556 return; // do nothing if there is ongoing composition. | 556 return; // do nothing if there is ongoing composition. |
| 557 | 557 if (offset < 0 && static_cast<uint32>(-1 * offset) != length) |
| 558 if (GetTextInputClient()) { | 558 return; // only preceding text can be deletable. |
| 559 uint32 before = offset >= 0 ? 0U : static_cast<uint32>(-1 * offset); | 559 if (GetTextInputClient()) |
| 560 GetTextInputClient()->ExtendSelectionAndDelete(before, length - before); | 560 GetTextInputClient()->ExtendSelectionAndDelete(length, 0U); |
| 561 } | |
| 562 } | 561 } |
| 563 | 562 |
| 564 bool InputMethodChromeOS::ExecuteCharacterComposer(const ui::KeyEvent& event) { | 563 bool InputMethodChromeOS::ExecuteCharacterComposer(const ui::KeyEvent& event) { |
| 565 if (!character_composer_.FilterKeyPress(event)) | 564 if (!character_composer_.FilterKeyPress(event)) |
| 566 return false; | 565 return false; |
| 567 | 566 |
| 568 // CharacterComposer consumed the key event. Update the composition text. | 567 // CharacterComposer consumed the key event. Update the composition text. |
| 569 chromeos::CompositionText preedit; | 568 chromeos::CompositionText preedit; |
| 570 preedit.set_text(character_composer_.preedit_string()); | 569 preedit.set_text(character_composer_.preedit_string()); |
| 571 UpdateCompositionText(preedit, preedit.text().size(), | 570 UpdateCompositionText(preedit, preedit.text().size(), |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 666 bool InputMethodChromeOS::IsNonPasswordInputFieldFocused() { | 665 bool InputMethodChromeOS::IsNonPasswordInputFieldFocused() { |
| 667 TextInputType type = GetTextInputType(); | 666 TextInputType type = GetTextInputType(); |
| 668 return (type != TEXT_INPUT_TYPE_NONE) && (type != TEXT_INPUT_TYPE_PASSWORD); | 667 return (type != TEXT_INPUT_TYPE_NONE) && (type != TEXT_INPUT_TYPE_PASSWORD); |
| 669 } | 668 } |
| 670 | 669 |
| 671 bool InputMethodChromeOS::IsInputFieldFocused() { | 670 bool InputMethodChromeOS::IsInputFieldFocused() { |
| 672 return GetTextInputType() != TEXT_INPUT_TYPE_NONE; | 671 return GetTextInputType() != TEXT_INPUT_TYPE_NONE; |
| 673 } | 672 } |
| 674 | 673 |
| 675 } // namespace ui | 674 } // namespace ui |
| OLD | NEW |