| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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/aura/mus/input_method_mus.h" | 5 #include "ui/aura/mus/input_method_mus.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "services/ui/public/interfaces/constants.mojom.h" | 10 #include "services/ui/public/interfaces/constants.mojom.h" |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 for (auto& callback_ptr : pending_callbacks_) { | 188 for (auto& callback_ptr : pending_callbacks_) { |
| 189 if (callback_ptr) | 189 if (callback_ptr) |
| 190 callback_ptr->Run(EventResult::UNHANDLED); | 190 callback_ptr->Run(EventResult::UNHANDLED); |
| 191 } | 191 } |
| 192 pending_callbacks_.clear(); | 192 pending_callbacks_.clear(); |
| 193 } | 193 } |
| 194 | 194 |
| 195 void InputMethodMus::ProcessKeyEventCallback( | 195 void InputMethodMus::ProcessKeyEventCallback( |
| 196 const ui::KeyEvent& event, | 196 const ui::KeyEvent& event, |
| 197 bool handled) { | 197 bool handled) { |
| 198 // Remove the callback as DispatchKeyEventPostIME() may lead to calling |
| 199 // AckPendingCallbacksUnhandled(), which mutates |pending_callbacks_|. |
| 200 DCHECK(!pending_callbacks_.empty()); |
| 201 std::unique_ptr<EventResultCallback> ack_callback = |
| 202 std::move(pending_callbacks_.front()); |
| 203 pending_callbacks_.pop_front(); |
| 198 EventResult event_result; | 204 EventResult event_result; |
| 199 if (!handled) { | 205 if (!handled) { |
| 200 // If not handled by IME, try dispatching the event to delegate to see if | 206 // If not handled by IME, try dispatching the event to delegate to see if |
| 201 // any client-side post-ime processing needs to be done. This includes cases | 207 // any client-side post-ime processing needs to be done. This includes cases |
| 202 // like backspace, return key, etc. | 208 // like backspace, return key, etc. |
| 203 std::unique_ptr<ui::Event> event_clone = ui::Event::Clone(event); | 209 std::unique_ptr<ui::Event> event_clone = ui::Event::Clone(event); |
| 204 DispatchKeyEventPostIME(event_clone->AsKeyEvent()); | 210 DispatchKeyEventPostIME(event_clone->AsKeyEvent()); |
| 205 event_result = | 211 event_result = |
| 206 event_clone->handled() ? EventResult::HANDLED : EventResult::UNHANDLED; | 212 event_clone->handled() ? EventResult::HANDLED : EventResult::UNHANDLED; |
| 207 } else { | 213 } else { |
| 208 event_result = EventResult::HANDLED; | 214 event_result = EventResult::HANDLED; |
| 209 } | 215 } |
| 210 DCHECK(!pending_callbacks_.empty()); | |
| 211 std::unique_ptr<EventResultCallback> ack_callback = | |
| 212 std::move(pending_callbacks_.front()); | |
| 213 pending_callbacks_.pop_front(); | |
| 214 // |ack_callback| can be null if the standard form of DispatchKeyEvent() is | 216 // |ack_callback| can be null if the standard form of DispatchKeyEvent() is |
| 215 // called instead of the version which provides a callback. In mus+ash we | 217 // called instead of the version which provides a callback. In mus+ash we |
| 216 // use the version with callback, but some unittests use the standard form. | 218 // use the version with callback, but some unittests use the standard form. |
| 217 if (ack_callback) | 219 if (ack_callback) |
| 218 ack_callback->Run(event_result); | 220 ack_callback->Run(event_result); |
| 219 } | 221 } |
| 220 | 222 |
| 221 } // namespace aura | 223 } // namespace aura |
| OLD | NEW |