Reviewed by Darin.
authorap@webkit.org <ap@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Dec 2007 16:57:56 +0000 (16:57 +0000)
committerap@webkit.org <ap@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Dec 2007 16:57:56 +0000 (16:57 +0000)
        http://bugs.webkit.org/show_bug.cgi?id=16410
        Implement isKeypadEvent() on Windows

        Test: platform/win/fast/events/keyLocation-numpad.html

        * platform/win/KeyEventWin.cpp:
        (WebCore::isKeypadEvent): Added.
        (WebCore::PlatformKeyboardEvent::PlatformKeyboardEvent): Also fixed a mistake with autorepeat.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@28652 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/platform/win/fast/events/keyLocation-numpad-expected.txt [new file with mode: 0644]
LayoutTests/platform/win/fast/events/keyLocation-numpad.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/platform/win/KeyEventWin.cpp

index 9aed05d..5eb7113 100644 (file)
@@ -1,5 +1,15 @@
 2007-12-12  Alexey Proskuryakov  <ap@webkit.org>
 
+        Reviewed by Darin.
+
+        http://bugs.webkit.org/show_bug.cgi?id=16410
+        Implement isKeypadEvent() on Windows
+
+        * platform/win/fast/events/keyLocation-numpad-expected.txt: Added.
+        * platform/win/fast/events/keyLocation-numpad.html: Added.
+
+2007-12-12  Alexey Proskuryakov  <ap@webkit.org>
+
         Reviewed by Oliver.
 
         http://bugs.webkit.org/show_bug.cgi?id=15248
diff --git a/LayoutTests/platform/win/fast/events/keyLocation-numpad-expected.txt b/LayoutTests/platform/win/fast/events/keyLocation-numpad-expected.txt
new file mode 100644 (file)
index 0000000..c1bd7c2
--- /dev/null
@@ -0,0 +1,9 @@
+Test for bug 16410: Implement isKeypadEvent() on Windows
+
+keydown: DOM_KEY_LOCATION_NUMPAD
+keyup: DOM_KEY_LOCATION_NUMPAD
+keydown: DOM_KEY_LOCATION_NUMPAD
+keyup: DOM_KEY_LOCATION_NUMPAD
+keydown: DOM_KEY_LOCATION_NUMPAD
+keyup: DOM_KEY_LOCATION_STANDARD
+
diff --git a/LayoutTests/platform/win/fast/events/keyLocation-numpad.html b/LayoutTests/platform/win/fast/events/keyLocation-numpad.html
new file mode 100644 (file)
index 0000000..7a20549
--- /dev/null
@@ -0,0 +1,41 @@
+<body>
+    <p>Test for <a href="http://bugs.webkit.org/show_bug.cgi?id=16410">bug 16410</a>:
+        Implement isKeypadEvent() on Windows
+    </p>
+    <div contenteditable id=ce onkeyup="keyEvent(event)" onkeydown="keyEvent(event)"></div>
+    <div id="log"></div>
+    <script>
+        function locationName(code) {
+          switch (code) {
+            case 0:
+                return "DOM_KEY_LOCATION_STANDARD";
+            case 1:
+                return "DOM_KEY_LOCATION_LEFT";
+            case 2:
+                return "DOM_KEY_LOCATION_RIGHT";
+            case 3:
+                return "DOM_KEY_LOCATION_NUMPAD";
+            default:
+                return code.toString();
+          }
+        }
+
+        function keyEvent(event) {
+            document.getElementById("log").innerHTML += (event.type + ": " + locationName(event.keyLocation) + "<br>");
+        }
+
+        document.getElementById("ce").focus();
+
+        if (window.layoutTestController) {
+            layoutTestController.dumpAsText();
+
+            eventSender.dispatchMessage(eventSender.WM_KEYDOWN, 96 /* VK_NUMPAD0 */, 0x00520001);
+            eventSender.dispatchMessage(eventSender.WM_KEYUP, 96 /* VK_NUMPAD0 */, 0xc0520001);
+            eventSender.dispatchMessage(eventSender.WM_KEYDOWN, 45 /* VK_INSERT */, 0x00520001);
+            eventSender.dispatchMessage(eventSender.WM_KEYUP, 45 /* VK_INSERT */, 0xc0520001);
+            eventSender.dispatchMessage(eventSender.WM_KEYDOWN, 13 /* VK_RETURN */, 0x011c0001);
+            eventSender.dispatchMessage(eventSender.WM_KEYUP, 13 /* VK_RETURN */, 0xc11c0001);
+        } else
+            document.write("To test manually, press any key on numpad.");
+    </script>
+</body>
index 54f1df1..aee214f 100644 (file)
@@ -1,3 +1,16 @@
+2007-12-12  Alexey Proskuryakov  <ap@webkit.org>
+
+        Reviewed by Darin.
+
+        http://bugs.webkit.org/show_bug.cgi?id=16410
+        Implement isKeypadEvent() on Windows
+
+        Test: platform/win/fast/events/keyLocation-numpad.html
+
+        * platform/win/KeyEventWin.cpp:
+        (WebCore::isKeypadEvent): Added.
+        (WebCore::PlatformKeyboardEvent::PlatformKeyboardEvent): Also fixed a mistake with autorepeat.
+
 2007-12-12  Oliver Hunt  <oliver@apple.com>
 
         Reviewed by Maciej.
