Title: [210668] trunk
Revision
210668
Author
[email protected]
Date
2017-01-12 10:34:20 -0800 (Thu, 12 Jan 2017)

Log Message

[iOS] Implement support for KeyboardEvent.code
https://bugs.webkit.org/show_bug.cgi?id=166932
<rdar://problem/29972518>

Reviewed by Darin Adler.

Source/WebCore:

Implement support for KeyboardEvent.code on iOS.

No new tests, updated existing test.

* platform/ios/PlatformEventFactoryIOS.h:
* platform/ios/PlatformEventFactoryIOS.mm:
(WebCore::codeForKeyEvent):
(WebCore::PlatformKeyboardEventBuilder::PlatformKeyboardEventBuilder):

Source/WebKit2:

Make sure KeyboardEvent.code is properly initialized on
iOS WK2.

* Shared/WebEvent.h:
* Shared/WebKeyboardEvent.cpp:
(WebKit::WebKeyboardEvent::WebKeyboardEvent):
* Shared/ios/WebIOSEventFactory.mm:
(WebIOSEventFactory::createWebKeyboardEvent):

Source/WTF:

Enable KEYBOARD_CODE_ATTRIBUTE feature on iOS.

* wtf/FeatureDefines.h:

LayoutTests:

Extend layout test coverage and rebaseline a couple of existing tests
now that more checks are passing.

* fast/events/ios/keyboard-event-key-attribute-expected.txt:
* fast/events/ios/keyboard-event-key-attribute.html:
* platform/ios-simulator/fast/events/constructors/keyboard-event-constructor-expected.txt:
* platform/ios-simulator/imported/w3c/web-platform-tests/dom/events/Event-subclasses-constructors-expected.txt:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (210667 => 210668)


--- trunk/LayoutTests/ChangeLog	2017-01-12 18:30:53 UTC (rev 210667)
+++ trunk/LayoutTests/ChangeLog	2017-01-12 18:34:20 UTC (rev 210668)
@@ -1,3 +1,19 @@
+2017-01-12  Chris Dumez  <[email protected]>
+
+        [iOS] Implement support for KeyboardEvent.code
+        https://bugs.webkit.org/show_bug.cgi?id=166932
+        <rdar://problem/29972518>
+
+        Reviewed by Darin Adler.
+
+        Extend layout test coverage and rebaseline a couple of existing tests
+        now that more checks are passing.
+
+        * fast/events/ios/keyboard-event-key-attribute-expected.txt:
+        * fast/events/ios/keyboard-event-key-attribute.html:
+        * platform/ios-simulator/fast/events/constructors/keyboard-event-constructor-expected.txt:
+        * platform/ios-simulator/imported/w3c/web-platform-tests/dom/events/Event-subclasses-constructors-expected.txt:
+
 2017-01-12  Sam Weinig  <[email protected]>
 
         [WebIDL] Autogenerate named getters

Modified: trunk/LayoutTests/fast/events/ios/keyboard-event-key-attribute-expected.txt (210667 => 210668)


--- trunk/LayoutTests/fast/events/ios/keyboard-event-key-attribute-expected.txt	2017-01-12 18:30:53 UTC (rev 210667)
+++ trunk/LayoutTests/fast/events/ios/keyboard-event-key-attribute-expected.txt	2017-01-12 18:34:20 UTC (rev 210668)
@@ -4,6 +4,9 @@
 
 
 PASS event.key is "a"
+PASS event.code is "KeyA"
+PASS event.key is "@"
+PASS event.code is "Digit2"
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/fast/events/ios/keyboard-event-key-attribute.html (210667 => 210668)


--- trunk/LayoutTests/fast/events/ios/keyboard-event-key-attribute.html	2017-01-12 18:30:53 UTC (rev 210667)
+++ trunk/LayoutTests/fast/events/ios/keyboard-event-key-attribute.html	2017-01-12 18:34:20 UTC (rev 210668)
@@ -10,6 +10,8 @@
 description("Tests that KeyboardEvent.key is properly initialized on iOS.");
 jsTestIsAsync = true;
 
