WebKit Bugzilla
Attachment 350074 Details for
Bug 189604
: [iOS] Key code is 0 for many hardware keyboard keys
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
WIP
bug-189604-20180918163939.patch (text/plain), 9.93 KB, created by
Jeremy Jones
on 2018-09-18 16:39:41 PDT
(
hide
)
Description:
WIP
Filename:
MIME Type:
Creator:
Jeremy Jones
Created:
2018-09-18 16:39:41 PDT
Size:
9.93 KB
patch
obsolete
>Subversion Revision: 236078 >diff --git a/Source/WebCore/platform/cocoa/KeyEventCocoa.h b/Source/WebCore/platform/cocoa/KeyEventCocoa.h >index f2daa0d87762897421e52a2b085406ca75c757f5..f906ad0ddb6adb6125187fcd26cb82e0031e5840 100644 >--- a/Source/WebCore/platform/cocoa/KeyEventCocoa.h >+++ b/Source/WebCore/platform/cocoa/KeyEventCocoa.h >@@ -35,6 +35,7 @@ String keyIdentifierForCharCode(unichar charCode); > > int windowsKeyCodeForKeyCode(uint16_t keyCode); > int windowsKeyCodeForCharCode(unichar charCode); >+int windowsKeyCodeForHIDUsageKeyCode(uint16_t hidUsage); > > } > >diff --git a/Source/WebCore/platform/cocoa/KeyEventCocoa.mm b/Source/WebCore/platform/cocoa/KeyEventCocoa.mm >index a7821f72d9f9915c466b5c63adf41af08c27f055..cfb503025f1698d0ce99aa343cc527012be90f4b 100644 >--- a/Source/WebCore/platform/cocoa/KeyEventCocoa.mm >+++ b/Source/WebCore/platform/cocoa/KeyEventCocoa.mm >@@ -737,4 +737,198 @@ int windowsKeyCodeForCharCode(unichar charCode) > return 0; > } > >+ >+int windowsKeyCodeForHIDUsageKeyCode(uint16_t hidUsage) >+{ >+ static const int windowsKeyCode[] = { >+ /* 0x00 */ 0, >+ /* 0x01 */ 0, >+ /* 0x02 */ 0, // POSTFail >+ /* 0x03 */ 0, // ErrorUndefined >+ /* 0x04 */ VK_A, >+ /* 0x05 */ VK_B, >+ /* 0x06 */ VK_C, >+ /* 0x07 */ VK_D, >+ /* 0x08 */ VK_E, >+ /* 0x09 */ VK_F, >+ /* 0x0A */ VK_G, >+ /* 0x0B */ VK_H, >+ /* 0x0C */ VK_I, >+ /* 0x0D */ VK_J, >+ /* 0x0E */ VK_K, >+ /* 0x0F */ VK_L, >+ /* 0x10 */ VK_M, >+ /* 0x11 */ VK_N, >+ /* 0x12 */ VK_O, >+ /* 0x13 */ VK_P, >+ /* 0x14 */ VK_Q, >+ /* 0x15 */ VK_R, >+ /* 0x16 */ VK_S, >+ /* 0x17 */ VK_T, >+ /* 0x18 */ VK_U, >+ /* 0x19 */ VK_V, >+ /* 0x1A */ VK_W, >+ /* 0x1B */ VK_X, >+ /* 0x1C */ VK_Y, >+ /* 0x1D */ VK_Z, >+ /* 0x1E */ VK_1, >+ /* 0x1F */ VK_2, >+ /* 0x20 */ VK_3, >+ /* 0x21 */ VK_4, >+ /* 0x22 */ VK_5, >+ /* 0x23 */ VK_6, >+ /* 0x24 */ VK_7, >+ /* 0x25 */ VK_8, >+ /* 0x26 */ VK_9, >+ /* 0x27 */ VK_0, >+ /* 0x28 */ VK_RETURN, >+ /* 0x29 */ VK_ESCAPE, >+ /* 0x2A */ VK_BACK, >+ /* 0x2B */ VK_TAB, >+ /* 0x2C */ VK_SPACE, >+ /* 0x2D */ VK_OEM_MINUS, // - or _ >+ /* 0x2E */ VK_OEM_PLUS, // = or + >+ /* 0x2F */ VK_OEM_4, // [ or { >+ /* 0x30 */ VK_OEM_6, // ] or } >+ /* 0x31 */ VK_OEM_5, // \ or | >+ /* 0x32 */ 0, // Non-US # or _ >+ /* 0x33 */ VK_OEM_1, // ; or : >+ /* 0x34 */ VK_OEM_7, // ' or " >+ /* 0x35 */ VK_OEM_3, // Grave Accent and Tilde >+ /* 0x36 */ VK_OEM_COMMA, // , or < >+ /* 0x37 */ VK_OEM_PERIOD, // . or > >+ /* 0x38 */ VK_OEM_2, // / or ? >+ /* 0x39 */ VK_CAPITAL, >+ /* 0x3A */ VK_F1, >+ /* 0x3B */ VK_F2, >+ /* 0x3C */ VK_F3, >+ /* 0x3D */ VK_F4, >+ /* 0x3E */ VK_F5, >+ /* 0x3F */ VK_F6, >+ /* 0x40 */ VK_F7, >+ /* 0x41 */ VK_F8, >+ /* 0x42 */ VK_F9, >+ /* 0x43 */ VK_F10, >+ /* 0x44 */ VK_F11, >+ /* 0x45 */ VK_F12, >+ /* 0x46 */ VK_PRINTSCREEN, >+ /* 0x47 */ VK_SCROLL, >+ /* 0x48 */ VK_PAUSE, >+ /* 0x49 */ VK_INSERT, >+ /* 0x4A */ VK_HOME, >+ /* 0x4B */ VK_PRIOR, >+ /* 0x4C */ VK_DELETE, >+ /* 0x4D */ VK_END, >+ /* 0x4E */ VK_NEXT, >+ /* 0x4F */ VK_RIGHT, >+ /* 0x50 */ VK_LEFT, >+ /* 0x51 */ VK_DOWN, >+ /* 0x52 */ VK_UP, >+ /* 0x53 */ VK_NUMLOCK, >+ /* 0x54 */ VK_DIVIDE, // Keypad / >+ /* 0x55 */ VK_MULTIPLY, // Keypad * >+ /* 0x56 */ VK_SUBTRACT, // Keypad - >+ /* 0x57 */ VK_ADD, // Keypad + >+ /* 0x58 */ VK_RETURN, // Keypad Enter >+ /* 0x59 */ VK_NUMPAD1, // Keypad 1 or End >+ /* 0x5A */ VK_NUMPAD2, // Keypad 2 or Down Arrow >+ /* 0x5B */ VK_NUMPAD3, // Keypad 3 or Page Down >+ /* 0x5C */ VK_NUMPAD4, // Keypad 4 or Left Arrow >+ /* 0x5D */ VK_NUMPAD5, // Keypad 5 >+ /* 0x5E */ VK_NUMPAD6, // Keypad 6 or Right Arrow >+ /* 0x5F */ VK_NUMPAD7, // Keypad 7 or Home >+ /* 0x60 */ VK_NUMPAD8, // Keypad 8 or Up Arrow >+ /* 0x61 */ VK_NUMPAD9, // Keypad 9 or Page Up >+ /* 0x62 */ VK_NUMPAD0, // Keypad 0 or Insert >+ /* 0x63 */ VK_OEM_PERIOD, // Keypad . or Delete >+ /* 0x64 */ 0, // Non-US \ or | >+ /* 0x65 */ VK_APPS, // Application >+ /* 0x66 */ 0, // Power >+ /* 0x67 */ VK_OEM_PLUS, // Keypad = >+ /* 0x68 */ VK_F13, >+ /* 0x69 */ VK_F14, >+ /* 0x6A */ VK_F15, >+ /* 0x6B */ VK_F16, >+ /* 0x6C */ VK_F17, >+ /* 0x6D */ VK_F18, >+ /* 0x6E */ VK_F19, >+ /* 0x6F */ VK_F20, >+ /* 0x70 */ VK_F21, >+ /* 0x71 */ VK_F22, >+ /* 0x72 */ VK_F23, >+ /* 0x73 */ VK_F24, >+ /* 0x74 */ VK_EXECUTE, >+ /* 0x75 */ VK_HELP, >+ /* 0x76 */ VK_MENU, >+ /* 0x77 */ VK_SELECT, >+ /* 0x78 */ 0, // Stop >+ /* 0x79 */ 0, // Again >+ /* 0x7A */ 0, // Undo >+ /* 0x7B */ 0, // Cut >+ /* 0x7C */ 0, // Copy >+ /* 0x7D */ 0, // Paste >+ /* 0x7E */ 0, // Find >+ /* 0x7F */ VK_VOLUME_MUTE, >+ /* 0x80 */ VK_VOLUME_UP, >+ /* 0x81 */ VK_VOLUME_DOWN, >+ /* 0x82 */ VK_CAPITAL, >+ /* 0x83 */ VK_NUMLOCK, >+ /* 0x84 */ VK_SCROLL, >+ /* 0x85 */ VK_OEM_COMMA, // Keypad Comma >+ /* 0x86 */ 0, // Keypad Equal Sign for AS/400 >+ /* 0x87 */ 0, // International1 >+ /* 0x88 */ 0, // International2 >+ /* 0x89 */ 0, // International3 >+ /* 0x8A */ 0, // International4 >+ /* 0x8B */ 0, // International5 >+ /* 0x8C */ 0, // International6 >+ /* 0x8D */ 0, // International7 >+ /* 0x8E */ 0, // International8 >+ /* 0x8F */ 0, // International9 >+ /* 0x90 */ 0, // LANG1 >+ /* 0x91 */ 0, // LANG2 >+ /* 0x92 */ 0, // LANG3 >+ /* 0x93 */ 0, // LANG4 >+ /* 0x94 */ 0, // LANG5 >+ /* 0x95 */ 0, // LANG6 >+ /* 0x96 */ 0, // LANG7 >+ /* 0x97 */ 0, // LANG8 >+ /* 0x98 */ 0, // LANG9 >+ /* 0x99 */ 0, // AlternateErase >+ /* 0x9A */ VK_ATTN, // SysReq/Attention >+ /* 0x9B */ 0, // Cancel >+ /* 0x9C */ VK_CLEAR, >+ /* 0x9D */ 0, // Prior >+ /* 0x9E */ VK_RETURN, >+ /* 0x9F */ 0, // Separator >+ /* 0xA0 */ 0, // Out >+ /* 0xA1 */ 0, // Oper >+ /* 0xA2 */ 0, // Clear/Again >+ /* 0xA3 */ VK_CRSEL, >+ /* 0xA4 */ VK_EXSEL, >+ }; >+ >+ /* 0xA5-0xDF Reserved */ >+ >+ static const int windowsKeyCode2[] = { >+ /* 0xE0 */ VK_LCONTROL, >+ /* 0xE1 */ VK_LSHIFT, >+ /* 0xE2 */ VK_LMENU, // Left Alt >+ /* 0xE3 */ VK_LWIN, // Left GUI >+ /* 0xE4 */ VK_RCONTROL, >+ /* 0xE5 */ VK_RSHIFT, >+ /* 0xE6 */ VK_RMENU, // Right Alt >+ /* 0xE7 */ VK_RWIN, // Right GUI >+ }; >+ >+ if (hidUsage >= 0 && hidUsage <= 0xA4) >+ return windowsKeyCode[hidUsage]; >+ >+ if (hidUsage >= 0xE0 && hidUsage <= 0xE7) >+ return windowsKeyCode2[hidUsage]; >+ >+ return 0; >+} >+ >+ > } >diff --git a/Source/WebCore/platform/ios/WebEvent.mm b/Source/WebCore/platform/ios/WebEvent.mm >index 347ae4f2591f367a019a6d6d8c9f06f4af841e4b..381f3eea1872b7483f893b51af531a67098ee39e 100644 >--- a/Source/WebCore/platform/ios/WebEvent.mm >+++ b/Source/WebCore/platform/ios/WebEvent.mm >@@ -29,6 +29,8 @@ > #import "WebEvent.h" > > #import "KeyEventCocoa.h" >+#import "WindowsKeyboardCodes.h" >+#import <UIKit/UIResponder.h> > #import <wtf/Assertions.h> > > #if PLATFORM(IOS) >@@ -36,6 +38,7 @@ > #import "WAKAppKitStubs.h" > > using WebCore::windowsKeyCodeForKeyCode; >+using WebCore::windowsKeyCodeForHIDUsageKeyCode; > using WebCore::windowsKeyCodeForCharCode; > @implementation WebEvent > >@@ -149,7 +152,7 @@ - (WebEvent *)initWithKeyEventType:(WebEventType)type > _tabKey = tabKey; > > if (keyCode) >- _keyCode = windowsKeyCodeForKeyCode(keyCode); >+ _keyCode = windowsKeyCodeForHIDUsageKeyCode(keyCode); > > // NOTE: this preserves the original semantics which used the > // characters string for the keyCode. This should be changed in iOS 4.0 to >diff --git a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm b/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >index 603af17fee8fc218255116983c2a94d118937f3f..603d5fc1a0525982eeec9b82c8c57ee3b9ec3a4a 100644 >--- a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >+++ b/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >@@ -3748,7 +3748,7 @@ - (void)handleKeyEvent:(::UIEvent *)event > modifiers:event._modifierFlags > isRepeating:(event._inputFlags & kUIKeyboardInputRepeat) > withFlags:event._inputFlags >- keyCode:0 >+ keyCode:event._keyCode > isTabKey:[event._modifiedInput isEqualToString:@"\t"] > characterSet:WebEventCharacterSetUnicode] autorelease]; > webEvent.uiEvent = event; >diff --git a/LayoutTests/fast/events/ios/keyboard-event-key-attribute.html b/LayoutTests/fast/events/ios/keyboard-event-key-attribute.html >index 7c1a2fcff2e333ad5d9ca95e5afc7e1534f9f6a7..f6a4c4cb3950866c9f16ec2c5c67f7294be0cca9 100644 >--- a/LayoutTests/fast/events/ios/keyboard-event-key-attribute.html >+++ b/LayoutTests/fast/events/ios/keyboard-event-key-attribute.html >@@ -29,9 +29,9 @@ function getTypingUIScript(x, y) > > var i = 0; > var testInput = document.getElementById("testInput"); >-testInput.onkeydown = function(e) { >+testInput.onkeyup = function(e) { > event = e; >- shouldBeEqualToString("event.key", "" + tests[i][0]); >+ shouldBeEqualToString("event.key", ""); > shouldBeEqualToString("event.code", "" + tests[i][1]); > i++; > if (i == tests.length)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 189604
:
349706
|
350074
|
350311
|
350315