Title: [210586] trunk
Revision
210586
Author
[email protected]
Date
2017-01-11 07:45:35 -0800 (Wed, 11 Jan 2017)

Log Message

[iOS][WK2] KeyboardEvent.key always returns an empty string
https://bugs.webkit.org/show_bug.cgi?id=166918
<rdar://problem/29861147>

Reviewed by Wenson Hsieh.

Source/WebKit2:

Make sure that KeyboardEvent.key gets properly initialized on iOS / WK2.

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

LayoutTests:

Add layout test coverage.

* fast/events/ios/keyboard-event-key-attribute-expected.txt: Added.
* fast/events/ios/keyboard-event-key-attribute.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (210585 => 210586)


--- trunk/LayoutTests/ChangeLog	2017-01-11 12:12:37 UTC (rev 210585)
+++ trunk/LayoutTests/ChangeLog	2017-01-11 15:45:35 UTC (rev 210586)
@@ -1,3 +1,16 @@
+2017-01-11  Chris Dumez  <[email protected]>
+
+        [iOS][WK2] KeyboardEvent.key always returns an empty string
+        https://bugs.webkit.org/show_bug.cgi?id=166918
+        <rdar://problem/29861147>
+
+        Reviewed by Wenson Hsieh.
+
+        Add layout test coverage.
+
+        * fast/events/ios/keyboard-event-key-attribute-expected.txt: Added.
+        * fast/events/ios/keyboard-event-key-attribute.html: Added.
+
 2017-01-11  Gyuyoung Kim  <[email protected]>
 
         [EFL] Update TestExpectation file for Ubuntu 16.04.

Added: trunk/LayoutTests/fast/events/ios/keyboard-event-key-attribute-expected.txt (0 => 210586)


--- trunk/LayoutTests/fast/events/ios/keyboard-event-key-attribute-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/events/ios/keyboard-event-key-attribute-expected.txt	2017-01-11 15:45:35 UTC (rev 210586)
@@ -0,0 +1,10 @@
+Tests that KeyboardEvent.key is properly initialized on iOS.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS event.key is "a"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/events/ios/keyboard-event-key-attribute.html (0 => 210586)


--- trunk/LayoutTests/fast/events/ios/keyboard-event-key-attribute.html	                        (rev 0)
+++ trunk/LayoutTests/fast/events/ios/keyboard-event-key-attribute.html	2017-01-11 15:45:35 UTC (rev 210586)
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta name="viewport" content="width=device-width">
+<script src=""
+</head>
+<body>
+<input id="testInput" type="text">
+<script>
+description("Tests that KeyboardEvent.key is properly initialized on iOS.");
+jsTestIsAsync = true;
+
+function getTypingUIScript(x, y)
+{
+    return `
+        (function() {
+            uiController.didShowKeyboardCallback = function() {
+                uiController.typeCharacterUsingHardwareKeyboard('a', function() {
+                    uiController.uiScriptComplete();
+                });
+            };
+            uiController.singleTapAtPoint(${x}, ${y}, function() { });
+        })();`
+}
+
+var testInput = document.getElementById("testInput");
+testInput._onkeydown_ = function(e) {
+    event = e;
+    shouldBeEqualToString("event.key", "a");
+    finishJSTest();
+};
+
+const x = testInput.offsetLeft + 5;
+const y = testInput.offsetTop + 5;
+testRunner.runUIScript(getTypingUIScript(x, y), function() { });
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebKit2/ChangeLog (210585 => 210586)


