Title: [206803] trunk
Revision
206803
Author
cdu...@apple.com
Date
2016-10-04 20:13:35 -0700 (Tue, 04 Oct 2016)

Log Message

Implement KeyboardEvent.code from the UI Event spec
https://bugs.webkit.org/show_bug.cgi?id=149584

Reviewed by Darin Adler.

LayoutTests/imported/w3c:

Rebaseline W3C test now that more checks are passing.

* web-platform-tests/dom/events/Event-subclasses-constructors-expected.txt:

Source/WebCore:

Add support for Keyboard.code attribute:
- https://w3c.github.io/uievents/#dom-keyboardevent-code
- https://w3c.github.io/uievents-code/

The feature is only enabled on Mac for now as the implementation is
platform-specific and Mac only.

Test: fast/events/keyboardevent-code.html

* dom/KeyboardEvent.cpp:
(WebCore::KeyboardEvent::KeyboardEvent):
* dom/KeyboardEvent.h:
* dom/KeyboardEvent.idl:
* platform/PlatformKeyboardEvent.h:
(WebCore::PlatformKeyboardEvent::PlatformKeyboardEvent):
(WebCore::PlatformKeyboardEvent::code):
(WebCore::PlatformKeyboardEvent::unmodifiedText): Deleted.
* platform/mac/PlatformEventFactoryMac.h:
* platform/mac/PlatformEventFactoryMac.mm:
(WebCore::codeForKeyEvent):
(WebCore::keyIdentifierForKeyEvent):
* replay/SerializationMethods.cpp:
(JSC::EncodingTraits<PlatformKeyboardEvent>::encodeValue):
(JSC::EncodingTraits<PlatformKeyboardEvent>::decodeValue):

Source/WebKit2:

Add support for Keyboard.code attribute:
- https://w3c.github.io/uievents/#dom-keyboardevent-code
- https://w3c.github.io/uievents-code/

* Shared/WebEvent.h:
(WebKit::WebKeyboardEvent::code):
* 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):

Source/WTF:

Add build time flag to toggle support for the code attribute on
KeyboardEvent and only enable it on Mac for now, given that the
implementation is missing on other platforms.

* wtf/FeatureDefines.h:

LayoutTests:

Extend layout test coverage.

* fast/events/arrow-keys-on-body-expected.txt:
* fast/events/arrow-keys-on-body.html:
* 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-code-expected.txt: Added.
* fast/events/keyboardevent-code.html: Added.
* fast/events/special-key-events-in-input-text-expected.txt:
* fast/events/special-key-events-in-input-text.html:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (206802 => 206803)


--- trunk/LayoutTests/ChangeLog	2016-10-05 01:52:35 UTC (rev 206802)
+++ trunk/LayoutTests/ChangeLog	2016-10-05 03:13:35 UTC (rev 206803)
@@ -1,3 +1,25 @@
+2016-10-04  Chris Dumez  <cdu...@apple.com>
+
+        Implement KeyboardEvent.code from the UI Event spec
+        https://bugs.webkit.org/show_bug.cgi?id=149584
+
+        Reviewed by Darin Adler.
+
+        Extend layout test coverage.
+
+        * fast/events/arrow-keys-on-body-expected.txt:
+        * fast/events/arrow-keys-on-body.html:
+        * 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-code-expected.txt: Added.
+        * fast/events/keyboardevent-code.html: Added.
+        * fast/events/special-key-events-in-input-text-expected.txt:
+        * fast/events/special-key-events-in-input-text.html:
+
 2016-10-04  Simon Fraser  <simon.fra...@apple.com>
 
         [iOS WK2] Make it possible for a test to describe a user gesture as a stream of events in JSON format

Modified: trunk/LayoutTests/fast/events/arrow-keys-on-body-expected.txt (206802 => 206803)


--- trunk/LayoutTests/fast/events/arrow-keys-on-body-expected.txt	2016-10-05 01:52:35 UTC (rev 206802)
+++ trunk/LayoutTests/fast/events/arrow-keys-on-body-expected.txt	2016-10-05 03:13:35 UTC (rev 206803)
@@ -2,7 +2,7 @@
 
 To test manually, press arrow keys and verify that no keypress events are logged.
 
-target - type - ctrlKey,altKey,shiftKey,metaKey - keyIdentifier - location - keyCode - charCode
-BODY - keydown - false,false,false,false - Left - DOM_KEY_LOCATION_STANDARD - 37 - 0
-BODY - keyup - false,false,false,false - Left - DOM_KEY_LOCATION_STANDARD - 37 - 0
+target - type - ctrlKey,altKey,shiftKey,metaKey - key - code - keyIdentifier - location - keyCode - charCode
+BODY - keydown - false,false,false,false - ArrowLeft - ArrowLeft - Left - DOM_KEY_LOCATION_STANDARD - 37 - 0
+BODY - keyup - false,false,false,false - ArrowLeft - ArrowLeft - Left - DOM_KEY_LOCATION_STANDARD - 37 - 0
 

Modified: trunk/LayoutTests/fast/events/arrow-keys-on-body.html (206802 => 206803)


--- trunk/LayoutTests/fast/events/arrow-keys-on-body.html	2016-10-05 01:52:35 UTC (rev 206802)
+++ trunk/LayoutTests/fast/events/arrow-keys-on-body.html	2016-10-05 03:13:35 UTC (rev 206803)
@@ -40,6 +40,8 @@
             + (target.tagName == "INPUT" ? " " + target.type : "")
             + " - " + event.type
             + ' - ' + [event.ctrlKey, event.altKey, event.shiftKey, event.metaKey]
+            + ' - ' + event.key
+            + ' - ' + event.code
             + ' - ' + event.keyIdentifier
             + ' - ' + (event.location === undefined ? "undefined" : locationName(event.location))
             + ' - ' + event.keyCode
@@ -50,6 +52,8 @@
     }
 }
 log("target - type - " + ["ctrlKey", "altKey", "shiftKey", "metaKey"]
+        + ' - ' + "key"
+        + ' - ' + "code"
         + ' - ' + "keyIdentifier"
         + ' - ' + "location"
         + ' - ' + "keyCode"

Modified: trunk/LayoutTests/fast/events/constructors/keyboard-event-constructor-expected.txt (206802 => 206803)


--- trunk/LayoutTests/fast/events/constructors/keyboard-event-constructor-expected.txt	2016-10-05 01:52:35 UTC (rev 206802)
+++ trunk/LayoutTests/fast/events/constructors/keyboard-event-constructor-expected.txt	2016-10-05 03:13:35 UTC (rev 206803)
@@ -106,17 +106,18 @@
 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, 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 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 }).bubbles is true
+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 }).cancelable is true
+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"
+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
+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 }).altKey is true
+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 }).shiftKey is true
+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 }).metaKey is true
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/fast/events/constructors/keyboard-event-constructor.html (206802 => 206803)


--- trunk/LayoutTests/fast/events/constructors/keyboard-event-constructor.html	2016-10-05 01:52:35 UTC (rev 206802)
+++ trunk/LayoutTests/fast/events/constructors/keyboard-event-constructor.html	2016-10-05 03:13:35 UTC (rev 206803)
@@ -122,17 +122,18 @@
 });
 
 // All initializers are passed.
-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");
+shouldBe("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 }).bubbles", "true");
+shouldBe("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 }).cancelable", "true");
+shouldBe("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", "window");
+shouldBe("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", "111");
+shouldBeEqualToString("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", "a");
+shouldBeEqualToString("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", "KeyA");
+shouldBeEqualToString("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", "chocolate");
+shouldBe("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", "222");
+shouldBe("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", "true");
+shouldBe("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 }).altKey", "true");
+shouldBe("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 }).shiftKey", "true");
+shouldBe("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 }).metaKey", "true");
 </script>
 <script src=""
 </body>

Modified: trunk/LayoutTests/fast/events/key-events-in-input-button-expected.txt (206802 => 206803)


--- trunk/LayoutTests/fast/events/key-events-in-input-button-expected.txt	2016-10-05 01:52:35 UTC (rev 206802)
+++ trunk/LayoutTests/fast/events/key-events-in-input-button-expected.txt	2016-10-05 03:13:35 UTC (rev 206803)
@@ -1,19 +1,19 @@
 To test manually, press keys and compare results to other browsers.
 
 
-target - type - ctrlKey,altKey,shiftKey,metaKey - key - keyIdentifier - keyCode - charCode
+target - type - ctrlKey,altKey,shiftKey,metaKey - key - code - 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 - - Space - U+0020 - 32 - 0
+INPUT - keypress - false,false,false,false - - Space - - 32 - 32
+INPUT - keyup - false,false,false,false - - Space - U+0020 - 32 - 0
 INPUT - click
 Enter:
-INPUT - keydown - false,false,false,false - Enter - Enter - 13 - 0
-INPUT - keypress - false,false,false,false - Enter - - 13 - 13
+INPUT - keydown - false,false,false,false - Enter - Enter - Enter - 13 - 0
+INPUT - keypress - false,false,false,false - Enter - Enter - - 13 - 13
 INPUT - click
-INPUT - keyup - false,false,false,false - Enter - Enter - 13 - 0
+INPUT - keyup - false,false,false,false - Enter - Enter - Enter - 13 - 0
 A:
