Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(205)

Issue 1378583003: Unstrangle unhandled key event callback for webview (Closed)

Created:
5 years, 2 months ago by Changwan Ryu
Modified:
4 years, 4 months ago
CC:
benm (inactive), chromium-reviews, darin-cc_chromium.org, jam, tdresser
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Unstrangle unhandled key event callback for webview Currently, when typing on an input form using a BT keyboard or when InputConnection#sendKeyEvent() is used, we end up getting unhandled ACTION_UP event in WebViewClient#onUnhandledInputEvent(). Here's what happens: 1) RawKeyDown event is not processed: we create Char event in ime_adapter_android.cc and process it instead. So RenderWidgetHostImpl::OnKeyboardEventAck() should normally propagate to onUnhandledInputEvent() as the event was not processed. But we've set the skip_in_browser flag in ime_adapter_android.cc so OnKeyboardEventAck() does not propagate this event. 2) Char event is processed. 3) KeyUp event is not processed, and OnKeyboardEventAck() propagates the event, and WebViewClient#onUnhandledInputEvent() is called. The last one is an incorrect behavior, and we get unpaired onUnhandledInputEvent() callback only for ACTION_UP. Also, when ACTION_DOWN / ACTION_UP are not handled (when no input form is focused), the following happens: 1) RawKeyDown event is not processed. But we set the skip_in_browser flag so OnKeyboardEventAck() does not propagate the event. (This is an incorrect behavior.) 2) Char event is not created. 3) KeyUp event is not processed, and OnKeyboardEventAck() propagates the event, and onUnhandledInputEvent() is called. We still get unpaired onUnhandledInputEvent() callback, only for ACTION_UP. The first problem here is that return value of handleInputEvent() for KeyUp event is different from that for RawKeyDown or Char events. Another problem is that we sometimes create Char event and sometimes we do not, but Char event cannot deliver (propagate) platform-specific event. So for a proper fix, we need the following changes: - When Char event is created, we set os_event such that if Char event is not processed, we make sure onUnhandledInputEvent() is called. - Change EventHandler::keyEvent to return the same value for KeyUp event as the value returned for RawKeyDown or Char event. BUG=538377

Patch Set 1 #

Total comments: 1

Patch Set 2 : new approach #

Patch Set 3 : changed variable names and comments #

Total comments: 1

Messages

Total messages: 14 (6 generated)
Changwan Ryu
5 years, 2 months ago (2015-10-02 17:29:05 UTC) #2
jdduke (slow)
Any simple way to test this?
5 years, 2 months ago (2015-10-02 17:51:29 UTC) #3
aelias_OOO_until_Jul13
https://codereview.chromium.org/1378583003/diff/1/content/browser/renderer_host/ime_adapter_android.cc File content/browser/renderer_host/ime_adapter_android.cc (right): https://codereview.chromium.org/1378583003/diff/1/content/browser/renderer_host/ime_adapter_android.cc#newcode154 content/browser/renderer_host/ime_adapter_android.cc:154: event.skip_in_browser = true; "true" seems unnecessarily broad. That will ...
5 years, 2 months ago (2015-10-02 20:11:51 UTC) #4
Changwan Ryu
On 2015/10/02 20:11:51, aelias wrote: > https://codereview.chromium.org/1378583003/diff/1/content/browser/renderer_host/ime_adapter_android.cc > File content/browser/renderer_host/ime_adapter_android.cc (right): > > https://codereview.chromium.org/1378583003/diff/1/content/browser/renderer_host/ime_adapter_android.cc#newcode154 > ...
5 years, 2 months ago (2015-10-05 12:59:32 UTC) #5
Changwan Ryu
There are some tests that should be added, and some chrome os test breakage that ...
5 years ago (2015-12-02 00:51:04 UTC) #7
dtapuska
https://codereview.chromium.org/1378583003/diff/40001/third_party/WebKit/Source/core/input/EventHandler.cpp File third_party/WebKit/Source/core/input/EventHandler.cpp (right): https://codereview.chromium.org/1378583003/diff/40001/third_party/WebKit/Source/core/input/EventHandler.cpp#newcode3155 third_party/WebKit/Source/core/input/EventHandler.cpp:3155: bool overrideKeyupEvent = false; Not every keyup corresponds to ...
5 years ago (2015-12-02 14:25:12 UTC) #12
aelias_OOO_until_Jul13
I agree we shouldn't try to fix this with tracking state. This bug is not ...
5 years ago (2015-12-03 04:04:59 UTC) #13
dtapuska
5 years ago (2015-12-03 19:15:22 UTC) #14
On 2015/12/03 04:04:59, aelias wrote:
> I agree we shouldn't try to fix this with tracking state.  This bug is not
> causing any real problem so I'd rather not land anything unless we have a fix
> that simplifies the system rather than makes it more complex.
> 
> Dave, I recall you told me you disliked KeyPress events in general, and this
> issue is related to that.  I was thinking browser-side code should not
generate
> any KeyPress events at all and just send the raw key down to the renderer and
> change it to do the KeyPress stuff when needed, what do you think?

The question is why is skip_in_browser is set. This is only set while we are
processing IME events right. So that those events like backspace don't cause the
page to go back in history when editing inside an IME.

Since this is all done after IME is present I'm not sure why skip_in_browser is
set for android.

Powered by Google App Engine
This is Rietveld 408576698