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}