| 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 if (offset < 0 && static_cast<uint32>(-1 * offset) != length) | 557 |
| 558 return; // only preceding text can be deletable. | 558 if (GetTextInputClient()) { |
| 559 if (GetTextInputClient()) | 559 uint32 before = offset >= 0 ? 0U : static_cast<uint32>(-1 * offset); |
| 560 GetTextInputClient()->ExtendSelectionAndDelete(length, 0U); | 560 GetTextInputClient()->ExtendSelectionAndDelete(before, length - before); |
| 561 } |
| 561 } | 562 } |
| 562 | 563 |
| 563 bool InputMethodChromeOS::ExecuteCharacterComposer(const ui::KeyEvent& event) { | 564 bool InputMethodChromeOS::ExecuteCharacterComposer(const ui::KeyEvent& event) { |
| 564 if (!character_composer_.FilterKeyPress(event)) | 565 if (!character_composer_.FilterKeyPress(event)) |
| 565 return false; | 566 return false; |
| 566 | 567 |
| 567 // CharacterComposer consumed the key event. Update the composition text. | 568 // CharacterComposer consumed the key event. Update the composition text. |
| 568 chromeos::CompositionText preedit; | 569 chromeos::CompositionText preedit; |
| 569 preedit.set_text(character_composer_.preedit_string()); | 570 preedit.set_text(character_composer_.preedit_string()); |
| 570 UpdateCompositionText(preedit, preedit.text().size(), | 571 UpdateCompositionText(preedit, preedit.text().size(), |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 665 bool InputMethodChromeOS::IsNonPasswordInputFieldFocused() { | 666 bool InputMethodChromeOS::IsNonPasswordInputFieldFocused() { |
| 666 TextInputType type = GetTextInputType(); | 667 TextInputType type = GetTextInputType(); |
| 667 return (type != TEXT_INPUT_TYPE_NONE) && (type != TEXT_INPUT_TYPE_PASSWORD); | 668 return (type != TEXT_INPUT_TYPE_NONE) && (type != TEXT_INPUT_TYPE_PASSWORD); |
| 668 } | 669 } |
| 669 | 670 |
| 670 bool InputMethodChromeOS::IsInputFieldFocused() { | 671 bool InputMethodChromeOS::IsInputFieldFocused() { |
| 671 return GetTextInputType() != TEXT_INPUT_TYPE_NONE; | 672 return GetTextInputType() != TEXT_INPUT_TYPE_NONE; |
| 672 } | 673 } |
| 673 | 674 |
| 674 } // namespace ui | 675 } // namespace ui |
| OLD | NEW |