Changeset 206750 in webkit
- Timestamp:
- Oct 3, 2016, 2:32:47 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 32 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r206748 r206750 1 2016-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 22 2016-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 1 43 2016-10-03 Ryan Haddad <ryanhaddad@apple.com> 2 44 -
trunk/LayoutTests/fast/events/constructors/keyboard-event-constructor-expected.txt
r206724 r206750 104 104 PASS new KeyboardEvent('eventType', { metaKey: false }).metaKey is false 105 105 PASS 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 106 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 107 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 108 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 109 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 110 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" 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 }).keyIdentifier is "chocolate" 112 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 113 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 114 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 115 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 116 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 116 117 PASS successfullyParsed is true 117 118 -
trunk/LayoutTests/fast/events/constructors/keyboard-event-constructor.html
r206724 r206750 118 118 119 119 // 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"); 120 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"); 121 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"); 122 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"); 123 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"); 124 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"); 125 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"); 126 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"); 127 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"); 128 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"); 129 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"); 130 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"); 130 131 </script> 131 132 <script src="../../../resources/js-test-post.js"></script> -
trunk/LayoutTests/fast/events/key-events-in-input-button-expected.txt
r28620 r206750 2 2 3 3 4 target - type - ctrlKey,altKey,shiftKey,metaKey - key Identifier - keyCode - charCode4 target - type - ctrlKey,altKey,shiftKey,metaKey - key - keyIdentifier - keyCode - charCode 5 5 Space: 6 INPUT - keydown - false,false,false,false - U+0020 - 32 - 07 INPUT - keypress - false,false,false,false - - 32 - 328 INPUT - keyup - false,false,false,false - U+0020 - 32 - 06 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 9 9 INPUT - click 10 10 Enter: 11 INPUT - keydown - false,false,false,false - Enter - 13 - 012 INPUT - keypress - false,false,false,false - - 13 - 1311 INPUT - keydown - false,false,false,false - Enter - Enter - 13 - 0 12 INPUT - keypress - false,false,false,false - Enter - - 13 - 13 13 13 INPUT - click 14 INPUT - keyup - false,false,false,false - Enter - 13 - 014 INPUT - keyup - false,false,false,false - Enter - Enter - 13 - 0 15 15 A: 16 INPUT - keydown - false,false,true,false - U+0041 - 65 - 017 INPUT - keypress - false,false,true,false - - 65 - 6518 INPUT - keyup - false,false,true,false - U+0041 - 65 - 016 INPUT - keydown - false,false,true,false - A - U+0041 - 65 - 0 17 INPUT - keypress - false,false,true,false - A - - 65 - 65 18 INPUT - keyup - false,false,true,false - A - U+0041 - 65 - 0 19 19 -
trunk/LayoutTests/fast/events/key-events-in-input-button.html
r120792 r206750 24 24 return (where ? "(" + where + ") " : "") + target.tagName + " - " + event.type 25 25 + ' - ' + [event.ctrlKey, event.altKey, event.shiftKey, event.metaKey] 26 + ' - ' + event.key 26 27 + ' - ' + event.keyIdentifier 27 28 + ' - ' + event.keyCode … … 35 36 } 36 37 log("target - type - " + ["ctrlKey", "altKey", "shiftKey", "metaKey"] 38 + ' - ' + "key" 37 39 + ' - ' + "keyIdentifier" 38 40 + ' - ' + "keyCode" -
trunk/LayoutTests/fast/events/key-events-in-input-text-expected.txt
r28620 r206750 2 2 3 3 4 target - type - ctrlKey,altKey,shiftKey,metaKey - key Identifier - keyCode - charCode4 target - type - ctrlKey,altKey,shiftKey,metaKey - key - keyIdentifier - keyCode - charCode 5 5 Space: 6 INPUT - keydown - false,false,false,false - U+0020 - 32 - 0. Value: "".7 INPUT - keypress - false,false,false,false - - 32 - 32. Value: "".6 INPUT - keydown - false,false,false,false - - U+0020 - 32 - 0. Value: "". 7 INPUT - keypress - false,false,false,false - - - 32 - 32. Value: "". 8 8 INPUT - textInput - . Value: "". 9 INPUT - keyup - false,false,false,false - U+0020 - 32 - 0. Value: " ".9 INPUT - keyup - false,false,false,false - - U+0020 - 32 - 0. Value: " ". 10 10 Backspace: 11 INPUT - keydown - false,false,false,false - U+0008 - 8 - 0. Value: " ".12 INPUT - keyup - false,false,false,false - U+0008 - 8 - 0. Value: "".11 INPUT - keydown - false,false,false,false - Backspace - U+0008 - 8 - 0. Value: " ". 12 INPUT - keyup - false,false,false,false - Backspace - U+0008 - 8 - 0. Value: "". 13 13 Left Arrow: 14 INPUT - keydown - false,false,false,false - Left - 37 - 0. Value: "".15 INPUT - keyup - false,false,false,false - Left - 37 - 0. Value: "".14 INPUT - keydown - false,false,false,false - ArrowLeft - Left - 37 - 0. Value: "". 15 INPUT - keyup - false,false,false,false - ArrowLeft - Left - 37 - 0. Value: "". 16 16 Tab: 17 INPUT - keydown - false,false,false,false - U+0009 - 9 - 0. Value: "".17 INPUT - keydown - false,false,false,false - Tab - U+0009 - 9 - 0. Value: "". 18 18 -
trunk/LayoutTests/fast/events/key-events-in-input-text.html
r120792 r206750 26 26 return (where ? "(" + where + ") " : "") + target.tagName + " - " + event.type 27 27 + ' - ' + [event.ctrlKey, event.altKey, event.shiftKey, event.metaKey] 28 + ' - ' + event.key 28 29 + ' - ' + event.keyIdentifier 29 30 + ' - ' + event.keyCode … … 39 40 } 40 41 log("target - type - " + ["ctrlKey", "altKey", "shiftKey", "metaKey"] 42 + ' - ' + "key" 41 43 + ' - ' + "keyIdentifier" 42 44 + ' - ' + "keyCode" -
trunk/LayoutTests/fast/events/special-key-events-in-input-text-expected.txt
r64555 r206750 2 2 3 3 4 target - type - ctrlKey,altKey,shiftKey,metaKey - key Identifier - keyCode - charCode4 target - type - ctrlKey,altKey,shiftKey,metaKey - key - keyIdentifier - keyCode - charCode 5 5 6 6 Ampersand: 7 INPUT - keydown - false,false,true,false - U+0037 - 55 - 0. Value: "".8 INPUT - keypress - false,false,true,false - - 55 - 55. Value: "".7 INPUT - keydown - false,false,true,false - 7 - U+0037 - 55 - 0. Value: "". 8 INPUT - keypress - false,false,true,false - 7 - - 55 - 55. Value: "". 9 9 INPUT - textInput - 7. Value: "". 10 INPUT - keyup - false,false,true,false - U+0037 - 55 - 0. Value: "7".10 INPUT - keyup - false,false,true,false - 7 - U+0037 - 55 - 0. Value: "7". 11 11 12 12 Backspace: 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: "".13 INPUT - keydown - false,false,false,false - Backspace - U+0008 - 8 - 0. Value: "7". 14 INPUT - keyup - false,false,false,false - Backspace - U+0008 - 8 - 0. Value: "". 15 15 16 16 Percent: 17 INPUT - keydown - false,false,true,false - U+0035 - 53 - 0. Value: "".18 INPUT - keypress - false,false,true,false - - 53 - 53. Value: "".17 INPUT - keydown - false,false,true,false - 5 - U+0035 - 53 - 0. Value: "". 18 INPUT - keypress - false,false,true,false - 5 - - 53 - 53. Value: "". 19 19 INPUT - textInput - 5. Value: "". 20 INPUT - keyup - false,false,true,false - U+0035 - 53 - 0. Value: "5".20 INPUT - keyup - false,false,true,false - 5 - U+0035 - 53 - 0. Value: "5". 21 21 22 22 Backspace: 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: "".23 INPUT - keydown - false,false,false,false - Backspace - U+0008 - 8 - 0. Value: "5". 24 INPUT - keyup - false,false,false,false - Backspace - U+0008 - 8 - 0. Value: "". 25 25 26 26 Left parenthesis: 27 INPUT - keydown - false,false,true,false - U+0039 - 57 - 0. Value: "".28 INPUT - keypress - false,false,true,false - - 57 - 57. Value: "".27 INPUT - keydown - false,false,true,false - 9 - U+0039 - 57 - 0. Value: "". 28 INPUT - keypress - false,false,true,false - 9 - - 57 - 57. Value: "". 29 29 INPUT - textInput - 9. Value: "". 30 INPUT - keyup - false,false,true,false - U+0039 - 57 - 0. Value: "9".30 INPUT - keyup - false,false,true,false - 9 - U+0039 - 57 - 0. Value: "9". 31 31 32 32 Backspace: 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: "".33 INPUT - keydown - false,false,false,false - Backspace - U+0008 - 8 - 0. Value: "9". 34 INPUT - keyup - false,false,false,false - Backspace - U+0008 - 8 - 0. Value: "". 35 35 36 36 Right parenthesis: 37 INPUT - keydown - false,false,true,false - U+0030 - 48 - 0. Value: "".38 INPUT - keypress - false,false,true,false - - 48 - 48. Value: "".37 INPUT - keydown - false,false,true,false - 0 - U+0030 - 48 - 0. Value: "". 38 INPUT - keypress - false,false,true,false - 0 - - 48 - 48. Value: "". 39 39 INPUT - textInput - 0. Value: "". 40 INPUT - keyup - false,false,true,false - U+0030 - 48 - 0. Value: "0".40 INPUT - keyup - false,false,true,false - 0 - U+0030 - 48 - 0. Value: "0". 41 41 42 42 Backspace: 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: "".43 INPUT - keydown - false,false,false,false - Backspace - U+0008 - 8 - 0. Value: "0". 44 INPUT - keyup - false,false,false,false - Backspace - U+0008 - 8 - 0. Value: "". 45 45 46 46 Print screen: 47 INPUT - keydown - false,false,false,false - PrintScreen - 44 - 0. Value: "".48 INPUT - keyup - false,false,false,false - PrintScreen - 44 - 0. Value: "".47 INPUT - keydown - false,false,false,false - PrintScreen - PrintScreen - 44 - 0. Value: "". 48 INPUT - keyup - false,false,false,false - PrintScreen - PrintScreen - 44 - 0. Value: "". 49 49 -
trunk/LayoutTests/fast/events/special-key-events-in-input-text.html
r120792 r206750 19 19 } else if (type == "keydown" || type == "keypress" || type == "keyup") { 20 20 info += [e.ctrlKey, e.altKey, e.shiftKey, e.metaKey] + 21 ' - ' + e.key + 21 22 ' - ' + e.keyIdentifier + 22 23 ' - ' + e.keyCode + … … 28 29 29 30 log("target - type - " + ["ctrlKey", "altKey", "shiftKey", "metaKey"] 31 + ' - ' + "key" 30 32 + ' - ' + "keyIdentifier" 31 33 + ' - ' + "keyCode" -
trunk/LayoutTests/imported/w3c/ChangeLog
r206733 r206750 1 2016-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 15 2016-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 1 29 2016-10-03 Chris Dumez <cdumez@apple.com> 2 30 -
trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-init-while-dispatching-expected.txt
r203164 r206750 1 1 2 FAIL Calling initKeyboardEvent while dispatching. assert_equals: initKeyboardEvent key setter should short-circuit expected (string) "A" but got (undefined) undefined 2 PASS Calling initKeyboardEvent while dispatching. 3 3 PASS Calling initMouseEvent while dispatching. 4 4 PASS Calling initCustomEvent while dispatching. -
trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-subclasses-constructors-expected.txt
r203950 r206750 30 30 FAIL WheelEvent constructor (argument with default values) assert_true: Event object "[object WheelEvent]" should have a buttons property expected true got false 31 31 FAIL 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 keyproperty expected true got false33 FAIL KeyboardEvent constructor (undefined argument) assert_true: Event object "[object KeyboardEvent]" should have a keyproperty expected true got false34 FAIL KeyboardEvent constructor (null argument) assert_true: Event object "[object KeyboardEvent]" should have a keyproperty expected true got false35 FAIL KeyboardEvent constructor (empty argument) assert_true: Event object "[object KeyboardEvent]" should have a keyproperty expected true got false36 FAIL KeyboardEvent constructor (argument with default values) assert_true: Event object "[object KeyboardEvent]" should have a keyproperty expected true got false37 FAIL KeyboardEvent constructor (argument with non-default values) assert_true: Event object "[object KeyboardEvent]" should have a keyproperty expected true got false32 FAIL KeyboardEvent constructor (no argument) assert_true: Event object "[object KeyboardEvent]" should have a code property expected true got false 33 FAIL KeyboardEvent constructor (undefined argument) assert_true: Event object "[object KeyboardEvent]" should have a code property expected true got false 34 FAIL KeyboardEvent constructor (null argument) assert_true: Event object "[object KeyboardEvent]" should have a code property expected true got false 35 FAIL KeyboardEvent constructor (empty argument) assert_true: Event object "[object KeyboardEvent]" should have a code property expected true got false 36 FAIL KeyboardEvent constructor (argument with default values) assert_true: Event object "[object KeyboardEvent]" should have a code property expected true got false 37 FAIL KeyboardEvent constructor (argument with non-default values) assert_true: Event object "[object KeyboardEvent]" should have a code property expected true got false 38 38 PASS CompositionEvent constructor (no argument) 39 39 PASS CompositionEvent constructor (undefined argument) -
trunk/LayoutTests/platform/ios-simulator/TestExpectations
r206657 r206750 337 337 fast/shadow-dom/shadow-host-removal-crash.html [ Skip ] 338 338 fast/shadow-dom/input-element-in-shadow.html [ Skip ] 339 fast/events/keyboardevent-key.html [ Skip ] 339 340 340 341 # The file-wrapper part of <attachment> is not yet working on iOS -
trunk/Source/WTF/ChangeLog
r206691 r206750 1 2016-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 1 13 2016-09-29 Sam Weinig <sam@webkit.org> 2 14 -
trunk/Source/WTF/wtf/FeatureDefines.h
r206440 r206750 256 256 #endif 257 257 258 #if !defined(ENABLE_KEYBOARD_KEY_ATTRIBUTE) 259 #define ENABLE_KEYBOARD_KEY_ATTRIBUTE 1 260 #endif 261 258 262 #endif /* PLATFORM(COCOA) */ 259 263 … … 770 774 #endif 771 775 776 #if !defined(ENABLE_KEYBOARD_KEY_ATTRIBUTE) 777 #define ENABLE_KEYBOARD_KEY_ATTRIBUTE 0 778 #endif 779 772 780 /* Asserts, invariants for macro definitions */ 773 781 -
trunk/Source/WebCore/ChangeLog
r206749 r206750 1 2016-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 39 2016-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 1 77 2016-10-03 Alex Christensen <achristensen@webkit.org> 2 78 -
trunk/Source/WebCore/dom/KeyboardEvent.cpp
r206725 r206750 105 105 true, true, key.timestamp(), view, 0, key.ctrlKey(), key.altKey(), key.shiftKey(), key.metaKey()) 106 106 , m_keyEvent(std::make_unique<PlatformKeyboardEvent>(key)) 107 #if ENABLE(KEYBOARD_KEY_ATTRIBUTE) 108 , m_key(key.key()) 109 #endif 107 110 , m_keyIdentifier(key.keyIdentifier()) 108 111 , m_location(keyLocationCode(key)) … … 128 131 KeyboardEvent::KeyboardEvent(const AtomicString& eventType, const KeyboardEventInit& initializer) 129 132 : UIEventWithKeyState(eventType, initializer) 133 #if ENABLE(KEYBOARD_KEY_ATTRIBUTE) 134 , m_key(initializer.key) 135 #endif 130 136 , m_keyIdentifier(initializer.keyIdentifier) 131 137 , m_location(initializer.location) -
trunk/Source/WebCore/dom/KeyboardEvent.h
r206724 r206750 35 35 36 36 struct KeyboardEventInit : public UIEventWithKeyStateInit { 37 #if ENABLE(KEYBOARD_KEY_ATTRIBUTE) 38 String key; 39 #endif 37 40 String keyIdentifier; 38 41 unsigned location { 0 }; … … 47 50 DOM_KEY_LOCATION_RIGHT = 0x02, 48 51 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 = 0x0552 52 }; 53 53 … … 80 80 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, bool altGraphKey = false); 81 81 82 #if ENABLE(KEYBOARD_KEY_ATTRIBUTE) 83 const String& key() const { return m_key; } 84 #endif 85 82 86 const String& keyIdentifier() const { return m_keyIdentifier; } 83 87 unsigned location() const { return m_location; } … … 109 113 WEBCORE_EXPORT KeyboardEvent(const PlatformKeyboardEvent&, DOMWindow*); 110 114 KeyboardEvent(const AtomicString&, const KeyboardEventInit&); 111 // FIXME: This method should be get rid eof in the future.115 // FIXME: This method should be get rid of in the future. 112 116 // DO NOT USE IT! 113 117 KeyboardEvent(WTF::HashTableDeletedValueType); 114 118 115 119 std::unique_ptr<PlatformKeyboardEvent> m_keyEvent; 120 #if ENABLE(KEYBOARD_KEY_ATTRIBUTE) 121 String m_key; 122 #endif 116 123 String m_keyIdentifier; 117 124 unsigned m_location; -
trunk/Source/WebCore/dom/KeyboardEvent.idl
r206725 r206750 29 29 const unsigned long DOM_KEY_LOCATION_NUMPAD = 0x03; 30 30 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 32 36 [InitializedByEventConstructor] readonly attribute unsigned long location; 33 [InitializedByEventConstructor, ImplementedAs=location] readonly attribute unsigned long keyLocation; // Deprecated. 37 34 38 [InitializedByEventConstructor] readonly attribute boolean ctrlKey; 35 39 [InitializedByEventConstructor] readonly attribute boolean shiftKey; 36 40 [InitializedByEventConstructor] readonly attribute boolean altKey; 37 41 [InitializedByEventConstructor] readonly attribute boolean metaKey; 38 readonly attribute boolean altGraphKey;39 40 42 [InitializedByEventConstructor] readonly attribute boolean repeat; 41 43 44 // FIXME: We should support this. 45 // readonly attribute boolean isComposing; 46 42 47 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; 43 53 44 54 // FIXME: this does not match the version in the DOM spec. -
trunk/Source/WebCore/platform/PlatformKeyboardEvent.h
r206644 r206750 71 71 } 72 72 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) 74 78 : PlatformEvent(type, modifiers, timestamp) 75 79 , m_text(text) 76 80 , m_unmodifiedText(unmodifiedText) 81 #if ENABLE(KEYBOARD_KEY_ATTRIBUTE) 82 , m_key(key) 83 #endif 77 84 , m_keyIdentifier(keyIdentifier) 78 85 , m_windowsVirtualKeyCode(windowsVirtualKeyCode) … … 102 109 103 110 String keyIdentifier() const { return m_keyIdentifier; } 111 112 #if ENABLE(KEYBOARD_KEY_ATTRIBUTE) 113 const String& key() const { return m_key; } 114 #endif 104 115 105 116 // Most compatible Windows virtual key code associated with the event. … … 155 166 String m_text; 156 167 String m_unmodifiedText; 168 #if ENABLE(KEYBOARD_KEY_ATTRIBUTE) 169 String m_key; 170 #endif 157 171 String m_keyIdentifier; 158 172 int m_windowsVirtualKeyCode; -
trunk/Source/WebCore/platform/cocoa/KeyEventCocoa.h
r165676 r206750 31 31 namespace WebCore { 32 32 33 String keyForCharCode(unichar charCode); 33 34 String keyIdentifierForCharCode(unichar charCode); 34 35 -
trunk/Source/WebCore/platform/cocoa/KeyEventCocoa.mm
r165676 r206750 39 39 40 40 namespace WebCore { 41 42 // https://w3c.github.io/uievents-key/ 43 String 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 } 41 196 42 197 String keyIdentifierForCharCode(unichar charCode) -
trunk/Source/WebCore/platform/ios/PlatformEventFactoryIOS.h
r176904 r206750 50 50 }; 51 51 52 WEBCORE_EXPORT String keyForKeyEvent(WebEvent *); 52 53 WEBCORE_EXPORT String keyIdentifierForKeyEvent(WebEvent *); 53 54 -
trunk/Source/WebCore/platform/ios/PlatformEventFactoryIOS.mm
r206644 r206750 130 130 } 131 131 132 String 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 132 149 class PlatformKeyboardEventBuilder : public PlatformKeyboardEvent { 133 150 public: … … 142 159 m_text = event.characters; 143 160 m_unmodifiedText = event.charactersIgnoringModifiers; 161 m_key = keyForKeyEvent(event); 144 162 m_keyIdentifier = keyIdentifierForKeyEvent(event); 145 163 m_windowsVirtualKeyCode = event.keyCode; -
trunk/Source/WebCore/platform/mac/PlatformEventFactoryMac.h
r201441 r206750 47 47 WEBCORE_EXPORT int windowsKeyCodeForKeyEvent(NSEvent *); 48 48 WEBCORE_EXPORT String keyIdentifierForKeyEvent(NSEvent *); 49 WEBCORE_EXPORT String keyForKeyEvent(NSEvent *); 49 50 WEBCORE_EXPORT double eventTimeStampSince1970(NSEvent *); 50 51 -
trunk/Source/WebCore/platform/mac/PlatformEventFactoryMac.mm
r206644 r206750 34 34 #import "WebCoreSystemInterface.h" 35 35 #import "WindowsKeyboardCodes.h" 36 #import <HIToolbox/Events.h> 36 37 #import <mach/mach_time.h> 37 38 #import <wtf/ASCIICType.h> … … 221 222 static inline String textFromEvent(NSEvent* event) 222 223 { 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 225 227 if ([event type] == NSFlagsChanged) 226 # pragma clang diagnostic pop228 #endif 227 229 return emptyString(); 228 230 return String([event characters]); … … 231 233 static inline String unmodifiedTextFromEvent(NSEvent* event) 232 234 { 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 235 238 if ([event type] == NSFlagsChanged) 236 # pragma clang diagnostic pop239 #endif 237 240 return emptyString(); 238 241 return String([event charactersIgnoringModifiers]); 239 242 } 240 243 244 String 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 241 289 String keyIdentifierForKeyEvent(NSEvent* event) 242 290 { 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 247 296 switch ([event keyCode]) { 248 297 case 54: // Right Command … … 269 318 return emptyString(); 270 319 } 320 } 271 321 272 322 NSString *s = [event charactersIgnoringModifiers]; … … 562 612 m_unmodifiedText = unmodifiedTextFromEvent(event); 563 613 m_keyIdentifier = keyIdentifierForKeyEvent(event); 614 m_key = keyForKeyEvent(event); 564 615 m_windowsVirtualKeyCode = windowsKeyCodeForKeyEvent(event); 565 616 #pragma clang diagnostic push -
trunk/Source/WebCore/replay/SerializationMethods.cpp
r206644 r206750 257 257 ENCODE_TYPE_WITH_KEY(encodedValue, String, text, input.text()); 258 258 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 259 262 ENCODE_TYPE_WITH_KEY(encodedValue, String, keyIdentifier, input.keyIdentifier()); 260 263 ENCODE_TYPE_WITH_KEY(encodedValue, int, windowsVirtualKeyCode, input.windowsVirtualKeyCode()); … … 276 279 DECODE_TYPE_WITH_KEY(encodedValue, String, text); 277 280 DECODE_TYPE_WITH_KEY(encodedValue, String, unmodifiedText); 281 #if ENABLE(KEYBOARD_KEY_ATTRIBUTE) 282 DECODE_TYPE_WITH_KEY(encodedValue, String, key); 283 #endif 278 284 DECODE_TYPE_WITH_KEY(encodedValue, String, keyIdentifier); 279 285 DECODE_TYPE_WITH_KEY(encodedValue, int, windowsVirtualKeyCode); … … 286 292 #endif 287 293 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 289 300 #if USE(APPKIT) 290 301 input = std::make_unique<PlatformKeyboardEventAppKit>(platformEvent, handledByInputMethod, commands); -
trunk/Source/WebKit2/ChangeLog
r206731 r206750 1 2016-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 22 2016-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 1 43 2016-10-03 Carlos Garcia Campos <cgarcia@igalia.com> 2 44 -
trunk/Source/WebKit2/Shared/WebEvent.h
r206651 r206750 245 245 246 246 #if USE(APPKIT) 247 WebKeyboardEvent(Type, const String& text, const String& unmodifiedText, const String& key Identifier, 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); 248 248 #elif PLATFORM(GTK) 249 249 WebKeyboardEvent(Type, const String& text, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool handledByInputMethod, Vector<String>&& commands, bool isKeypad, Modifiers, double timestamp); … … 254 254 const String& text() const { return m_text; } 255 255 const String& unmodifiedText() const { return m_unmodifiedText; } 256 #if ENABLE(KEYBOARD_KEY_ATTRIBUTE) 257 const String& key() const { return m_key; } 258 #endif 256 259 const String& keyIdentifier() const { return m_keyIdentifier; } 257 260 int32_t windowsVirtualKeyCode() const { return m_windowsVirtualKeyCode; } … … 278 281 String m_text; 279 282 String m_unmodifiedText; 283 #if ENABLE(KEYBOARD_KEY_ATTRIBUTE) 284 String m_key; 285 #endif 280 286 String m_keyIdentifier; 281 287 int32_t m_windowsVirtualKeyCode; -
trunk/Source/WebKit2/Shared/WebEventConversion.cpp
r206651 r206750 192 192 m_text = webEvent.text(); 193 193 m_unmodifiedText = webEvent.unmodifiedText(); 194 #if ENABLE(KEYBOARD_KEY_ATTRIBUTE) 195 m_key = webEvent.key(); 196 #endif 194 197 m_keyIdentifier = webEvent.keyIdentifier(); 195 198 m_windowsVirtualKeyCode = webEvent.windowsVirtualKeyCode(); -
trunk/Source/WebKit2/Shared/WebKeyboardEvent.cpp
r204668 r206750 38 38 #if USE(APPKIT) 39 39 40 WebKeyboardEvent::WebKeyboardEvent(Type type, const String& text, const String& unmodifiedText, const String& key Identifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, int macCharCode, bool handledByInputMethod, const Vector<WebCore::KeypressCommand>& commands, bool isAutoRepeat, bool isKeypad, bool isSystemKey, Modifiers modifiers, double timestamp)40 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) 41 41 : WebEvent(type, modifiers, timestamp) 42 42 , m_text(text) 43 43 , m_unmodifiedText(unmodifiedText) 44 , m_key(key) 44 45 , m_keyIdentifier(keyIdentifier) 45 46 , m_windowsVirtualKeyCode(windowsVirtualKeyCode) … … 103 104 encoder << m_text; 104 105 encoder << m_unmodifiedText; 106 #if ENABLE(KEYBOARD_KEY_ATTRIBUTE) 107 encoder << m_key; 108 #endif 105 109 encoder << m_keyIdentifier; 106 110 encoder << m_windowsVirtualKeyCode; … … 125 129 if (!decoder.decode(result.m_unmodifiedText)) 126 130 return false; 131 #if ENABLE(KEYBOARD_KEY_ATTRIBUTE) 132 if (!decoder.decode(result.m_key)) 133 return false; 134 #endif 127 135 if (!decoder.decode(result.m_keyIdentifier)) 128 136 return false; -
trunk/Source/WebKit2/Shared/mac/WebEventFactory.mm
r206033 r206750 467 467 String text = textFromEvent(event, replacesSoftSpace); 468 468 String unmodifiedText = unmodifiedTextFromEvent(event, replacesSoftSpace); 469 String key = keyForKeyEvent(event); 469 470 String keyIdentifier = keyIdentifierForKeyEvent(event); 470 471 int windowsVirtualKeyCode = windowsKeyCodeForKeyEvent(event); … … 498 499 } 499 500 500 return WebKeyboardEvent(type, text, unmodifiedText, key Identifier, 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); 501 502 } 502 503
Note:
See TracChangeset
for help on using the changeset viewer.