Bug 204672
Summary: | [Win] 'key' property of keydown KeyboardEvent doesn't have the diacritic for alphabet key following a dead key | ||
---|---|---|---|
Product: | WebKit | Reporter: | Fujii Hironori <fujii.hironori> |
Component: | Platform | Assignee: | Nobody <webkit-unassigned> |
Status: | NEW | ||
Severity: | Normal | ||
Priority: | P2 | ||
Version: | WebKit Nightly Build | ||
Hardware: | Unspecified | ||
OS: | Unspecified | ||
Bug Depends on: | 204694 | ||
Bug Blocks: |
Fujii Hironori
[Win] 'key' property of keydown KeyboardEvent doesn't have the diacritic for alphabet key following a dead key
1. Switch the Windows keyboard layout to German
2. Start MiniBrowser
3. Open https://bug-202183-attachments.webkit.org/attachment.cgi?id=380407
4. typing [^] and [a] keys
Windows port is showing:
type:keydown key:Dead code:Equal
type:keyup key:Dead code:Equal
type:keydown key:a code:KeyA ★
type:keypress key:á code:KeyA
type:keyup key:a code:KeyA
On the other hand, Chrome and Firefox
type:keydown key:Dead code:Equal
type:keyup key:Dead code:Equal
type:keydown key:á code:KeyA ★
type:keypress key:á code:KeyA
type:keyup key:a code:KeyA
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Fujii Hironori
In Chromium, InputMethodWinBase::DispatchKeyEvent retrieves queued WM_CHAR events, and sets a char information from WM_CHAR to the keydown event.
> std::vector<MSG> char_msgs;
> // Combines the WM_KEY* and WM_CHAR messages in the event processing flow
> // which is necessary to let Chrome IME extension to process the key event
> // and perform corresponding IME actions.
> // Chrome IME extension may wants to consume certain key events based on
> // the character information of WM_CHAR messages. Holding WM_KEY* messages
> // until WM_CHAR is processed by the IME extension is not feasible because
> // there is no way to know whether there will or not be a WM_CHAR following
> // the WM_KEY*.
> // Chrome never handles dead chars so it is safe to remove/ignore
> // WM_*DEADCHAR messages.
> MSG msg;
> while (::PeekMessage(&msg, native_key_event.hwnd, WM_CHAR, WM_DEADCHAR,
> PM_REMOVE)) {
> if (msg.message == WM_CHAR)
> char_msgs.push_back(msg);
> }
> while (::PeekMessage(&msg, native_key_event.hwnd, WM_SYSCHAR, WM_SYSDEADCHAR,
> PM_REMOVE)) {
> if (msg.message == WM_SYSCHAR)
> char_msgs.push_back(msg);
> }
(...)
> // If only 1 WM_CHAR per the key event, set it as the character of it.
> if (char_msgs.size() == 1 &&
> !std::iswcntrl(static_cast<wint_t>(char_msgs[0].wParam)))
> event->set_character(static_cast<base::char16>(char_msgs[0].wParam));
https://cs.chromium.org/chromium/src/ui/base/ime/win/input_method_win_base.cc?type=cs&q=InputMethodWinBase::DispatchKeyEvent&sq=package:chromium&g=0&l=193