| 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..d45ef944d42a41c190496eb9d5fe3f35938d8c55 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,13 @@ 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);
|
| + ignore_result(DispatchKeyEventPostIME(event));
|
|
|
| suppress_next_result_ = false;
|
| composition_changed_ = false;
|
| @@ -63,29 +60,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());
|
| + 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()) {
|
| ResetContext();
|
| - return true;
|
| + return;
|
| }
|
|
|
| // Don't send VKEY_PROCESSKEY event if there is no result text or
|
| @@ -100,7 +93,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 +120,14 @@ bool InputMethodAuraLinux::DispatchKeyEvent(const ui::KeyEvent& event) {
|
| composition_.Clear();
|
|
|
| if (!filtered) {
|
| - {
|
| - 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()) {
|
| 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 +136,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 +321,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() {
|
|
|