+var tests = [['a', 'KeyA'], ['@', 'Digit2']];
+
 function getTypingUIScript(x, y)
 {
     return `
@@ -16,7 +18,9 @@
         (function() {
             uiController.didShowKeyboardCallback = function() {
                 uiController.typeCharacterUsingHardwareKeyboard('a', function() {
-                    uiController.uiScriptComplete();
+                    uiController.typeCharacterUsingHardwareKeyboard('@', function() {
+                        uiController.uiScriptComplete();
+                    });
                 });
             };
             uiController.singleTapAtPoint(${x}, ${y}, function() { });
@@ -23,11 +27,15 @@
         })();`
 }
 
+var i = 0;
 var testInput = document.getElementById("testInput");
 testInput._onkeydown_ = function(e) {
     event = e;
-    shouldBeEqualToString("event.key", "a");
-    finishJSTest();
+    shouldBeEqualToString("event.key", "" + tests[i][0]);
+    shouldBeEqualToString("event.code", "" + tests[i][1]);
+    i++;
+    if (i == tests.length)
+        finishJSTest();
 };
 
 const x = testInput.offsetLeft + 5;

Modified: trunk/LayoutTests/platform/ios-simulator/fast/events/constructors/keyboard-event-constructor-expected.txt (210667 => 210668)


--- trunk/LayoutTests/platform/ios-simulator/fast/events/constructors/keyboard-event-constructor-expected.txt	2017-01-12 18:30:53 UTC (rev 210667)
+++ trunk/LayoutTests/platform/ios-simulator/fast/events/constructors/keyboard-event-constructor-expected.txt	2017-01-12 18:34:20 UTC (rev 210668)
@@ -113,7 +113,7 @@
 PASS new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, key: 'a', code: 'KeyA', keyIdentifier: 'chocolate', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true }).view is window
 PASS new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, key: 'a', code: 'KeyA', keyIdentifier: 'chocolate', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true }).detail is 111
 PASS new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, key: 'a', code: 'KeyA', keyIdentifier: 'chocolate', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true }).key is "a"
-FAIL new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, key: 'a', code: 'KeyA', keyIdentifier: 'chocolate', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true }).code should be KeyA (of type string). Was undefined (of type undefined).
+PASS new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, key: 'a', code: 'KeyA', keyIdentifier: 'chocolate', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true }).code is "KeyA"
 PASS new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, key: 'a', code: 'KeyA', keyIdentifier: 'chocolate', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true }).keyIdentifier is "chocolate"
 PASS new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, key: 'a', code: 'KeyA', keyIdentifier: 'chocolate', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true }).location is 222
 PASS new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, key: 'a', code: 'KeyA', keyIdentifier: 'chocolate', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true }).ctrlKey is true

Modified: trunk/LayoutTests/platform/ios-simulator/imported/w3c/web-platform-tests/dom/events/Event-subclasses-constructors-expected.txt (210667 => 210668)


--- trunk/LayoutTests/platform/ios-simulator/imported/w3c/web-platform-tests/dom/events/Event-subclasses-constructors-expected.txt	2017-01-12 18:30:53 UTC (rev 210667)
+++ trunk/LayoutTests/platform/ios-simulator/imported/w3c/web-platform-tests/dom/events/Event-subclasses-constructors-expected.txt	2017-01-12 18:34:20 UTC (rev 210668)
@@ -29,12 +29,12 @@
 FAIL WheelEvent constructor (empty argument) assert_true: Event object "[object WheelEvent]" should have a buttons property expected true got false
 FAIL WheelEvent constructor (argument with default values) assert_true: Event object "[object WheelEvent]" should have a buttons property expected true got false
 FAIL WheelEvent constructor (argument with non-default values) assert_true: Event object "[object WheelEvent]" should have a buttons property expected true got false
-FAIL KeyboardEvent constructor (no argument) assert_true: Event object "[object KeyboardEvent]" should have a code property expected true got false
-FAIL KeyboardEvent constructor (undefined argument) assert_true: Event object "[object KeyboardEvent]" should have a code property expected true got false
-FAIL KeyboardEvent constructor (null argument) assert_true: Event object "[object KeyboardEvent]" should have a code property expected true got false
-FAIL KeyboardEvent constructor (empty argument) assert_true: Event object "[object KeyboardEvent]" should have a code property expected true got false
-FAIL KeyboardEvent constructor (argument with default values) assert_true: Event object "[object KeyboardEvent]" should have a code property expected true got false
-FAIL KeyboardEvent constructor (argument with non-default values) assert_true: Event object "[object KeyboardEvent]" should have a code property expected true got false
+PASS KeyboardEvent constructor (no argument) 
+PASS KeyboardEvent constructor (undefined argument) 
+PASS KeyboardEvent constructor (null argument) 
+PASS KeyboardEvent constructor (empty argument) 
+PASS KeyboardEvent constructor (argument with default values) 
+PASS KeyboardEvent constructor (argument with non-default values) 
 PASS CompositionEvent constructor (no argument) 
 PASS CompositionEvent constructor (undefined argument) 
 PASS CompositionEvent constructor (null argument) 

Modified: trunk/Source/WTF/ChangeLog (210667 => 210668)


--- trunk/Source/WTF/ChangeLog	2017-01-12 18:30:53 UTC (rev 210667)
+++ trunk/Source/WTF/ChangeLog	2017-01-12 18:34:20 UTC (rev 210668)
@@ -1,3 +1,15 @@
+2017-01-12  Chris Dumez  <[email protected]>
+
+        [iOS] Implement support for KeyboardEvent.code
+        https://bugs.webkit.org/show_bug.cgi?id=166932
+        <rdar://problem/29972518>
+
+        Reviewed by Darin Adler.
+
+        Enable KEYBOARD_CODE_ATTRIBUTE feature on iOS.
+
+        * wtf/FeatureDefines.h:
+
 2017-01-11  Andreas Kling  <[email protected]>
 
         Crash when WebCore's GC heap grows way too large.

Modified: trunk/Source/WTF/wtf/FeatureDefines.h (210667 => 210668)


--- trunk/Source/WTF/wtf/FeatureDefines.h	2017-01-12 18:30:53 UTC (rev 210667)
+++ trunk/Source/WTF/wtf/FeatureDefines.h	2017-01-12 18:34:20 UTC (rev 210668)
@@ -247,10 +247,6 @@
 #define ENABLE_MAC_GESTURE_EVENTS 1
 #endif
 
-#if !defined(ENABLE_KEYBOARD_CODE_ATTRIBUTE)
-#define ENABLE_KEYBOARD_CODE_ATTRIBUTE 1
-#endif
-
 #endif /* PLATFORM(MAC) */
 
 #if PLATFORM(COCOA)
@@ -263,6 +259,10 @@
 #define ENABLE_KEYBOARD_KEY_ATTRIBUTE 1
 #endif
 
+#if !defined(ENABLE_KEYBOARD_CODE_ATTRIBUTE)
+#define ENABLE_KEYBOARD_CODE_ATTRIBUTE 1
+#endif
+
 #endif /* PLATFORM(COCOA) */
 
 #if !PLATFORM(COCOA)

Modified: trunk/Source/WebCore/ChangeLog (210667 => 210668)


--- trunk/Source/WebCore/ChangeLog	2017-01-12 18:30:53 UTC (rev 210667)
+++ trunk/Source/WebCore/ChangeLog	2017-01-12 18:34:20 UTC (rev 210668)
@@ -1,3 +1,20 @@
+2017-01-12  Chris Dumez  <[email protected]>
+
+        [iOS] Implement support for KeyboardEvent.code
+        https://bugs.webkit.org/show_bug.cgi?id=166932
+        <rdar://problem/29972518>
+
+        Reviewed by Darin Adler.
+
+        Implement support for KeyboardEvent.code on iOS.
+
+        No new tests, updated existing test.
+
+        * platform/ios/PlatformEventFactoryIOS.h:
+        * platform/ios/PlatformEventFactoryIOS.mm:
+        (WebCore::codeForKeyEvent):
+        (WebCore::PlatformKeyboardEventBuilder::PlatformKeyboardEventBuilder):
+
 2017-01-12  Sam Weinig  <[email protected]>
 
         [WebIDL] Autogenerate named getters

Modified: trunk/Source/WebCore/platform/ios/PlatformEventFactoryIOS.h (210667 => 210668)