--- trunk/Source/WebKit2/ChangeLog	2017-01-11 12:12:37 UTC (rev 210585)
+++ trunk/Source/WebKit2/ChangeLog	2017-01-11 15:45:35 UTC (rev 210586)
@@ -1,3 +1,19 @@
+2017-01-11  Chris Dumez  <[email protected]>
+
+        [iOS][WK2] KeyboardEvent.key always returns an empty string
+        https://bugs.webkit.org/show_bug.cgi?id=166918
+        <rdar://problem/29861147>
+
+        Reviewed by Wenson Hsieh.
+
+        Make sure that KeyboardEvent.key gets properly initialized on iOS / WK2.
+
+        * Shared/WebEvent.h:
+        * Shared/WebKeyboardEvent.cpp:
+        (WebKit::WebKeyboardEvent::WebKeyboardEvent):
+        * Shared/ios/WebIOSEventFactory.mm:
+        (WebIOSEventFactory::createWebKeyboardEvent):
+
 2017-01-10  Michael Catanzaro  <[email protected]>
 
         [GTK] No way for applications to set notification permissions without waiting for permission request

Modified: trunk/Source/WebKit2/Shared/WebEvent.h (210585 => 210586)


--- trunk/Source/WebKit2/Shared/WebEvent.h	2017-01-11 12:12:37 UTC (rev 210585)
+++ trunk/Source/WebKit2/Shared/WebEvent.h	2017-01-11 15:45:35 UTC (rev 210586)
@@ -247,6 +247,8 @@
     WebKeyboardEvent(Type, const String& text, const String& unmodifiedText, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, int macCharCode, bool handledByInputMethod, const Vector<WebCore::KeypressCommand>&, bool isAutoRepeat, bool isKeypad, bool isSystemKey, Modifiers, double timestamp);
 #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);
 #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 (210585 => 210586)


--- trunk/Source/WebKit2/Shared/WebKeyboardEvent.cpp	2017-01-11 12:12:37 UTC (rev 210585)
+++ trunk/Source/WebKit2/Shared/WebKeyboardEvent.cpp	2017-01-11 15:45:35 UTC (rev 210586)
@@ -77,6 +77,24 @@
     ASSERT(isKeyboardEventType(type));
 }
 
+#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)
+    : WebEvent(type, modifiers, timestamp)
+    , m_text(text)
+    , m_unmodifiedText(unmodifiedText)
+    , m_key(key)
+    , m_keyIdentifier(keyIdentifier)
+    , m_windowsVirtualKeyCode(windowsVirtualKeyCode)
+    , m_nativeVirtualKeyCode(nativeVirtualKeyCode)
+    , m_macCharCode(macCharCode)
+    , m_isAutoRepeat(isAutoRepeat)
+    , m_isKeypad(isKeypad)
+    , m_isSystemKey(isSystemKey)
+{
+    ASSERT(isKeyboardEventType(type));
+}
+
 #else
 
 WebKeyboardEvent::WebKeyboardEvent(Type type, const String& text, const String& unmodifiedText, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, int macCharCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, Modifiers modifiers, double timestamp)

Modified: trunk/Source/WebKit2/Shared/ios/WebIOSEventFactory.mm (210585 => 210586)


--- trunk/Source/WebKit2/Shared/ios/WebIOSEventFactory.mm	2017-01-11 12:12:37 UTC (rev 210585)
+++ trunk/Source/WebKit2/Shared/ios/WebIOSEventFactory.mm	2017-01-11 15:45:35 UTC (rev 210586)
@@ -55,6 +55,7 @@
     WebKit::WebEvent::Type type = (event.type == WebEventKeyUp) ? WebKit::WebEvent::KeyUp : WebKit::WebEvent::KeyDown;
     String text = event.characters;
     String unmodifiedText = event.charactersIgnoringModifiers;
+    String key = WebCore::keyForKeyEvent(event);
     String keyIdentifier = WebCore::keyIdentifierForKeyEvent(event);
     int windowsVirtualKeyCode = event.keyCode;
     int nativeVirtualKeyCode = event.keyCode;
@@ -83,7 +84,7 @@
         unmodifiedText = text;
     }
 
-    return WebKit::WebKeyboardEvent(type, text, unmodifiedText, keyIdentifier, windowsVirtualKeyCode, nativeVirtualKeyCode, macCharCode, autoRepeat, isKeypad, isSystemKey, modifiers, timestamp);
+    return WebKit::WebKeyboardEvent(type, text, unmodifiedText, key, 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