-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
+INPUT - keydown - false,false,true,false - A - KeyA - U+0041 - 65 - 0
+INPUT - keypress - false,false,true,false - A - KeyA - - 65 - 65
+INPUT - keyup - false,false,true,false - A - KeyA - U+0041 - 65 - 0
 

Modified: trunk/LayoutTests/fast/events/key-events-in-input-button.html (206802 => 206803)


--- trunk/LayoutTests/fast/events/key-events-in-input-button.html	2016-10-05 01:52:35 UTC (rev 206802)
+++ trunk/LayoutTests/fast/events/key-events-in-input-button.html	2016-10-05 03:13:35 UTC (rev 206803)
@@ -24,6 +24,7 @@
         return (where ? "(" + where + ") " : "") + target.tagName + " - " + event.type
             + ' - ' + [event.ctrlKey, event.altKey, event.shiftKey, event.metaKey]
             + ' - ' + event.key
+            + ' - ' + event.code
             + ' - ' + event.keyIdentifier
             + ' - ' + event.keyCode
             + ' - ' + event.charCode;
@@ -36,6 +37,7 @@
 }
 log("target - type - " + ["ctrlKey", "altKey", "shiftKey", "metaKey"]
         + ' - ' + "key"
+        + ' - ' + "code"
         + ' - ' + "keyIdentifier"
         + ' - ' + "keyCode"
         + ' - ' + "charCode");

Modified: trunk/LayoutTests/fast/events/key-events-in-input-text-expected.txt (206802 => 206803)


--- trunk/LayoutTests/fast/events/key-events-in-input-text-expected.txt	2016-10-05 01:52:35 UTC (rev 206802)
+++ trunk/LayoutTests/fast/events/key-events-in-input-text-expected.txt	2016-10-05 03:13:35 UTC (rev 206803)
@@ -1,18 +1,18 @@
 To test manually, press keys and compare results to other browsers.
 
   
-target - type - ctrlKey,altKey,shiftKey,metaKey - key - keyIdentifier - keyCode - charCode
+target - type - ctrlKey,altKey,shiftKey,metaKey - key - code - 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 - - Space - U+0020 - 32 - 0. Value: "".
+INPUT - keypress - false,false,false,false - - Space - - 32 - 32. Value: "".
 INPUT - textInput - . Value: "".
-INPUT - keyup - false,false,false,false - - U+0020 - 32 - 0. Value: " ".
+INPUT - keyup - false,false,false,false - - Space - U+0020 - 32 - 0. Value: " ".
 Backspace:
-INPUT - keydown - false,false,false,false - Backspace - U+0008 - 8 - 0. Value: " ".
-INPUT - keyup - false,false,false,false - Backspace - U+0008 - 8 - 0. Value: "".
+INPUT - keydown - false,false,false,false - Backspace - Backspace - U+0008 - 8 - 0. Value: " ".
+INPUT - keyup - false,false,false,false - Backspace - Backspace - U+0008 - 8 - 0. Value: "".
 Left Arrow:
-INPUT - keydown - false,false,false,false - ArrowLeft - Left - 37 - 0. Value: "".
-INPUT - keyup - false,false,false,false - ArrowLeft - Left - 37 - 0. Value: "".
+INPUT - keydown - false,false,false,false - ArrowLeft - ArrowLeft - Left - 37 - 0. Value: "".
+INPUT - keyup - false,false,false,false - ArrowLeft - ArrowLeft - Left - 37 - 0. Value: "".
 Tab:
-INPUT - keydown - false,false,false,false - Tab - U+0009 - 9 - 0. Value: "".
+INPUT - keydown - false,false,false,false - Tab - Tab - U+0009 - 9 - 0. Value: "".
 

Modified: trunk/LayoutTests/fast/events/key-events-in-input-text.html (206802 => 206803)


--- trunk/LayoutTests/fast/events/key-events-in-input-text.html	2016-10-05 01:52:35 UTC (rev 206802)
+++ trunk/LayoutTests/fast/events/key-events-in-input-text.html	2016-10-05 03:13:35 UTC (rev 206803)
@@ -26,6 +26,7 @@
         return (where ? "(" + where + ") " : "") + target.tagName + " - " + event.type
             + ' - ' + [event.ctrlKey, event.altKey, event.shiftKey, event.metaKey]
             + ' - ' + event.key
+            + ' - ' + event.code
             + ' - ' + event.keyIdentifier
             + ' - ' + event.keyCode
             + ' - ' + event.charCode
@@ -40,6 +41,7 @@
 }
 log("target - type - " + ["ctrlKey", "altKey", "shiftKey", "metaKey"]
         + ' - ' + "key"
+        + ' - ' + "code"
         + ' - ' + "keyIdentifier"
         + ' - ' + "keyCode"
         + ' - ' + "charCode");

Added: trunk/LayoutTests/fast/events/keyboardevent-code-expected.txt (0 => 206803)


--- trunk/LayoutTests/fast/events/keyboardevent-code-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/events/keyboardevent-code-expected.txt	2016-10-05 03:13:35 UTC (rev 206803)
@@ -0,0 +1,190 @@
+Test the code attribute on KeyboardEvent.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+
+* keydown
+PASS keyboardEvent.code is "Space"
+* keyup
+PASS keyboardEvent.code is "Space"
+
+* keydown
+PASS keyboardEvent.code is "KeyA"
+* keyup
+PASS keyboardEvent.code is "KeyA"
+
+* keydown
+PASS keyboardEvent.code is "Backspace"
+* keyup
+PASS keyboardEvent.code is "Backspace"
+
+* keydown
+PASS keyboardEvent.code is "Minus"
+* keyup
+PASS keyboardEvent.code is "Minus"
+
+* keydown
+PASS keyboardEvent.code is "ArrowLeft"
+* keyup
+PASS keyboardEvent.code is "ArrowLeft"
+
+* keydown
+PASS keyboardEvent.code is "ArrowRight"
+* keyup
+PASS keyboardEvent.code is "ArrowRight"
+
+* keydown
+PASS keyboardEvent.code is "ArrowUp"
+* keyup
+PASS keyboardEvent.code is "ArrowUp"
+
+* keydown
+PASS keyboardEvent.code is "ArrowDown"
+* keyup
+PASS keyboardEvent.code is "ArrowDown"
+
+* keydown
+PASS keyboardEvent.code is "PageUp"
+* keyup
+PASS keyboardEvent.code is "PageUp"
+
+* keydown
+PASS keyboardEvent.code is "PageDown"
+* keyup
+PASS keyboardEvent.code is "PageDown"
+
+* keydown
+PASS keyboardEvent.code is "Home"
+* keyup
+PASS keyboardEvent.code is "Home"
+
+* keydown
+PASS keyboardEvent.code is "End"
+* keyup
+PASS keyboardEvent.code is "End"
+
+* keydown
+PASS keyboardEvent.code is "Delete"
+* keyup
+PASS keyboardEvent.code is "Delete"
+
+* keydown
+PASS keyboardEvent.code is "ControlLeft"
+* keyup
+PASS keyboardEvent.code is "ControlLeft"
+
+* keydown
+PASS keyboardEvent.code is "ShiftLeft"
+* keyup
+PASS keyboardEvent.code is "ShiftLeft"
+
+* keydown
+PASS keyboardEvent.code is "AltLeft"
+* keyup
+PASS keyboardEvent.code is "AltLeft"
+
+* keydown
+PASS keyboardEvent.code is "ControlRight"
+* keyup
+PASS keyboardEvent.code is "ControlRight"
+
+* keydown
+PASS keyboardEvent.code is "ShiftRight"
+* keyup
+PASS keyboardEvent.code is "ShiftRight"
+
+* keydown
+PASS keyboardEvent.code is "AltRight"
+* keyup
+PASS keyboardEvent.code is "AltRight"
+
+* keydown
+PASS keyboardEvent.code is "F1"
+* keyup
+PASS keyboardEvent.code is "F1"
+
+* keydown
+PASS keyboardEvent.code is "F2"
+* keyup
+PASS keyboardEvent.code is "F2"
+
+* keydown
+PASS keyboardEvent.code is "F3"
+* keyup
+PASS keyboardEvent.code is "F3"
+
+* keydown
+PASS keyboardEvent.code is "F4"
+* keyup
+PASS keyboardEvent.code is "F4"
+
+* keydown
+PASS keyboardEvent.code is "F5"
+* keyup
+PASS keyboardEvent.code is "F5"
+
+* keydown
+PASS keyboardEvent.code is "F6"
+* keyup
+PASS keyboardEvent.code is "F6"
+
+* keydown
+PASS keyboardEvent.code is "F7"
+* keyup
+PASS keyboardEvent.code is "F7"
+
+* keydown
+PASS keyboardEvent.code is "F8"
+* keyup
+PASS keyboardEvent.code is "F8"
+
+* keydown
+PASS keyboardEvent.code is "F9"
+* keyup
+PASS keyboardEvent.code is "F9"
+
+* keydown
+PASS keyboardEvent.code is "F10"
+* keyup
+PASS keyboardEvent.code is "F10"
+
+* keydown
+PASS keyboardEvent.code is "F11"
+* keyup
+PASS keyboardEvent.code is "F11"
+
+* keydown
+PASS keyboardEvent.code is "F12"
+* keyup
+PASS keyboardEvent.code is "F12"
+
+* keydown
+PASS keyboardEvent.code is "NumpadEnter"
+* keyup
+PASS keyboardEvent.code is "NumpadEnter"
+
+* keydown
+PASS keyboardEvent.code is "KeyA"
+* keyup
+PASS keyboardEvent.code is "KeyA"
+
+* keydown
+PASS keyboardEvent.code is "KeyA"
+* keyup
+PASS keyboardEvent.code is "KeyA"
+
+* keydown
+PASS keyboardEvent.code is "KeyA"
+* keyup
+PASS keyboardEvent.code is "KeyA"
+
+* keydown
+PASS keyboardEvent.code is "Digit1"
+* keyup
+PASS keyboardEvent.code is "Digit1"
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/events/keyboardevent-code.html (0 => 206803)


