- Revision
- 275750
- Author
- [email protected]
- Date
- 2021-04-08 23:05:46 -0700 (Thu, 08 Apr 2021)
Log Message
[Win] Wrong KeyboardEvent.key for numeric key pad with NumLock
https://bugs.webkit.org/show_bug.cgi?id=224352
Reviewed by Don Olmstead.
Source/WebCore:
`8` key on a numeric key pad with NumLock dispatched a wrong
KeyboardEvent with `ArrowUp` as the `key` value. It should be `8`.
WindowsKeyNames::domKeyFromLParam computed a virtual key by
MapVirtualKey and a scan code. But, it should use a real virtual
key conveyed by WPARAM of WM_KEYDOWN and WM_KEYUP events.
* platform/win/KeyEventWin.cpp:
(WebCore::PlatformKeyboardEvent::PlatformKeyboardEvent):
* platform/win/WindowsKeyNames.cpp:
(WebCore::WindowsKeyNames::domKeyFromParams):
(WebCore::WindowsKeyNames::domKeyFromLParam): Deleted.
* platform/win/WindowsKeyNames.h:
Source/WebKit:
* Shared/win/WebEventFactory.cpp:
(WebKit::WebEventFactory::createWebKeyboardEvent):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (275749 => 275750)
--- trunk/Source/WebCore/ChangeLog 2021-04-09 04:25:33 UTC (rev 275749)
+++ trunk/Source/WebCore/ChangeLog 2021-04-09 06:05:46 UTC (rev 275750)
@@ -1,3 +1,24 @@
+2021-04-08 Fujii Hironori <[email protected]>
+
+ [Win] Wrong KeyboardEvent.key for numeric key pad with NumLock
+ https://bugs.webkit.org/show_bug.cgi?id=224352
+
+ Reviewed by Don Olmstead.
+
+ `8` key on a numeric key pad with NumLock dispatched a wrong
+ KeyboardEvent with `ArrowUp` as the `key` value. It should be `8`.
+
+ WindowsKeyNames::domKeyFromLParam computed a virtual key by
+ MapVirtualKey and a scan code. But, it should use a real virtual
+ key conveyed by WPARAM of WM_KEYDOWN and WM_KEYUP events.
+
+ * platform/win/KeyEventWin.cpp:
+ (WebCore::PlatformKeyboardEvent::PlatformKeyboardEvent):
+ * platform/win/WindowsKeyNames.cpp:
+ (WebCore::WindowsKeyNames::domKeyFromParams):
+ (WebCore::WindowsKeyNames::domKeyFromLParam): Deleted.
+ * platform/win/WindowsKeyNames.h:
+
2021-04-08 Wenson Hsieh <[email protected]>
Add a completion handler argument to `ChromeClient::requestImageExtraction`
Modified: trunk/Source/WebCore/platform/win/KeyEventWin.cpp (275749 => 275750)
--- trunk/Source/WebCore/platform/win/KeyEventWin.cpp 2021-04-09 04:25:33 UTC (rev 275749)
+++ trunk/Source/WebCore/platform/win/KeyEventWin.cpp 2021-04-09 06:05:46 UTC (rev 275750)
@@ -229,7 +229,7 @@
: PlatformEvent(type, GetKeyState(VK_SHIFT) & HIGH_BIT_MASK_SHORT, GetKeyState(VK_CONTROL) & HIGH_BIT_MASK_SHORT, GetKeyState(VK_MENU) & HIGH_BIT_MASK_SHORT, false, WallTime::fromRawSeconds(::GetTickCount() * 0.001))
, m_text((type == PlatformEvent::Char) ? singleCharacterString(code) : String())
, m_unmodifiedText((type == PlatformEvent::Char) ? singleCharacterString(code) : String())
- , m_key(type == PlatformEvent::Char ? windowsKeyNames().domKeyFromChar(code) : windowsKeyNames().domKeyFromLParam(keyData))
+ , m_key(type == PlatformEvent::Char ? windowsKeyNames().domKeyFromChar(code) : windowsKeyNames().domKeyFromParams(code, keyData))
, m_code(windowsKeyNames().domCodeFromLParam(keyData))
, m_keyIdentifier((type == PlatformEvent::Char) ? String() : keyIdentifierForWindowsKeyCode(code))
, m_windowsVirtualKeyCode((type == RawKeyDown || type == KeyUp) ? windowsKeycodeWithLocation(code, keyData) : 0)
Modified: trunk/Source/WebCore/platform/win/WindowsKeyNames.cpp (275749 => 275750)
--- trunk/Source/WebCore/platform/win/WindowsKeyNames.cpp 2021-04-09 04:25:33 UTC (rev 275749)
+++ trunk/Source/WebCore/platform/win/WindowsKeyNames.cpp 2021-04-09 06:05:46 UTC (rev 275750)
@@ -240,11 +240,9 @@
updateLayout();
}
-String WindowsKeyNames::domKeyFromLParam(LPARAM lParam)
+String WindowsKeyNames::domKeyFromParams(WPARAM virtualKey, LPARAM lParam)
{
- unsigned scanCode = (lParam >> 16) & 0xff;
bool extended = lParam & 0x01000000;
- unsigned virtualKey = MapVirtualKey(scanCode, MAPVK_VSC_TO_VK);
KeyModifierSet modifiers;
if (GetKeyState(VK_SHIFT) < 0)
modifiers.add(KeyModifier::Shift);
Modified: trunk/Source/WebCore/platform/win/WindowsKeyNames.h (275749 => 275750)
--- trunk/Source/WebCore/platform/win/WindowsKeyNames.h 2021-04-09 04:25:33 UTC (rev 275749)
+++ trunk/Source/WebCore/platform/win/WindowsKeyNames.h 2021-04-09 06:05:46 UTC (rev 275750)
@@ -40,7 +40,7 @@
public:
WindowsKeyNames();
- String domKeyFromLParam(LPARAM);
+ String domKeyFromParams(WPARAM, LPARAM);
String domKeyFromChar(UChar);
String domCodeFromLParam(LPARAM);
Modified: trunk/Source/WebKit/ChangeLog (275749 => 275750)
--- trunk/Source/WebKit/ChangeLog 2021-04-09 04:25:33 UTC (rev 275749)
+++ trunk/Source/WebKit/ChangeLog 2021-04-09 06:05:46 UTC (rev 275750)
@@ -1,3 +1,13 @@
+2021-04-08 Fujii Hironori <[email protected]>
+
+ [Win] Wrong KeyboardEvent.key for numeric key pad with NumLock
+ https://bugs.webkit.org/show_bug.cgi?id=224352
+
+ Reviewed by Don Olmstead.
+
+ * Shared/win/WebEventFactory.cpp:
+ (WebKit::WebEventFactory::createWebKeyboardEvent):
+
2021-04-08 Wenson Hsieh <[email protected]>
Add a completion handler argument to `ChromeClient::requestImageExtraction`
Modified: trunk/Source/WebKit/Shared/win/WebEventFactory.cpp (275749 => 275750)
--- trunk/Source/WebKit/Shared/win/WebEventFactory.cpp 2021-04-09 04:25:33 UTC (rev 275749)
+++ trunk/Source/WebKit/Shared/win/WebEventFactory.cpp 2021-04-09 06:05:46 UTC (rev 275750)
@@ -458,7 +458,7 @@
WebEvent::Type type = keyboardEventTypeForEvent(message);
String text = textFromEvent(wparam, type);
String unmodifiedText = unmodifiedTextFromEvent(wparam, type);
- String key = message == WM_CHAR ? windowsKeyNames().domKeyFromChar(wparam) : windowsKeyNames().domKeyFromLParam(lparam);
+ String key = message == WM_CHAR ? windowsKeyNames().domKeyFromChar(wparam) : windowsKeyNames().domKeyFromParams(wparam, lparam);
String code = windowsKeyNames().domCodeFromLParam(lparam);
String keyIdentifier = keyIdentifierFromEvent(wparam, type);
int windowsVirtualKeyCode = static_cast<int>(wparam);