Chromium Code Reviews| Index: ui/base/ime/input_method_auralinux.cc |
| diff --git a/ui/base/ime/input_method_auralinux.cc b/ui/base/ime/input_method_auralinux.cc |
| index a084195de193ed74a101f89ba2a776a4aa6be7fd..1f8859a25a3e29c3977fd7eacd732fa75bf91039 100644 |
| --- a/ui/base/ime/input_method_auralinux.cc |
| +++ b/ui/base/ime/input_method_auralinux.cc |
| @@ -17,8 +17,7 @@ InputMethodAuraLinux::InputMethodAuraLinux( |
| : text_input_type_(TEXT_INPUT_TYPE_NONE), |
| is_sync_mode_(false), |
| composition_changed_(false), |
| - suppress_next_result_(false), |
| - destroyed_ptr_(nullptr) { |
| + suppress_next_result_(false) { |
| SetDelegate(delegate); |
| context_ = |
| LinuxInputMethodContextFactory::instance()->CreateInputMethodContext( |
| @@ -29,8 +28,6 @@ InputMethodAuraLinux::InputMethodAuraLinux( |
| } |
| InputMethodAuraLinux::~InputMethodAuraLinux() { |
| - if (destroyed_ptr_) |
| - *destroyed_ptr_ = true; |
| } |
| LinuxInputMethodContext* InputMethodAuraLinux::GetContextForTesting( |
| @@ -46,13 +43,15 @@ bool InputMethodAuraLinux::OnUntranslatedIMEMessage( |
| return false; |
| } |
| -bool InputMethodAuraLinux::DispatchKeyEvent(const ui::KeyEvent& event) { |
| - DCHECK(event.type() == ET_KEY_PRESSED || event.type() == ET_KEY_RELEASED); |
| +void InputMethodAuraLinux::DispatchKeyEvent(ui::KeyEvent* event) { |
| + DCHECK(event->type() == ET_KEY_PRESSED || event->type() == ET_KEY_RELEASED); |
| DCHECK(system_toplevel_window_focused()); |
| // If no text input client, do nothing. |
| - if (!GetTextInputClient()) |
| - return DispatchKeyEventPostIME(event); |
| + if (!GetTextInputClient()) { |
| + ignore_result(DispatchKeyEventPostIME(event)); |
| + return; |
| + } |
| suppress_next_result_ = false; |
| composition_changed_ = false; |
| @@ -63,29 +62,25 @@ bool InputMethodAuraLinux::DispatchKeyEvent(const ui::KeyEvent& event) { |
| base::AutoReset<bool> flipper(&is_sync_mode_, true); |
| if (text_input_type_ != TEXT_INPUT_TYPE_NONE && |
| text_input_type_ != TEXT_INPUT_TYPE_PASSWORD) { |
| - filtered = context_->DispatchKeyEvent(event); |
| + filtered = context_->DispatchKeyEvent(*event); |
| } else { |
| - filtered = context_simple_->DispatchKeyEvent(event); |
| + filtered = context_simple_->DispatchKeyEvent(*event); |
| } |
| } |
| - bool destroyed = false; |
| - bool handled = false; |
| - if (event.type() == ui::ET_KEY_PRESSED && filtered) { |
| - { |
| - base::AutoReset<bool*> auto_reset(&destroyed_ptr_, &destroyed); |
| - if (NeedInsertChar()) |
| - handled = DispatchKeyEventPostIME(event); |
| - else if (HasInputMethodResult()) |
| - handled = SendFakeProcessKeyEvent(event.flags()); |
| - if (destroyed) |
| - return true; |
| - } |
| + ui::EventDispatchDetails details; |
| + if (event->type() == ui::ET_KEY_PRESSED && filtered) { |
| + if (NeedInsertChar()) |
| + details = DispatchKeyEventPostIME(event); |
| + else if (HasInputMethodResult()) |
| + SendFakeProcessKeyEvent(event->flags()); |
|
James Su
2015/07/31 11:43:57
This method should return ui::EventDispatchDetails
Shu Chen
2015/08/03 01:44:47
Done.
|
| + if (details.dispatcher_destroyed) |
| + return; |
| // If the KEYDOWN is stopped propagation (e.g. triggered an accelerator), |
| // don't InsertChar/InsertText to the input field. |
| - if (handled) { |
| + if (event->stopped_propagation()) { |
|
James Su
2015/07/31 11:43:58
needs to check details.target_destroyed here.
Shu Chen
2015/08/03 01:44:47
Done.
|
| ResetContext(); |
| - return true; |
| + return; |
| } |
| // Don't send VKEY_PROCESSKEY event if there is no result text or |
| @@ -100,7 +95,7 @@ bool InputMethodAuraLinux::DispatchKeyEvent(const ui::KeyEvent& event) { |
| if (!result_text_.empty()) { |
| if (filtered && NeedInsertChar()) { |
| for (const auto ch : result_text_) |
| - client->InsertChar(ch, event.flags()); |
| + client->InsertChar(ch, event->flags()); |
| } else { |
| // If |filtered| is false, that means the IME wants to commit some text |
| // but still release the key to the application. For example, Korean IME |
| @@ -127,17 +122,14 @@ bool InputMethodAuraLinux::DispatchKeyEvent(const ui::KeyEvent& event) { |
| composition_.Clear(); |
| if (!filtered) { |
|
James Su
2015/07/31 11:43:57
just noticed that we send nothing if a key up even
Shu Chen
2015/08/03 01:44:47
This behavior has not been changed for years.
Wha
|
| - { |
| - base::AutoReset<bool*> auto_reset(&destroyed_ptr_, &destroyed); |
| - handled = DispatchKeyEventPostIME(event); |
| - if (destroyed) |
| - return true; |
| - } |
| - if (handled) { |
| + details = DispatchKeyEventPostIME(event); |
| + if (details.dispatcher_destroyed) |
| + return; |
| + if (event->stopped_propagation()) { |
|
James Su
2015/07/31 11:43:57
needs to check details.target_destroyed here.
Shu Chen
2015/08/03 01:44:47
Done.
|
| ResetContext(); |
| - return true; |
| + return; |
| } |
| - if (event.type() == ui::ET_KEY_PRESSED) { |
| + if (event->type() == ui::ET_KEY_PRESSED) { |
| // If a key event was not filtered by |context_| or |context_simple_|, |
| // then it means the key event didn't generate any result text. For some |
| // cases, the key event may still generate a valid character, eg. a |
| @@ -146,13 +138,11 @@ bool InputMethodAuraLinux::DispatchKeyEvent(const ui::KeyEvent& event) { |
| // TextInputClient::InsertChar(). |
| // Note: don't use |client| and use GetTextInputClient() here because |
| // DispatchKeyEventPostIME may cause the current text input client change. |
| - base::char16 ch = event.GetCharacter(); |
| + base::char16 ch = event->GetCharacter(); |
| if (ch && GetTextInputClient()) |
| - GetTextInputClient()->InsertChar(ch, event.flags()); |
| + GetTextInputClient()->InsertChar(ch, event->flags()); |
| } |
| } |
| - |
| - return true; |
| } |
| void InputMethodAuraLinux::UpdateContextFocusState() { |
| @@ -333,9 +323,9 @@ bool InputMethodAuraLinux::NeedInsertChar() const { |
| result_text_.length() == 1); |
| } |
| -bool InputMethodAuraLinux::SendFakeProcessKeyEvent(int flags) const { |
| - return DispatchKeyEventPostIME( |
| - KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_PROCESSKEY, flags)); |
| +void InputMethodAuraLinux::SendFakeProcessKeyEvent(int flags) const { |
| + KeyEvent key_event(ui::ET_KEY_PRESSED, ui::VKEY_PROCESSKEY, flags); |
| + ignore_result(DispatchKeyEventPostIME(&key_event)); |
| } |
| void InputMethodAuraLinux::ConfirmCompositionText() { |