Title: [134855] trunk/Source/WebCore
- Revision
- 134855
- Author
- [email protected]
- Date
- 2012-11-15 16:30:14 -0800 (Thu, 15 Nov 2012)
Log Message
[Win] key event's location does not work on Windows platform.
https://bugs.webkit.org/show_bug.cgi?id=89742
Patch by Takashi Sakamoto <[email protected]> on 2012-11-15
Reviewed by Brent Fulgham.
As WM_KEYDOWN, WM_KEYUP, WM_SYSKEYDOWN, and WM_SYSKEYUP doesn't
directly provide a virtual keycode which distinguish between left-hand
and right-hand keys. To obtain a virtual keycode, we have to look at
lparam, i.e. scancode and extended key bit. So if the given virtual
keycode is control, shift, or menu, use MapVirtualKey with scancode and
extended key bit and recreate a virtual keycode which distinguishes
between left-hand and right-hand.
No new tests, because left-hand keys, right-hand keys layout tests
have been already added.
* platform/win/KeyEventWin.cpp:
(WebCore::windowsKeycodeWithLocation):
Use wparam and lparam to recreate a virtual keycode which distinguishes
between left-hand and right-hand if the given wparam (=virtual keycode)
is control, shift, or menu.
(WebCore):
(WebCore::PlatformKeyboardEvent::PlatformKeyboardEvent):
Use the newly added function to obtain windows virtual keycode.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (134854 => 134855)
--- trunk/Source/WebCore/ChangeLog 2012-11-16 00:29:23 UTC (rev 134854)
+++ trunk/Source/WebCore/ChangeLog 2012-11-16 00:30:14 UTC (rev 134855)
@@ -1,3 +1,30 @@
+2012-11-15 Takashi Sakamoto <[email protected]>
+
+ [Win] key event's location does not work on Windows platform.
+ https://bugs.webkit.org/show_bug.cgi?id=89742
+
+ Reviewed by Brent Fulgham.
+
+ As WM_KEYDOWN, WM_KEYUP, WM_SYSKEYDOWN, and WM_SYSKEYUP doesn't
+ directly provide a virtual keycode which distinguish between left-hand
+ and right-hand keys. To obtain a virtual keycode, we have to look at
+ lparam, i.e. scancode and extended key bit. So if the given virtual
+ keycode is control, shift, or menu, use MapVirtualKey with scancode and
+ extended key bit and recreate a virtual keycode which distinguishes
+ between left-hand and right-hand.
+
+ No new tests, because left-hand keys, right-hand keys layout tests
+ have been already added.
+
+ * platform/win/KeyEventWin.cpp:
+ (WebCore::windowsKeycodeWithLocation):
+ Use wparam and lparam to recreate a virtual keycode which distinguishes
+ between left-hand and right-hand if the given wparam (=virtual keycode)
+ is control, shift, or menu.
+ (WebCore):
+ (WebCore::PlatformKeyboardEvent::PlatformKeyboardEvent):
+ Use the newly added function to obtain windows virtual keycode.
+
2012-11-15 Joe Mason <[email protected]>
[BlackBerry] Don't assert when notifyAuthReceived is called with a different auth type
Modified: trunk/Source/WebCore/platform/win/KeyEventWin.cpp (134854 => 134855)
--- trunk/Source/WebCore/platform/win/KeyEventWin.cpp 2012-11-16 00:29:23 UTC (rev 134854)
+++ trunk/Source/WebCore/platform/win/KeyEventWin.cpp 2012-11-16 00:30:14 UTC (rev 134855)
@@ -29,6 +29,10 @@
#include <windows.h>
#include <wtf/ASCIICType.h>
+#ifndef MAPVK_VSC_TO_VK_EX
+#define MAPVK_VSC_TO_VK_EX 3
+#endif
+
using namespace WTF;
namespace WebCore {
@@ -184,6 +188,32 @@
}
}
+static int windowsKeycodeWithLocation(WPARAM keycode, LPARAM keyData)
+{
+ if (keycode != VK_CONTROL && keycode != VK_MENU && keycode != VK_SHIFT)
+ return keycode;
+
+ // If we don't need to support Windows XP or older Windows,
+ // it might be better to use MapVirtualKeyEx with scancode and
+ // extended keycode (i.e. 0xe0 or 0xe1).
+ if ((keyData >> 16) & KF_EXTENDED) {
+ switch (keycode) {
+ case VK_CONTROL:
+ return VK_RCONTROL;
+ case VK_SHIFT:
+ return VK_RSHIFT;
+ case VK_MENU:
+ return VK_RMENU;
+ default:
+ break;
+ }
+ }
+
+ int scancode = (keyData >> 16) & 0xFF;
+ int regeneratedVirtualKeyCode = ::MapVirtualKey(scancode, MAPVK_VSC_TO_VK_EX);
+ return regeneratedVirtualKeyCode ? regeneratedVirtualKeyCode : keycode;
+}
+
static inline String singleCharacterString(UChar c)
{
return String(&c, 1);
@@ -194,7 +224,7 @@
, m_text((type == PlatformEvent::Char) ? singleCharacterString(code) : String())
, m_unmodifiedText((type == PlatformEvent::Char) ? singleCharacterString(code) : String())
, m_keyIdentifier((type == PlatformEvent::Char) ? String() : keyIdentifierForWindowsKeyCode(code))
- , m_windowsVirtualKeyCode((type == RawKeyDown || type == KeyUp) ? code : 0)
+ , m_windowsVirtualKeyCode((type == RawKeyDown || type == KeyUp) ? windowsKeycodeWithLocation(code, keyData) : 0)
, m_nativeVirtualKeyCode(m_windowsVirtualKeyCode)
, m_macCharCode(0)
, m_autoRepeat(HIWORD(keyData) & KF_REPEAT)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes