Diff
Modified: trunk/LayoutTests/ChangeLog (206749 => 206750)
--- trunk/LayoutTests/ChangeLog 2016-10-03 21:31:15 UTC (rev 206749)
+++ trunk/LayoutTests/ChangeLog 2016-10-03 21:32:47 UTC (rev 206750)
@@ -1,3 +1,45 @@
+2016-10-03 Chris Dumez <[email protected]>
+
+ Add support for KeyboardEvent.key attribute
+ https://bugs.webkit.org/show_bug.cgi?id=36267
+
+ Reviewed by Darin Adler.
+
+ Extend layout test coverage.
+
+ * fast/events/constructors/keyboard-event-constructor-expected.txt:
+ * fast/events/constructors/keyboard-event-constructor.html:
+ * fast/events/key-events-in-input-button-expected.txt:
+ * fast/events/key-events-in-input-button.html:
+ * fast/events/key-events-in-input-text-expected.txt:
+ * fast/events/key-events-in-input-text.html:
+ * fast/events/keyboardevent-key-expected.txt: Added.
+ * fast/events/keyboardevent-key.html: Added.
+ * fast/events/special-key-events-in-input-text-expected.txt:
+ * fast/events/special-key-events-in-input-text.html:
+ * platform/ios-simulator/TestExpectations:
+
+2016-10-03 Chris Dumez <[email protected]>
+
+ Add support for KeyboardEvent.key attribute
+ https://bugs.webkit.org/show_bug.cgi?id=36267
+
+ Reviewed by Darin Adler.
+
+ Extend layout test coverage.
+
+ * fast/events/constructors/keyboard-event-constructor-expected.txt:
+ * fast/events/constructors/keyboard-event-constructor.html:
+ * fast/events/key-events-in-input-button-expected.txt:
+ * fast/events/key-events-in-input-button.html:
+ * fast/events/key-events-in-input-text-expected.txt:
+ * fast/events/key-events-in-input-text.html:
+ * fast/events/keyboardevent-key-expected.txt: Added.
+ * fast/events/keyboardevent-key.html: Added.
+ * fast/events/special-key-events-in-input-text-expected.txt:
+ * fast/events/special-key-events-in-input-text.html:
+ * platform/ios-simulator/TestExpectations:
+
2016-10-03 Ryan Haddad <[email protected]>
Marking storage/indexeddb/index-cursor.html as flaky on mac-wk2.
Modified: trunk/LayoutTests/fast/events/constructors/keyboard-event-constructor-expected.txt (206749 => 206750)
--- trunk/LayoutTests/fast/events/constructors/keyboard-event-constructor-expected.txt 2016-10-03 21:31:15 UTC (rev 206749)
+++ trunk/LayoutTests/fast/events/constructors/keyboard-event-constructor-expected.txt 2016-10-03 21:32:47 UTC (rev 206750)
@@ -103,16 +103,17 @@
PASS new KeyboardEvent('eventType', { shiftKey: true }).shiftKey is true
PASS new KeyboardEvent('eventType', { metaKey: false }).metaKey is false
PASS new KeyboardEvent('eventType', { metaKey: true }).metaKey is true
-PASS new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, keyIdentifier: 'chocolate', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true }).bubbles is true
-PASS new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, keyIdentifier: 'chocolate', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true }).cancelable is true
-PASS new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, 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, 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, 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, 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, keyIdentifier: 'chocolate', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true }).ctrlKey is true
-PASS new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, keyIdentifier: 'chocolate', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true }).altKey is true
-PASS new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, keyIdentifier: 'chocolate', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true }).shiftKey is true
-PASS new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, keyIdentifier: 'chocolate', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true }).metaKey is true
+PASS new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, key: 'a', keyIdentifier: 'chocolate', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true }).bubbles is true
+PASS new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, key: 'a', keyIdentifier: 'chocolate', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true }).cancelable is true
+PASS new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, key: 'a', 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', 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', keyIdentifier: 'chocolate', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true }).key is "a"
+PASS new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, key: 'a', 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', 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', keyIdentifier: 'chocolate', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true }).ctrlKey is true
+PASS new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, key: 'a', keyIdentifier: 'chocolate', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true }).altKey is true
+PASS new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, key: 'a', keyIdentifier: 'chocolate', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true }).shiftKey is true
+PASS new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, key: 'a', keyIdentifier: 'chocolate', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true }).metaKey is true
PASS successfullyParsed is true
TEST COMPLETE
Modified: trunk/LayoutTests/fast/events/constructors/keyboard-event-constructor.html (206749 => 206750)
--- trunk/LayoutTests/fast/events/constructors/keyboard-event-constructor.html 2016-10-03 21:31:15 UTC (rev 206749)
+++ trunk/LayoutTests/fast/events/constructors/keyboard-event-constructor.html 2016-10-03 21:32:47 UTC (rev 206750)
@@ -117,16 +117,17 @@
});
// All initializers are passed.
-shouldBe("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, keyIdentifier: 'chocolate', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true }).bubbles", "true");
-shouldBe("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, keyIdentifier: 'chocolate', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true }).cancelable", "true");
-shouldBe("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, keyIdentifier: 'chocolate', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true }).view", "window");
-shouldBe("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, keyIdentifier: 'chocolate', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true }).detail", "111");
-shouldBeEqualToString("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, keyIdentifier: 'chocolate', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true }).keyIdentifier", "chocolate");
-shouldBe("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, keyIdentifier: 'chocolate', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true }).location", "222");
-shouldBe("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, keyIdentifier: 'chocolate', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true }).ctrlKey", "true");
-shouldBe("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, keyIdentifier: 'chocolate', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true }).altKey", "true");
-shouldBe("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, keyIdentifier: 'chocolate', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true }).shiftKey", "true");
-shouldBe("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, keyIdentifier: 'chocolate', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true }).metaKey", "true");
+shouldBe("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, key: 'a', keyIdentifier: 'chocolate', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true }).bubbles", "true");
+shouldBe("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, key: 'a', keyIdentifier: 'chocolate', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true }).cancelable", "true");
+shouldBe("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, key: 'a', keyIdentifier: 'chocolate', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true }).view", "window");
+shouldBe("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, key: 'a', keyIdentifier: 'chocolate', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true }).detail", "111");
+shouldBeEqualToString("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, key: 'a', keyIdentifier: 'chocolate', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true }).key", "a");
+shouldBeEqualToString("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, key: 'a', keyIdentifier: 'chocolate', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true }).keyIdentifier", "chocolate");
+shouldBe("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, key: 'a', keyIdentifier: 'chocolate', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true }).location", "222");
+shouldBe("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, key: 'a', keyIdentifier: 'chocolate', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true }).ctrlKey", "true");
+shouldBe("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, key: 'a', keyIdentifier: 'chocolate', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true }).altKey", "true");
+shouldBe("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, key: 'a', keyIdentifier: 'chocolate', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true }).shiftKey", "true");
+shouldBe("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, key: 'a', keyIdentifier: 'chocolate', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true }).metaKey", "true");
</script>
<script src=""
</body>
Modified: trunk/LayoutTests/fast/events/key-events-in-input-button-expected.txt (206749 => 206750)
--- trunk/LayoutTests/fast/events/key-events-in-input-button-expected.txt 2016-10-03 21:31:15 UTC (rev 206749)
+++ trunk/LayoutTests/fast/events/key-events-in-input-button-expected.txt 2016-10-03 21:32:47 UTC (rev 206750)
@@ -1,19 +1,19 @@
To test manually, press keys and compare results to other browsers.
-target - type - ctrlKey,altKey,shiftKey,metaKey - keyIdentifier - keyCode - charCode
+target - type - ctrlKey,altKey,shiftKey,metaKey - key - keyIdentifier - keyCode - charCode
Space:
-INPUT - keydown - false,false,false,false - U+0020 - 32 - 0
-INPUT - keypress - false,false,false,false - - 32 - 32
-INPUT - keyup - false,false,false,false - U+0020 - 32 - 0
+INPUT - keydown - false,false,false,false - - U+0020 - 32 - 0
+INPUT - keypress - false,false,false,false - - - 32 - 32
+INPUT - keyup - false,false,false,false - - U+0020 - 32 - 0
INPUT - click
Enter:
-INPUT - keydown - false,false,false,false - Enter - 13 - 0
-INPUT - keypress - false,false,false,false - - 13 - 13
+INPUT - keydown - false,false,false,false - Enter - Enter - 13 - 0
+INPUT - keypress - false,false,false,false - Enter - - 13 - 13
INPUT - click
-INPUT - keyup - false,false,false,false - Enter - 13 - 0
+INPUT - keyup - false,false,false,false - Enter - Enter - 13 - 0
A:
-INPUT - keydown - false,false,true,false - U+0041 - 65 - 0
-INPUT - keypress - false,false,true,false - - 65 - 65
-INPUT - keyup - false,false,true,false - U+0041 - 65 - 0
+INPUT - keydown - false,false,true,false - A - U+0041 - 65 - 0
+INPUT - keypress - false,false,true,false - A - - 65 - 65
+INPUT - keyup - false,false,true,false - A - U+0041 - 65 - 0
Modified: trunk/LayoutTests/fast/events/key-events-in-input-button.html (206749 => 206750)
--- trunk/LayoutTests/fast/events/key-events-in-input-button.html 2016-10-03 21:31:15 UTC (rev 206749)
+++ trunk/LayoutTests/fast/events/key-events-in-input-button.html 2016-10-03 21:32:47 UTC (rev 206750)
@@ -23,6 +23,7 @@
else if (event.type == "keydown" || event.type == "keypress" || event.type == "keyup")
return (where ? "(" + where + ") " : "") + target.tagName + " - " + event.type
+ ' - ' + [event.ctrlKey, event.altKey, event.shiftKey, event.metaKey]
+ + ' - ' + event.key
+ ' - ' + event.keyIdentifier
+ ' - ' + event.keyCode
+ ' - ' + event.charCode;
@@ -34,6 +35,7 @@
}
}
log("target - type - " + ["ctrlKey", "altKey", "shiftKey", "metaKey"]
+ + ' - ' + "key"
+ ' - ' + "keyIdentifier"
+ ' - ' + "keyCode"
+ ' - ' + "charCode");
Modified: trunk/LayoutTests/fast/events/key-events-in-input-text-expected.txt (206749 => 206750)
--- trunk/LayoutTests/fast/events/key-events-in-input-text-expected.txt 2016-10-03 21:31:15 UTC (rev 206749)
+++ trunk/LayoutTests/fast/events/key-events-in-input-text-expected.txt 2016-10-03 21:32:47 UTC (rev 206750)
@@ -1,18 +1,18 @@
To test manually, press keys and compare results to other browsers.
-target - type - ctrlKey,altKey,shiftKey,metaKey - keyIdentifier - keyCode - charCode
+target - type - ctrlKey,altKey,shiftKey,metaKey - key - keyIdentifier - keyCode - charCode
Space:
-INPUT - keydown - false,false,false,false - U+0020 - 32 - 0. Value: "".
-INPUT - keypress - false,false,false,false - - 32 - 32. Value: "".
+INPUT - keydown - false,false,false,false - - U+0020 - 32 - 0. Value: "".
+INPUT - keypress - false,false,false,false - - - 32 - 32. Value: "".
INPUT - textInput - . Value: "".
-INPUT - keyup - false,false,false,false - U+0020 - 32 - 0. Value: " ".
+INPUT - keyup - false,false,false,false - - U+0020 - 32 - 0. Value: " ".
Backspace:
-INPUT - keydown - false,false,false,false - U+0008 - 8 - 0. Value: " ".
-INPUT - keyup - false,false,false,false - U+0008 - 8 - 0. Value: "".
+INPUT - keydown - false,false,false,false - Backspace - U+0008 - 8 - 0. Value: " ".
+INPUT - keyup - false,false,false,false - Backspace - U+0008 - 8 - 0. Value: "".
Left Arrow:
-INPUT - keydown - false,false,false,false - Left - 37 - 0. Value: "".
-INPUT - keyup - false,false,false,false - Left - 37 - 0. Value: "".
+INPUT - keydown - false,false,false,false - ArrowLeft - Left - 37 - 0. Value: "".
+INPUT - keyup - false,false,false,false - ArrowLeft - Left - 37 - 0. Value: "".
Tab:
-INPUT - keydown - false,false,false,false - U+0009 - 9 - 0. Value: "".
+INPUT - keydown - false,false,false,false - Tab - U+0009 - 9 - 0. Value: "".
Modified: trunk/LayoutTests/fast/events/key-events-in-input-text.html (206749 => 206750)
--- trunk/LayoutTests/fast/events/key-events-in-input-text.html 2016-10-03 21:31:15 UTC (rev 206749)
+++ trunk/LayoutTests/fast/events/key-events-in-input-text.html 2016-10-03 21:32:47 UTC (rev 206750)
@@ -25,6 +25,7 @@
else if (event.type == "keydown" || event.type == "keypress" || event.type == "keyup")
return (where ? "(" + where + ") " : "") + target.tagName + " - " + event.type
+ ' - ' + [event.ctrlKey, event.altKey, event.shiftKey, event.metaKey]
+ + ' - ' + event.key
+ ' - ' + event.keyIdentifier
+ ' - ' + event.keyCode
+ ' - ' + event.charCode
@@ -38,6 +39,7 @@
}
}
log("target - type - " + ["ctrlKey", "altKey", "shiftKey", "metaKey"]
+ + ' - ' + "key"
+ ' - ' + "keyIdentifier"
+ ' - ' + "keyCode"
+ ' - ' + "charCode");
Added: trunk/LayoutTests/fast/events/keyboardevent-key-expected.txt (0 => 206750)
--- trunk/LayoutTests/fast/events/keyboardevent-key-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/events/keyboardevent-key-expected.txt 2016-10-03 21:32:47 UTC (rev 206750)
@@ -0,0 +1,200 @@
+Test the key attribute on KeyboardEvent.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+
+* keydown
+PASS keyboardEvent.key is " "
+* keyup
+PASS keyboardEvent.key is " "
+
+* keydown
+PASS keyboardEvent.key is "a"
+* keyup
+PASS keyboardEvent.key is "a"
+
+* keydown
+PASS keyboardEvent.key is "Backspace"
+* keyup
+PASS keyboardEvent.key is "Backspace"
+
+* keydown
+PASS keyboardEvent.key is "Escape"
+* keyup
+PASS keyboardEvent.key is "Escape"
+
+* keydown
+PASS keyboardEvent.key is "ArrowLeft"
+* keyup
+PASS keyboardEvent.key is "ArrowLeft"
+
+* keydown
+PASS keyboardEvent.key is "ArrowRight"
+* keyup
+PASS keyboardEvent.key is "ArrowRight"
+
+* keydown
+PASS keyboardEvent.key is "ArrowUp"
+* keyup
+PASS keyboardEvent.key is "ArrowUp"
+
+* keydown
+PASS keyboardEvent.key is "ArrowDown"
+* keyup
+PASS keyboardEvent.key is "ArrowDown"
+
+* keydown
+PASS keyboardEvent.key is "PageUp"
+* keyup
+PASS keyboardEvent.key is "PageUp"
+
+* keydown
+PASS keyboardEvent.key is "PageDown"
+* keyup
+PASS keyboardEvent.key is "PageDown"
+
+* keydown
+PASS keyboardEvent.key is "Home"
+* keyup
+PASS keyboardEvent.key is "Home"
+
+* keydown
+PASS keyboardEvent.key is "End"
+* keyup
+PASS keyboardEvent.key is "End"
+
+* keydown
+PASS keyboardEvent.key is "Insert"
+* keyup
+PASS keyboardEvent.key is "Insert"
+
+* keydown
+PASS keyboardEvent.key is "Delete"
+* keyup
+PASS keyboardEvent.key is "Delete"
+
+* keydown
+PASS keyboardEvent.key is "PrintScreen"
+* keyup
+PASS keyboardEvent.key is "PrintScreen"
+
+* keydown
+PASS keyboardEvent.key is "Control"
+* keyup
+PASS keyboardEvent.key is "Control"
+
+* keydown
+PASS keyboardEvent.key is "Shift"
+* keyup
+PASS keyboardEvent.key is "Shift"
+
+* keydown
+PASS keyboardEvent.key is "Alt"
+* keyup
+PASS keyboardEvent.key is "Alt"
+
+* keydown
+PASS keyboardEvent.key is "Control"
+* keyup
+PASS keyboardEvent.key is "Control"
+
+* keydown
+PASS keyboardEvent.key is "Shift"
+* keyup
+PASS keyboardEvent.key is "Shift"
+
+* keydown
+PASS keyboardEvent.key is "Alt"
+* keyup
+PASS keyboardEvent.key is "Alt"
+
+* keydown
+PASS keyboardEvent.key is "F1"
+* keyup
+PASS keyboardEvent.key is "F1"
+
+* keydown
+PASS keyboardEvent.key is "F2"
+* keyup
+PASS keyboardEvent.key is "F2"
+
+* keydown
+PASS keyboardEvent.key is "F3"
+* keyup
+PASS keyboardEvent.key is "F3"
+
+* keydown
+PASS keyboardEvent.key is "F4"
+* keyup
+PASS keyboardEvent.key is "F4"
+
+* keydown
+PASS keyboardEvent.key is "F5"
+* keyup
+PASS keyboardEvent.key is "F5"
+
+* keydown
+PASS keyboardEvent.key is "F6"
+* keyup
+PASS keyboardEvent.key is "F6"
+
+* keydown
+PASS keyboardEvent.key is "F7"
+* keyup
+PASS keyboardEvent.key is "F7"
+
+* keydown
+PASS keyboardEvent.key is "F8"
+* keyup
+PASS keyboardEvent.key is "F8"
+
+* keydown
+PASS keyboardEvent.key is "F9"
+* keyup
+PASS keyboardEvent.key is "F9"
+
+* keydown
+PASS keyboardEvent.key is "F10"
+* keyup
+PASS keyboardEvent.key is "F10"
+
+* keydown
+PASS keyboardEvent.key is "F11"
+* keyup
+PASS keyboardEvent.key is "F11"
+
+* keydown
+PASS keyboardEvent.key is "F12"
+* keyup
+PASS keyboardEvent.key is "F12"
+
+* keydown
+PASS keyboardEvent.key is "Enter"
+* keyup
+PASS keyboardEvent.key is "Enter"
+
+* keydown
+PASS keyboardEvent.key is "A"
+* keyup
+PASS keyboardEvent.key is "A"
+
+* keydown
+PASS keyboardEvent.key is "a"
+* keyup
+PASS keyboardEvent.key is "a"
+
+* keydown
+PASS keyboardEvent.key is "a"
+* keyup
+PASS keyboardEvent.key is "a"
+
+* keydown
+PASS keyboardEvent.key is "1"
+* keyup
+PASS keyboardEvent.key is "1"
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/events/keyboardevent-key.html (0 => 206750)
--- trunk/LayoutTests/fast/events/keyboardevent-key.html (rev 0)
+++ trunk/LayoutTests/fast/events/keyboardevent-key.html 2016-10-03 21:32:47 UTC (rev 206750)
@@ -0,0 +1,63 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<input type="text" id="testInput">
+<script>
+description("Test the key attribute on KeyboardEvent.");
+
+var expectedKey;
+
+function testEvent(event)
+{
+ keyboardEvent = event;
+ debug("* " + event.type);
+ shouldBeEqualToString("keyboardEvent.key", "" + expectedKey);
+}
+
+var input = document.getElementById("testInput");
+input._onkeydown_ = testEvent;
+input._onkeyup_ = testEvent;
+input.focus();
+
+function sendKeyAndTest(key, modifiers, expected)
+{
+ debug("");
+ expectedKey = expected;
+ eventSender.keyDown(key, []);
+}
+
+sendKeyAndTest(" ", [], " ");
+sendKeyAndTest("a", [], "a");
+sendKeyAndTest("\x08", [], "Backspace");
+sendKeyAndTest("\x1B", [], "Escape");
+sendKeyAndTest("leftArrow", [], "ArrowLeft");
+sendKeyAndTest("rightArrow", [], "ArrowRight");
+sendKeyAndTest("upArrow", [], "ArrowUp");
+sendKeyAndTest("downArrow", [], "ArrowDown");
+sendKeyAndTest("pageUp", [], "PageUp");
+sendKeyAndTest("pageDown", [], "PageDown");
+sendKeyAndTest("home", [], "Home");
+sendKeyAndTest("end", [], "End");
+sendKeyAndTest("insert", [], "Insert");
+sendKeyAndTest("delete", [], "Delete");
+sendKeyAndTest("printScreen", [], "PrintScreen");
+sendKeyAndTest("leftControl", ["ctrlKey"], "Control");
+sendKeyAndTest("leftShift", ["shiftKey"], "Shift");
+sendKeyAndTest("leftAlt", ["altKey"], "Alt");
+sendKeyAndTest("rightControl", ["ctrlKey"], "Control");
+sendKeyAndTest("rightShift", ["shiftKey"], "Shift");
+sendKeyAndTest("rightAlt", ["altKey"], "Alt");
+for (var i = 1; i <= 12; i++)
+ sendKeyAndTest("F" + i, [], "F" + i);
+sendKeyAndTest("\n", [], "Enter");
+sendKeyAndTest("A", [], "A");
+sendKeyAndTest("a", ["ctrlKey"], "a");
+sendKeyAndTest("a", ["metaKey"], "a");
+sendKeyAndTest("1", ['altKey'], "1");
+
+debug("");
+</script>
+<script src=""
+</body>
+</html>
Modified: trunk/LayoutTests/fast/events/special-key-events-in-input-text-expected.txt (206749 => 206750)
--- trunk/LayoutTests/fast/events/special-key-events-in-input-text-expected.txt 2016-10-03 21:31:15 UTC (rev 206749)
+++ trunk/LayoutTests/fast/events/special-key-events-in-input-text-expected.txt 2016-10-03 21:32:47 UTC (rev 206750)
@@ -1,49 +1,49 @@
This test verifies that the correct sequence of keyboard events is generated for a keypress for certain special keys. To test manually, press keys and compare results to other browsers.
-target - type - ctrlKey,altKey,shiftKey,metaKey - keyIdentifier - keyCode - charCode
+target - type - ctrlKey,altKey,shiftKey,metaKey - key - keyIdentifier - keyCode - charCode
Ampersand:
-INPUT - keydown - false,false,true,false - U+0037 - 55 - 0. Value: "".
-INPUT - keypress - false,false,true,false - - 55 - 55. Value: "".
+INPUT - keydown - false,false,true,false - 7 - U+0037 - 55 - 0. Value: "".
+INPUT - keypress - false,false,true,false - 7 - - 55 - 55. Value: "".
INPUT - textInput - 7. Value: "".
-INPUT - keyup - false,false,true,false - U+0037 - 55 - 0. Value: "7".
+INPUT - keyup - false,false,true,false - 7 - U+0037 - 55 - 0. Value: "7".
Backspace:
-INPUT - keydown - false,false,false,false - U+0008 - 8 - 0. Value: "7".
-INPUT - keyup - false,false,false,false - U+0008 - 8 - 0. Value: "".
+INPUT - keydown - false,false,false,false - Backspace - U+0008 - 8 - 0. Value: "7".
+INPUT - keyup - false,false,false,false - Backspace - U+0008 - 8 - 0. Value: "".
Percent:
-INPUT - keydown - false,false,true,false - U+0035 - 53 - 0. Value: "".
-INPUT - keypress - false,false,true,false - - 53 - 53. Value: "".
+INPUT - keydown - false,false,true,false - 5 - U+0035 - 53 - 0. Value: "".
+INPUT - keypress - false,false,true,false - 5 - - 53 - 53. Value: "".
INPUT - textInput - 5. Value: "".
-INPUT - keyup - false,false,true,false - U+0035 - 53 - 0. Value: "5".
+INPUT - keyup - false,false,true,false - 5 - U+0035 - 53 - 0. Value: "5".
Backspace:
-INPUT - keydown - false,false,false,false - U+0008 - 8 - 0. Value: "5".
-INPUT - keyup - false,false,false,false - U+0008 - 8 - 0. Value: "".
+INPUT - keydown - false,false,false,false - Backspace - U+0008 - 8 - 0. Value: "5".
+INPUT - keyup - false,false,false,false - Backspace - U+0008 - 8 - 0. Value: "".
Left parenthesis:
-INPUT - keydown - false,false,true,false - U+0039 - 57 - 0. Value: "".
-INPUT - keypress - false,false,true,false - - 57 - 57. Value: "".
+INPUT - keydown - false,false,true,false - 9 - U+0039 - 57 - 0. Value: "".
+INPUT - keypress - false,false,true,false - 9 - - 57 - 57. Value: "".
INPUT - textInput - 9. Value: "".
-INPUT - keyup - false,false,true,false - U+0039 - 57 - 0. Value: "9".
+INPUT - keyup - false,false,true,false - 9 - U+0039 - 57 - 0. Value: "9".
Backspace:
-INPUT - keydown - false,false,false,false - U+0008 - 8 - 0. Value: "9".
-INPUT - keyup - false,false,false,false - U+0008 - 8 - 0. Value: "".
+INPUT - keydown - false,false,false,false - Backspace - U+0008 - 8 - 0. Value: "9".
+INPUT - keyup - false,false,false,false - Backspace - U+0008 - 8 - 0. Value: "".
Right parenthesis:
-INPUT - keydown - false,false,true,false - U+0030 - 48 - 0. Value: "".
-INPUT - keypress - false,false,true,false - - 48 - 48. Value: "".
+INPUT - keydown - false,false,true,false - 0 - U+0030 - 48 - 0. Value: "".
+INPUT - keypress - false,false,true,false - 0 - - 48 - 48. Value: "".
INPUT - textInput - 0. Value: "".
-INPUT - keyup - false,false,true,false - U+0030 - 48 - 0. Value: "0".
+INPUT - keyup - false,false,true,false - 0 - U+0030 - 48 - 0. Value: "0".
Backspace:
-INPUT - keydown - false,false,false,false - U+0008 - 8 - 0. Value: "0".
-INPUT - keyup - false,false,false,false - U+0008 - 8 - 0. Value: "".
+INPUT - keydown - false,false,false,false - Backspace - U+0008 - 8 - 0. Value: "0".
+INPUT - keyup - false,false,false,false - Backspace - U+0008 - 8 - 0. Value: "".
Print screen:
-INPUT - keydown - false,false,false,false - PrintScreen - 44 - 0. Value: "".
-INPUT - keyup - false,false,false,false - PrintScreen - 44 - 0. Value: "".
+INPUT - keydown - false,false,false,false - PrintScreen - PrintScreen - 44 - 0. Value: "".
+INPUT - keyup - false,false,false,false - PrintScreen - PrintScreen - 44 - 0. Value: "".
Modified: trunk/LayoutTests/fast/events/special-key-events-in-input-text.html (206749 => 206750)
--- trunk/LayoutTests/fast/events/special-key-events-in-input-text.html 2016-10-03 21:31:15 UTC (rev 206749)
+++ trunk/LayoutTests/fast/events/special-key-events-in-input-text.html 2016-10-03 21:32:47 UTC (rev 206750)
@@ -18,6 +18,7 @@
info += e.data;
} else if (type == "keydown" || type == "keypress" || type == "keyup") {
info += [e.ctrlKey, e.altKey, e.shiftKey, e.metaKey] +
+ ' - ' + e.key +
' - ' + e.keyIdentifier +
' - ' + e.keyCode +
' - ' + e.charCode;
@@ -27,6 +28,7 @@
}
log("target - type - " + ["ctrlKey", "altKey", "shiftKey", "metaKey"]
+ + ' - ' + "key"
+ ' - ' + "keyIdentifier"
+ ' - ' + "keyCode"
+ ' - ' + "charCode");
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (206749 => 206750)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2016-10-03 21:31:15 UTC (rev 206749)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2016-10-03 21:32:47 UTC (rev 206750)
@@ -1,5 +1,33 @@
2016-10-03 Chris Dumez <[email protected]>
+ Add support for KeyboardEvent.key attribute
+ https://bugs.webkit.org/show_bug.cgi?id=36267
+
+ Reviewed by Darin Adler.
+
+ Rebaseline because that the tests are failing differently now that we support
+ the key attribute on KeyboardEvent but are still missing other standard API
+ on this interface.
+
+ * web-platform-tests/dom/events/Event-init-while-dispatching-expected.txt:
+ * web-platform-tests/dom/events/Event-subclasses-constructors-expected.txt:
+
+2016-10-03 Chris Dumez <[email protected]>
+
+ Add support for KeyboardEvent.key attribute
+ https://bugs.webkit.org/show_bug.cgi?id=36267
+
+ Reviewed by Darin Adler.
+
+ Rebaseline because that the tests are failing differently now that we support
+ the key attribute on KeyboardEvent but are still missing other standard API
+ on this interface.
+
+ * web-platform-tests/dom/events/Event-init-while-dispatching-expected.txt:
+ * web-platform-tests/dom/events/Event-subclasses-constructors-expected.txt:
+
+2016-10-03 Chris Dumez <[email protected]>
+
td.scope should only return known values
https://bugs.webkit.org/show_bug.cgi?id=162755
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-init-while-dispatching-expected.txt (206749 => 206750)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-init-while-dispatching-expected.txt 2016-10-03 21:31:15 UTC (rev 206749)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-init-while-dispatching-expected.txt 2016-10-03 21:32:47 UTC (rev 206750)
@@ -1,5 +1,5 @@
-FAIL Calling initKeyboardEvent while dispatching. assert_equals: initKeyboardEvent key setter should short-circuit expected (string) "A" but got (undefined) undefined
+PASS Calling initKeyboardEvent while dispatching.
PASS Calling initMouseEvent while dispatching.
PASS Calling initCustomEvent while dispatching.
PASS Calling initUIEvent while dispatching.
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-subclasses-constructors-expected.txt (206749 => 206750)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-subclasses-constructors-expected.txt 2016-10-03 21:31:15 UTC (rev 206749)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-subclasses-constructors-expected.txt 2016-10-03 21:32:47 UTC (rev 206750)
@@ -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 key property expected true got false
-FAIL KeyboardEvent constructor (undefined argument) assert_true: Event object "[object KeyboardEvent]" should have a key property expected true got false
-FAIL KeyboardEvent constructor (null argument) assert_true: Event object "[object KeyboardEvent]" should have a key property expected true got false
-FAIL KeyboardEvent constructor (empty argument) assert_true: Event object "[object KeyboardEvent]" should have a key property expected true got false
-FAIL KeyboardEvent constructor (argument with default values) assert_true: Event object "[object KeyboardEvent]" should have a key property expected true got false
-FAIL KeyboardEvent constructor (argument with non-default values) assert_true: Event object "[object KeyboardEvent]" should have a key 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 CompositionEvent constructor (no argument)
PASS CompositionEvent constructor (undefined argument)
PASS CompositionEvent constructor (null argument)
Modified: trunk/LayoutTests/platform/ios-simulator/TestExpectations (206749 => 206750)
--- trunk/LayoutTests/platform/ios-simulator/TestExpectations 2016-10-03 21:31:15 UTC (rev 206749)
+++ trunk/LayoutTests/platform/ios-simulator/TestExpectations 2016-10-03 21:32:47 UTC (rev 206750)
@@ -336,6 +336,7 @@
webkit.org/b/155233 fast/events/max-tabindex-focus.html [ Skip ]
fast/shadow-dom/shadow-host-removal-crash.html [ Skip ]
fast/shadow-dom/input-element-in-shadow.html [ Skip ]
+fast/events/keyboardevent-key.html [ Skip ]
# The file-wrapper part of <attachment> is not yet working on iOS
fast/attachment/attachment-type-attribute.html [ Skip ]
Modified: trunk/Source/WTF/ChangeLog (206749 => 206750)
--- trunk/Source/WTF/ChangeLog 2016-10-03 21:31:15 UTC (rev 206749)
+++ trunk/Source/WTF/ChangeLog 2016-10-03 21:32:47 UTC (rev 206750)
@@ -1,3 +1,15 @@
+2016-10-03 Chris Dumez <[email protected]>
+
+ Add support for KeyboardEvent.key attribute
+ https://bugs.webkit.org/show_bug.cgi?id=36267
+
+ Reviewed by Darin Adler.
+
+ Add compile time flag for the key attribute on KeyboardEvent and enable
+ it on Cocoa only.
+
+ * wtf/FeatureDefines.h:
+
2016-09-29 Sam Weinig <[email protected]>
Add initial support for IDL union conversion
Modified: trunk/Source/WTF/wtf/FeatureDefines.h (206749 => 206750)
--- trunk/Source/WTF/wtf/FeatureDefines.h 2016-10-03 21:31:15 UTC (rev 206749)
+++ trunk/Source/WTF/wtf/FeatureDefines.h 2016-10-03 21:32:47 UTC (rev 206750)
@@ -255,6 +255,10 @@
#define ENABLE_DATA_DETECTION 1
#endif
+#if !defined(ENABLE_KEYBOARD_KEY_ATTRIBUTE)
+#define ENABLE_KEYBOARD_KEY_ATTRIBUTE 1
+#endif
+
#endif /* PLATFORM(COCOA) */
#if !PLATFORM(COCOA)
@@ -769,6 +773,10 @@
#define ENABLE_XSLT 1
#endif
+#if !defined(ENABLE_KEYBOARD_KEY_ATTRIBUTE)
+#define ENABLE_KEYBOARD_KEY_ATTRIBUTE 0
+#endif
+
/* Asserts, invariants for macro definitions */
#if ENABLE(VIDEO_TRACK) && !ENABLE(VIDEO)
Modified: trunk/Source/WebCore/ChangeLog (206749 => 206750)
--- trunk/Source/WebCore/ChangeLog 2016-10-03 21:31:15 UTC (rev 206749)
+++ trunk/Source/WebCore/ChangeLog 2016-10-03 21:32:47 UTC (rev 206750)
@@ -1,3 +1,79 @@
+2016-10-03 Chris Dumez <[email protected]>
+
+ Add support for KeyboardEvent.key attribute
+ https://bugs.webkit.org/show_bug.cgi?id=36267
+
+ Reviewed by Darin Adler.
+
+ Add support for KeyboardEvent.key attribute:
+ - https://w3c.github.io/uievents/#dom-keyboardevent-key
+
+ This is behind a compile time flag that is only enabled on Mac and
+ iOS and the implementation is still missing for other platforms.
+
+ Test: fast/events/keyboardevent-key.html
+
+ * dom/KeyboardEvent.cpp:
+ (WebCore::KeyboardEvent::KeyboardEvent):
+ * dom/KeyboardEvent.h:
+ * dom/KeyboardEvent.idl:
+ * platform/PlatformKeyboardEvent.h:
+ (WebCore::PlatformKeyboardEvent::PlatformKeyboardEvent):
+ (WebCore::PlatformKeyboardEvent::key):
+ * platform/cocoa/KeyEventCocoa.h:
+ * platform/cocoa/KeyEventCocoa.mm:
+ (WebCore::keyForCharCode):
+ * platform/ios/PlatformEventFactoryIOS.h:
+ * platform/ios/PlatformEventFactoryIOS.mm:
+ (WebCore::keyForKeyEvent):
+ (WebCore::PlatformKeyboardEventBuilder::PlatformKeyboardEventBuilder):
+ * platform/mac/PlatformEventFactoryMac.h:
+ * platform/mac/PlatformEventFactoryMac.mm:
+ (WebCore::keyForKeyEvent):
+ (WebCore::PlatformKeyboardEventBuilder::PlatformKeyboardEventBuilder):
+ (WebCore::PlatformWheelEventBuilder::PlatformWheelEventBuilder): Deleted.
+ * replay/SerializationMethods.cpp:
+ (JSC::EncodingTraits<PlatformKeyboardEvent>::encodeValue):
+ (JSC::EncodingTraits<PlatformKeyboardEvent>::decodeValue):
+
+2016-10-03 Chris Dumez <[email protected]>
+
+ Add support for KeyboardEvent.key attribute
+ https://bugs.webkit.org/show_bug.cgi?id=36267
+
+ Reviewed by Darin Adler.
+
+ Add support for KeyboardEvent.key attribute:
+ - https://w3c.github.io/uievents/#dom-keyboardevent-key
+
+ This is behind a compile time flag that is only enabled on Mac and
+ iOS and the implementation is still missing for other platforms.
+
+ Test: fast/events/keyboardevent-key.html
+
+ * dom/KeyboardEvent.cpp:
+ (WebCore::KeyboardEvent::KeyboardEvent):
+ * dom/KeyboardEvent.h:
+ * dom/KeyboardEvent.idl:
+ * platform/PlatformKeyboardEvent.h:
+ (WebCore::PlatformKeyboardEvent::PlatformKeyboardEvent):
+ (WebCore::PlatformKeyboardEvent::key):
+ * platform/cocoa/KeyEventCocoa.h:
+ * platform/cocoa/KeyEventCocoa.mm:
+ (WebCore::keyForCharCode):
+ * platform/ios/PlatformEventFactoryIOS.h:
+ * platform/ios/PlatformEventFactoryIOS.mm:
+ (WebCore::keyForKeyEvent):
+ (WebCore::PlatformKeyboardEventBuilder::PlatformKeyboardEventBuilder):
+ * platform/mac/PlatformEventFactoryMac.h:
+ * platform/mac/PlatformEventFactoryMac.mm:
+ (WebCore::keyForKeyEvent):
+ (WebCore::PlatformKeyboardEventBuilder::PlatformKeyboardEventBuilder):
+ (WebCore::PlatformWheelEventBuilder::PlatformWheelEventBuilder): Deleted.
+ * replay/SerializationMethods.cpp:
+ (JSC::EncodingTraits<PlatformKeyboardEvent>::encodeValue):
+ (JSC::EncodingTraits<PlatformKeyboardEvent>::decodeValue):
+
2016-10-03 Alex Christensen <[email protected]>
URLParser: fragment-only URLs relative to file URLs should just add a fragment
Modified: trunk/Source/WebCore/dom/KeyboardEvent.cpp (206749 => 206750)
--- trunk/Source/WebCore/dom/KeyboardEvent.cpp 2016-10-03 21:31:15 UTC (rev 206749)
+++ trunk/Source/WebCore/dom/KeyboardEvent.cpp 2016-10-03 21:32:47 UTC (rev 206750)
@@ -104,6 +104,9 @@
: UIEventWithKeyState(eventTypeForKeyboardEventType(key.type()),
true, true, key.timestamp(), view, 0, key.ctrlKey(), key.altKey(), key.shiftKey(), key.metaKey())
, m_keyEvent(std::make_unique<PlatformKeyboardEvent>(key))
+#if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
+ , m_key(key.key())
+#endif
, m_keyIdentifier(key.keyIdentifier())
, m_location(keyLocationCode(key))
, m_repeat(key.isAutoRepeat())
@@ -127,6 +130,9 @@
KeyboardEvent::KeyboardEvent(const AtomicString& eventType, const KeyboardEventInit& initializer)
: UIEventWithKeyState(eventType, initializer)
+#if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
+ , m_key(initializer.key)
+#endif
, m_keyIdentifier(initializer.keyIdentifier)
, m_location(initializer.location)
, m_repeat(initializer.repeat)
Modified: trunk/Source/WebCore/dom/KeyboardEvent.h (206749 => 206750)
--- trunk/Source/WebCore/dom/KeyboardEvent.h 2016-10-03 21:31:15 UTC (rev 206749)
+++ trunk/Source/WebCore/dom/KeyboardEvent.h 2016-10-03 21:32:47 UTC (rev 206750)
@@ -34,6 +34,9 @@
class PlatformKeyboardEvent;
struct KeyboardEventInit : public UIEventWithKeyStateInit {
+#if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
+ String key;
+#endif
String keyIdentifier;
unsigned location { 0 };
bool repeat { false };
@@ -46,9 +49,6 @@
DOM_KEY_LOCATION_LEFT = 0x01,
DOM_KEY_LOCATION_RIGHT = 0x02,
DOM_KEY_LOCATION_NUMPAD = 0x03
- // FIXME: The following values are not supported yet (crbug.com/265446)
- // DOM_KEY_LOCATION_MOBILE = 0x04,
- // DOM_KEY_LOCATION_JOYSTICK = 0x05
};
static Ref<KeyboardEvent> create(const PlatformKeyboardEvent& platformEvent, DOMWindow* view)
@@ -79,6 +79,10 @@
const String& keyIdentifier, unsigned location,
bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, bool altGraphKey = false);
+#if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
+ const String& key() const { return m_key; }
+#endif
+
const String& keyIdentifier() const { return m_keyIdentifier; }
unsigned location() const { return m_location; }
bool repeat() const { return m_repeat; }
@@ -108,11 +112,14 @@
WEBCORE_EXPORT KeyboardEvent();
WEBCORE_EXPORT KeyboardEvent(const PlatformKeyboardEvent&, DOMWindow*);
KeyboardEvent(const AtomicString&, const KeyboardEventInit&);
- // FIXME: This method should be get ride of in the future.
+ // FIXME: This method should be get rid of in the future.
// DO NOT USE IT!
KeyboardEvent(WTF::HashTableDeletedValueType);
std::unique_ptr<PlatformKeyboardEvent> m_keyEvent;
+#if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
+ String m_key;
+#endif
String m_keyIdentifier;
unsigned m_location;
bool m_repeat : 1;
Modified: trunk/Source/WebCore/dom/KeyboardEvent.idl (206749 => 206750)
--- trunk/Source/WebCore/dom/KeyboardEvent.idl 2016-10-03 21:31:15 UTC (rev 206749)
+++ trunk/Source/WebCore/dom/KeyboardEvent.idl 2016-10-03 21:32:47 UTC (rev 206750)
@@ -28,19 +28,29 @@
const unsigned long DOM_KEY_LOCATION_RIGHT = 0x02;
const unsigned long DOM_KEY_LOCATION_NUMPAD = 0x03;
- [InitializedByEventConstructor] readonly attribute DOMString keyIdentifier;
+ [InitializedByEventConstructor, Conditional=KEYBOARD_KEY_ATTRIBUTE] readonly attribute DOMString key;
+
+ // FIXME: We should support this.
+ // [InitializedByEventConstructor] readonly attribute DOMString code;
+
[InitializedByEventConstructor] readonly attribute unsigned long location;
- [InitializedByEventConstructor, ImplementedAs=location] readonly attribute unsigned long keyLocation; // Deprecated.
+
[InitializedByEventConstructor] readonly attribute boolean ctrlKey;
[InitializedByEventConstructor] readonly attribute boolean shiftKey;
[InitializedByEventConstructor] readonly attribute boolean altKey;
[InitializedByEventConstructor] readonly attribute boolean metaKey;
- readonly attribute boolean altGraphKey;
-
[InitializedByEventConstructor] readonly attribute boolean repeat;
+ // FIXME: We should support this.
+ // readonly attribute boolean isComposing;
+
boolean getModifierState(DOMString keyArg);
+ // Everything below is legacy.
+ [InitializedByEventConstructor] readonly attribute DOMString keyIdentifier;
+ [InitializedByEventConstructor, ImplementedAs=location] readonly attribute unsigned long keyLocation;
+ readonly attribute boolean altGraphKey;
+
// FIXME: this does not match the version in the DOM spec.
// FIXME: Using "undefined" as default parameter value is wrong.
void initKeyboardEvent(optional DOMString type = "undefined", optional boolean canBubble = false, optional boolean cancelable = false,
Modified: trunk/Source/WebCore/platform/PlatformKeyboardEvent.h (206749 => 206750)
--- trunk/Source/WebCore/platform/PlatformKeyboardEvent.h 2016-10-03 21:31:15 UTC (rev 206749)
+++ trunk/Source/WebCore/platform/PlatformKeyboardEvent.h 2016-10-03 21:32:47 UTC (rev 206750)
@@ -70,10 +70,17 @@
{
}
- PlatformKeyboardEvent(Type type, const String& text, const String& unmodifiedText, const String& keyIdentifier, int windowsVirtualKeyCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, OptionSet<Modifier> modifiers, double timestamp)
+ PlatformKeyboardEvent(Type type, const String& text, const String& unmodifiedText,
+#if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
+ const String& key,
+#endif
+ const String& keyIdentifier, int windowsVirtualKeyCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, OptionSet<Modifier> modifiers, double timestamp)
: PlatformEvent(type, modifiers, timestamp)
, m_text(text)
, m_unmodifiedText(unmodifiedText)
+#if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
+ , m_key(key)
+#endif
, m_keyIdentifier(keyIdentifier)
, m_windowsVirtualKeyCode(windowsVirtualKeyCode)
#if USE(APPKIT) || PLATFORM(GTK)
@@ -102,6 +109,10 @@
String keyIdentifier() const { return m_keyIdentifier; }
+#if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
+ const String& key() const { return m_key; }
+#endif
+
// Most compatible Windows virtual key code associated with the event.
// Zero for Char events.
int windowsVirtualKeyCode() const { return m_windowsVirtualKeyCode; }
@@ -154,6 +165,9 @@
protected:
String m_text;
String m_unmodifiedText;
+#if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
+ String m_key;
+#endif
String m_keyIdentifier;
int m_windowsVirtualKeyCode;
#if USE(APPKIT) || PLATFORM(GTK)
Modified: trunk/Source/WebCore/platform/cocoa/KeyEventCocoa.h (206749 => 206750)
--- trunk/Source/WebCore/platform/cocoa/KeyEventCocoa.h 2016-10-03 21:31:15 UTC (rev 206749)
+++ trunk/Source/WebCore/platform/cocoa/KeyEventCocoa.h 2016-10-03 21:32:47 UTC (rev 206750)
@@ -30,6 +30,7 @@
namespace WebCore {
+String keyForCharCode(unichar charCode);
String keyIdentifierForCharCode(unichar charCode);
int windowsKeyCodeForKeyCode(uint16_t keyCode);
Modified: trunk/Source/WebCore/platform/cocoa/KeyEventCocoa.mm (206749 => 206750)
--- trunk/Source/WebCore/platform/cocoa/KeyEventCocoa.mm 2016-10-03 21:31:15 UTC (rev 206749)
+++ trunk/Source/WebCore/platform/cocoa/KeyEventCocoa.mm 2016-10-03 21:32:47 UTC (rev 206750)
@@ -39,6 +39,161 @@
namespace WebCore {
+// https://w3c.github.io/uievents-key/
+String keyForCharCode(unichar charCode)
+{
+ switch (charCode) {
+ case NSUpArrowFunctionKey:
+ return ASCIILiteral("ArrowUp");
+ case NSDownArrowFunctionKey:
+ return ASCIILiteral("ArrowDown");
+ case NSLeftArrowFunctionKey:
+ return ASCIILiteral("ArrowLeft");
+ case NSRightArrowFunctionKey:
+ return ASCIILiteral("ArrowRight");
+ case NSF1FunctionKey:
+ return ASCIILiteral("F1");
+ case NSF2FunctionKey:
+ return ASCIILiteral("F2");
+ case NSF3FunctionKey:
+ return ASCIILiteral("F3");
+ case NSF4FunctionKey:
+ return ASCIILiteral("F4");
+ case NSF5FunctionKey:
+ return ASCIILiteral("F5");
+ case NSF6FunctionKey:
+ return ASCIILiteral("F6");
+ case NSF7FunctionKey:
+ return ASCIILiteral("F7");
+ case NSF8FunctionKey:
+ return ASCIILiteral("F8");
+ case NSF9FunctionKey:
+ return ASCIILiteral("F9");
+ case NSF10FunctionKey:
+ return ASCIILiteral("F10");
+ case NSF11FunctionKey:
+ return ASCIILiteral("F11");
+ case NSF12FunctionKey:
+ return ASCIILiteral("F12");
+ case NSF13FunctionKey:
+ return ASCIILiteral("F13");
+ case NSF14FunctionKey:
+ return ASCIILiteral("F14");
+ case NSF15FunctionKey:
+ return ASCIILiteral("F15");
+ case NSF16FunctionKey:
+ return ASCIILiteral("F16");
+ case NSF17FunctionKey:
+ return ASCIILiteral("F17");
+ case NSF18FunctionKey:
+ return ASCIILiteral("F18");
+ case NSF19FunctionKey:
+ return ASCIILiteral("F19");
+ case NSF20FunctionKey:
+ return ASCIILiteral("F20");
+ case NSF21FunctionKey:
+ return ASCIILiteral("F21");
+ case NSF22FunctionKey:
+ return ASCIILiteral("F22");
+ case NSF23FunctionKey:
+ return ASCIILiteral("F23");
+ case NSF24FunctionKey:
+ return ASCIILiteral("F24");
+ case NSF25FunctionKey:
+ return ASCIILiteral("F25");
+ case NSF26FunctionKey:
+ return ASCIILiteral("F26");
+ case NSF27FunctionKey:
+ return ASCIILiteral("F27");
+ case NSF28FunctionKey:
+ return ASCIILiteral("F28");
+ case NSF29FunctionKey:
+ return ASCIILiteral("F29");
+ case NSF30FunctionKey:
+ return ASCIILiteral("F30");
+ case NSF31FunctionKey:
+ return ASCIILiteral("F31");
+ case NSF32FunctionKey:
+ return ASCIILiteral("F32");
+ case NSF33FunctionKey:
+ return ASCIILiteral("F33");
+ case NSF34FunctionKey:
+ return ASCIILiteral("F34");
+ case NSF35FunctionKey:
+ return ASCIILiteral("F35");
+ case NSInsertFunctionKey:
+ return ASCIILiteral("Insert");
+ case NSDeleteFunctionKey:
+ return ASCIILiteral("Delete");
+ case NSHomeFunctionKey:
+ return ASCIILiteral("Home");
+ case NSEndFunctionKey:
+ return ASCIILiteral("End");
+ case NSPageUpFunctionKey:
+ return ASCIILiteral("PageUp");
+ case NSPageDownFunctionKey:
+ return ASCIILiteral("PageDown");
+ case NSPrintScreenFunctionKey:
+ return ASCIILiteral("PrintScreen");
+ case NSScrollLockFunctionKey:
+ return ASCIILiteral("ScrollLock");
+ case NSPauseFunctionKey:
+ return ASCIILiteral("Pause");
+ case NSMenuFunctionKey:
+ return ASCIILiteral("ContextMenu");
+ case NSPrintFunctionKey:
+ return ASCIILiteral("Print");
+ case NSClearLineFunctionKey:
+ return ASCIILiteral("Clear");
+ case NSSelectFunctionKey:
+ return ASCIILiteral("Select");
+ case NSExecuteFunctionKey:
+ return ASCIILiteral("Execute");
+ case NSUndoFunctionKey:
+ return ASCIILiteral("Undo");
+ case NSRedoFunctionKey:
+ return ASCIILiteral("Redo");
+ case NSFindFunctionKey:
+ return ASCIILiteral("Find");
+ case NSHelpFunctionKey:
+ return ASCIILiteral("Help");
+ case NSModeSwitchFunctionKey:
+ return ASCIILiteral("ModeChange");
+ case NSEnterCharacter:
+ case NSNewlineCharacter:
+ case NSCarriageReturnCharacter:
+ return ASCIILiteral("Enter");
+ case NSDeleteCharacter:
+ case NSBackspaceCharacter:
+ return ASCIILiteral("Backspace");
+ case NSBackTabCharacter:
+ case NSTabCharacter:
+ return ASCIILiteral("Tab");
+ case 0x1B:
+ return ASCIILiteral("Escape");
+ case NSFormFeedCharacter:
+ case NSParagraphSeparatorCharacter:
+ case NSLineSeparatorCharacter:
+ case NSBeginFunctionKey:
+ case NSSysReqFunctionKey:
+ case NSBreakFunctionKey:
+ case NSResetFunctionKey:
+ case NSStopFunctionKey:
+ case NSUserFunctionKey:
+ case NSSystemFunctionKey:
+ case NSClearDisplayFunctionKey:
+ case NSInsertLineFunctionKey:
+ case NSDeleteLineFunctionKey:
+ case NSInsertCharFunctionKey:
+ case NSDeleteCharFunctionKey:
+ case NSPrevFunctionKey:
+ case NSNextFunctionKey:
+ return ASCIILiteral("Unidentified");
+ default:
+ return String(&charCode, 1);
+ }
+}
+
String keyIdentifierForCharCode(unichar charCode)
{
switch (charCode) {
Modified: trunk/Source/WebCore/platform/ios/PlatformEventFactoryIOS.h (206749 => 206750)
--- trunk/Source/WebCore/platform/ios/PlatformEventFactoryIOS.h 2016-10-03 21:31:15 UTC (rev 206749)
+++ trunk/Source/WebCore/platform/ios/PlatformEventFactoryIOS.h 2016-10-03 21:32:47 UTC (rev 206750)
@@ -49,6 +49,7 @@
#endif
};
+WEBCORE_EXPORT String keyForKeyEvent(WebEvent *);
WEBCORE_EXPORT String keyIdentifierForKeyEvent(WebEvent *);
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/ios/PlatformEventFactoryIOS.mm (206749 => 206750)
--- trunk/Source/WebCore/platform/ios/PlatformEventFactoryIOS.mm 2016-10-03 21:31:15 UTC (rev 206749)
+++ trunk/Source/WebCore/platform/ios/PlatformEventFactoryIOS.mm 2016-10-03 21:32:47 UTC (rev 206750)
@@ -129,6 +129,23 @@
return keyIdentifierForCharCode(CFStringGetCharacterAtIndex((CFStringRef)s, 0));
}
+String keyForKeyEvent(WebEvent *event)
+{
+ NSString *characters = event.characters;
+ auto length = [characters length];
+
+ // characters return an empty string for dead keys.
+ // https://developer.apple.com/reference/appkit/nsevent/1534183-characters
+ // "Dead" is defined here https://w3c.github.io/uievents-key/#keys-composition.
+ if (!length)
+ return ASCIILiteral("Dead");
+
+ if (length > 1)
+ return characters;
+
+ return keyForCharCode([characters characterAtIndex:0]);
+}
+
class PlatformKeyboardEventBuilder : public PlatformKeyboardEvent {
public:
PlatformKeyboardEventBuilder(WebEvent *event)
@@ -141,6 +158,7 @@
m_text = event.characters;
m_unmodifiedText = event.charactersIgnoringModifiers;
+ m_key = keyForKeyEvent(event);
m_keyIdentifier = keyIdentifierForKeyEvent(event);
m_windowsVirtualKeyCode = event.keyCode;
m_autoRepeat = event.isKeyRepeating;
Modified: trunk/Source/WebCore/platform/mac/PlatformEventFactoryMac.h (206749 => 206750)
--- trunk/Source/WebCore/platform/mac/PlatformEventFactoryMac.h 2016-10-03 21:31:15 UTC (rev 206749)
+++ trunk/Source/WebCore/platform/mac/PlatformEventFactoryMac.h 2016-10-03 21:32:47 UTC (rev 206750)
@@ -46,6 +46,7 @@
// FIXME: WebKit2 has a lot of code copied and pasted from PlatformEventFactoryMac in WebEventFactory. More of it should be shared with WebCore.
WEBCORE_EXPORT int windowsKeyCodeForKeyEvent(NSEvent *);
WEBCORE_EXPORT String keyIdentifierForKeyEvent(NSEvent *);
+WEBCORE_EXPORT String keyForKeyEvent(NSEvent *);
WEBCORE_EXPORT double eventTimeStampSince1970(NSEvent *);
#endif
Modified: trunk/Source/WebCore/platform/mac/PlatformEventFactoryMac.mm (206749 => 206750)
--- trunk/Source/WebCore/platform/mac/PlatformEventFactoryMac.mm 2016-10-03 21:31:15 UTC (rev 206749)
+++ trunk/Source/WebCore/platform/mac/PlatformEventFactoryMac.mm 2016-10-03 21:32:47 UTC (rev 206750)
@@ -33,6 +33,7 @@
#import "Scrollbar.h"
#import "WebCoreSystemInterface.h"
#import "WindowsKeyboardCodes.h"
+#import <HIToolbox/Events.h>
#import <mach/mach_time.h>
#import <wtf/ASCIICType.h>
@@ -220,10 +221,11 @@
static inline String textFromEvent(NSEvent* event)
{
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
+ if ([event type] == NSEventTypeFlagsChanged)
+#else
if ([event type] == NSFlagsChanged)
-#pragma clang diagnostic pop
+#endif
return emptyString();
return String([event characters]);
}
@@ -230,20 +232,67 @@
static inline String unmodifiedTextFromEvent(NSEvent* event)
{
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
+ if ([event type] == NSEventTypeFlagsChanged)
+#else
if ([event type] == NSFlagsChanged)
-#pragma clang diagnostic pop
+#endif
return emptyString();
return String([event charactersIgnoringModifiers]);
}
+String keyForKeyEvent(NSEvent *event)
+{
+ // This constant was missing before OS X Sierra.
+#ifndef kVK_RightCommand
+#define kVK_RightCommand 0x36
+#endif
+ switch ([event keyCode]) {
+ case kVK_RightCommand:
+ case kVK_Command:
+ return ASCIILiteral("Meta");
+ case kVK_Shift:
+ case kVK_RightShift:
+ return ASCIILiteral("Shift");
+ case kVK_CapsLock:
+ return ASCIILiteral("CapsLock");
+ case kVK_Option: // Left Alt.
+ case kVK_RightOption: // Right Alt.
+ return ASCIILiteral("Alt");
+ case kVK_Control:
+ case kVK_RightControl:
+ return ASCIILiteral("Control");
+ }
+
+ // If more than one key is being pressed and the key combination includes one or more modifier keys
+ // that result in the key no longer producing a printable character (e.g., Control + a), then the
+ // key value should be the printable key value that would have been produced if the key had been
+ // typed with the default keyboard layout with no modifier keys except for Shift and AltGr applied.
+ // https://w3c.github.io/uievents/#keys-guidelines
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
+ bool isControlDown = ([event modifierFlags] & NSEventModifierFlagControl);
+#else
+ bool isControlDown = ([event modifierFlags] & NSControlKeyMask);
+#endif
+ NSString *s = isControlDown ? [event charactersIgnoringModifiers] : [event characters];
+ auto length = [s length];
+ // characters / charactersIgnoringModifiers return an empty string for dead keys.
+ // https://developer.apple.com/reference/appkit/nsevent/1534183-characters
+ if (!length)
+ return ASCIILiteral("Dead");
+ // High unicode codepoints are coded with a character sequence in Mac OS X.
+ if (length > 1)
+ return s;
+ return keyForCharCode([s characterAtIndex:0]);
+}
+
String keyIdentifierForKeyEvent(NSEvent* event)
{
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- if ([event type] == NSFlagsChanged)
-#pragma clang diagnostic pop
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
+ if ([event type] == NSEventTypeFlagsChanged) {
+#else
+ if ([event type] == NSFlagsChanged) {
+#endif
switch ([event keyCode]) {
case 54: // Right Command
case 55: // Left Command
@@ -268,6 +317,7 @@
ASSERT_NOT_REACHED();
return emptyString();
}
+ }
NSString *s = [event charactersIgnoringModifiers];
if ([s length] != 1) {
@@ -561,6 +611,7 @@
m_text = textFromEvent(event);
m_unmodifiedText = unmodifiedTextFromEvent(event);
m_keyIdentifier = keyIdentifierForKeyEvent(event);
+ m_key = keyForKeyEvent(event);
m_windowsVirtualKeyCode = windowsKeyCodeForKeyEvent(event);
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
Modified: trunk/Source/WebCore/replay/SerializationMethods.cpp (206749 => 206750)
--- trunk/Source/WebCore/replay/SerializationMethods.cpp 2016-10-03 21:31:15 UTC (rev 206749)
+++ trunk/Source/WebCore/replay/SerializationMethods.cpp 2016-10-03 21:32:47 UTC (rev 206750)
@@ -256,6 +256,9 @@
ENCODE_TYPE_WITH_KEY(encodedValue, PlatformEvent::Modifier, modifiers, input.modifiers());
ENCODE_TYPE_WITH_KEY(encodedValue, String, text, input.text());
ENCODE_TYPE_WITH_KEY(encodedValue, String, unmodifiedText, input.unmodifiedText());
+#if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
+ ENCODE_TYPE_WITH_KEY(encodedValue, String, key, input.key());
+#endif
ENCODE_TYPE_WITH_KEY(encodedValue, String, keyIdentifier, input.keyIdentifier());
ENCODE_TYPE_WITH_KEY(encodedValue, int, windowsVirtualKeyCode, input.windowsVirtualKeyCode());
ENCODE_TYPE_WITH_KEY(encodedValue, bool, autoRepeat, input.isAutoRepeat());
@@ -275,6 +278,9 @@
DECODE_TYPE_WITH_KEY(encodedValue, PlatformEvent::Modifier, modifiers);
DECODE_TYPE_WITH_KEY(encodedValue, String, text);
DECODE_TYPE_WITH_KEY(encodedValue, String, unmodifiedText);
+#if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
+ DECODE_TYPE_WITH_KEY(encodedValue, String, key);
+#endif
DECODE_TYPE_WITH_KEY(encodedValue, String, keyIdentifier);
DECODE_TYPE_WITH_KEY(encodedValue, int, windowsVirtualKeyCode);
DECODE_TYPE_WITH_KEY(encodedValue, bool, autoRepeat);
@@ -285,7 +291,12 @@
DECODE_TYPE_WITH_KEY(encodedValue, Vector<KeypressCommand>, commands);
#endif
- PlatformKeyboardEvent platformEvent = PlatformKeyboardEvent(type, text, unmodifiedText, keyIdentifier, WTF::safeCast<int>(windowsVirtualKeyCode), autoRepeat, keypad, systemKey, modifiers, timestamp);
+ PlatformKeyboardEvent platformEvent = PlatformKeyboardEvent(type, text, unmodifiedText,
+#if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
+ key,
+#endif
+ keyIdentifier, WTF::safeCast<int>(windowsVirtualKeyCode), autoRepeat, keypad, systemKey, modifiers, timestamp);
+
#if USE(APPKIT)
input = std::make_unique<PlatformKeyboardEventAppKit>(platformEvent, handledByInputMethod, commands);
#else
Modified: trunk/Source/WebKit2/ChangeLog (206749 => 206750)
--- trunk/Source/WebKit2/ChangeLog 2016-10-03 21:31:15 UTC (rev 206749)
+++ trunk/Source/WebKit2/ChangeLog 2016-10-03 21:32:47 UTC (rev 206750)
@@ -1,3 +1,45 @@
+2016-10-03 Chris Dumez <[email protected]>
+
+ Add support for KeyboardEvent.key attribute
+ https://bugs.webkit.org/show_bug.cgi?id=36267
+
+ Reviewed by Darin Adler.
+
+ Add support for KeyboardEvent.key attribute.
+
+ * Shared/WebEvent.h:
+ (WebKit::WebKeyboardEvent::key):
+ (WebKit::WebKeyboardEvent::unmodifiedText): Deleted.
+ * Shared/WebEventConversion.cpp:
+ (WebKit::WebKit2PlatformKeyboardEvent::WebKit2PlatformKeyboardEvent):
+ * Shared/WebKeyboardEvent.cpp:
+ (WebKit::WebKeyboardEvent::WebKeyboardEvent):
+ (WebKit::WebKeyboardEvent::encode):
+ (WebKit::WebKeyboardEvent::decode):
+ * Shared/mac/WebEventFactory.mm:
+ (WebKit::WebEventFactory::createWebKeyboardEvent):
+
+2016-10-03 Chris Dumez <[email protected]>
+
+ Add support for KeyboardEvent.key attribute
+ https://bugs.webkit.org/show_bug.cgi?id=36267
+
+ Reviewed by Darin Adler.
+
+ Add support for KeyboardEvent.key attribute.
+
+ * Shared/WebEvent.h:
+ (WebKit::WebKeyboardEvent::key):
+ (WebKit::WebKeyboardEvent::unmodifiedText): Deleted.
+ * Shared/WebEventConversion.cpp:
+ (WebKit::WebKit2PlatformKeyboardEvent::WebKit2PlatformKeyboardEvent):
+ * Shared/WebKeyboardEvent.cpp:
+ (WebKit::WebKeyboardEvent::WebKeyboardEvent):
+ (WebKit::WebKeyboardEvent::encode):
+ (WebKit::WebKeyboardEvent::decode):
+ * Shared/mac/WebEventFactory.mm:
+ (WebKit::WebEventFactory::createWebKeyboardEvent):
+
2016-10-03 Carlos Garcia Campos <[email protected]>
[SOUP] Cleanup persistent credential storage code
Modified: trunk/Source/WebKit2/Shared/WebEvent.h (206749 => 206750)
--- trunk/Source/WebKit2/Shared/WebEvent.h 2016-10-03 21:31:15 UTC (rev 206749)
+++ trunk/Source/WebKit2/Shared/WebEvent.h 2016-10-03 21:32:47 UTC (rev 206750)
@@ -244,7 +244,7 @@
~WebKeyboardEvent();
#if USE(APPKIT)
- WebKeyboardEvent(Type, const String& text, const String& unmodifiedText, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, int macCharCode, bool handledByInputMethod, const Vector<WebCore::KeypressCommand>&, bool isAutoRepeat, bool isKeypad, bool isSystemKey, Modifiers, double timestamp);
+ WebKeyboardEvent(Type, const String& text, const String& unmodifiedText, const String& key, 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& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool handledByInputMethod, Vector<String>&& commands, bool isKeypad, Modifiers, double timestamp);
#else
@@ -253,6 +253,9 @@
const String& text() const { return m_text; }
const String& unmodifiedText() const { return m_unmodifiedText; }
+#if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
+ const String& key() const { return m_key; }
+#endif
const String& keyIdentifier() const { return m_keyIdentifier; }
int32_t windowsVirtualKeyCode() const { return m_windowsVirtualKeyCode; }
int32_t nativeVirtualKeyCode() const { return m_nativeVirtualKeyCode; }
@@ -277,6 +280,9 @@
private:
String m_text;
String m_unmodifiedText;
+#if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
+ String m_key;
+#endif
String m_keyIdentifier;
int32_t m_windowsVirtualKeyCode;
int32_t m_nativeVirtualKeyCode;
Modified: trunk/Source/WebKit2/Shared/WebEventConversion.cpp (206749 => 206750)
--- trunk/Source/WebKit2/Shared/WebEventConversion.cpp 2016-10-03 21:31:15 UTC (rev 206749)
+++ trunk/Source/WebKit2/Shared/WebEventConversion.cpp 2016-10-03 21:32:47 UTC (rev 206750)
@@ -191,6 +191,9 @@
// PlatformKeyboardEvent
m_text = webEvent.text();
m_unmodifiedText = webEvent.unmodifiedText();
+#if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
+ m_key = webEvent.key();
+#endif
m_keyIdentifier = webEvent.keyIdentifier();
m_windowsVirtualKeyCode = webEvent.windowsVirtualKeyCode();
#if USE(APPKIT) || PLATFORM(GTK)
Modified: trunk/Source/WebKit2/Shared/WebKeyboardEvent.cpp (206749 => 206750)
--- trunk/Source/WebKit2/Shared/WebKeyboardEvent.cpp 2016-10-03 21:31:15 UTC (rev 206749)
+++ trunk/Source/WebKit2/Shared/WebKeyboardEvent.cpp 2016-10-03 21:32:47 UTC (rev 206750)
@@ -37,10 +37,11 @@
#if USE(APPKIT)
-WebKeyboardEvent::WebKeyboardEvent(Type type, const String& text, const String& unmodifiedText, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, int macCharCode, bool handledByInputMethod, const Vector<WebCore::KeypressCommand>& commands, 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& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, int macCharCode, bool handledByInputMethod, const Vector<WebCore::KeypressCommand>& commands, 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)
@@ -102,6 +103,9 @@
encoder << m_text;
encoder << m_unmodifiedText;
+#if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
+ encoder << m_key;
+#endif
encoder << m_keyIdentifier;
encoder << m_windowsVirtualKeyCode;
encoder << m_nativeVirtualKeyCode;
@@ -124,6 +128,10 @@
return false;
if (!decoder.decode(result.m_unmodifiedText))
return false;
+#if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
+ if (!decoder.decode(result.m_key))
+ return false;
+#endif
if (!decoder.decode(result.m_keyIdentifier))
return false;
if (!decoder.decode(result.m_windowsVirtualKeyCode))
Modified: trunk/Source/WebKit2/Shared/mac/WebEventFactory.mm (206749 => 206750)
--- trunk/Source/WebKit2/Shared/mac/WebEventFactory.mm 2016-10-03 21:31:15 UTC (rev 206749)
+++ trunk/Source/WebKit2/Shared/mac/WebEventFactory.mm 2016-10-03 21:32:47 UTC (rev 206750)
@@ -466,6 +466,7 @@
WebEvent::Type type = isKeyUpEvent(event) ? WebEvent::KeyUp : WebEvent::KeyDown;
String text = textFromEvent(event, replacesSoftSpace);
String unmodifiedText = unmodifiedTextFromEvent(event, replacesSoftSpace);
+ String key = keyForKeyEvent(event);
String keyIdentifier = keyIdentifierForKeyEvent(event);
int windowsVirtualKeyCode = windowsKeyCodeForKeyEvent(event);
int nativeVirtualKeyCode = [event keyCode];
@@ -497,7 +498,7 @@
unmodifiedText = "\x9";
}
- return WebKeyboardEvent(type, text, unmodifiedText, keyIdentifier, windowsVirtualKeyCode, nativeVirtualKeyCode, macCharCode, handledByInputMethod, commands, autoRepeat, isKeypad, isSystemKey, modifiers, timestamp);
+ return WebKeyboardEvent(type, text, unmodifiedText, key, keyIdentifier, windowsVirtualKeyCode, nativeVirtualKeyCode, macCharCode, handledByInputMethod, commands, autoRepeat, isKeypad, isSystemKey, modifiers, timestamp);
}
} // namespace WebKit