index 2434cd1..2813fbb 100644 (file)
@@ -142,6 +142,48 @@ static String keyIdentifierForWindowsKeyCode(unsigned short keyCode)
     }
 }
 
+static bool isKeypadEvent(WPARAM code, LPARAM keyData, PlatformKeyboardEvent::Type type)
+{
+    if (type != PlatformKeyboardEvent::RawKeyDown && type != PlatformKeyboardEvent::KeyUp)
+        return false;
+
+    switch (code) {
+        case VK_NUMLOCK:
+        case VK_NUMPAD0:
+        case VK_NUMPAD1:
+        case VK_NUMPAD2:
+        case VK_NUMPAD3:
+        case VK_NUMPAD4:
+        case VK_NUMPAD5:
+        case VK_NUMPAD6:
+        case VK_NUMPAD7:
+        case VK_NUMPAD8:
+        case VK_NUMPAD9:
+        case VK_MULTIPLY:
+        case VK_ADD:
+        case VK_SEPARATOR:
+        case VK_SUBTRACT:
+        case VK_DECIMAL:
+        case VK_DIVIDE:
+            return true;
+        case VK_RETURN:
+            return (keyData >> 16) & KF_EXTENDED;
+        case VK_INSERT:
+        case VK_DELETE:
+        case VK_PRIOR:
+        case VK_NEXT:
+        case VK_END:
+        case VK_HOME:
+        case VK_LEFT:
+        case VK_UP:
+        case VK_RIGHT:
+        case VK_DOWN:
+            return !((keyData >> 16) & KF_EXTENDED);
+        default:
+            return false;
+    }
+}
+
 static inline String singleCharacterString(UChar c) { return String(&c, 1); }
 
 PlatformKeyboardEvent::PlatformKeyboardEvent(HWND, WPARAM code, LPARAM keyData, Type type, bool systemKey)
@@ -149,9 +191,9 @@ PlatformKeyboardEvent::PlatformKeyboardEvent(HWND, WPARAM code, LPARAM keyData,
     , m_text((type == Char) ? singleCharacterString(code) : String())
     , m_unmodifiedText((type == Char) ? singleCharacterString(code) : String())
     , m_keyIdentifier((type == Char) ? String() : keyIdentifierForWindowsKeyCode(code))
-    , m_autoRepeat(keyData & KF_REPEAT)
+    , m_autoRepeat((keyData >> 16) & KF_REPEAT)
     , m_windowsVirtualKeyCode((type == RawKeyDown || type == KeyUp) ? code : 0)
-    , m_isKeypad(false) // FIXME: Need to implement this.
+    , m_isKeypad(isKeypadEvent(code, keyData, type))
     , m_shiftKey(GetKeyState(VK_SHIFT) & HIGH_BIT_MASK_SHORT)
     , m_ctrlKey(GetKeyState(VK_CONTROL) & HIGH_BIT_MASK_SHORT)
     , m_altKey(GetKeyState(VK_MENU) & HIGH_BIT_MASK_SHORT)
@@ -162,7 +204,7 @@ PlatformKeyboardEvent::PlatformKeyboardEvent(HWND, WPARAM code, LPARAM keyData,
 
 void PlatformKeyboardEvent::disambiguateKeyDownEvent(Type, bool)
 {
-    // No KeyDown events here to change.
+    // No KeyDown events on Windows to disambiguate.
     ASSERT_NOT_REACHED();
 }