--- trunk/LayoutTests/fast/events/keyboardevent-code.html	                        (rev 0)
+++ trunk/LayoutTests/fast/events/keyboardevent-code.html	2016-10-05 03:13:35 UTC (rev 206803)
@@ -0,0 +1,61 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<input type="text" id="testInput">
+<script>
+description("Test the code attribute on KeyboardEvent.");
+
+var expectedCode;
+
+function testEvent(event)
+{
+    keyboardEvent = event;
+    debug("* " + event.type);
+    shouldBeEqualToString("keyboardEvent.code", "" + expectedCode);
+}
+
+var input = document.getElementById("testInput");
+input._onkeydown_ = testEvent;
+input._onkeyup_ = testEvent;
+input.focus();
+
+function sendKeyAndTest(key, modifiers, expected)
+{
+    debug("");
+    expectedCode = expected;
+    eventSender.keyDown(key, []);
+}
+
+sendKeyAndTest(" ", [], "Space");
+sendKeyAndTest("a", [], "KeyA");
+sendKeyAndTest("\x08", [], "Backspace");
+sendKeyAndTest("\x1B", [], "Minus");
+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("delete", [], "Delete");
+sendKeyAndTest("leftControl", ["ctrlKey"], "ControlLeft");
+sendKeyAndTest("leftShift", ["shiftKey"], "ShiftLeft");
+sendKeyAndTest("leftAlt", ["altKey"], "AltLeft");
+sendKeyAndTest("rightControl", ["ctrlKey"], "ControlRight");
+sendKeyAndTest("rightShift", ["shiftKey"], "ShiftRight");
+sendKeyAndTest("rightAlt", ["altKey"], "AltRight");
+for (var i = 1; i <= 12; i++)
+    sendKeyAndTest("F" + i, [], "F" + i);
+sendKeyAndTest("\n", [], "NumpadEnter");
+sendKeyAndTest("A", [], "KeyA");
+sendKeyAndTest("a", ["ctrlKey"], "KeyA");
+sendKeyAndTest("a", ["metaKey"], "KeyA");
+sendKeyAndTest("1", ['altKey'], "Digit1");
+
+debug("");
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/LayoutTests/fast/events/special-key-events-in-input-text-expected.txt (206802 => 206803)


--- trunk/LayoutTests/fast/events/special-key-events-in-input-text-expected.txt	2016-10-05 01:52:35 UTC (rev 206802)
+++ trunk/LayoutTests/fast/events/special-key-events-in-input-text-expected.txt	2016-10-05 03:13:35 UTC (rev 206803)
@@ -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 - key - keyIdentifier - keyCode - charCode
+target - type - ctrlKey,altKey,shiftKey,metaKey - key - code - keyIdentifier - keyCode - charCode
 
 Ampersand:
-INPUT - keydown - false,false,true,false - 7 - U+0037 - 55 - 0. Value: "".
-INPUT - keypress - false,false,true,false - 7 - - 55 - 55. Value: "".
+INPUT - keydown - false,false,true,false - 7 - Digit7 - U+0037 - 55 - 0. Value: "".
+INPUT - keypress - false,false,true,false - 7 - Digit7 - - 55 - 55. Value: "".
 INPUT - textInput - 7. Value: "".
-INPUT - keyup - false,false,true,false - 7 - U+0037 - 55 - 0. Value: "7".
+INPUT - keyup - false,false,true,false - 7 - Digit7 - U+0037 - 55 - 0. Value: "7".
 
 Backspace:
-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: "".
+INPUT - keydown - false,false,false,false - Backspace - Backspace - U+0008 - 8 - 0. Value: "7".
+INPUT - keyup - false,false,false,false - Backspace - Backspace - U+0008 - 8 - 0. Value: "".
 
 Percent:
-INPUT - keydown - false,false,true,false - 5 - U+0035 - 53 - 0. Value: "".
-INPUT - keypress - false,false,true,false - 5 - - 53 - 53. Value: "".
+INPUT - keydown - false,false,true,false - 5 - Digit5 - U+0035 - 53 - 0. Value: "".
+INPUT - keypress - false,false,true,false - 5 - Digit5 - - 53 - 53. Value: "".
 INPUT - textInput - 5. Value: "".
-INPUT - keyup - false,false,true,false - 5 - U+0035 - 53 - 0. Value: "5".
+INPUT - keyup - false,false,true,false - 5 - Digit5 - U+0035 - 53 - 0. Value: "5".
 
 Backspace:
-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: "".
+INPUT - keydown - false,false,false,false - Backspace - Backspace - U+0008 - 8 - 0. Value: "5".
+INPUT - keyup - false,false,false,false - Backspace - Backspace - U+0008 - 8 - 0. Value: "".
 
 Left parenthesis:
-INPUT - keydown - false,false,true,false - 9 - U+0039 - 57 - 0. Value: "".
-INPUT - keypress - false,false,true,false - 9 - - 57 - 57. Value: "".
+INPUT - keydown - false,false,true,false - 9 - Digit9 - U+0039 - 57 - 0. Value: "".
+INPUT - keypress - false,false,true,false - 9 - Digit9 - - 57 - 57. Value: "".
 INPUT - textInput - 9. Value: "".
-INPUT - keyup - false,false,true,false - 9 - U+0039 - 57 - 0. Value: "9".
+INPUT - keyup - false,false,true,false - 9 - Digit9 - U+0039 - 57 - 0. Value: "9".
 
 Backspace:
-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: "".
+INPUT - keydown - false,false,false,false - Backspace - Backspace - U+0008 - 8 - 0. Value: "9".
+INPUT - keyup - false,false,false,false - Backspace - Backspace - U+0008 - 8 - 0. Value: "".
 
 Right parenthesis:
-INPUT - keydown - false,false,true,false - 0 - U+0030 - 48 - 0. Value: "".
-INPUT - keypress - false,false,true,false - 0 - - 48 - 48. Value: "".
+INPUT - keydown - false,false,true,false - 0 - Digit0 - U+0030 - 48 - 0. Value: "".
+INPUT - keypress - false,false,true,false - 0 - Digit0 - - 48 - 48. Value: "".
 INPUT - textInput - 0. Value: "".
-INPUT - keyup - false,false,true,false - 0 - U+0030 - 48 - 0. Value: "0".
+INPUT - keyup - false,false,true,false - 0 - Digit0 - U+0030 - 48 - 0. Value: "0".
 
 Backspace:
-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: "".
+INPUT - keydown - false,false,false,false - Backspace - Backspace - U+0008 - 8 - 0. Value: "0".
+INPUT - keyup - false,false,false,false - Backspace - Backspace - U+0008 - 8 - 0. Value: "".
 
 Print screen:
-INPUT - keydown - false,false,false,false - PrintScreen - PrintScreen - 44 - 0. Value: "".
-INPUT - keyup - false,false,false,false - PrintScreen - PrintScreen - 44 - 0. Value: "".
+INPUT - keydown - false,false,false,false - PrintScreen - KeyA - PrintScreen - 44 - 0. Value: "".
+INPUT - keyup - false,false,false,false - PrintScreen - KeyA - PrintScreen - 44 - 0. Value: "".
 

Modified: trunk/LayoutTests/fast/events/special-key-events-in-input-text.html (206802 => 206803)


--- trunk/LayoutTests/fast/events/special-key-events-in-input-text.html	2016-10-05 01:52:35 UTC (rev 206802)
+++ trunk/LayoutTests/fast/events/special-key-events-in-input-text.html	2016-10-05 03:13:35 UTC (rev 206803)
@@ -19,6 +19,7 @@
    } else if (type == "keydown" || type == "keypress" || type == "keyup") {
      info += [e.ctrlKey, e.altKey, e.shiftKey, e.metaKey] +
          ' - ' + e.key +
+         ' - ' + e.code +
          ' - ' + e.keyIdentifier +
          ' - ' + e.keyCode +
          ' - ' + e.charCode;
@@ -29,6 +30,7 @@
 
 log("target - type - " + ["ctrlKey", "altKey", "shiftKey", "metaKey"]
        + ' - ' + "key"
+       + ' - ' + "code"
        + ' - ' + "keyIdentifier"
        + ' - ' + "keyCode"
        + ' - ' + "charCode");

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (206802 => 206803)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2016-10-05 01:52:35 UTC (rev 206802)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2016-10-05 03:13:35 UTC (rev 206803)
@@ -1,3 +1,14 @@
+2016-10-04  Chris Dumez  <cdu...@apple.com>
+
+        Implement KeyboardEvent.code from the UI Event spec
+        https://bugs.webkit.org/show_bug.cgi?id=149584
+
+        Reviewed by Darin Adler.
+
+        Rebaseline W3C test now that more checks are passing.
+
+        * web-platform-tests/dom/events/Event-subclasses-constructors-expected.txt:
+
 2016-10-04  Youenn Fablet  <you...@apple.com>
 
         [Fetch API] ReadableStream should be errored with TypeError values

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-subclasses-constructors-expected.txt (206802 => 206803)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-subclasses-constructors-expected.txt	2016-10-05 01:52:35 UTC (rev 206802)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-subclasses-constructors-expected.txt	2016-10-05 03:13:35 UTC (rev 206803)
@@ -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) 
+FAIL KeyboardEvent constructor (argument with non-default values) assert_equals: The value of the charCode property should be 7 expected 7 but got 0
 PASS CompositionEvent constructor (no argument) 
 PASS CompositionEvent constructor (undefined argument) 
 PASS CompositionEvent constructor (null argument) 

