| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <cstring> | 10 #include <cstring> |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 } | 33 } |
| 34 } // namespace | 34 } // namespace |
| 35 | 35 |
| 36 namespace ui { | 36 namespace ui { |
| 37 | 37 |
| 38 // InputMethodChromeOS implementation ----------------------------------------- | 38 // InputMethodChromeOS implementation ----------------------------------------- |
| 39 InputMethodChromeOS::InputMethodChromeOS( | 39 InputMethodChromeOS::InputMethodChromeOS( |
| 40 internal::InputMethodDelegate* delegate) | 40 internal::InputMethodDelegate* delegate) |
| 41 : composing_text_(false), | 41 : composing_text_(false), |
| 42 composition_changed_(false), | 42 composition_changed_(false), |
| 43 handling_key_event_(false), | |
| 44 weak_ptr_factory_(this) { | 43 weak_ptr_factory_(this) { |
| 45 SetDelegate(delegate); | 44 SetDelegate(delegate); |
| 46 ui::IMEBridge::Get()->SetInputContextHandler(this); | 45 ui::IMEBridge::Get()->SetInputContextHandler(this); |
| 47 | 46 |
| 48 UpdateContextFocusState(); | 47 UpdateContextFocusState(); |
| 49 } | 48 } |
| 50 | 49 |
| 51 InputMethodChromeOS::~InputMethodChromeOS() { | 50 InputMethodChromeOS::~InputMethodChromeOS() { |
| 52 ConfirmCompositionText(); | 51 ConfirmCompositionText(); |
| 53 // We are dead, so we need to ask the client to stop relying on us. | 52 // We are dead, so we need to ask the client to stop relying on us. |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 bool InputMethodChromeOS::NeedInsertChar() const { | 431 bool InputMethodChromeOS::NeedInsertChar() const { |
| 433 return GetTextInputClient() && | 432 return GetTextInputClient() && |
| 434 (IsTextInputTypeNone() || | 433 (IsTextInputTypeNone() || |
| 435 (!composing_text_ && result_text_.length() == 1)); | 434 (!composing_text_ && result_text_.length() == 1)); |
| 436 } | 435 } |
| 437 | 436 |
| 438 bool InputMethodChromeOS::HasInputMethodResult() const { | 437 bool InputMethodChromeOS::HasInputMethodResult() const { |
| 439 return result_text_.length() || composition_changed_; | 438 return result_text_.length() || composition_changed_; |
| 440 } | 439 } |
| 441 | 440 |
| 442 bool InputMethodChromeOS::SendFakeProcessKeyEvent(bool pressed) const { | |
| 443 KeyEvent evt(pressed ? ET_KEY_PRESSED : ET_KEY_RELEASED, | |
| 444 pressed ? VKEY_PROCESSKEY : VKEY_UNKNOWN, | |
| 445 EF_IME_FABRICATED_KEY); | |
| 446 ignore_result(DispatchKeyEventPostIME(&evt)); | |
| 447 return evt.stopped_propagation(); | |
| 448 } | |
| 449 | |
| 450 void InputMethodChromeOS::CommitText(const std::string& text) { | 441 void InputMethodChromeOS::CommitText(const std::string& text) { |
| 451 if (text.empty()) | 442 if (text.empty()) |
| 452 return; | 443 return; |
| 453 | 444 |
| 454 // We need to receive input method result even if the text input type is | 445 // We need to receive input method result even if the text input type is |
| 455 // TEXT_INPUT_TYPE_NONE, to make sure we can always send correct | 446 // TEXT_INPUT_TYPE_NONE, to make sure we can always send correct |
| 456 // character for each key event to the focused text input client. | 447 // character for each key event to the focused text input client. |
| 457 if (!GetTextInputClient()) | 448 if (!GetTextInputClient()) |
| 458 return; | 449 return; |
| 459 | 450 |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 641 bool InputMethodChromeOS::IsNonPasswordInputFieldFocused() { | 632 bool InputMethodChromeOS::IsNonPasswordInputFieldFocused() { |
| 642 TextInputType type = GetTextInputType(); | 633 TextInputType type = GetTextInputType(); |
| 643 return (type != TEXT_INPUT_TYPE_NONE) && (type != TEXT_INPUT_TYPE_PASSWORD); | 634 return (type != TEXT_INPUT_TYPE_NONE) && (type != TEXT_INPUT_TYPE_PASSWORD); |
| 644 } | 635 } |
| 645 | 636 |
| 646 bool InputMethodChromeOS::IsInputFieldFocused() { | 637 bool InputMethodChromeOS::IsInputFieldFocused() { |
| 647 return GetTextInputType() != TEXT_INPUT_TYPE_NONE; | 638 return GetTextInputType() != TEXT_INPUT_TYPE_NONE; |
| 648 } | 639 } |
| 649 | 640 |
| 650 } // namespace ui | 641 } // namespace ui |
| OLD | NEW |