diff options
author | komatsu@chromium.org <komatsu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-30 12:43:43 +0000 |
---|---|---|
committer | komatsu@chromium.org <komatsu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-30 12:43:43 +0000 |
commit | 4612c4cbfcacbe0b7c72aeaa8416ac479ee74b20 (patch) | |
tree | ab485396d315386f2aa2f2422f9f5b18a7e687c4 | |
parent | f5cbed05d92a26f40ad601f44c66522d9c822456 (diff) | |
download | chromium_src-4612c4cbfcacbe0b7c72aeaa8416ac479ee74b20.zip chromium_src-4612c4cbfcacbe0b7c72aeaa8416ac479ee74b20.tar.gz chromium_src-4612c4cbfcacbe0b7c72aeaa8416ac479ee74b20.tar.bz2 |
Unify ProcessUnfilteredFabricatedKeyPressEvent to ProcessFabricatedKeyPressEvent.
BUG=312218
Review URL: https://codereview.chromium.org/96203002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@237988 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | ui/base/ime/input_method_ibus.cc | 53 | ||||
-rw-r--r-- | ui/base/ime/input_method_ibus.h | 1 |
2 files changed, 17 insertions, 37 deletions
diff --git a/ui/base/ime/input_method_ibus.cc b/ui/base/ime/input_method_ibus.cc index d098de7..081c808 100644 --- a/ui/base/ime/input_method_ibus.cc +++ b/ui/base/ime/input_method_ibus.cc @@ -289,7 +289,7 @@ void InputMethodIBus::ConfirmCompositionText() { bool InputMethodIBus::DispatchFabricatedKeyEvent(const ui::KeyEvent& event) { // TODO(bryeung): The fabricated events should also pass through IME. if (event.type() == ET_KEY_PRESSED) - ProcessUnfilteredFabricatedKeyPressEvent(event); + ProcessUnfilteredKeyPressEvent(event); else DispatchKeyEventPostIME(event); @@ -424,15 +424,7 @@ void InputMethodIBus::ProcessFilteredKeyPressEvent(const ui::KeyEvent& event) { void InputMethodIBus::ProcessUnfilteredKeyPressEvent( const ui::KeyEvent& event) { - // For a fabricated event, ProcessUnfilteredFabricatedKeyPressEvent should be - // called instead. - if (!event.HasNativeEvent()) - return ProcessUnfilteredFabricatedKeyPressEvent(event); - - const base::NativeEvent& native_event = event.native_event(); - DCHECK(native_event); - - TextInputClient* client = GetTextInputClient(); + const TextInputClient* prev_client = GetTextInputClient(); DispatchKeyEventPostIME(event); // We shouldn't dispatch the character anymore if the key event dispatch @@ -442,43 +434,32 @@ void InputMethodIBus::ProcessUnfilteredKeyPressEvent( // 3. enable Korean IME, press A, then press Tab to move the focus to the web // page. // We should return here not to send the Tab key event to RWHV. - if (client != GetTextInputClient()) + TextInputClient* client = GetTextInputClient(); + if (!client || client != prev_client) return; - const uint32 event_flags = event.flags(); - // If a key event was not filtered by |context_| and |character_composer_|, // then it means the key event didn't generate any result text. So we need // to send corresponding character to the focused text input client. - client = GetTextInputClient(); - + const uint32 event_flags = event.flags(); uint16 ch = 0; - if (!(event_flags & ui::EF_CONTROL_DOWN)) - ch = ui::GetCharacterFromXEvent(native_event); - if (!ch) { - ch = ui::GetCharacterFromKeyCode( - ui::KeyboardCodeFromNative(native_event), event_flags); + if (event.HasNativeEvent()) { + const base::NativeEvent& native_event = event.native_event(); + + if (!(event_flags & ui::EF_CONTROL_DOWN)) + ch = ui::GetCharacterFromXEvent(native_event); + if (!ch) { + ch = ui::GetCharacterFromKeyCode( + ui::KeyboardCodeFromNative(native_event), event_flags); + } + } else { + ch = ui::GetCharacterFromKeyCode(event.key_code(), event_flags); } - if (client && ch) + if (ch) client->InsertChar(ch, event_flags); } -void InputMethodIBus::ProcessUnfilteredFabricatedKeyPressEvent( - const ui::KeyEvent& event) { - TextInputClient* client = GetTextInputClient(); - DispatchKeyEventPostIME(event); - - if (client != GetTextInputClient()) - return; - - client = GetTextInputClient(); - const uint16 ch = ui::GetCharacterFromKeyCode(event.key_code(), - event.flags()); - if (client && ch) - client->InsertChar(ch, event.flags()); -} - void InputMethodIBus::ProcessInputMethodResult(const ui::KeyEvent& event, bool handled) { TextInputClient* client = GetTextInputClient(); diff --git a/ui/base/ime/input_method_ibus.h b/ui/base/ime/input_method_ibus.h index d9dbbcf..e558524 100644 --- a/ui/base/ime/input_method_ibus.h +++ b/ui/base/ime/input_method_ibus.h @@ -89,7 +89,6 @@ class UI_EXPORT InputMethodIBus // Processes a key event that was not filtered by the input method. void ProcessUnfilteredKeyPressEvent(const ui::KeyEvent& event); - void ProcessUnfilteredFabricatedKeyPressEvent(const ui::KeyEvent& event); // Sends input method result caused by the given key event to the focused text // input client. |