Modified: trunk/LayoutTests/platform/ios-simulator/TestExpectations (206802 => 206803)


--- trunk/LayoutTests/platform/ios-simulator/TestExpectations	2016-10-05 01:52:35 UTC (rev 206802)
+++ trunk/LayoutTests/platform/ios-simulator/TestExpectations	2016-10-05 03:13:35 UTC (rev 206803)
@@ -337,6 +337,7 @@
 fast/shadow-dom/shadow-host-removal-crash.html [ Skip ]
 fast/shadow-dom/input-element-in-shadow.html [ Skip ]
 fast/events/keyboardevent-key.html [ Skip ]
+fast/events/keyboardevent-code.html [ Skip ]
 
 # The file-wrapper part of <attachment> is not yet working on iOS
 fast/attachment/attachment-type-attribute.html [ Skip ]

Copied: trunk/LayoutTests/platform/ios-simulator/fast/events/constructors/keyboard-event-constructor-expected.txt (from rev 206802, trunk/LayoutTests/fast/events/constructors/keyboard-event-constructor-expected.txt) (0 => 206803)


--- trunk/LayoutTests/platform/ios-simulator/fast/events/constructors/keyboard-event-constructor-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/ios-simulator/fast/events/constructors/keyboard-event-constructor-expected.txt	2016-10-05 03:13:35 UTC (rev 206803)
@@ -0,0 +1,124 @@
+This tests the constructor for the KeyboardEvent DOM class.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS new KeyboardEvent('eventType').bubbles is false
+PASS new KeyboardEvent('eventType').cancelable is false
+PASS new KeyboardEvent('eventType').view is null
+PASS new KeyboardEvent('eventType').detail is 0
+PASS new KeyboardEvent('eventType').keyIdentifier is ""
+PASS new KeyboardEvent('eventType').location is 0
+PASS new KeyboardEvent('eventType').ctrlKey is false
+PASS new KeyboardEvent('eventType').altKey is false
+PASS new KeyboardEvent('eventType').shiftKey is false
+PASS new KeyboardEvent('eventType').metaKey is false
+PASS new KeyboardEvent('eventType', { bubbles: false }).bubbles is false
+PASS new KeyboardEvent('eventType', { bubbles: true }).bubbles is true
+PASS new KeyboardEvent('eventType', { cancelable: false }).cancelable is false
+PASS new KeyboardEvent('eventType', { cancelable: true }).cancelable is true
+PASS new KeyboardEvent('eventType', { view: window }).view is window
+PASS new KeyboardEvent('eventType', { view: this }).view is this
+PASS new KeyboardEvent('eventType', { }).repeat is false
+PASS new KeyboardEvent('eventType', { repeat: false }).repeat is false
+PASS new KeyboardEvent('eventType', { repeat: true }).repeat is true
+PASS new KeyboardEvent('eventType', { }).isComposing is false
+PASS new KeyboardEvent('eventType', { isComposing: false }).isComposing is false
+PASS new KeyboardEvent('eventType', { isComposing: true }).isComposing is true
+PASS new KeyboardEvent('eventType', { view: testObject }).view threw exception TypeError: Dictionary member is not of type Window.
+PASS new KeyboardEvent('eventType', { view: document }).view threw exception TypeError: Dictionary member is not of type Window.
+PASS new KeyboardEvent('eventType', { view: undefined }).view is null
+PASS new KeyboardEvent('eventType', { view: null }).view is null
+PASS new KeyboardEvent('eventType', { view: false }).view threw exception TypeError: Dictionary member is not of type Window.
+PASS new KeyboardEvent('eventType', { view: true }).view threw exception TypeError: Dictionary member is not of type Window.
+PASS new KeyboardEvent('eventType', { view: '' }).view threw exception TypeError: Dictionary member is not of type Window.
+PASS new KeyboardEvent('eventType', { view: 'chocolate' }).view threw exception TypeError: Dictionary member is not of type Window.
+PASS new KeyboardEvent('eventType', { view: 12345 }).view threw exception TypeError: Dictionary member is not of type Window.
+PASS new KeyboardEvent('eventType', { view: 18446744073709551615 }).view threw exception TypeError: Dictionary member is not of type Window.
+PASS new KeyboardEvent('eventType', { view: NaN }).view threw exception TypeError: Dictionary member is not of type Window.
+PASS new KeyboardEvent('eventType', { view: {valueOf: function () { return window; } } }).view threw exception TypeError: Dictionary member is not of type Window.
+PASS new KeyboardEvent('eventType', { get view() { return 123; } }).view threw exception TypeError: Dictionary member is not of type Window.
+PASS new KeyboardEvent('eventType', { get view() { throw 'KeyboardEvent Error'; } }) threw exception KeyboardEvent Error.
+PASS new KeyboardEvent('eventType', { keyIdentifier: 'koakuma' }).keyIdentifier is "koakuma"
+PASS new KeyboardEvent('eventType', { keyIdentifier: '' }).keyIdentifier is ""
+PASS new KeyboardEvent('eventType', { keyIdentifier: undefined }).keyIdentifier is "undefined"
+PASS new KeyboardEvent('eventType', { keyIdentifier: null }).keyIdentifier is "null"
+PASS new KeyboardEvent('eventType', { keyIdentifier: false }).keyIdentifier is "false"
+PASS new KeyboardEvent('eventType', { keyIdentifier: true }).keyIdentifier is "true"
+PASS new KeyboardEvent('eventType', { keyIdentifier: 12345 }).keyIdentifier is "12345"
+PASS new KeyboardEvent('eventType', { keyIdentifier: 18446744073709551615 }).keyIdentifier is "18446744073709552000"
+PASS new KeyboardEvent('eventType', { keyIdentifier: NaN }).keyIdentifier is "NaN"
+PASS new KeyboardEvent('eventType', { keyIdentifier: [] }).keyIdentifier is ""
+PASS new KeyboardEvent('eventType', { keyIdentifier: [1, 2, 3] }).keyIdentifier is "1,2,3"
+PASS new KeyboardEvent('eventType', { keyIdentifier: {koakuma: 12345} }).keyIdentifier is "[object Object]"
+PASS new KeyboardEvent('eventType', { keyIdentifier: {valueOf: function () { return 'koakuma'; } } }).keyIdentifier is "[object Object]"
+PASS new KeyboardEvent('eventType', { location: KeyboardEvent.DOM_KEY_LOCATION_STANDARD }).location is KeyboardEvent.DOM_KEY_LOCATION_STANDARD
+PASS new KeyboardEvent('eventType', { location: KeyboardEvent.DOM_KEY_LOCATION_LEFT }).location is KeyboardEvent.DOM_KEY_LOCATION_LEFT
+PASS new KeyboardEvent('eventType', { location: 4294967294 }).location is 4294967294
+PASS new KeyboardEvent('eventType', { location: 4294967295 }).location is 4294967295
+PASS new KeyboardEvent('eventType', { location: 9007199254740991 }).location is 4294967295
+PASS new KeyboardEvent('eventType', { location: 18446744073709551615 }).location is KeyboardEvent.DOM_KEY_LOCATION_STANDARD
+PASS new KeyboardEvent('eventType', { location: 12345678901234567890 }).location is 3944679424
+PASS new KeyboardEvent('eventType', { location: -1 }).location is 4294967295
+PASS new KeyboardEvent('eventType', { location: 123.45 }).location is 123
+PASS new KeyboardEvent('eventType', { location: NaN }).location is KeyboardEvent.DOM_KEY_LOCATION_STANDARD
+PASS new KeyboardEvent('eventType', { location: undefined }).location is KeyboardEvent.DOM_KEY_LOCATION_STANDARD
+PASS new KeyboardEvent('eventType', { location: null }).location is KeyboardEvent.DOM_KEY_LOCATION_STANDARD
+PASS new KeyboardEvent('eventType', { location: '' }).location is KeyboardEvent.DOM_KEY_LOCATION_STANDARD
+PASS new KeyboardEvent('eventType', { location: '12345' }).location is 12345
+PASS new KeyboardEvent('eventType', { location: '12345a' }).location is KeyboardEvent.DOM_KEY_LOCATION_STANDARD
+PASS new KeyboardEvent('eventType', { location: 'abc' }).location is KeyboardEvent.DOM_KEY_LOCATION_STANDARD
+PASS new KeyboardEvent('eventType', { location: [] }).location is KeyboardEvent.DOM_KEY_LOCATION_STANDARD
+PASS new KeyboardEvent('eventType', { location: [12345] }).location is 12345
+PASS new KeyboardEvent('eventType', { location: [12345, 67890] }).location is KeyboardEvent.DOM_KEY_LOCATION_STANDARD
+PASS new KeyboardEvent('eventType', { location: {} }).location is KeyboardEvent.DOM_KEY_LOCATION_STANDARD
+PASS new KeyboardEvent('eventType', { location: {moemoe: 12345} }).location is KeyboardEvent.DOM_KEY_LOCATION_STANDARD
+PASS new KeyboardEvent('eventType', { location: {valueOf: function () { return 12345; }} }).location is 12345
+PASS new KeyboardEvent('eventType', { keyLocation: KeyboardEvent.DOM_KEY_LOCATION_STANDARD }).keyLocation is KeyboardEvent.DOM_KEY_LOCATION_STANDARD
+PASS new KeyboardEvent('eventType', { keyLocation: KeyboardEvent.DOM_KEY_LOCATION_LEFT }).keyLocation is KeyboardEvent.DOM_KEY_LOCATION_LEFT
+PASS new KeyboardEvent('eventType', { keyLocation: 4294967294 }).keyLocation is 4294967294
+PASS new KeyboardEvent('eventType', { keyLocation: 4294967295 }).keyLocation is 4294967295
+PASS new KeyboardEvent('eventType', { keyLocation: 9007199254740991 }).keyLocation is 4294967295
+PASS new KeyboardEvent('eventType', { keyLocation: 18446744073709551615 }).keyLocation is KeyboardEvent.DOM_KEY_LOCATION_STANDARD
+PASS new KeyboardEvent('eventType', { keyLocation: 12345678901234567890 }).keyLocation is 3944679424
+PASS new KeyboardEvent('eventType', { keyLocation: -1 }).keyLocation is 4294967295
+PASS new KeyboardEvent('eventType', { keyLocation: 123.45 }).keyLocation is 123
+PASS new KeyboardEvent('eventType', { keyLocation: NaN }).keyLocation is KeyboardEvent.DOM_KEY_LOCATION_STANDARD
+PASS new KeyboardEvent('eventType', { keyLocation: undefined }).keyLocation is KeyboardEvent.DOM_KEY_LOCATION_STANDARD
+PASS new KeyboardEvent('eventType', { keyLocation: null }).keyLocation is KeyboardEvent.DOM_KEY_LOCATION_STANDARD
+PASS new KeyboardEvent('eventType', { keyLocation: '' }).keyLocation is KeyboardEvent.DOM_KEY_LOCATION_STANDARD
+PASS new KeyboardEvent('eventType', { keyLocation: '12345' }).keyLocation is 12345
+PASS new KeyboardEvent('eventType', { keyLocation: '12345a' }).keyLocation is KeyboardEvent.DOM_KEY_LOCATION_STANDARD
+PASS new KeyboardEvent('eventType', { keyLocation: 'abc' }).keyLocation is KeyboardEvent.DOM_KEY_LOCATION_STANDARD
+PASS new KeyboardEvent('eventType', { keyLocation: [] }).keyLocation is KeyboardEvent.DOM_KEY_LOCATION_STANDARD
+PASS new KeyboardEvent('eventType', { keyLocation: [12345] }).keyLocation is 12345
+PASS new KeyboardEvent('eventType', { keyLocation: [12345, 67890] }).keyLocation is KeyboardEvent.DOM_KEY_LOCATION_STANDARD
+PASS new KeyboardEvent('eventType', { keyLocation: {} }).keyLocation is KeyboardEvent.DOM_KEY_LOCATION_STANDARD
+PASS new KeyboardEvent('eventType', { keyLocation: {moemoe: 12345} }).keyLocation is KeyboardEvent.DOM_KEY_LOCATION_STANDARD
+PASS new KeyboardEvent('eventType', { keyLocation: {valueOf: function () { return 12345; }} }).keyLocation is 12345
+PASS new KeyboardEvent('eventType', { keyLocation: KeyboardEvent.DOM_KEY_LOCATION_LEFT }).location is KeyboardEvent.DOM_KEY_LOCATION_LEFT
+PASS new KeyboardEvent('eventType', { location: KeyboardEvent.DOM_KEY_LOCATION_LEFT }).keyLocation is KeyboardEvent.DOM_KEY_LOCATION_LEFT
+PASS new KeyboardEvent('eventType', { ctrlKey: false }).ctrlKey is false
+PASS new KeyboardEvent('eventType', { ctrlKey: true }).ctrlKey is true
+PASS new KeyboardEvent('eventType', { altKey: false }).altKey is false
+PASS new KeyboardEvent('eventType', { altKey: true }).altKey is true
+PASS new KeyboardEvent('eventType', { shiftKey: false }).shiftKey is false
+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, key: 'a', code: 'KeyA', 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', code: 'KeyA', 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', 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 }).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
+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 }).altKey is true
+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 }).shiftKey is true
+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 }).metaKey is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Copied: trunk/LayoutTests/platform/ios-simulator/imported/w3c/web-platform-tests/dom/events/Event-subclasses-constructors-expected.txt (from rev 206802, trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-subclasses-constructors-expected.txt) (0 => 206803)