--- trunk/Source/WebCore/platform/ios/PlatformEventFactoryIOS.h	2017-01-12 18:30:53 UTC (rev 210667)
+++ trunk/Source/WebCore/platform/ios/PlatformEventFactoryIOS.h	2017-01-12 18:34:20 UTC (rev 210668)
@@ -50,6 +50,7 @@
 };
 
 WEBCORE_EXPORT String keyForKeyEvent(WebEvent *);
+WEBCORE_EXPORT String codeForKeyEvent(WebEvent *);
 WEBCORE_EXPORT String keyIdentifierForKeyEvent(WebEvent *);
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/ios/PlatformEventFactoryIOS.mm (210667 => 210668)


--- trunk/Source/WebCore/platform/ios/PlatformEventFactoryIOS.mm	2017-01-12 18:30:53 UTC (rev 210667)
+++ trunk/Source/WebCore/platform/ios/PlatformEventFactoryIOS.mm	2017-01-12 18:34:20 UTC (rev 210668)
@@ -31,6 +31,7 @@
 #import "Logging.h"
 #import "WAKAppKitStubs.h"
 #import "WebEvent.h"
+#import "WindowsKeyboardCodes.h"
 #import <wtf/CurrentTime.h>
 
 namespace WebCore {
@@ -148,6 +149,218 @@
     return keyForCharCode([characters characterAtIndex:0]);
 }
 
