Changeset 206750 in webkit


Ignore:
Timestamp:
Oct 3, 2016 2:32:47 PM (8 years ago)
Author:
Chris Dumez
Message:

Add support for KeyboardEvent.key attribute
https://bugs.webkit.org/show_bug.cgi?id=36267

Reviewed by Darin Adler.

LayoutTests/imported/w3c:

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:

Source/WebCore:

Add support for KeyboardEvent.key attribute:

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):

Source/WebKit2:

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):

Source/WTF:

Add compile time flag for the key attribute on KeyboardEvent and enable
it on Cocoa only.

  • wtf/FeatureDefines.h:

LayoutTests:

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:
Location:
trunk
Files:
2 added
32 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r206748 r206750  
     12016-10-03  Chris Dumez  <cdumez@apple.com>
     2
     3        Add support for KeyboardEvent.key attribute
     4        https://bugs.webkit.org/show_bug.cgi?id=36267
     5
     6        Reviewed by Darin Adler.
     7
     8        Extend layout test coverage.
     9
     10        * fast/events/constructors/keyboard-event-constructor-expected.txt:
     11        * fast/events/constructors/keyboard-event-constructor.html:
     12        * fast/events/key-events-in-input-button-expected.txt:
     13        * fast/events/key-events-in-input-button.html:
     14        * fast/events/key-events-in-input-text-expected.txt:
     15        * fast/events/key-events-in-input-text.html:
     16        * fast/events/keyboardevent-key-expected.txt: Added.
     17        * fast/events/keyboardevent-key.html: Added.
     18        * fast/events/special-key-events-in-input-text-expected.txt:
     19        * fast/events/special-key-events-in-input-text.html:
     20        * platform/ios-simulator/TestExpectations:
     21
     222016-10-03  Chris Dumez  <cdumez@apple.com>
     23
     24        Add support for KeyboardEvent.key attribute
     25        https://bugs.webkit.org/show_bug.cgi?id=36267
     26
     27        Reviewed by Darin Adler.
     28
     29        Extend layout test coverage.
     30
     31        * fast/events/constructors/keyboard-event-constructor-expected.txt:
     32        * fast/events/constructors/keyboard-event-constructor.html:
     33        * fast/events/key-events-in-input-button-expected.txt:
     34        * fast/events/key-events-in-input-button.html:
     35        * fast/events/key-events-in-input-text-expected.txt:
     36        * fast/events/key-events-in-input-text.html:
     37        * fast/events/keyboardevent-key-expected.txt: Added.
     38        * fast/events/keyboardevent-key.html: Added.
     39        * fast/events/special-key-events-in-input-text-expected.txt:
     40        * fast/events/special-key-events-in-input-text.html:
     41        * platform/ios-simulator/TestExpectations:
     42
    1432016-10-03  Ryan Haddad  <ryanhaddad@apple.com>
    244
  • trunk/LayoutTests/fast/events/constructors/keyboard-event-constructor-expected.txt

    r206724 r206750  
    104104PASS new KeyboardEvent('eventType', { metaKey: false }).metaKey is false
    105105PASS new KeyboardEvent('eventType', { metaKey: true }).metaKey is true
    106 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
    107 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
    108 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
    109 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
    110 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"
    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 }).location is 222
    112 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
    113 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
    114 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
    115 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
     106PASS 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
     107PASS 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
     108PASS 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
     109PASS 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
     110PASS 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"
     111PASS 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"
     112PASS 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
     113PASS 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
     114PASS 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
     115PASS 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
     116PASS 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
    116117PASS successfullyParsed is true
    117118
  • trunk/LayoutTests/fast/events/constructors/keyboard-event-constructor.html

    r206724 r206750  
    118118
    119119// All initializers are passed.
    120 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");
    121 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");
    122 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");
    123 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");
    124 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");
    125 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");
    126 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");
    127 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");
    128 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");
    129 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");
     120shouldBe("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");
     121shouldBe("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");
     122shouldBe("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");
     123shouldBe("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");
     124shouldBeEqualToString("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");
     125shouldBeEqualToString("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");
     126shouldBe("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");
     127shouldBe("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");
     128shouldBe("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");
     129shouldBe("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");
     130shouldBe("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");
    130131</script>
    131132<script src="../../../resources/js-test-post.js"></script>
  • trunk/LayoutTests/fast/events/key-events-in-input-button-expected.txt

    r28620 r206750  
    22
    33
    4 target - type - ctrlKey,altKey,shiftKey,metaKey - keyIdentifier - keyCode - charCode
     4target - type - ctrlKey,altKey,shiftKey,metaKey - key - keyIdentifier - keyCode - charCode
    55Space:
    6 INPUT - keydown - false,false,false,false - U+0020 - 32 - 0
    7 INPUT - keypress - false,false,false,false - - 32 - 32
    8 INPUT - keyup - false,false,false,false - U+0020 - 32 - 0
     6INPUT - keydown - false,false,false,false - - U+0020 - 32 - 0
     7INPUT - keypress - false,false,false,false - - - 32 - 32
     8INPUT - keyup - false,false,false,false - - U+0020 - 32 - 0
    99INPUT - click
    1010Enter:
    11 INPUT - keydown - false,false,false,false - Enter - 13 - 0
    12 INPUT - keypress - false,false,false,false - - 13 - 13
     11INPUT - keydown - false,false,false,false - Enter - Enter - 13 - 0
     12INPUT - keypress - false,false,false,false - Enter - - 13 - 13
    1313INPUT - click
    14 INPUT - keyup - false,false,false,false - Enter - 13 - 0
     14INPUT - keyup - false,false,false,false - Enter - Enter - 13 - 0
    1515A:
    16 INPUT - keydown - false,false,true,false - U+0041 - 65 - 0
    17 INPUT - keypress - false,false,true,false - - 65 - 65
    18 INPUT - keyup - false,false,true,false - U+0041 - 65 - 0
     16INPUT - keydown - false,false,true,false - A - U+0041 - 65 - 0
     17INPUT - keypress - false,false,true,false - A - - 65 - 65
     18INPUT - keyup - false,false,true,false - A - U+0041 - 65 - 0
    1919
  • trunk/LayoutTests/fast/events/key-events-in-input-button.html

    r120792 r206750  
    2424        return (where ? "(" + where + ") " : "") + target.tagName + " - " + event.type
    2525            + ' - ' + [event.ctrlKey, event.altKey, event.shiftKey, event.metaKey]
     26            + ' - ' + event.key
    2627            + ' - ' + event.keyIdentifier
    2728            + ' - ' + event.keyCode
     
    3536}
    3637log("target - type - " + ["ctrlKey", "altKey", "shiftKey", "metaKey"]
     38        + ' - ' + "key"
    3739        + ' - ' + "keyIdentifier"
    3840        + ' - ' + "keyCode"
  • trunk/LayoutTests/fast/events/key-events-in-input-text-expected.txt

    r28620 r206750  
    22
    33 
    4 target - type - ctrlKey,altKey,shiftKey,metaKey - keyIdentifier - keyCode - charCode
     4target - type - ctrlKey,altKey,shiftKey,metaKey - key - keyIdentifier - keyCode - charCode
    55Space:
    6 INPUT - keydown - false,false,false,false - U+0020 - 32 - 0. Value: "".
    7 INPUT - keypress - false,false,false,false - - 32 - 32. Value: "".
     6INPUT - keydown - false,false,false,false - - U+0020 - 32 - 0. Value: "".
     7INPUT - keypress - false,false,false,false - - - 32 - 32. Value: "".
    88INPUT - textInput - . Value: "".
    9 INPUT - keyup - false,false,false,false - U+0020 - 32 - 0. Value: " ".
     9INPUT - keyup - false,false,false,false - - U+0020 - 32 - 0. Value: " ".
    1010Backspace:
    11 INPUT - keydown - false,false,false,false - U+0008 - 8 - 0. Value: " ".
    12 INPUT - keyup - false,false,false,false - U+0008 - 8 - 0. Value: "".
     11INPUT - keydown - false,false,false,false - Backspace - U+0008 - 8 - 0. Value: " ".
     12INPUT - keyup - false,false,false,false - Backspace - U+0008 - 8 - 0. Value: "".
    1313Left Arrow:
    14 INPUT - keydown - false,false,false,false - Left - 37 - 0. Value: "".
    15 INPUT - keyup - false,false,false,false - Left - 37 - 0. Value: "".
     14INPUT - keydown - false,false,false,false - ArrowLeft - Left - 37 - 0. Value: "".
     15INPUT - keyup - false,false,false,false - ArrowLeft - Left - 37 - 0. Value: "".
    1616Tab:
    17 INPUT - keydown - false,false,false,false - U+0009 - 9 - 0. Value: "".
     17INPUT - keydown - false,false,false,false - Tab - U+0009 - 9 - 0. Value: "".
    1818
  • trunk/LayoutTests/fast/events/key-events-in-input-text.html

    r120792 r206750  
    2626        return (where ? "(" + where + ") " : "") + target.tagName + " - " + event.type
    2727            + ' - ' + [event.ctrlKey, event.altKey, event.shiftKey, event.metaKey]
     28            + ' - ' + event.key
    2829            + ' - ' + event.keyIdentifier
    2930            + ' - ' + event.keyCode
     
    3940}
    4041log("target - type - " + ["ctrlKey", "altKey", "shiftKey", "metaKey"]
     42        + ' - ' + "key"
    4143        + ' - ' + "keyIdentifier"
    4244        + ' - ' + "keyCode"
  • trunk/LayoutTests/fast/events/special-key-events-in-input-text-expected.txt

    r64555 r206750  
    22
    33
    4 target - type - ctrlKey,altKey,shiftKey,metaKey - keyIdentifier - keyCode - charCode
     4target - type - ctrlKey,altKey,shiftKey,metaKey - key - keyIdentifier - keyCode - charCode
    55
    66Ampersand:
    7 INPUT - keydown - false,false,true,false - U+0037 - 55 - 0. Value: "".
    8 INPUT - keypress - false,false,true,false - - 55 - 55. Value: "".
     7INPUT - keydown - false,false,true,false - 7 - U+0037 - 55 - 0. Value: "".
     8INPUT - keypress - false,false,true,false - 7 - - 55 - 55. Value: "".
    99INPUT - textInput - 7. Value: "".
    10 INPUT - keyup - false,false,true,false - U+0037 - 55 - 0. Value: "7".
     10INPUT - keyup - false,false,true,false - 7 - U+0037 - 55 - 0. Value: "7".
    1111
    1212Backspace:
    13 INPUT - keydown - false,false,false,false - U+0008 - 8 - 0. Value: "7".
    14 INPUT - keyup - false,false,false,false - U+0008 - 8 - 0. Value: "".
     13INPUT - keydown - false,false,false,false - Backspace - U+0008 - 8 - 0. Value: "7".
     14INPUT - keyup - false,false,false,false - Backspace - U+0008 - 8 - 0. Value: "".
    1515
    1616Percent:
    17 INPUT - keydown - false,false,true,false - U+0035 - 53 - 0. Value: "".
    18 INPUT - keypress - false,false,true,false - - 53 - 53. Value: "".
     17INPUT - keydown - false,false,true,false - 5 - U+0035 - 53 - 0. Value: "".
     18INPUT - keypress - false,false,true,false - 5 - - 53 - 53. Value: "".
    1919INPUT - textInput - 5. Value: "".
    20 INPUT - keyup - false,false,true,false - U+0035 - 53 - 0. Value: "5".
     20INPUT - keyup - false,false,true,false - 5 - U+0035 - 53 - 0. Value: "5".
    2121
    2222Backspace:
    23 INPUT - keydown - false,false,false,false - U+0008 - 8 - 0. Value: "5".
    24 INPUT - keyup - false,false,false,false - U+0008 - 8 - 0. Value: "".
     23INPUT - keydown - false,false,false,false - Backspace - U+0008 - 8 - 0. Value: "5".
     24INPUT - keyup - false,false,false,false - Backspace - U+0008 - 8 - 0. Value: "".
    2525
    2626Left parenthesis:
    27 INPUT - keydown - false,false,true,false - U+0039 - 57 - 0. Value: "".
    28 INPUT - keypress - false,false,true,false - - 57 - 57. Value: "".
     27INPUT - keydown - false,false,true,false - 9 - U+0039 - 57 - 0. Value: "".
     28INPUT - keypress - false,false,true,false - 9 - - 57 - 57. Value: "".
    2929INPUT - textInput - 9. Value: "".
    30 INPUT - keyup - false,false,true,false - U+0039 - 57 - 0. Value: "9".
     30INPUT - keyup - false,false,true,false - 9 - U+0039 - 57 - 0. Value: "9".
    3131
    3232Backspace:
    33 INPUT - keydown - false,false,false,false - U+0008 - 8 - 0. Value: "9".
    34 INPUT - keyup - false,false,false,false - U+0008 - 8 - 0. Value: "".
     33INPUT - keydown - false,false,false,false - Backspace - U+0008 - 8 - 0. Value: "9".
     34INPUT - keyup - false,false,false,false - Backspace - U+0008 - 8 - 0. Value: "".
    3535
    3636Right parenthesis:
    37 INPUT - keydown - false,false,true,false - U+0030 - 48 - 0. Value: "".
    38 INPUT - keypress - false,false,true,false - - 48 - 48. Value: "".
     37INPUT - keydown - false,false,true,false - 0 - U+0030 - 48 - 0. Value: "".
     38INPUT - keypress - false,false,true,false - 0 - - 48 - 48. Value: "".
    3939INPUT - textInput - 0. Value: "".
    40 INPUT - keyup - false,false,true,false - U+0030 - 48 - 0. Value: "0".
     40INPUT - keyup - false,false,true,false - 0 - U+0030 - 48 - 0. Value: "0".
    4141
    4242Backspace:
    43 INPUT - keydown - false,false,false,false - U+0008 - 8 - 0. Value: "0".
    44 INPUT - keyup - false,false,false,false - U+0008 - 8 - 0. Value: "".
     43INPUT - keydown - false,false,false,false - Backspace - U+0008 - 8 - 0. Value: "0".
     44INPUT - keyup - false,false,false,false - Backspace - U+0008 - 8 - 0. Value: "".
    4545
    4646Print screen:
    47 INPUT - keydown - false,false,false,false - PrintScreen - 44 - 0. Value: "".
    48 INPUT - keyup - false,false,false,false - PrintScreen - 44 - 0. Value: "".
     47INPUT - keydown - false,false,false,false - PrintScreen - PrintScreen - 44 - 0. Value: "".
     48INPUT - keyup - false,false,false,false - PrintScreen - PrintScreen - 44 - 0. Value: "".
    4949
  • trunk/LayoutTests/fast/events/special-key-events-in-input-text.html

    r120792 r206750  
    1919   } else if (type == "keydown" || type == "keypress" || type == "keyup") {
    2020     info += [e.ctrlKey, e.altKey, e.shiftKey, e.metaKey] +
     21         ' - ' + e.key +
    2122         ' - ' + e.keyIdentifier +
    2223         ' - ' + e.keyCode +
     
    2829
    2930log("target - type - " + ["ctrlKey", "altKey", "shiftKey", "metaKey"]
     31       + ' - ' + "key"
    3032       + ' - ' + "keyIdentifier"
    3133       + ' - ' + "keyCode"
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r206733 r206750  
     12016-10-03  Chris Dumez  <cdumez@apple.com>
     2
     3        Add support for KeyboardEvent.key attribute
     4        https://bugs.webkit.org/show_bug.cgi?id=36267
     5
     6        Reviewed by Darin Adler.
     7
     8        Rebaseline because that the tests are failing differently now that we support
     9        the key attribute on KeyboardEvent but are still missing other standard API
     10        on this interface.
     11
     12        * web-platform-tests/dom/events/Event-init-while-dispatching-expected.txt:
     13        * web-platform-tests/dom/events/Event-subclasses-constructors-expected.txt:
     14
     152016-10-03  Chris Dumez  <cdumez@apple.com>
     16
     17        Add support for KeyboardEvent.key attribute
     18        https://bugs.webkit.org/show_bug.cgi?id=36267
     19
     20        Reviewed by Darin Adler.
     21
     22        Rebaseline because that the tests are failing differently now that we support
     23        the key attribute on KeyboardEvent but are still missing other standard API
     24        on this interface.
     25
     26        * web-platform-tests/dom/events/Event-init-while-dispatching-expected.txt:
     27        * web-platform-tests/dom/events/Event-subclasses-constructors-expected.txt:
     28
    1292016-10-03  Chris Dumez  <cdumez@apple.com>
    230
  • trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-init-while-dispatching-expected.txt

    r203164 r206750  
    11
    2 FAIL Calling initKeyboardEvent while dispatching. assert_equals: initKeyboardEvent key setter should short-circuit expected (string) "A" but got (undefined) undefined
     2PASS Calling initKeyboardEvent while dispatching.
    33PASS Calling initMouseEvent while dispatching.
    44PASS Calling initCustomEvent while dispatching.
  • trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-subclasses-constructors-expected.txt

    r203950 r206750  
    3030FAIL WheelEvent constructor (argument with default values) assert_true: Event object "[object WheelEvent]" should have a buttons property expected true got false
    3131FAIL WheelEvent constructor (argument with non-default values) assert_true: Event object "[object WheelEvent]" should have a buttons property expected true got false
    32 FAIL KeyboardEvent constructor (no argument) assert_true: Event object "[object KeyboardEvent]" should have a key property expected true got false
    33 FAIL KeyboardEvent constructor (undefined argument) assert_true: Event object "[object KeyboardEvent]" should have a key property expected true got false
    34 FAIL KeyboardEvent constructor (null argument) assert_true: Event object "[object KeyboardEvent]" should have a key property expected true got false
    35 FAIL KeyboardEvent constructor (empty argument) assert_true: Event object "[object KeyboardEvent]" should have a key property expected true got false
    36 FAIL KeyboardEvent constructor (argument with default values) assert_true: Event object "[object KeyboardEvent]" should have a key property expected true got false
    37 FAIL KeyboardEvent constructor (argument with non-default values) assert_true: Event object "[object KeyboardEvent]" should have a key property expected true got false
     32FAIL KeyboardEvent constructor (no argument) assert_true: Event object "[object KeyboardEvent]" should have a code property expected true got false
     33FAIL KeyboardEvent constructor (undefined argument) assert_true: Event object "[object KeyboardEvent]" should have a code property expected true got false
     34FAIL KeyboardEvent constructor (null argument) assert_true: Event object "[object KeyboardEvent]" should have a code property expected true got false
     35FAIL KeyboardEvent constructor (empty argument) assert_true: Event object "[object KeyboardEvent]" should have a code property expected true got false
     36FAIL KeyboardEvent constructor (argument with default values) assert_true: Event object "[object KeyboardEvent]" should have a code property expected true got false
     37FAIL KeyboardEvent constructor (argument with non-default values) assert_true: Event object "[object KeyboardEvent]" should have a code property expected true got false
    3838PASS CompositionEvent constructor (no argument)
    3939PASS CompositionEvent constructor (undefined argument)
  • trunk/LayoutTests/platform/ios-simulator/TestExpectations

    r206657 r206750  
    337337fast/shadow-dom/shadow-host-removal-crash.html [ Skip ]
    338338fast/shadow-dom/input-element-in-shadow.html [ Skip ]
     339fast/events/keyboardevent-key.html [ Skip ]
    339340
    340341# The file-wrapper part of <attachment> is not yet working on iOS
  • trunk/Source/WTF/ChangeLog

    r206691 r206750  
     12016-10-03  Chris Dumez  <cdumez@apple.com>
     2
     3        Add support for KeyboardEvent.key attribute
     4        https://bugs.webkit.org/show_bug.cgi?id=36267
     5
     6        Reviewed by Darin Adler.
     7
     8        Add compile time flag for the key attribute on KeyboardEvent and enable
     9        it on Cocoa only.
     10
     11        * wtf/FeatureDefines.h:
     12
    1132016-09-29  Sam Weinig  <sam@webkit.org>
    214
  • trunk/Source/WTF/wtf/FeatureDefines.h

    r206440 r206750  
    256256#endif
    257257
     258#if !defined(ENABLE_KEYBOARD_KEY_ATTRIBUTE)
     259#define ENABLE_KEYBOARD_KEY_ATTRIBUTE 1
     260#endif
     261
    258262#endif /* PLATFORM(COCOA) */
    259263
     
    770774#endif
    771775
     776#if !defined(ENABLE_KEYBOARD_KEY_ATTRIBUTE)
     777#define ENABLE_KEYBOARD_KEY_ATTRIBUTE 0
     778#endif
     779
    772780/* Asserts, invariants for macro definitions */
    773781
  • trunk/Source/WebCore/ChangeLog

    r206749 r206750  
     12016-10-03  Chris Dumez  <cdumez@apple.com>
     2
     3        Add support for KeyboardEvent.key attribute
     4        https://bugs.webkit.org/show_bug.cgi?id=36267
     5
     6        Reviewed by Darin Adler.
     7
     8        Add support for KeyboardEvent.key attribute:
     9        - https://w3c.github.io/uievents/#dom-keyboardevent-key
     10
     11        This is behind a compile time flag that is only enabled on Mac and
     12        iOS and the implementation is still missing for other platforms.
     13
     14        Test: fast/events/keyboardevent-key.html
     15
     16        * dom/KeyboardEvent.cpp:
     17        (WebCore::KeyboardEvent::KeyboardEvent):
     18        * dom/KeyboardEvent.h:
     19        * dom/KeyboardEvent.idl:
     20        * platform/PlatformKeyboardEvent.h:
     21        (WebCore::PlatformKeyboardEvent::PlatformKeyboardEvent):
     22        (WebCore::PlatformKeyboardEvent::key):
     23        * platform/cocoa/KeyEventCocoa.h:
     24        * platform/cocoa/KeyEventCocoa.mm:
     25        (WebCore::keyForCharCode):
     26        * platform/ios/PlatformEventFactoryIOS.h:
     27        * platform/ios/PlatformEventFactoryIOS.mm:
     28        (WebCore::keyForKeyEvent):
     29        (WebCore::PlatformKeyboardEventBuilder::PlatformKeyboardEventBuilder):
     30        * platform/mac/PlatformEventFactoryMac.h:
     31        * platform/mac/PlatformEventFactoryMac.mm:
     32        (WebCore::keyForKeyEvent):
     33        (WebCore::PlatformKeyboardEventBuilder::PlatformKeyboardEventBuilder):
     34        (WebCore::PlatformWheelEventBuilder::PlatformWheelEventBuilder): Deleted.
     35        * replay/SerializationMethods.cpp:
     36        (JSC::EncodingTraits<PlatformKeyboardEvent>::encodeValue):
     37        (JSC::EncodingTraits<PlatformKeyboardEvent>::decodeValue):
     38
     392016-10-03  Chris Dumez  <cdumez@apple.com>
     40
     41        Add support for KeyboardEvent.key attribute
     42        https://bugs.webkit.org/show_bug.cgi?id=36267
     43
     44        Reviewed by Darin Adler.
     45
     46        Add support for KeyboardEvent.key attribute:
     47        - https://w3c.github.io/uievents/#dom-keyboardevent-key
     48
     49        This is behind a compile time flag that is only enabled on Mac and
     50        iOS and the implementation is still missing for other platforms.
     51
     52        Test: fast/events/keyboardevent-key.html
     53
     54        * dom/KeyboardEvent.cpp:
     55        (WebCore::KeyboardEvent::KeyboardEvent):
     56        * dom/KeyboardEvent.h:
     57        * dom/KeyboardEvent.idl:
     58        * platform/PlatformKeyboardEvent.h:
     59        (WebCore::PlatformKeyboardEvent::PlatformKeyboardEvent):
     60        (WebCore::PlatformKeyboardEvent::key):
     61        * platform/cocoa/KeyEventCocoa.h:
     62        * platform/cocoa/KeyEventCocoa.mm:
     63        (WebCore::keyForCharCode):
     64        * platform/ios/PlatformEventFactoryIOS.h:
     65        * platform/ios/PlatformEventFactoryIOS.mm:
     66        (WebCore::keyForKeyEvent):
     67        (WebCore::PlatformKeyboardEventBuilder::PlatformKeyboardEventBuilder):
     68        * platform/mac/PlatformEventFactoryMac.h:
     69        * platform/mac/PlatformEventFactoryMac.mm:
     70        (WebCore::keyForKeyEvent):
     71        (WebCore::PlatformKeyboardEventBuilder::PlatformKeyboardEventBuilder):
     72        (WebCore::PlatformWheelEventBuilder::PlatformWheelEventBuilder): Deleted.
     73        * replay/SerializationMethods.cpp:
     74        (JSC::EncodingTraits<PlatformKeyboardEvent>::encodeValue):
     75        (JSC::EncodingTraits<PlatformKeyboardEvent>::decodeValue):
     76
    1772016-10-03  Alex Christensen  <achristensen@webkit.org>
    278
  • trunk/Source/WebCore/dom/KeyboardEvent.cpp

    r206725 r206750  
    105105                          true, true, key.timestamp(), view, 0, key.ctrlKey(), key.altKey(), key.shiftKey(), key.metaKey())
    106106    , m_keyEvent(std::make_unique<PlatformKeyboardEvent>(key))
     107#if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
     108    , m_key(key.key())
     109#endif
    107110    , m_keyIdentifier(key.keyIdentifier())
    108111    , m_location(keyLocationCode(key))
     
    128131KeyboardEvent::KeyboardEvent(const AtomicString& eventType, const KeyboardEventInit& initializer)
    129132    : UIEventWithKeyState(eventType, initializer)
     133#if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
     134    , m_key(initializer.key)
     135#endif
    130136    , m_keyIdentifier(initializer.keyIdentifier)
    131137    , m_location(initializer.location)
  • trunk/Source/WebCore/dom/KeyboardEvent.h

    r206724 r206750  
    3535
    3636struct KeyboardEventInit : public UIEventWithKeyStateInit {
     37#if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
     38    String key;
     39#endif
    3740    String keyIdentifier;
    3841    unsigned location { 0 };
     
    4750        DOM_KEY_LOCATION_RIGHT      = 0x02,
    4851        DOM_KEY_LOCATION_NUMPAD     = 0x03
    49         // FIXME: The following values are not supported yet (crbug.com/265446)
    50         // DOM_KEY_LOCATION_MOBILE     = 0x04,
    51         // DOM_KEY_LOCATION_JOYSTICK   = 0x05
    5252    };
    5353
     
    8080        bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, bool altGraphKey = false);
    8181   
     82#if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
     83    const String& key() const { return m_key; }
     84#endif
     85
    8286    const String& keyIdentifier() const { return m_keyIdentifier; }
    8387    unsigned location() const { return m_location; }
     
    109113    WEBCORE_EXPORT KeyboardEvent(const PlatformKeyboardEvent&, DOMWindow*);
    110114    KeyboardEvent(const AtomicString&, const KeyboardEventInit&);
    111     // FIXME: This method should be get ride of in the future.
     115    // FIXME: This method should be get rid of in the future.
    112116    // DO NOT USE IT!
    113117    KeyboardEvent(WTF::HashTableDeletedValueType);
    114118
    115119    std::unique_ptr<PlatformKeyboardEvent> m_keyEvent;
     120#if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
     121    String m_key;
     122#endif
    116123    String m_keyIdentifier;
    117124    unsigned m_location;
  • trunk/Source/WebCore/dom/KeyboardEvent.idl

    r206725 r206750  
    2929    const unsigned long DOM_KEY_LOCATION_NUMPAD = 0x03;
    3030
    31     [InitializedByEventConstructor] readonly attribute DOMString keyIdentifier;
     31    [InitializedByEventConstructor, Conditional=KEYBOARD_KEY_ATTRIBUTE] readonly attribute DOMString key;
     32
     33    // FIXME: We should support this.
     34    // [InitializedByEventConstructor] readonly attribute DOMString code;
     35
    3236    [InitializedByEventConstructor] readonly attribute unsigned long location;
    33     [InitializedByEventConstructor, ImplementedAs=location] readonly attribute unsigned long keyLocation; // Deprecated.
     37
    3438    [InitializedByEventConstructor] readonly attribute boolean ctrlKey;
    3539    [InitializedByEventConstructor] readonly attribute boolean shiftKey;
    3640    [InitializedByEventConstructor] readonly attribute boolean altKey;
    3741    [InitializedByEventConstructor] readonly attribute boolean metaKey;
    38     readonly attribute boolean altGraphKey;
    39 
    4042    [InitializedByEventConstructor] readonly attribute boolean repeat;
    4143
     44    // FIXME: We should support this.
     45    // readonly attribute boolean isComposing;
     46
    4247    boolean getModifierState(DOMString keyArg);
     48
     49    // Everything below is legacy.
     50    [InitializedByEventConstructor] readonly attribute DOMString keyIdentifier;
     51    [InitializedByEventConstructor, ImplementedAs=location] readonly attribute unsigned long keyLocation;
     52    readonly attribute boolean altGraphKey;
    4353
    4454    // FIXME: this does not match the version in the DOM spec.
  • trunk/Source/WebCore/platform/PlatformKeyboardEvent.h

    r206644 r206750  
    7171        }
    7272
    73         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)
     73        PlatformKeyboardEvent(Type type, const String& text, const String& unmodifiedText,
     74#if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
     75        const String& key,
     76#endif
     77        const String& keyIdentifier, int windowsVirtualKeyCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, OptionSet<Modifier> modifiers, double timestamp)
    7478            : PlatformEvent(type, modifiers, timestamp)
    7579            , m_text(text)
    7680            , m_unmodifiedText(unmodifiedText)
     81#if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
     82            , m_key(key)
     83#endif
    7784            , m_keyIdentifier(keyIdentifier)
    7885            , m_windowsVirtualKeyCode(windowsVirtualKeyCode)
     
    102109
    103110        String keyIdentifier() const { return m_keyIdentifier; }
     111
     112#if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
     113        const String& key() const { return m_key; }
     114#endif
    104115
    105116        // Most compatible Windows virtual key code associated with the event.
     
    155166        String m_text;
    156167        String m_unmodifiedText;
     168#if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
     169        String m_key;
     170#endif
    157171        String m_keyIdentifier;
    158172        int m_windowsVirtualKeyCode;
  • trunk/Source/WebCore/platform/cocoa/KeyEventCocoa.h

    r165676 r206750  
    3131namespace WebCore {
    3232
     33String keyForCharCode(unichar charCode);
    3334String keyIdentifierForCharCode(unichar charCode);
    3435
  • trunk/Source/WebCore/platform/cocoa/KeyEventCocoa.mm

    r165676 r206750  
    3939
    4040namespace WebCore {
     41
     42// https://w3c.github.io/uievents-key/
     43String keyForCharCode(unichar charCode)
     44{
     45    switch (charCode) {
     46    case NSUpArrowFunctionKey:
     47        return ASCIILiteral("ArrowUp");
     48    case NSDownArrowFunctionKey:
     49        return ASCIILiteral("ArrowDown");
     50    case NSLeftArrowFunctionKey:
     51        return ASCIILiteral("ArrowLeft");
     52    case NSRightArrowFunctionKey:
     53        return ASCIILiteral("ArrowRight");
     54    case NSF1FunctionKey:
     55        return ASCIILiteral("F1");
     56    case NSF2FunctionKey:
     57        return ASCIILiteral("F2");
     58    case NSF3FunctionKey:
     59        return ASCIILiteral("F3");
     60    case NSF4FunctionKey:
     61        return ASCIILiteral("F4");
     62    case NSF5FunctionKey:
     63        return ASCIILiteral("F5");
     64    case NSF6FunctionKey:
     65        return ASCIILiteral("F6");
     66    case NSF7FunctionKey:
     67        return ASCIILiteral("F7");
     68    case NSF8FunctionKey:
     69        return ASCIILiteral("F8");
     70    case NSF9FunctionKey:
     71        return ASCIILiteral("F9");
     72    case NSF10FunctionKey:
     73        return ASCIILiteral("F10");
     74    case NSF11FunctionKey:
     75        return ASCIILiteral("F11");
     76    case NSF12FunctionKey:
     77        return ASCIILiteral("F12");
     78    case NSF13FunctionKey:
     79        return ASCIILiteral("F13");
     80    case NSF14FunctionKey:
     81        return ASCIILiteral("F14");
     82    case NSF15FunctionKey:
     83        return ASCIILiteral("F15");
     84    case NSF16FunctionKey:
     85        return ASCIILiteral("F16");
     86    case NSF17FunctionKey:
     87        return ASCIILiteral("F17");
     88    case NSF18FunctionKey:
     89        return ASCIILiteral("F18");
     90    case NSF19FunctionKey:
     91        return ASCIILiteral("F19");
     92    case NSF20FunctionKey:
     93        return ASCIILiteral("F20");
     94    case NSF21FunctionKey:
     95        return ASCIILiteral("F21");
     96    case NSF22FunctionKey:
     97        return ASCIILiteral("F22");
     98    case NSF23FunctionKey:
     99        return ASCIILiteral("F23");
     100    case NSF24FunctionKey:
     101        return ASCIILiteral("F24");
     102    case NSF25FunctionKey:
     103        return ASCIILiteral("F25");
     104    case NSF26FunctionKey:
     105        return ASCIILiteral("F26");
     106    case NSF27FunctionKey:
     107        return ASCIILiteral("F27");
     108    case NSF28FunctionKey:
     109        return ASCIILiteral("F28");
     110    case NSF29FunctionKey:
     111        return ASCIILiteral("F29");
     112    case NSF30FunctionKey:
     113        return ASCIILiteral("F30");
     114    case NSF31FunctionKey:
     115        return ASCIILiteral("F31");
     116    case NSF32FunctionKey:
     117        return ASCIILiteral("F32");
     118    case NSF33FunctionKey:
     119        return ASCIILiteral("F33");
     120    case NSF34FunctionKey:
     121        return ASCIILiteral("F34");
     122    case NSF35FunctionKey:
     123        return ASCIILiteral("F35");
     124    case NSInsertFunctionKey:
     125        return ASCIILiteral("Insert");
     126    case NSDeleteFunctionKey:
     127        return ASCIILiteral("Delete");
     128    case NSHomeFunctionKey:
     129        return ASCIILiteral("Home");
     130    case NSEndFunctionKey:
     131        return ASCIILiteral("End");
     132    case NSPageUpFunctionKey:
     133        return ASCIILiteral("PageUp");
     134    case NSPageDownFunctionKey:
     135        return ASCIILiteral("PageDown");
     136    case NSPrintScreenFunctionKey:
     137        return ASCIILiteral("PrintScreen");
     138    case NSScrollLockFunctionKey:
     139        return ASCIILiteral("ScrollLock");
     140    case NSPauseFunctionKey:
     141        return ASCIILiteral("Pause");
     142    case NSMenuFunctionKey:
     143        return ASCIILiteral("ContextMenu");
     144    case NSPrintFunctionKey:
     145        return ASCIILiteral("Print");
     146    case NSClearLineFunctionKey:
     147        return ASCIILiteral("Clear");
     148    case NSSelectFunctionKey:
     149        return ASCIILiteral("Select");
     150    case NSExecuteFunctionKey:
     151        return ASCIILiteral("Execute");
     152    case NSUndoFunctionKey:
     153        return ASCIILiteral("Undo");
     154    case NSRedoFunctionKey:
     155        return ASCIILiteral("Redo");
     156    case NSFindFunctionKey:
     157        return ASCIILiteral("Find");
     158    case NSHelpFunctionKey:
     159        return ASCIILiteral("Help");
     160    case NSModeSwitchFunctionKey:
     161        return ASCIILiteral("ModeChange");
     162    case NSEnterCharacter:
     163    case NSNewlineCharacter:
     164    case NSCarriageReturnCharacter:
     165        return ASCIILiteral("Enter");
     166    case NSDeleteCharacter:
     167    case NSBackspaceCharacter:
     168        return ASCIILiteral("Backspace");
     169    case NSBackTabCharacter:
     170    case NSTabCharacter:
     171        return ASCIILiteral("Tab");
     172    case 0x1B:
     173        return ASCIILiteral("Escape");
     174    case NSFormFeedCharacter:
     175    case NSParagraphSeparatorCharacter:
     176    case NSLineSeparatorCharacter:
     177    case NSBeginFunctionKey:
     178    case NSSysReqFunctionKey:
     179    case NSBreakFunctionKey:
     180    case NSResetFunctionKey:
     181    case NSStopFunctionKey:
     182    case NSUserFunctionKey:
     183    case NSSystemFunctionKey:
     184    case NSClearDisplayFunctionKey:
     185    case NSInsertLineFunctionKey:
     186    case NSDeleteLineFunctionKey:
     187    case NSInsertCharFunctionKey:
     188    case NSDeleteCharFunctionKey:
     189    case NSPrevFunctionKey:
     190    case NSNextFunctionKey:
     191        return ASCIILiteral("Unidentified");
     192    default:
     193        return String(&charCode, 1);
     194    }
     195}
    41196
    42197String keyIdentifierForCharCode(unichar charCode)
  • trunk/Source/WebCore/platform/ios/PlatformEventFactoryIOS.h

    r176904 r206750  
    5050};
    5151
     52WEBCORE_EXPORT String keyForKeyEvent(WebEvent *);
    5253WEBCORE_EXPORT String keyIdentifierForKeyEvent(WebEvent *);
    5354
  • trunk/Source/WebCore/platform/ios/PlatformEventFactoryIOS.mm

    r206644 r206750  
    130130}
    131131
     132String keyForKeyEvent(WebEvent *event)
     133{
     134    NSString *characters = event.characters;
     135    auto length = [characters length];
     136
     137    // characters return an empty string for dead keys.
     138    // https://developer.apple.com/reference/appkit/nsevent/1534183-characters
     139    // "Dead" is defined here https://w3c.github.io/uievents-key/#keys-composition.
     140    if (!length)
     141        return ASCIILiteral("Dead");
     142
     143    if (length > 1)
     144        return characters;
     145
     146    return keyForCharCode([characters characterAtIndex:0]);
     147}
     148
    132149class PlatformKeyboardEventBuilder : public PlatformKeyboardEvent {
    133150public:
     
    142159        m_text = event.characters;
    143160        m_unmodifiedText = event.charactersIgnoringModifiers;
     161        m_key = keyForKeyEvent(event);
    144162        m_keyIdentifier = keyIdentifierForKeyEvent(event);
    145163        m_windowsVirtualKeyCode = event.keyCode;
  • trunk/Source/WebCore/platform/mac/PlatformEventFactoryMac.h

    r201441 r206750  
    4747WEBCORE_EXPORT int windowsKeyCodeForKeyEvent(NSEvent *);
    4848WEBCORE_EXPORT String keyIdentifierForKeyEvent(NSEvent *);
     49WEBCORE_EXPORT String keyForKeyEvent(NSEvent *);
    4950WEBCORE_EXPORT double eventTimeStampSince1970(NSEvent *);
    5051
  • trunk/Source/WebCore/platform/mac/PlatformEventFactoryMac.mm

    r206644 r206750  
    3434#import "WebCoreSystemInterface.h"
    3535#import "WindowsKeyboardCodes.h"
     36#import <HIToolbox/Events.h>
    3637#import <mach/mach_time.h>
    3738#import <wtf/ASCIICType.h>
     
    221222static inline String textFromEvent(NSEvent* event)
    222223{
    223 #pragma clang diagnostic push
    224 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
     224#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
     225    if ([event type] == NSEventTypeFlagsChanged)
     226#else
    225227    if ([event type] == NSFlagsChanged)
    226 #pragma clang diagnostic pop
     228#endif
    227229        return emptyString();
    228230    return String([event characters]);
     
    231233static inline String unmodifiedTextFromEvent(NSEvent* event)
    232234{
    233 #pragma clang diagnostic push
    234 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
     235#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
     236    if ([event type] == NSEventTypeFlagsChanged)
     237#else
    235238    if ([event type] == NSFlagsChanged)
    236 #pragma clang diagnostic pop
     239#endif
    237240        return emptyString();
    238241    return String([event charactersIgnoringModifiers]);
    239242}
    240243
     244String keyForKeyEvent(NSEvent *event)
     245{
     246    // This constant was missing before OS X Sierra.
     247#ifndef kVK_RightCommand
     248#define kVK_RightCommand 0x36
     249#endif
     250    switch ([event keyCode]) {
     251    case kVK_RightCommand:
     252    case kVK_Command:
     253        return ASCIILiteral("Meta");
     254    case kVK_Shift:
     255    case kVK_RightShift:
     256        return ASCIILiteral("Shift");
     257    case kVK_CapsLock:
     258        return ASCIILiteral("CapsLock");
     259    case kVK_Option: // Left Alt.
     260    case kVK_RightOption: // Right Alt.
     261        return ASCIILiteral("Alt");
     262    case kVK_Control:
     263    case kVK_RightControl:
     264        return ASCIILiteral("Control");
     265    }
     266
     267    // If more than one key is being pressed and the key combination includes one or more modifier keys
     268    // that result in the key no longer producing a printable character (e.g., Control + a), then the
     269    // key value should be the printable key value that would have been produced if the key had been
     270    // typed with the default keyboard layout with no modifier keys except for Shift and AltGr applied.
     271    // https://w3c.github.io/uievents/#keys-guidelines
     272#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
     273    bool isControlDown = ([event modifierFlags] & NSEventModifierFlagControl);
     274#else
     275    bool isControlDown = ([event modifierFlags] & NSControlKeyMask);
     276#endif
     277    NSString *s = isControlDown ? [event charactersIgnoringModifiers] : [event characters];
     278    auto length = [s length];
     279    // characters / charactersIgnoringModifiers return an empty string for dead keys.
     280    // https://developer.apple.com/reference/appkit/nsevent/1534183-characters
     281    if (!length)
     282        return ASCIILiteral("Dead");
     283    // High unicode codepoints are coded with a character sequence in Mac OS X.
     284    if (length > 1)
     285        return s;
     286    return keyForCharCode([s characterAtIndex:0]);
     287}
     288
    241289String keyIdentifierForKeyEvent(NSEvent* event)
    242290{
    243 #pragma clang diagnostic push
    244 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
    245     if ([event type] == NSFlagsChanged)
    246 #pragma clang diagnostic pop
     291#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
     292    if ([event type] == NSEventTypeFlagsChanged) {
     293#else
     294    if ([event type] == NSFlagsChanged) {
     295#endif
    247296        switch ([event keyCode]) {
    248297            case 54: // Right Command
     
    269318                return emptyString();
    270319        }
     320    }
    271321   
    272322    NSString *s = [event charactersIgnoringModifiers];
     
    562612        m_unmodifiedText = unmodifiedTextFromEvent(event);
    563613        m_keyIdentifier = keyIdentifierForKeyEvent(event);
     614        m_key = keyForKeyEvent(event);
    564615        m_windowsVirtualKeyCode = windowsKeyCodeForKeyEvent(event);
    565616#pragma clang diagnostic push
  • trunk/Source/WebCore/replay/SerializationMethods.cpp

    r206644 r206750  
    257257    ENCODE_TYPE_WITH_KEY(encodedValue, String, text, input.text());
    258258    ENCODE_TYPE_WITH_KEY(encodedValue, String, unmodifiedText, input.unmodifiedText());
     259#if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
     260    ENCODE_TYPE_WITH_KEY(encodedValue, String, key, input.key());
     261#endif
    259262    ENCODE_TYPE_WITH_KEY(encodedValue, String, keyIdentifier, input.keyIdentifier());
    260263    ENCODE_TYPE_WITH_KEY(encodedValue, int, windowsVirtualKeyCode, input.windowsVirtualKeyCode());
     
    276279    DECODE_TYPE_WITH_KEY(encodedValue, String, text);
    277280    DECODE_TYPE_WITH_KEY(encodedValue, String, unmodifiedText);
     281#if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
     282    DECODE_TYPE_WITH_KEY(encodedValue, String, key);
     283#endif
    278284    DECODE_TYPE_WITH_KEY(encodedValue, String, keyIdentifier);
    279285    DECODE_TYPE_WITH_KEY(encodedValue, int, windowsVirtualKeyCode);
     
    286292#endif
    287293
    288     PlatformKeyboardEvent platformEvent = PlatformKeyboardEvent(type, text, unmodifiedText, keyIdentifier, WTF::safeCast<int>(windowsVirtualKeyCode), autoRepeat, keypad, systemKey, modifiers, timestamp);
     294    PlatformKeyboardEvent platformEvent = PlatformKeyboardEvent(type, text, unmodifiedText,
     295#if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
     296        key,
     297#endif
     298        keyIdentifier, WTF::safeCast<int>(windowsVirtualKeyCode), autoRepeat, keypad, systemKey, modifiers, timestamp);
     299
    289300#if USE(APPKIT)
    290301    input = std::make_unique<PlatformKeyboardEventAppKit>(platformEvent, handledByInputMethod, commands);
  • trunk/Source/WebKit2/ChangeLog

    r206731 r206750  
     12016-10-03  Chris Dumez  <cdumez@apple.com>
     2
     3        Add support for KeyboardEvent.key attribute
     4        https://bugs.webkit.org/show_bug.cgi?id=36267
     5
     6        Reviewed by Darin Adler.
     7
     8        Add support for KeyboardEvent.key attribute.
     9
     10        * Shared/WebEvent.h:
     11        (WebKit::WebKeyboardEvent::key):
     12        (WebKit::WebKeyboardEvent::unmodifiedText): Deleted.
     13        * Shared/WebEventConversion.cpp:
     14        (WebKit::WebKit2PlatformKeyboardEvent::WebKit2PlatformKeyboardEvent):
     15        * Shared/WebKeyboardEvent.cpp:
     16        (WebKit::WebKeyboardEvent::WebKeyboardEvent):
     17        (WebKit::WebKeyboardEvent::encode):
     18        (WebKit::WebKeyboardEvent::decode):
     19        * Shared/mac/WebEventFactory.mm:
     20        (WebKit::WebEventFactory::createWebKeyboardEvent):
     21
     222016-10-03  Chris Dumez  <cdumez@apple.com>
     23
     24        Add support for KeyboardEvent.key attribute
     25        https://bugs.webkit.org/show_bug.cgi?id=36267
     26
     27        Reviewed by Darin Adler.
     28
     29        Add support for KeyboardEvent.key attribute.
     30
     31        * Shared/WebEvent.h:
     32        (WebKit::WebKeyboardEvent::key):
     33        (WebKit::WebKeyboardEvent::unmodifiedText): Deleted.
     34        * Shared/WebEventConversion.cpp:
     35        (WebKit::WebKit2PlatformKeyboardEvent::WebKit2PlatformKeyboardEvent):
     36        * Shared/WebKeyboardEvent.cpp:
     37        (WebKit::WebKeyboardEvent::WebKeyboardEvent):
     38        (WebKit::WebKeyboardEvent::encode):
     39        (WebKit::WebKeyboardEvent::decode):
     40        * Shared/mac/WebEventFactory.mm:
     41        (WebKit::WebEventFactory::createWebKeyboardEvent):
     42
    1432016-10-03  Carlos Garcia Campos  <cgarcia@igalia.com>
    244
  • trunk/Source/WebKit2/Shared/WebEvent.h

    r206651 r206750  
    245245
    246246#if USE(APPKIT)
    247     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);
     247    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);
    248248#elif PLATFORM(GTK)
    249249    WebKeyboardEvent(Type, const String& text, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool handledByInputMethod, Vector<String>&& commands, bool isKeypad, Modifiers, double timestamp);
     
    254254    const String& text() const { return m_text; }
    255255    const String& unmodifiedText() const { return m_unmodifiedText; }
     256#if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
     257    const String& key() const { return m_key; }
     258#endif
    256259    const String& keyIdentifier() const { return m_keyIdentifier; }
    257260    int32_t windowsVirtualKeyCode() const { return m_windowsVirtualKeyCode; }
     
    278281    String m_text;
    279282    String m_unmodifiedText;
     283#if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
     284    String m_key;
     285#endif
    280286    String m_keyIdentifier;
    281287    int32_t m_windowsVirtualKeyCode;
  • trunk/Source/WebKit2/Shared/WebEventConversion.cpp

    r206651 r206750  
    192192        m_text = webEvent.text();
    193193        m_unmodifiedText = webEvent.unmodifiedText();
     194#if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
     195        m_key = webEvent.key();
     196#endif
    194197        m_keyIdentifier = webEvent.keyIdentifier();
    195198        m_windowsVirtualKeyCode = webEvent.windowsVirtualKeyCode();
  • trunk/Source/WebKit2/Shared/WebKeyboardEvent.cpp

    r204668 r206750  
    3838#if USE(APPKIT)
    3939
    40 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)
     40WebKeyboardEvent::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)
    4141    : WebEvent(type, modifiers, timestamp)
    4242    , m_text(text)
    4343    , m_unmodifiedText(unmodifiedText)
     44    , m_key(key)
    4445    , m_keyIdentifier(keyIdentifier)
    4546    , m_windowsVirtualKeyCode(windowsVirtualKeyCode)
     
    103104    encoder << m_text;
    104105    encoder << m_unmodifiedText;
     106#if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
     107    encoder << m_key;
     108#endif
    105109    encoder << m_keyIdentifier;
    106110    encoder << m_windowsVirtualKeyCode;
     
    125129    if (!decoder.decode(result.m_unmodifiedText))
    126130        return false;
     131#if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
     132    if (!decoder.decode(result.m_key))
     133        return false;
     134#endif
    127135    if (!decoder.decode(result.m_keyIdentifier))
    128136        return false;
  • trunk/Source/WebKit2/Shared/mac/WebEventFactory.mm

    r206033 r206750  
    467467    String text                     = textFromEvent(event, replacesSoftSpace);
    468468    String unmodifiedText           = unmodifiedTextFromEvent(event, replacesSoftSpace);
     469    String key                      = keyForKeyEvent(event);
    469470    String keyIdentifier            = keyIdentifierForKeyEvent(event);
    470471    int windowsVirtualKeyCode       = windowsKeyCodeForKeyEvent(event);
     
    498499    }
    499500
    500     return WebKeyboardEvent(type, text, unmodifiedText, keyIdentifier, windowsVirtualKeyCode, nativeVirtualKeyCode, macCharCode, handledByInputMethod, commands, autoRepeat, isKeypad, isSystemKey, modifiers, timestamp);
     501    return WebKeyboardEvent(type, text, unmodifiedText, key, keyIdentifier, windowsVirtualKeyCode, nativeVirtualKeyCode, macCharCode, handledByInputMethod, commands, autoRepeat, isKeypad, isSystemKey, modifiers, timestamp);
    501502}
    502503
Note: See TracChangeset for help on using the changeset viewer.