--- trunk/LayoutTests/platform/ios-simulator/imported/w3c/web-platform-tests/dom/events/Event-subclasses-constructors-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/ios-simulator/imported/w3c/web-platform-tests/dom/events/Event-subclasses-constructors-expected.txt	2016-10-05 03:13:35 UTC (rev 206803)
@@ -0,0 +1,45 @@
+
+PASS Event constructor (no argument) 
+PASS Event constructor (undefined argument) 
+PASS Event constructor (null argument) 
+PASS Event constructor (empty argument) 
+PASS Event constructor (argument with default values) 
+PASS Event constructor (argument with non-default values) 
+PASS UIEvent constructor (no argument) 
+PASS UIEvent constructor (undefined argument) 
+PASS UIEvent constructor (null argument) 
+PASS UIEvent constructor (empty argument) 
+PASS UIEvent constructor (argument with default values) 
+PASS UIEvent constructor (argument with non-default values) 
+PASS FocusEvent constructor (no argument) 
+PASS FocusEvent constructor (undefined argument) 
+PASS FocusEvent constructor (null argument) 
+PASS FocusEvent constructor (empty argument) 
+PASS FocusEvent constructor (argument with default values) 
+PASS FocusEvent constructor (argument with non-default values) 
+FAIL MouseEvent constructor (no argument) assert_true: Event object "[object MouseEvent]" should have a buttons property expected true got false
+FAIL MouseEvent constructor (undefined argument) assert_true: Event object "[object MouseEvent]" should have a buttons property expected true got false
+FAIL MouseEvent constructor (null argument) assert_true: Event object "[object MouseEvent]" should have a buttons property expected true got false
+FAIL MouseEvent constructor (empty argument) assert_true: Event object "[object MouseEvent]" should have a buttons property expected true got false
+FAIL MouseEvent constructor (argument with default values) assert_true: Event object "[object MouseEvent]" should have a buttons property expected true got false
+FAIL MouseEvent constructor (argument with non-default values) assert_true: Event object "[object MouseEvent]" should have a buttons property expected true got false
+FAIL WheelEvent constructor (no argument) assert_true: Event object "[object WheelEvent]" should have a buttons property expected true got false
+FAIL WheelEvent constructor (undefined argument) assert_true: Event object "[object WheelEvent]" should have a buttons property expected true got false
+FAIL WheelEvent constructor (null argument) assert_true: Event object "[object WheelEvent]" should have a buttons property expected true got false
+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 CompositionEvent constructor (no argument) 
+PASS CompositionEvent constructor (undefined argument) 
+PASS CompositionEvent constructor (null argument) 
+PASS CompositionEvent constructor (empty argument) 
+PASS CompositionEvent constructor (argument with default values) 
+PASS CompositionEvent constructor (argument with non-default values) 
+PASS UIEvent constructor (view argument with wrong type) 
+

Modified: trunk/Source/WTF/ChangeLog (206802 => 206803)


--- trunk/Source/WTF/ChangeLog	2016-10-05 01:52:35 UTC (rev 206802)
+++ trunk/Source/WTF/ChangeLog	2016-10-05 03:13:35 UTC (rev 206803)
@@ -1,3 +1,16 @@
+2016-10-04  Chris Dumez  <cdu...@apple.com>
+
+        Implement KeyboardEvent.code from the UI Event spec
+        https://bugs.webkit.org/show_bug.cgi?id=149584
+
+        Reviewed by Darin Adler.
+
+        Add build time flag to toggle support for the code attribute on
+        KeyboardEvent and only enable it on Mac for now, given that the
+        implementation is missing on other platforms.
+
+        * wtf/FeatureDefines.h:
+
 2016-10-03  Chris Dumez  <cdu...@apple.com>
 
         Add support for KeyboardEvent.key attribute

Modified: trunk/Source/WTF/wtf/FeatureDefines.h (206802 => 206803)