+// https://w3c.github.io/uievents-code/
+String codeForKeyEvent(WebEvent *event)
+{
+    switch (event.keyCode) {
+    // Keys in the alphanumeric section.
+    case VK_OEM_3: return ASCIILiteral("Backquote");
+    case VK_OEM_5: return ASCIILiteral("Backslash");
+    case VK_BACK: return ASCIILiteral("Backspace");
+    case VK_OEM_4: return ASCIILiteral("BracketLeft");
+    case VK_OEM_6: return ASCIILiteral("BracketRight");
+    case VK_OEM_COMMA: return ASCIILiteral("Comma");
+    case VK_0: return ASCIILiteral("Digit0");
+    case VK_1: return ASCIILiteral("Digit1");
+    case VK_2: return ASCIILiteral("Digit2");
+    case VK_3: return ASCIILiteral("Digit3");
+    case VK_4: return ASCIILiteral("Digit4");
+    case VK_5: return ASCIILiteral("Digit5");
+    case VK_6: return ASCIILiteral("Digit6");
+    case VK_7: return ASCIILiteral("Digit7");
+    case VK_8: return ASCIILiteral("Digit8");
+    case VK_9: return ASCIILiteral("Digit9");
+    case VK_OEM_PLUS: return ASCIILiteral("Equal");
+    case VK_OEM_102: return ASCIILiteral("IntlBackslash");
+    // IntlRo.
+    // IntlYen.
+    case VK_A: return ASCIILiteral("KeyA");
+    case VK_B: return ASCIILiteral("KeyB");
+    case VK_C: return ASCIILiteral("KeyC");
+    case VK_D: return ASCIILiteral("KeyD");
+    case VK_E: return ASCIILiteral("KeyE");
+    case VK_F: return ASCIILiteral("KeyF");
+    case VK_G: return ASCIILiteral("KeyG");
+    case VK_H: return ASCIILiteral("KeyH");
+    case VK_I: return ASCIILiteral("KeyI");
+    case VK_J: return ASCIILiteral("KeyJ");
+    case VK_K: return ASCIILiteral("KeyK");
+    case VK_L: return ASCIILiteral("KeyL");
+    case VK_M: return ASCIILiteral("KeyM");
+    case VK_N: return ASCIILiteral("KeyN");
+    case VK_O: return ASCIILiteral("KeyO");
+    case VK_P: return ASCIILiteral("KeyP");
+    case VK_Q: return ASCIILiteral("KeyQ");
+    case VK_R: return ASCIILiteral("KeyR");
+    case VK_S: return ASCIILiteral("KeyS");
+    case VK_T: return ASCIILiteral("KeyT");
+    case VK_U: return ASCIILiteral("KeyU");
+    case VK_V: return ASCIILiteral("KeyV");
+    case VK_W: return ASCIILiteral("KeyW");
+    case VK_X: return ASCIILiteral("KeyX");
+    case VK_Y: return ASCIILiteral("KeyY");
+    case VK_Z: return ASCIILiteral("KeyZ");
+    case VK_OEM_MINUS: return ASCIILiteral("Minus");
+    case VK_OEM_PERIOD: return ASCIILiteral("Period");
+    case VK_OEM_7: return ASCIILiteral("Quote");
+    case VK_OEM_1: return ASCIILiteral("Semicolon");
+    case VK_OEM_2: return ASCIILiteral("Slash");
+
+    // Functional keys in alphanumeric section.
+    case VK_MENU: return ASCIILiteral("AltLeft");
+    // AltRight.
+    case VK_CAPITAL: return ASCIILiteral("CapsLock");
+    // ContextMenu.
+    case VK_LCONTROL: return ASCIILiteral("ControlLeft");
+    case VK_RCONTROL: return ASCIILiteral("ControlRight");
+    case VK_RETURN: return ASCIILiteral("Enter"); //  Labeled Return on Apple keyboards.
+    case VK_LWIN: return ASCIILiteral("MetaLeft");
+    case VK_RWIN: return ASCIILiteral("MetaRight");
+    case VK_LSHIFT: return ASCIILiteral("ShiftLeft");
+    case VK_RSHIFT: return ASCIILiteral("ShiftRight");
+    case VK_SPACE: return ASCIILiteral("Space");
+    case VK_TAB: return ASCIILiteral("Tab");
+
+    // Functional keys found on Japanese and Korean keyboards.
+    // Convert.
+    case VK_KANA: return ASCIILiteral("KanaMode");
+    // Lang1.
+    // Lang2.
+    // Lang3.
+    // Lang4.
+    // Lang5.
+    // NonConvert.
+
+    // Keys in the ControlPad section.
+    // Delete
+    case VK_END: return ASCIILiteral("End");
+    case VK_HELP: return ASCIILiteral("Help");
+    case VK_HOME: return ASCIILiteral("Home");
+    // Insert: Not present on Apple keyboards.
+    case VK_NEXT: return ASCIILiteral("PageDown");
+    case VK_PRIOR: return ASCIILiteral("PageUp");
+
+    // Keys in the ArrowPad section.
+    case VK_DOWN: return ASCIILiteral("ArrowDown");
+    case VK_LEFT: return ASCIILiteral("ArrowLeft");
+    case VK_RIGHT: return ASCIILiteral("ArrowRight");
+    case VK_UP: return ASCIILiteral("ArrowUp");
+
+    // Keys in the Numpad section.
+    case VK_NUMLOCK: return ASCIILiteral("NumLock");
+    case VK_NUMPAD0: return ASCIILiteral("Numpad0");
+    case VK_NUMPAD1: return ASCIILiteral("Numpad1");
+    case VK_NUMPAD2: return ASCIILiteral("Numpad2");
+    case VK_NUMPAD3: return ASCIILiteral("Numpad3");
+    case VK_NUMPAD4: return ASCIILiteral("Numpad4");
+    case VK_NUMPAD5: return ASCIILiteral("Numpad5");
+    case VK_NUMPAD6: return ASCIILiteral("Numpad6");
+    case VK_NUMPAD7: return ASCIILiteral("Numpad7");
+    case VK_NUMPAD8: return ASCIILiteral("Numpad8");
+    case VK_NUMPAD9: return ASCIILiteral("Numpad9");
+    case VK_ADD: return ASCIILiteral("NumpadAdd");
+    // NumpadBackspace.
+    // NumpadClear.
+    // NumpadClearEntry.
+    case VK_SEPARATOR: return ASCIILiteral("NumpadComma");
+    case VK_DECIMAL: return ASCIILiteral("NumpadDecimal");
+    case VK_DIVIDE: return ASCIILiteral("NumpadDivide");
+    // NumpadEnter.
+    case VK_CLEAR: return ASCIILiteral("NumpadEqual");
+    // NumpadHash.
+    // NumpadMemoryAdd.
+    // NumpadMemoryClear.
+    // NumpadMemoryRecall.
+    // NumpadMemoryStore.
+    // NumpadMemorySubtract.
+    case VK_MULTIPLY: return ASCIILiteral("NumpadMultiply");
+    // NumpadParenLeft.
+    // NumpadParenRight.
+    // NumpadStar: The specification says to use "NumpadMultiply" for the * key on numeric keypads.
+    case VK_SUBTRACT: return ASCIILiteral("NumpadSubtract");
+
+    // Keys in the Function section.
+    case VK_ESCAPE: return ASCIILiteral("Escape");
+    case VK_F1: return ASCIILiteral("F1");
+    case VK_F2: return ASCIILiteral("F2");
+    case VK_F3: return ASCIILiteral("F3");
+    case VK_F4: return ASCIILiteral("F4");
+    case VK_F5: return ASCIILiteral("F5");
+    case VK_F6: return ASCIILiteral("F6");
+    case VK_F7: return ASCIILiteral("F7");
+    case VK_F8: return ASCIILiteral("F8");
+    case VK_F9: return ASCIILiteral("F9");
+    case VK_F10: return ASCIILiteral("F10");
+    case VK_F11: return ASCIILiteral("F11");
+    case VK_F12: return ASCIILiteral("F12");
+    case VK_F13: return ASCIILiteral("F13");
+    case VK_F14: return ASCIILiteral("F14");
+    case VK_F15: return ASCIILiteral("F15");
+    case VK_F16: return ASCIILiteral("F16");
+    case VK_F17: return ASCIILiteral("F17");
+    case VK_F18: return ASCIILiteral("F18");
+    case VK_F19: return ASCIILiteral("F19");
+    case VK_F20: return ASCIILiteral("F20");
+    // Fn: This is typically a hardware key that does not generate a separate code.
+    // FnLock.
+    // PrintScreen.
+    // ScrollLock.
+    // Pause.
+
+    // Media keys.
+    // BrowserBack.
+    // BrowserFavorites.
+    // BrowserForward.
+    // BrowserHome.
+    // BrowserRefresh.
+    // BrowserSearch.
+    // BrowserStop.
+    // Eject.
+    // LaunchApp1.
+    // LaunchApp2.
+    // LaunchMail.
+    // MediaPlayPause.
+    // MediaSelect.
+    // MediaStop.
+    // MediaTrackNext.
+    // MediaTrackPrevious.
+    // Power.
+    // Sleep.
+    case VK_VOLUME_DOWN: return ASCIILiteral("AudioVolumeDown");
+    case VK_VOLUME_MUTE: return ASCIILiteral("AudioVolumeMute");
+    case VK_VOLUME_UP: return ASCIILiteral("AudioVolumeUp");
+    // WakeUp.
+
+    // Legacy modifier keys.
+    // Hyper.
+    // Super.
+    // Turbo.
+
+    // Legacy process control keys.
+    // Abort.
+    // Resume.
+    // Suspend.
+
+    // Legacy editing keys.
+    // Again.
+    // Copy.
+    // Cut.
+    // Find.
+    // Open.
+    // Paste.
+    // Props.
+    // Select.
+    // Undo.
+
+    // Keys found on international keyboards.
+    // Hiragana.
+    // Katakana.
+
+    default:
+        return ASCIILiteral("Unidentified");
+    }
+}
+
 class PlatformKeyboardEventBuilder : public PlatformKeyboardEvent {
 public:
     PlatformKeyboardEventBuilder(WebEvent *event)
@@ -161,6 +374,7 @@
         m_text = event.characters;
         m_unmodifiedText = event.charactersIgnoringModifiers;
         m_key = keyForKeyEvent(event);
+        m_code = codeForKeyEvent(event);
         m_keyIdentifier = keyIdentifierForKeyEvent(event);
         m_windowsVirtualKeyCode = event.keyCode;
         m_autoRepeat = event.isKeyRepeating;

Modified: trunk/Source/WebKit2/ChangeLog (210667 => 210668)


--- trunk/Source/WebKit2/ChangeLog	2017-01-12 18:30:53 UTC (rev 210667)
+++ trunk/Source/WebKit2/ChangeLog	2017-01-12 18:34:20 UTC (rev 210668)
@@ -1,3 +1,20 @@
+2017-01-12  Chris Dumez  <[email protected]>
+
+        [iOS] Implement support for KeyboardEvent.code
+        https://bugs.webkit.org/show_bug.cgi?id=166932
+        <rdar://problem/29972518>
+
+        Reviewed by Darin Adler.
+
+        Make sure KeyboardEvent.code is properly initialized on
+        iOS WK2.
+
+        * Shared/WebEvent.h:
+        * Shared/WebKeyboardEvent.cpp:
+        (WebKit::WebKeyboardEvent::WebKeyboardEvent):
+        * Shared/ios/WebIOSEventFactory.mm:
+        (WebIOSEventFactory::createWebKeyboardEvent):
+
 2017-01-12  Andreas Kling  <[email protected]>
 
         WebBackForwardListProxy should remove restored session history items from PageCache on close.

Modified: trunk/Source/WebKit2/Shared/WebEvent.h (210667 => 210668)


--- trunk/Source/WebKit2/Shared/WebEvent.h	2017-01-12 18:30:53 UTC (rev 210667)
+++ trunk/Source/WebKit2/Shared/WebEvent.h	2017-01-12 18:34:20 UTC (rev 210668)
@@ -248,7 +248,7 @@
 #elif PLATFORM(GTK)
     WebKeyboardEvent(Type, const String& text, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool handledByInputMethod, Vector<String>&& commands, bool isKeypad, Modifiers, double timestamp);
 #elif PLATFORM(IOS)
-    WebKeyboardEvent(Type, const String& text, const String& unmodifiedText, const String& key, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, int macCharCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, Modifiers, double timestamp);
+    WebKeyboardEvent(Type, const String& text, const String& unmodifiedText, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, int macCharCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, Modifiers, double timestamp);
 #else
     WebKeyboardEvent(Type, const String& text, const String& unmodifiedText, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, int macCharCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, Modifiers, double timestamp);
 #endif

Modified: trunk/Source/WebKit2/Shared/WebKeyboardEvent.cpp (210667 => 210668)


--- trunk/Source/WebKit2/Shared/WebKeyboardEvent.cpp	2017-01-12 18:30:53 UTC (rev 210667)
+++ trunk/Source/WebKit2/Shared/WebKeyboardEvent.cpp	2017-01-12 18:34:20 UTC (rev 210668)
@@ -79,11 +79,12 @@
 
 #elif PLATFORM(IOS)
 
-WebKeyboardEvent::WebKeyboardEvent(Type type, const String& text, const String& unmodifiedText, const String& key, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, int macCharCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, Modifiers modifiers, double timestamp)
+WebKeyboardEvent::WebKeyboardEvent(Type type, const String& text, const String& unmodifiedText, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, int macCharCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, Modifiers modifiers, double timestamp)
     : WebEvent(type, modifiers, timestamp)
     , m_text(text)
     , m_unmodifiedText(unmodifiedText)
     , m_key(key)
+    , m_code(code)
     , m_keyIdentifier(keyIdentifier)
     , m_windowsVirtualKeyCode(windowsVirtualKeyCode)
     , m_nativeVirtualKeyCode(nativeVirtualKeyCode)

Modified: trunk/Source/WebKit2/Shared/ios/WebIOSEventFactory.mm (210667 => 210668)


--- trunk/Source/WebKit2/Shared/ios/WebIOSEventFactory.mm	2017-01-12 18:30:53 UTC (rev 210667)
+++ trunk/Source/WebKit2/Shared/ios/WebIOSEventFactory.mm	2017-01-12 18:34:20 UTC (rev 210668)
@@ -56,6 +56,7 @@
     String text = event.characters;
     String unmodifiedText = event.charactersIgnoringModifiers;
     String key = WebCore::keyForKeyEvent(event);
+    String code = WebCore::codeForKeyEvent(event);
     String keyIdentifier = WebCore::keyIdentifierForKeyEvent(event);
     int windowsVirtualKeyCode = event.keyCode;
     int nativeVirtualKeyCode = event.keyCode;
@@ -84,7 +85,7 @@
         unmodifiedText = text;
     }
 
-    return WebKit::WebKeyboardEvent(type, text, unmodifiedText, key, keyIdentifier, windowsVirtualKeyCode, nativeVirtualKeyCode, macCharCode, autoRepeat, isKeypad, isSystemKey, modifiers, timestamp);
+    return WebKit::WebKeyboardEvent(type, text, unmodifiedText, key, code, keyIdentifier, windowsVirtualKeyCode, nativeVirtualKeyCode, macCharCode, autoRepeat, isKeypad, isSystemKey, modifiers, timestamp);
 }
 
 #endif // PLATFORM(IOS)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to