diff options
author | yukishiino@chromium.org <yukishiino@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-22 17:52:45 +0000 |
---|---|---|
committer | yukishiino@chromium.org <yukishiino@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-22 17:52:45 +0000 |
commit | 19d46db411a6caba696d77dc88f7bc3adf31032f (patch) | |
tree | 83c4065d0da9539bae1b2f892d7d9322010633f2 /ui/wm | |
parent | 2ec3b46c57e95a12d56277a9355801dcdd200788 (diff) | |
download | chromium_src-19d46db411a6caba696d77dc88f7bc3adf31032f.zip chromium_src-19d46db411a6caba696d77dc88f7bc3adf31032f.tar.gz chromium_src-19d46db411a6caba696d77dc88f7bc3adf31032f.tar.bz2 |
Retires ui::TranslatedKeyEvent and replaces it with KeyEvent.
BUG=339355
TEST=Run unittests.
TBR=jamesr@chromium.org, pfeldman@chromium.org
Review URL: https://codereview.chromium.org/267723008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@272228 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/wm')
-rw-r--r-- | ui/wm/core/input_method_event_filter.cc | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/ui/wm/core/input_method_event_filter.cc b/ui/wm/core/input_method_event_filter.cc index 4854a1b..65bd5b5 100644 --- a/ui/wm/core/input_method_event_filter.cc +++ b/ui/wm/core/input_method_event_filter.cc @@ -37,12 +37,31 @@ void InputMethodEventFilter::SetInputMethodPropertyInRootWindow( // InputMethodEventFilter, EventFilter implementation: void InputMethodEventFilter::OnKeyEvent(ui::KeyEvent* event) { - const ui::EventType type = event->type(); - if (type == ui::ET_TRANSLATED_KEY_PRESS || - type == ui::ET_TRANSLATED_KEY_RELEASE) { - // The |event| is already handled by this object, change the type of the - // event to ui::ET_KEY_* and pass it to the next filter. - static_cast<ui::TranslatedKeyEvent*>(event)->ConvertToKeyEvent(); + // We're processing key events as follows (details are simplified). + // + // At the beginning, key events have a ET_KEY_{PRESSED,RELEASED} event type, + // and they're passed from step 1 through step 3. + // 1. EventProcessor::OnEventFromSource() + // 2. InputMethodEventFilter::OnKeyEvent() + // 3. InputMethod::DispatchKeyEvent() + // where InputMethod may call DispatchKeyEventPostIME() if IME didn't consume + // the key event. Otherwise, step 4 through step 6 are skipped and we fall + // down to step 7 directly. + // 4. InputMethodEventFilter::DispatchKeyEventPostIME() + // where the key event is marked as TRANSLATED and the event type becomes + // ET_TRANSLATED_KEY_{PRESS,RELEASE}. Then, we dispatch the event again from + // the beginning. + // 5. EventProcessor::OnEventFromSource() [second time] + // 6. InputMethodEventFilter::OnKeyEvent() [second time] + // where we know that the event was already processed once by IME and + // re-dispatched, we don't pass the event to IME again. Instead we unmark the + // event as not translated (as same as the original state), and let the event + // dispatcher continue to dispatch the event to the rest event handlers. + // 7. EventHandler::OnKeyEvent() + if (event->IsTranslated()) { + // The |event| was already processed by IME, so we don't pass the event to + // IME again. Just let the event dispatcher continue to dispatch the event. + event->SetTranslated(false); } else { // If the focused window is changed, all requests to IME will be // discarded so it's safe to update the target_dispatcher_ here. @@ -62,7 +81,13 @@ bool InputMethodEventFilter::DispatchKeyEventPostIME( #if defined(OS_WIN) DCHECK(!event.HasNativeEvent() || event.native_event().message != WM_CHAR); #endif - ui::TranslatedKeyEvent aura_event(event); + // Since the underlying IME didn't consume the key event, we're going to + // dispatch the event again from the beginning of the tree of event targets. + // This time we have to skip dispatching the event to the IME, we mark the + // event as TRANSLATED so we can distinguish this event as a second time + // dispatched event. + ui::KeyEvent aura_event(event); + aura_event.SetTranslated(true); ui::EventDispatchDetails details = target_dispatcher_->OnEventFromSource(&aura_event); CHECK(!details.dispatcher_destroyed); |