Fix a crash which occurs due to a CHECK firing in the HWNDMessageHandler::OnKeyEvent...
commit005229b167c1a9e415fc814520bf1d650adebb22
authorananta <ananta@chromium.org>
Wed, 28 Jan 2015 21:38:06 +0000 (28 13:38 -0800)
committerCommit bot <commit-bot@chromium.org>
Wed, 28 Jan 2015 21:40:17 +0000 (28 21:40 +0000)
treeaaaaec7b092f60098f2a5f3fe10931c0c7ca5281
parent259030a756bf9894df7e67320918db3e000f965a
Fix a crash which occurs due to a CHECK firing in the HWNDMessageHandler::OnKeyEvent code path on Windows.

This crash occurs when the LegacyRenderWidgetHostHWND instance sends WM_CHAR/WM_SYSCHAR messages via the
WindowEventTarget::HandleKeyboardMessage function.

The HWNDMessageHandler class handles these messages via the OnImeMessages handler in the normal case.

The CHECK fires in the KeyEvent ctor where we validate that the KeyEvent instance has a valid event type.
In this case the WM_CHAR/WM_SYSCHAR messages are processed via the OnKeyEvent handler which leads to the problem.

Fix is to add a check for WM_CHAR/WM_SYSCHAR messages in the HWNDMessageHandler::HandleKeyboardMessage function
and call the OnImeMessages handler there. The alternative would be to add a new method to the WindowEventTarget
interface and change the LegacyRenderWidgetHostHWND class to handle these messages separately and call the new
method. I think that change would be a touch big for this case.

I also added WM_SYSDEADCHAR to the list of messages processed by the EventTypeFromNative function. We set the
type as ET_KEY_RELEASED on the same lines as WM_DEADCHAR.

BUG=451797
TEST=Covered by views_unittest WidgetTest.CharMessagesAsKeyboardMessagesDoesNotCrash

Review URL: https://codereview.chromium.org/881163002

Cr-Commit-Position: refs/heads/master@{#313591}
ui/events/win/events_win.cc
ui/views/widget/widget_unittest.cc
ui/views/win/hwnd_message_handler.cc