--- trunk/Source/WTF/wtf/FeatureDefines.h	2016-10-05 01:52:35 UTC (rev 206802)
+++ trunk/Source/WTF/wtf/FeatureDefines.h	2016-10-05 03:13:35 UTC (rev 206803)
@@ -247,6 +247,10 @@
 #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)
@@ -777,6 +781,10 @@
 #define ENABLE_KEYBOARD_KEY_ATTRIBUTE 0
 #endif
 
+#if !defined(ENABLE_KEYBOARD_CODE_ATTRIBUTE)
+#define ENABLE_KEYBOARD_CODE_ATTRIBUTE 0
+#endif
+
 /* Asserts, invariants for macro definitions */
 
 #if ENABLE(VIDEO_TRACK) && !ENABLE(VIDEO)

Modified: trunk/Source/WebCore/ChangeLog (206802 => 206803)


--- trunk/Source/WebCore/ChangeLog	2016-10-05 01:52:35 UTC (rev 206802)
+++ trunk/Source/WebCore/ChangeLog	2016-10-05 03:13:35 UTC (rev 206803)
@@ -1,3 +1,35 @@
+2016-10-04  Chris Dumez  <cdu...@apple.com>
+
+        Implement KeyboardEvent.code from the UI Event spec
+        https://bugs.webkit.org/show_bug.cgi?id=149584
+
+        Reviewed by Darin Adler.
+
+        Add support for Keyboard.code attribute:
+        - https://w3c.github.io/uievents/#dom-keyboardevent-code
+        - https://w3c.github.io/uievents-code/
+
+        The feature is only enabled on Mac for now as the implementation is
+        platform-specific and Mac only.
+
+        Test: fast/events/keyboardevent-code.html
+
+        * dom/KeyboardEvent.cpp:
+        (WebCore::KeyboardEvent::KeyboardEvent):
+        * dom/KeyboardEvent.h:
+        * dom/KeyboardEvent.idl:
+        * platform/PlatformKeyboardEvent.h:
+        (WebCore::PlatformKeyboardEvent::PlatformKeyboardEvent):
+        (WebCore::PlatformKeyboardEvent::code):
+        (WebCore::PlatformKeyboardEvent::unmodifiedText): Deleted.
+        * platform/mac/PlatformEventFactoryMac.h:
+        * platform/mac/PlatformEventFactoryMac.mm:
+        (WebCore::codeForKeyEvent):
+        (WebCore::keyIdentifierForKeyEvent):
+        * replay/SerializationMethods.cpp:
+        (JSC::EncodingTraits<PlatformKeyboardEvent>::encodeValue):
+        (JSC::EncodingTraits<PlatformKeyboardEvent>::decodeValue):
+
 2016-10-04  Said Abou-Hallawa  <sabouhall...@apple.com>
 
         The dragged image should be the current frame only of the animated image

Modified: trunk/Source/WebCore/dom/KeyboardEvent.cpp (206802 => 206803)


--- trunk/Source/WebCore/dom/KeyboardEvent.cpp	2016-10-05 01:52:35 UTC (rev 206802)
+++ trunk/Source/WebCore/dom/KeyboardEvent.cpp	2016-10-05 03:13:35 UTC (rev 206803)
@@ -101,6 +101,9 @@
 #if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
     , m_key(key.key())
 #endif
+#if ENABLE(KEYBOARD_CODE_ATTRIBUTE)
+    , m_code(key.code())
+#endif
     , m_keyIdentifier(key.keyIdentifier())
     , m_location(keyLocationCode(key))
     , m_repeat(key.isAutoRepeat())
@@ -128,6 +131,9 @@
 #if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
     , m_key(initializer.key)
 #endif
+#if ENABLE(KEYBOARD_CODE_ATTRIBUTE)
+    , m_code(initializer.code)
+#endif
     , m_keyIdentifier(initializer.keyIdentifier)
     , m_location(initializer.location)
     , m_repeat(initializer.repeat)

Modified: trunk/Source/WebCore/dom/KeyboardEvent.h (206802 => 206803)


--- trunk/Source/WebCore/dom/KeyboardEvent.h	2016-10-05 01:52:35 UTC (rev 206802)
+++ trunk/Source/WebCore/dom/KeyboardEvent.h	2016-10-05 03:13:35 UTC (rev 206803)
@@ -37,6 +37,9 @@
 #if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
     String key;
 #endif
+#if ENABLE(KEYBOARD_CODE_ATTRIBUTE)
+    String code;
+#endif
     String keyIdentifier;
     unsigned location { 0 };
     bool repeat { false };
@@ -83,6 +86,9 @@
 #if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
     const String& key() const { return m_key; }
 #endif
+#if ENABLE(KEYBOARD_CODE_ATTRIBUTE)
+    const String& code() const { return m_code; }
+#endif
 
     const String& keyIdentifier() const { return m_keyIdentifier; }
     unsigned location() const { return m_location; }
@@ -123,6 +129,9 @@
 #if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
     String m_key;
 #endif
+#if ENABLE(KEYBOARD_CODE_ATTRIBUTE)
+    String m_code;
+#endif
     String m_keyIdentifier;
     unsigned m_location { DOM_KEY_LOCATION_STANDARD };
     bool m_repeat { false };

Modified: trunk/Source/WebCore/dom/KeyboardEvent.idl (206802 => 206803)


--- trunk/Source/WebCore/dom/KeyboardEvent.idl	2016-10-05 01:52:35 UTC (rev 206802)
+++ trunk/Source/WebCore/dom/KeyboardEvent.idl	2016-10-05 03:13:35 UTC (rev 206803)
@@ -29,10 +29,7 @@
     const unsigned long DOM_KEY_LOCATION_NUMPAD = 0x03;
 
     [InitializedByEventConstructor, Conditional=KEYBOARD_KEY_ATTRIBUTE] readonly attribute DOMString key;
-
-    // FIXME: We should support this.
-    // [InitializedByEventConstructor] readonly attribute DOMString code;
-
+    [InitializedByEventConstructor, Conditional=KEYBOARD_CODE_ATTRIBUTE] readonly attribute DOMString code;
     [InitializedByEventConstructor] readonly attribute unsigned long location;
 
     [InitializedByEventConstructor] readonly attribute boolean ctrlKey;

Modified: trunk/Source/WebCore/platform/PlatformKeyboardEvent.h (206802 => 206803)


--- trunk/Source/WebCore/platform/PlatformKeyboardEvent.h	2016-10-05 01:52:35 UTC (rev 206802)
+++ trunk/Source/WebCore/platform/PlatformKeyboardEvent.h	2016-10-05 03:13:35 UTC (rev 206803)
@@ -74,6 +74,9 @@
 #if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
         const String& key,
 #endif
+#if ENABLE(KEYBOARD_CODE_ATTRIBUTE)
+        const String& code,
+#endif
         const String& keyIdentifier, int windowsVirtualKeyCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, OptionSet<Modifier> modifiers, double timestamp)
             : PlatformEvent(type, modifiers, timestamp)
             , m_text(text)
@@ -81,6 +84,9 @@
 #if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
             , m_key(key)
 #endif
+#if ENABLE(KEYBOARD_CODE_ATTRIBUTE)
+            , m_code(code)
+#endif
             , m_keyIdentifier(keyIdentifier)
             , m_windowsVirtualKeyCode(windowsVirtualKeyCode)
 #if USE(APPKIT) || PLATFORM(GTK)
@@ -112,6 +118,9 @@
 #if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
         const String& key() const { return m_key; }
 #endif
+#if ENABLE(KEYBOARD_CODE_ATTRIBUTE)
+        const String& code() const { return m_code; }
+#endif
 
         // Most compatible Windows virtual key code associated with the event.
         // Zero for Char events.
@@ -168,6 +177,9 @@
 #if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
         String m_key;
 #endif
+#if ENABLE(KEYBOARD_CODE_ATTRIBUTE)
+        String m_code;
+#endif
         String m_keyIdentifier;
         int m_windowsVirtualKeyCode;
 #if USE(APPKIT) || PLATFORM(GTK)

Modified: trunk/Source/WebCore/platform/mac/PlatformEventFactoryMac.h (206802 => 206803)


--- trunk/Source/WebCore/platform/mac/PlatformEventFactoryMac.h	2016-10-05 01:52:35 UTC (rev 206802)
+++ trunk/Source/WebCore/platform/mac/PlatformEventFactoryMac.h	2016-10-05 03:13:35 UTC (rev 206803)
@@ -47,6 +47,7 @@
 WEBCORE_EXPORT int windowsKeyCodeForKeyEvent(NSEvent *);
 WEBCORE_EXPORT String keyIdentifierForKeyEvent(NSEvent *);
 WEBCORE_EXPORT String keyForKeyEvent(NSEvent *);
+WEBCORE_EXPORT String codeForKeyEvent(NSEvent *);
 WEBCORE_EXPORT double eventTimeStampSince1970(NSEvent *);
 
 #endif

Modified: trunk/Source/WebCore/platform/mac/PlatformEventFactoryMac.mm (206802 => 206803)


--- trunk/Source/WebCore/platform/mac/PlatformEventFactoryMac.mm	2016-10-05 01:52:35 UTC (rev 206802)
+++ trunk/Source/WebCore/platform/mac/PlatformEventFactoryMac.mm	2016-10-05 03:13:35 UTC (rev 206803)
@@ -286,6 +286,218 @@
     return keyForCharCode([s characterAtIndex:0]);
 }
 
+// https://w3c.github.io/uievents-code/
+String codeForKeyEvent(NSEvent *event)
+{
+    switch ([event keyCode]) {
+    // Keys in the alphanumeric section.
+    case kVK_ANSI_Grave: return ASCIILiteral("Backquote");
+    case kVK_ANSI_Backslash: return ASCIILiteral("Backslash");
+    case kVK_Delete: return ASCIILiteral("Backspace");
+    case kVK_ANSI_LeftBracket: return ASCIILiteral("BracketLeft");
+    case kVK_ANSI_RightBracket: return ASCIILiteral("BracketRight");
+    case kVK_ANSI_Comma: return ASCIILiteral("Comma");
+    case kVK_ANSI_0: return ASCIILiteral("Digit0");
+    case kVK_ANSI_1: return ASCIILiteral("Digit1");
+    case kVK_ANSI_2: return ASCIILiteral("Digit2");
+    case kVK_ANSI_3: return ASCIILiteral("Digit3");
+    case kVK_ANSI_4: return ASCIILiteral("Digit4");
+    case kVK_ANSI_5: return ASCIILiteral("Digit5");
+    case kVK_ANSI_6: return ASCIILiteral("Digit6");
+    case kVK_ANSI_7: return ASCIILiteral("Digit7");
+    case kVK_ANSI_8: return ASCIILiteral("Digit8");
+    case kVK_ANSI_9: return ASCIILiteral("Digit9");
+    case kVK_ANSI_Equal: return ASCIILiteral("Equal");
+    case kVK_ISO_Section: return ASCIILiteral("IntlBackslash");
+    case kVK_JIS_Underscore: return ASCIILiteral("IntlRo");
+    case kVK_JIS_Yen: return ASCIILiteral("IntlYen");
+    case kVK_ANSI_A: return ASCIILiteral("KeyA");
+    case kVK_ANSI_B: return ASCIILiteral("KeyB");
+    case kVK_ANSI_C: return ASCIILiteral("KeyC");
+    case kVK_ANSI_D: return ASCIILiteral("KeyD");
+    case kVK_ANSI_E: return ASCIILiteral("KeyE");
+    case kVK_ANSI_F: return ASCIILiteral("KeyF");
+    case kVK_ANSI_G: return ASCIILiteral("KeyG");
+    case kVK_ANSI_H: return ASCIILiteral("KeyH");
+    case kVK_ANSI_I: return ASCIILiteral("KeyI");
+    case kVK_ANSI_J: return ASCIILiteral("KeyJ");
+    case kVK_ANSI_K: return ASCIILiteral("KeyK");
+    case kVK_ANSI_L: return ASCIILiteral("KeyL");
+    case kVK_ANSI_M: return ASCIILiteral("KeyM");
+    case kVK_ANSI_N: return ASCIILiteral("KeyN");
+    case kVK_ANSI_O: return ASCIILiteral("KeyO");
+    case kVK_ANSI_P: return ASCIILiteral("KeyP");
+    case kVK_ANSI_Q: return ASCIILiteral("KeyQ");
+    case kVK_ANSI_R: return ASCIILiteral("KeyR");
+    case kVK_ANSI_S: return ASCIILiteral("KeyS");
+    case kVK_ANSI_T: return ASCIILiteral("KeyT");
+    case kVK_ANSI_U: return ASCIILiteral("KeyU");
+    case kVK_ANSI_V: return ASCIILiteral("KeyV");
+    case kVK_ANSI_W: return ASCIILiteral("KeyW");
+    case kVK_ANSI_X: return ASCIILiteral("KeyX");
+    case kVK_ANSI_Y: return ASCIILiteral("KeyY");
+    case kVK_ANSI_Z: return ASCIILiteral("KeyZ");
+    case kVK_ANSI_Minus: return ASCIILiteral("Minus");
+    case kVK_ANSI_Period: return ASCIILiteral("Period");
+    case kVK_ANSI_Quote: return ASCIILiteral("Quote");
+    case kVK_ANSI_Semicolon: return ASCIILiteral("Semicolon");
+    case kVK_ANSI_Slash: return ASCIILiteral("Slash");
+
+    // Functional keys in alphanumeric section.
+    case kVK_Option: return ASCIILiteral("AltLeft");
+    case kVK_RightOption: return ASCIILiteral("AltRight");
+    case kVK_CapsLock: return ASCIILiteral("CapsLock");
+    // ContextMenu.
+    case kVK_Control: return ASCIILiteral("ControlLeft");
+    case kVK_RightControl: return ASCIILiteral("ControlRight");
+    case kVK_Return: return ASCIILiteral("Enter"); //  Labeled Return on Apple keyboards.
+    case kVK_Command: return ASCIILiteral("MetaLeft");
+    case kVK_RightCommand: return ASCIILiteral("MetaRight");
+    case kVK_Shift: return ASCIILiteral("ShiftLeft");
+    case kVK_RightShift: return ASCIILiteral("ShiftRight");
+    case kVK_Space: return ASCIILiteral("Space");
+    case kVK_Tab: return ASCIILiteral("Tab");
+
+    // Functional keys found on Japanese and Korean keyboards.
+    // Convert.
+    case kVK_JIS_Kana: return ASCIILiteral("KanaMode");
+    // Lang1.
+    case kVK_JIS_Eisu: return ASCIILiteral("Lang2"); // Japanese (Mac keyboard): eisu.
+    // Lang3.
+    // Lang4.
+    // Lang5.
+    // NonConvert.
+
+    // Keys in the ControlPad section.
+    case kVK_ForwardDelete: return ASCIILiteral("Delete");
+    case kVK_End: return ASCIILiteral("End");
+    case kVK_Help: return ASCIILiteral("Help");
+    case kVK_Home: return ASCIILiteral("Home");
+    // Insert: Not present on Apple keyboards.
+    case kVK_PageDown: return ASCIILiteral("PageDown");
+    case kVK_PageUp: return ASCIILiteral("PageUp");
+
+    // Keys in the ArrowPad section.
+    case kVK_DownArrow: return ASCIILiteral("ArrowDown");
+    case kVK_LeftArrow: return ASCIILiteral("ArrowLeft");
+    case kVK_RightArrow: return ASCIILiteral("ArrowRight");
+    case kVK_UpArrow: return ASCIILiteral("ArrowUp");
+
+    // Keys in the Numpad section.
+    case kVK_ANSI_KeypadClear: return ASCIILiteral("NumLock"); // The specification says to use "NumLock" on Mac for the numpad Clear key.
+    case kVK_ANSI_Keypad0: return ASCIILiteral("Numpad0");
+    case kVK_ANSI_Keypad1: return ASCIILiteral("Numpad1");
+    case kVK_ANSI_Keypad2: return ASCIILiteral("Numpad2");
+    case kVK_ANSI_Keypad3: return ASCIILiteral("Numpad3");
+    case kVK_ANSI_Keypad4: return ASCIILiteral("Numpad4");
+    case kVK_ANSI_Keypad5: return ASCIILiteral("Numpad5");
+    case kVK_ANSI_Keypad6: return ASCIILiteral("Numpad6");
+    case kVK_ANSI_Keypad7: return ASCIILiteral("Numpad7");
+    case kVK_ANSI_Keypad8: return ASCIILiteral("Numpad8");
+    case kVK_ANSI_Keypad9: return ASCIILiteral("Numpad9");
+    case kVK_ANSI_KeypadPlus: return ASCIILiteral("NumpadAdd");
+    // NumpadBackspace.
+    // NumpadClear: The specification says that the numpad Clear key should always be encoded as "NumLock" on Mac.
+    // NumpadClearEntry.
+    case kVK_JIS_KeypadComma: return ASCIILiteral("NumpadComma");
+    case kVK_ANSI_KeypadDecimal: return ASCIILiteral("NumpadDecimal");
+    case kVK_ANSI_KeypadDivide: return ASCIILiteral("NumpadDivide");
+    case kVK_ANSI_KeypadEnter: return ASCIILiteral("NumpadEnter");
+    case kVK_ANSI_KeypadEquals: return ASCIILiteral("NumpadEqual");
+    // NumpadHash.
+    // NumpadMemoryAdd.
+    // NumpadMemoryClear.
+    // NumpadMemoryRecall.
+    // NumpadMemoryStore.
+    // NumpadMemorySubtract.
+    case kVK_ANSI_KeypadMultiply: return ASCIILiteral("NumpadMultiply");
+    // NumpadParenLeft.
+    // NumpadParenRight.
+    // NumpadStar: The specification says to use "NumpadMultiply" for the * key on numeric keypads.
+    case kVK_ANSI_KeypadMinus: return ASCIILiteral("NumpadSubtract");
+
+    // Keys in the Function section.
+    case kVK_Escape: return ASCIILiteral("Escape");
+    case kVK_F1: return ASCIILiteral("F1");
+    case kVK_F2: return ASCIILiteral("F2");
+    case kVK_F3: return ASCIILiteral("F3");
+    case kVK_F4: return ASCIILiteral("F4");
+    case kVK_F5: return ASCIILiteral("F5");
+    case kVK_F6: return ASCIILiteral("F6");
+    case kVK_F7: return ASCIILiteral("F7");
+    case kVK_F8: return ASCIILiteral("F8");
+    case kVK_F9: return ASCIILiteral("F9");
+    case kVK_F10: return ASCIILiteral("F10");
+    case kVK_F11: return ASCIILiteral("F11");
+    case kVK_F12: return ASCIILiteral("F12");
+    case kVK_F13: return ASCIILiteral("F13");
+    case kVK_F14: return ASCIILiteral("F14");
+    case kVK_F15: return ASCIILiteral("F15");
+    case kVK_F16: return ASCIILiteral("F16");
+    case kVK_F17: return ASCIILiteral("F17");
+    case kVK_F18: return ASCIILiteral("F18");
+    case kVK_F19: return ASCIILiteral("F19");
+    case kVK_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 kVK_VolumeDown: return ASCIILiteral("AudioVolumeDown");
+    case kVK_Mute: return ASCIILiteral("AudioVolumeMute");
+    case kVK_VolumeUp: 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");
+    }
+}
+
 String keyIdentifierForKeyEvent(NSEvent* event)
 {
 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
@@ -612,6 +824,7 @@
         m_unmodifiedText = unmodifiedTextFromEvent(event);
         m_keyIdentifier = keyIdentifierForKeyEvent(event);
         m_key = keyForKeyEvent(event);
+        m_code = codeForKeyEvent(event);
         m_windowsVirtualKeyCode = windowsKeyCodeForKeyEvent(event);
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wdeprecated-declarations"

Modified: trunk/Source/WebCore/replay/SerializationMethods.cpp (206802 => 206803)


--- trunk/Source/WebCore/replay/SerializationMethods.cpp	2016-10-05 01:52:35 UTC (rev 206802)
+++ trunk/Source/WebCore/replay/SerializationMethods.cpp	2016-10-05 03:13:35 UTC (rev 206803)
@@ -259,6 +259,9 @@
 #if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
     ENCODE_TYPE_WITH_KEY(encodedValue, String, key, input.key());
 #endif
+#if ENABLE(KEYBOARD_CODE_ATTRIBUTE)
+    ENCODE_TYPE_WITH_KEY(encodedValue, String, code, input.code());
+#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());
@@ -281,6 +284,9 @@
 #if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
     DECODE_TYPE_WITH_KEY(encodedValue, String, key);
 #endif
+#if ENABLE(KEYBOARD_CODE_ATTRIBUTE)
+    DECODE_TYPE_WITH_KEY(encodedValue, String, code);
+#endif
     DECODE_TYPE_WITH_KEY(encodedValue, String, keyIdentifier);
     DECODE_TYPE_WITH_KEY(encodedValue, int, windowsVirtualKeyCode);
     DECODE_TYPE_WITH_KEY(encodedValue, bool, autoRepeat);
@@ -295,6 +301,9 @@
 #if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
         key,
 #endif
+#if ENABLE(KEYBOARD_CODE_ATTRIBUTE)
+        code,
+#endif
         keyIdentifier, WTF::safeCast<int>(windowsVirtualKeyCode), autoRepeat, keypad, systemKey, modifiers, timestamp);
 
 #if USE(APPKIT)

Modified: trunk/Source/WebKit2/ChangeLog (206802 => 206803)


--- trunk/Source/WebKit2/ChangeLog	2016-10-05 01:52:35 UTC (rev 206802)
+++ trunk/Source/WebKit2/ChangeLog	2016-10-05 03:13:35 UTC (rev 206803)
@@ -1,3 +1,25 @@
+2016-10-04  Chris Dumez  <cdu...@apple.com>
+
+        Implement KeyboardEvent.code from the UI Event spec
+        https://bugs.webkit.org/show_bug.cgi?id=149584
+
+        Reviewed by Darin Adler.
+
+        Add support for Keyboard.code attribute:
+        - https://w3c.github.io/uievents/#dom-keyboardevent-code
+        - https://w3c.github.io/uievents-code/
+
+        * Shared/WebEvent.h:
+        (WebKit::WebKeyboardEvent::code):
+        * 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-04  Said Abou-Hallawa  <sabouhall...@apple.com>
 
         The dragged image should be the current frame only of the animated image

Modified: trunk/Source/WebKit2/Shared/WebEvent.h (206802 => 206803)


--- trunk/Source/WebKit2/Shared/WebEvent.h	2016-10-05 01:52:35 UTC (rev 206802)
+++ trunk/Source/WebKit2/Shared/WebEvent.h	2016-10-05 03:13:35 UTC (rev 206803)
@@ -244,7 +244,7 @@
     ~WebKeyboardEvent();
 
 #if USE(APPKIT)
-    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);
+    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& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool handledByInputMethod, Vector<String>&& commands, bool isKeypad, Modifiers, double timestamp);
 #else
@@ -256,6 +256,9 @@
 #if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
     const String& key() const { return m_key; }
 #endif
+#if ENABLE(KEYBOARD_CODE_ATTRIBUTE)
+    const String& code() const { return m_code; }
+#endif
     const String& keyIdentifier() const { return m_keyIdentifier; }
     int32_t windowsVirtualKeyCode() const { return m_windowsVirtualKeyCode; }
     int32_t nativeVirtualKeyCode() const { return m_nativeVirtualKeyCode; }
@@ -283,6 +286,9 @@
 #if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
     String m_key;
 #endif
+#if ENABLE(KEYBOARD_CODE_ATTRIBUTE)
+    String m_code;
+#endif
     String m_keyIdentifier;
     int32_t m_windowsVirtualKeyCode;
     int32_t m_nativeVirtualKeyCode;

Modified: trunk/Source/WebKit2/Shared/WebEventConversion.cpp (206802 => 206803)


--- trunk/Source/WebKit2/Shared/WebEventConversion.cpp	2016-10-05 01:52:35 UTC (rev 206802)
+++ trunk/Source/WebKit2/Shared/WebEventConversion.cpp	2016-10-05 03:13:35 UTC (rev 206803)
@@ -194,6 +194,9 @@
 #if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
         m_key = webEvent.key();
 #endif
+#if ENABLE(KEYBOARD_CODE_ATTRIBUTE)
+        m_code = webEvent.code();
+#endif
         m_keyIdentifier = webEvent.keyIdentifier();
         m_windowsVirtualKeyCode = webEvent.windowsVirtualKeyCode();
 #if USE(APPKIT) || PLATFORM(GTK)

Modified: trunk/Source/WebKit2/Shared/WebKeyboardEvent.cpp (206802 => 206803)


--- trunk/Source/WebKit2/Shared/WebKeyboardEvent.cpp	2016-10-05 01:52:35 UTC (rev 206802)
+++ trunk/Source/WebKit2/Shared/WebKeyboardEvent.cpp	2016-10-05 03:13:35 UTC (rev 206803)
@@ -37,11 +37,12 @@
 
 #if USE(APPKIT)
 
-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)
+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 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_code(code)
     , m_keyIdentifier(keyIdentifier)
     , m_windowsVirtualKeyCode(windowsVirtualKeyCode)
     , m_nativeVirtualKeyCode(nativeVirtualKeyCode)
@@ -106,6 +107,9 @@
 #if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
     encoder << m_key;
 #endif
+#if ENABLE(KEYBOARD_CODE_ATTRIBUTE)
+    encoder << m_code;
+#endif
     encoder << m_keyIdentifier;
     encoder << m_windowsVirtualKeyCode;
     encoder << m_nativeVirtualKeyCode;
@@ -132,6 +136,10 @@
     if (!decoder.decode(result.m_key))
         return false;
 #endif
+#if ENABLE(KEYBOARD_CODE_ATTRIBUTE)
+    if (!decoder.decode(result.m_code))
+        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 (206802 => 206803)


--- trunk/Source/WebKit2/Shared/mac/WebEventFactory.mm	2016-10-05 01:52:35 UTC (rev 206802)
+++ trunk/Source/WebKit2/Shared/mac/WebEventFactory.mm	2016-10-05 03:13:35 UTC (rev 206803)
@@ -467,6 +467,7 @@
     String text                     = textFromEvent(event, replacesSoftSpace);
     String unmodifiedText           = unmodifiedTextFromEvent(event, replacesSoftSpace);
     String key                      = keyForKeyEvent(event);
+    String code                     = codeForKeyEvent(event);
     String keyIdentifier            = keyIdentifierForKeyEvent(event);
     int windowsVirtualKeyCode       = windowsKeyCodeForKeyEvent(event);
     int nativeVirtualKeyCode        = [event keyCode];
@@ -498,7 +499,7 @@
         unmodifiedText = "\x9";
     }
 
-    return WebKeyboardEvent(type, text, unmodifiedText, key, keyIdentifier, windowsVirtualKeyCode, nativeVirtualKeyCode, macCharCode, handledByInputMethod, commands, autoRepeat, isKeypad, isSystemKey, modifiers, timestamp);
+    return WebKeyboardEvent(type, text, unmodifiedText, key, code, keyIdentifier, windowsVirtualKeyCode, nativeVirtualKeyCode, macCharCode, handledByInputMethod, commands, autoRepeat, isKeypad, isSystemKey, modifiers, timestamp);
 }
 
 } // namespace WebKit
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to