Changeset 206971 in webkit


Ignore:
Timestamp:
Oct 9, 2016 4:11:56 PM (8 years ago)
Author:
Chris Dumez
Message:

Update KeyboardEvent to stop using legacy [ConstructorTemplate=Event]
https://bugs.webkit.org/show_bug.cgi?id=163176

Reviewed by Darin Adler.

Source/WebCore:

Update KeyboardEvent to stop using legacy [ConstructorTemplate=Event]
and use a proper constructor instead, like in the specification:

Also add support for passing modifierAltGraph / modifierCapsLock
in the inialization dictionary as we support those modifiers via
getModifierState().

No new tests, extended existing test.

  • CMakeLists.txt:
  • DerivedSources.cpp:
  • DerivedSources.make:
  • WebCore.xcodeproj/project.pbxproj:
  • dom/EventModifierInit.h: Added.

(WebCore::EventModifierInit::EventModifierInit):

  • dom/EventModifierInit.idl: Added.
  • dom/KeyboardEvent.cpp:

(WebCore::KeyboardEvent::KeyboardEvent):
(WebCore::KeyboardEvent::getModifierState):

  • dom/KeyboardEvent.h:
  • dom/KeyboardEvent.idl:
  • dom/MouseRelatedEvent.cpp:

(WebCore::MouseRelatedEvent::MouseRelatedEvent):

  • dom/MouseRelatedEvent.h:
  • dom/UIEvent.cpp:

(WebCore::UIEvent::UIEvent):

  • dom/UIEvent.h:

(WebCore::UIEvent::create): Deleted.

  • dom/UIEventInit.h: Added.

(WebCore::UIEventInit::UIEventInit):

  • dom/UIEventInit.idl: Added.
  • dom/UIEventWithKeyState.h:

(WebCore::UIEventWithKeyState::altGraphKey):
(WebCore::UIEventWithKeyState::capsLockKey):
(WebCore::UIEventWithKeyState::UIEventWithKeyState):
(WebCore::UIEventWithKeyState::ctrlKey): Deleted.
(WebCore::UIEventWithKeyState::shiftKey): Deleted.
(WebCore::UIEventWithKeyState::altKey): Deleted.
(WebCore::UIEventWithKeyState::metaKey): Deleted.

LayoutTests:

Rebaseline existing test now that the exception message is slightly
different in some cases. Also add test coverage for passing
modifierAltGraph / modifierCapsLock in initialization dictionary.

  • fast/events/constructors/keyboard-event-constructor-expected.txt:
  • fast/events/constructors/keyboard-event-constructor.html:
Location:
trunk
Files:
4 added
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r206969 r206971  
     12016-10-09  Chris Dumez  <cdumez@apple.com>
     2
     3        Update KeyboardEvent to stop using legacy [ConstructorTemplate=Event]
     4        https://bugs.webkit.org/show_bug.cgi?id=163176
     5
     6        Reviewed by Darin Adler.
     7
     8        Rebaseline existing test now that the exception message is slightly
     9        different in some cases. Also add test coverage for passing
     10        modifierAltGraph / modifierCapsLock in initialization dictionary.
     11
     12        * fast/events/constructors/keyboard-event-constructor-expected.txt:
     13        * fast/events/constructors/keyboard-event-constructor.html:
     14
    1152016-10-09  Michael Catanzaro  <mcatanzaro@igalia.com>
    216
  • trunk/LayoutTests/fast/events/constructors/keyboard-event-constructor-expected.txt

    r206803 r206971  
    2626PASS new KeyboardEvent('eventType', { isComposing: false }).isComposing is false
    2727PASS new KeyboardEvent('eventType', { isComposing: true }).isComposing is true
    28 PASS new KeyboardEvent('eventType', { view: testObject }).view threw exception TypeError: Dictionary member is not of type Window.
    29 PASS new KeyboardEvent('eventType', { view: document }).view threw exception TypeError: Dictionary member is not of type Window.
     28PASS new KeyboardEvent('eventType', { view: testObject }).view threw exception TypeError: Type error.
     29PASS new KeyboardEvent('eventType', { view: document }).view threw exception TypeError: Type error.
    3030PASS new KeyboardEvent('eventType', { view: undefined }).view is null
    3131PASS new KeyboardEvent('eventType', { view: null }).view is null
    32 PASS new KeyboardEvent('eventType', { view: false }).view threw exception TypeError: Dictionary member is not of type Window.
    33 PASS new KeyboardEvent('eventType', { view: true }).view threw exception TypeError: Dictionary member is not of type Window.
    34 PASS new KeyboardEvent('eventType', { view: '' }).view threw exception TypeError: Dictionary member is not of type Window.
    35 PASS new KeyboardEvent('eventType', { view: 'chocolate' }).view threw exception TypeError: Dictionary member is not of type Window.
    36 PASS new KeyboardEvent('eventType', { view: 12345 }).view threw exception TypeError: Dictionary member is not of type Window.
    37 PASS new KeyboardEvent('eventType', { view: 18446744073709551615 }).view threw exception TypeError: Dictionary member is not of type Window.
    38 PASS new KeyboardEvent('eventType', { view: NaN }).view threw exception TypeError: Dictionary member is not of type Window.
    39 PASS new KeyboardEvent('eventType', { view: {valueOf: function () { return window; } } }).view threw exception TypeError: Dictionary member is not of type Window.
    40 PASS new KeyboardEvent('eventType', { get view() { return 123; } }).view threw exception TypeError: Dictionary member is not of type Window.
     32PASS new KeyboardEvent('eventType', { view: false }).view threw exception TypeError: Type error.
     33PASS new KeyboardEvent('eventType', { view: true }).view threw exception TypeError: Type error.
     34PASS new KeyboardEvent('eventType', { view: '' }).view threw exception TypeError: Type error.
     35PASS new KeyboardEvent('eventType', { view: 'chocolate' }).view threw exception TypeError: Type error.
     36PASS new KeyboardEvent('eventType', { view: 12345 }).view threw exception TypeError: Type error.
     37PASS new KeyboardEvent('eventType', { view: 18446744073709551615 }).view threw exception TypeError: Type error.
     38PASS new KeyboardEvent('eventType', { view: NaN }).view threw exception TypeError: Type error.
     39PASS new KeyboardEvent('eventType', { view: {valueOf: function () { return window; } } }).view threw exception TypeError: Type error.
     40PASS new KeyboardEvent('eventType', { get view() { return 123; } }).view threw exception TypeError: Type error.
    4141PASS new KeyboardEvent('eventType', { get view() { throw 'KeyboardEvent Error'; } }) threw exception KeyboardEvent Error.
    4242PASS new KeyboardEvent('eventType', { keyIdentifier: 'koakuma' }).keyIdentifier is "koakuma"
    4343PASS new KeyboardEvent('eventType', { keyIdentifier: '' }).keyIdentifier is ""
    44 PASS new KeyboardEvent('eventType', { keyIdentifier: undefined }).keyIdentifier is "undefined"
     44PASS new KeyboardEvent('eventType', { keyIdentifier: undefined }).keyIdentifier is ""
    4545PASS new KeyboardEvent('eventType', { keyIdentifier: null }).keyIdentifier is "null"
    4646PASS new KeyboardEvent('eventType', { keyIdentifier: false }).keyIdentifier is "false"
     
    107107PASS new KeyboardEvent('eventType', { metaKey: false }).metaKey is false
    108108PASS new KeyboardEvent('eventType', { metaKey: true }).metaKey is true
     109PASS new KeyboardEvent('eventType', { modifierAltGraph: true }).getModifierState('AltGraph') is true
     110PASS new KeyboardEvent('eventType', { modifierCapsLock: true }).getModifierState('CapsLock') is true
    109111PASS new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, key: 'a', code: 'KeyA', keyIdentifier: 'chocolate', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true }).bubbles is true
    110112PASS new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, key: 'a', code: 'KeyA', keyIdentifier: 'chocolate', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true }).cancelable is true
  • trunk/LayoutTests/fast/events/constructors/keyboard-event-constructor.html

    r206803 r206971  
    6969
    7070// Non-strings.
    71 shouldBeEqualToString("new KeyboardEvent('eventType', { keyIdentifier: undefined }).keyIdentifier", "undefined");
     71shouldBeEqualToString("new KeyboardEvent('eventType', { keyIdentifier: undefined }).keyIdentifier", "");
    7272shouldBeEqualToString("new KeyboardEvent('eventType', { keyIdentifier: null }).keyIdentifier", "null");
    7373shouldBeEqualToString("new KeyboardEvent('eventType', { keyIdentifier: false }).keyIdentifier", "false");
     
    122122});
    123123
     124shouldBeTrue("new KeyboardEvent('eventType', { modifierAltGraph: true }).getModifierState('AltGraph')");
     125shouldBeTrue("new KeyboardEvent('eventType', { modifierCapsLock: true }).getModifierState('CapsLock')");
     126
    124127// All initializers are passed.
    125128shouldBe("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, key: 'a', code: 'KeyA', keyIdentifier: 'chocolate', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true }).bubbles", "true");
  • trunk/LayoutTests/platform/ios-simulator/fast/events/constructors/keyboard-event-constructor-expected.txt

    r206803 r206971  
    2626PASS new KeyboardEvent('eventType', { isComposing: false }).isComposing is false
    2727PASS new KeyboardEvent('eventType', { isComposing: true }).isComposing is true
    28 PASS new KeyboardEvent('eventType', { view: testObject }).view threw exception TypeError: Dictionary member is not of type Window.
    29 PASS new KeyboardEvent('eventType', { view: document }).view threw exception TypeError: Dictionary member is not of type Window.
     28PASS new KeyboardEvent('eventType', { view: testObject }).view threw exception TypeError: Type error.
     29PASS new KeyboardEvent('eventType', { view: document }).view threw exception TypeError: Type error.
    3030PASS new KeyboardEvent('eventType', { view: undefined }).view is null
    3131PASS new KeyboardEvent('eventType', { view: null }).view is null
    32 PASS new KeyboardEvent('eventType', { view: false }).view threw exception TypeError: Dictionary member is not of type Window.
    33 PASS new KeyboardEvent('eventType', { view: true }).view threw exception TypeError: Dictionary member is not of type Window.
    34 PASS new KeyboardEvent('eventType', { view: '' }).view threw exception TypeError: Dictionary member is not of type Window.
    35 PASS new KeyboardEvent('eventType', { view: 'chocolate' }).view threw exception TypeError: Dictionary member is not of type Window.
    36 PASS new KeyboardEvent('eventType', { view: 12345 }).view threw exception TypeError: Dictionary member is not of type Window.
    37 PASS new KeyboardEvent('eventType', { view: 18446744073709551615 }).view threw exception TypeError: Dictionary member is not of type Window.
    38 PASS new KeyboardEvent('eventType', { view: NaN }).view threw exception TypeError: Dictionary member is not of type Window.
    39 PASS new KeyboardEvent('eventType', { view: {valueOf: function () { return window; } } }).view threw exception TypeError: Dictionary member is not of type Window.
    40 PASS new KeyboardEvent('eventType', { get view() { return 123; } }).view threw exception TypeError: Dictionary member is not of type Window.
     32PASS new KeyboardEvent('eventType', { view: false }).view threw exception TypeError: Type error.
     33PASS new KeyboardEvent('eventType', { view: true }).view threw exception TypeError: Type error.
     34PASS new KeyboardEvent('eventType', { view: '' }).view threw exception TypeError: Type error.
     35PASS new KeyboardEvent('eventType', { view: 'chocolate' }).view threw exception TypeError: Type error.
     36PASS new KeyboardEvent('eventType', { view: 12345 }).view threw exception TypeError: Type error.
     37PASS new KeyboardEvent('eventType', { view: 18446744073709551615 }).view threw exception TypeError: Type error.
     38PASS new KeyboardEvent('eventType', { view: NaN }).view threw exception TypeError: Type error.
     39PASS new KeyboardEvent('eventType', { view: {valueOf: function () { return window; } } }).view threw exception TypeError: Type error.
     40PASS new KeyboardEvent('eventType', { get view() { return 123; } }).view threw exception TypeError: Type error.
    4141PASS new KeyboardEvent('eventType', { get view() { throw 'KeyboardEvent Error'; } }) threw exception KeyboardEvent Error.
    4242PASS new KeyboardEvent('eventType', { keyIdentifier: 'koakuma' }).keyIdentifier is "koakuma"
    4343PASS new KeyboardEvent('eventType', { keyIdentifier: '' }).keyIdentifier is ""
    44 PASS new KeyboardEvent('eventType', { keyIdentifier: undefined }).keyIdentifier is "undefined"
     44PASS new KeyboardEvent('eventType', { keyIdentifier: undefined }).keyIdentifier is ""
    4545PASS new KeyboardEvent('eventType', { keyIdentifier: null }).keyIdentifier is "null"
    4646PASS new KeyboardEvent('eventType', { keyIdentifier: false }).keyIdentifier is "false"
     
    107107PASS new KeyboardEvent('eventType', { metaKey: false }).metaKey is false
    108108PASS new KeyboardEvent('eventType', { metaKey: true }).metaKey is true
     109PASS new KeyboardEvent('eventType', { modifierAltGraph: true }).getModifierState('AltGraph') is true
     110PASS new KeyboardEvent('eventType', { modifierCapsLock: true }).getModifierState('CapsLock') is true
    109111PASS new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, key: 'a', code: 'KeyA', keyIdentifier: 'chocolate', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true }).bubbles is true
    110112PASS new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, key: 'a', code: 'KeyA', keyIdentifier: 'chocolate', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true }).cancelable is true
  • trunk/Source/WebCore/CMakeLists.txt

    r206963 r206971  
    400400    dom/Event.idl
    401401    dom/EventInit.idl
     402    dom/EventModifierInit.idl
    402403    dom/EventTarget.idl
    403404    dom/FocusEvent.idl
     
    440441    dom/TreeWalker.idl
    441442    dom/UIEvent.idl
     443    dom/UIEventInit.idl
    442444    dom/WebKitAnimationEvent.idl
    443445    dom/WebKitNamedFlow.idl
  • trunk/Source/WebCore/ChangeLog

    r206966 r206971  
     12016-10-09  Chris Dumez  <cdumez@apple.com>
     2
     3        Update KeyboardEvent to stop using legacy [ConstructorTemplate=Event]
     4        https://bugs.webkit.org/show_bug.cgi?id=163176
     5
     6        Reviewed by Darin Adler.
     7
     8        Update KeyboardEvent to stop using legacy [ConstructorTemplate=Event]
     9        and use a proper constructor instead, like in the specification:
     10        - https://www.w3.org/TR/uievents/#interface-keyboardevent
     11
     12        Also add support for passing modifierAltGraph / modifierCapsLock
     13        in the inialization dictionary as we support those modifiers via
     14        getModifierState().
     15
     16        No new tests, extended existing test.
     17
     18        * CMakeLists.txt:
     19        * DerivedSources.cpp:
     20        * DerivedSources.make:
     21        * WebCore.xcodeproj/project.pbxproj:
     22        * dom/EventModifierInit.h: Added.
     23        (WebCore::EventModifierInit::EventModifierInit):
     24        * dom/EventModifierInit.idl: Added.
     25        * dom/KeyboardEvent.cpp:
     26        (WebCore::KeyboardEvent::KeyboardEvent):
     27        (WebCore::KeyboardEvent::getModifierState):
     28        * dom/KeyboardEvent.h:
     29        * dom/KeyboardEvent.idl:
     30        * dom/MouseRelatedEvent.cpp:
     31        (WebCore::MouseRelatedEvent::MouseRelatedEvent):
     32        * dom/MouseRelatedEvent.h:
     33        * dom/UIEvent.cpp:
     34        (WebCore::UIEvent::UIEvent):
     35        * dom/UIEvent.h:
     36        (WebCore::UIEvent::create): Deleted.
     37        * dom/UIEventInit.h: Added.
     38        (WebCore::UIEventInit::UIEventInit):
     39        * dom/UIEventInit.idl: Added.
     40        * dom/UIEventWithKeyState.h:
     41        (WebCore::UIEventWithKeyState::altGraphKey):
     42        (WebCore::UIEventWithKeyState::capsLockKey):
     43        (WebCore::UIEventWithKeyState::UIEventWithKeyState):
     44        (WebCore::UIEventWithKeyState::ctrlKey): Deleted.
     45        (WebCore::UIEventWithKeyState::shiftKey): Deleted.
     46        (WebCore::UIEventWithKeyState::altKey): Deleted.
     47        (WebCore::UIEventWithKeyState::metaKey): Deleted.
     48
    1492016-10-09  Youenn Fablet  <youenn@apple.com>
    250
  • trunk/Source/WebCore/DerivedSources.cpp

    r206963 r206971  
    191191#include "JSEvent.cpp"
    192192#include "JSEventInit.cpp"
     193#include "JSEventModifierInit.cpp"
    193194#include "JSEventSource.cpp"
    194195#include "JSEventTarget.cpp"
     
    631632#include "JSTreeWalker.cpp"
    632633#include "JSUIEvent.cpp"
     634#include "JSUIEventInit.cpp"
    633635#include "JSUIRequestEvent.cpp"
    634636#include "JSURLUtils.cpp"
  • trunk/Source/WebCore/DerivedSources.make

    r206963 r206971  
    311311    $(WebCore)/dom/EventInit.idl \
    312312    $(WebCore)/dom/EventListener.idl \
     313    $(WebCore)/dom/EventModifierInit.idl \
    313314    $(WebCore)/dom/EventTarget.idl \
    314315    $(WebCore)/dom/FocusEvent.idl \
     
    349350    $(WebCore)/dom/TreeWalker.idl \
    350351    $(WebCore)/dom/UIEvent.idl \
     352    $(WebCore)/dom/UIEventInit.idl \
    351353    $(WebCore)/dom/WebKitAnimationEvent.idl \
    352354    $(WebCore)/dom/WebKitNamedFlow.idl \
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r206963 r206971  
    29322932                83E359A31BB1031D002CEB98 /* JSHTMLTimeElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83E359A11BB1031D002CEB98 /* JSHTMLTimeElement.cpp */; };
    29332933                83F1206B1B8C104700D75F63 /* JSNodeFilterCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83F1206A1B8C103600D75F63 /* JSNodeFilterCustom.cpp */; };
     2934                83FE7CA71DA9F1A70037237C /* UIEventInit.h in Headers */ = {isa = PBXBuildFile; fileRef = 83FE7CA41DA9F1660037237C /* UIEventInit.h */; settings = {ATTRIBUTES = (Private, ); }; };
     2935                83FE7CA81DA9F1B60037237C /* EventModifierInit.h in Headers */ = {isa = PBXBuildFile; fileRef = 83FE7CA31DA9F1650037237C /* EventModifierInit.h */; settings = {ATTRIBUTES = (Private, ); }; };
    29342936                8419D2A7120D92D000141F8F /* SVGPathByteStream.h in Headers */ = {isa = PBXBuildFile; fileRef = 8419D2A4120D92D000141F8F /* SVGPathByteStream.h */; };
    29352937                8419D2A8120D92D000141F8F /* SVGPathByteStreamBuilder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8419D2A5120D92D000141F8F /* SVGPathByteStreamBuilder.cpp */; };
     
    1006610068                83D35AEF1C718D8400F70D5A /* JSXMLHttpRequestEventTarget.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSXMLHttpRequestEventTarget.cpp; sourceTree = "<group>"; };
    1006710069                83D35AF01C718D8400F70D5A /* JSXMLHttpRequestEventTarget.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSXMLHttpRequestEventTarget.h; sourceTree = "<group>"; };
     10070                83E045EC1DAA104F00B0D8B9 /* JSEventModifierInit.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSEventModifierInit.cpp; sourceTree = "<group>"; };
     10071                83E045ED1DAA104F00B0D8B9 /* JSEventModifierInit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSEventModifierInit.h; sourceTree = "<group>"; };
     10072                83E045EE1DAA104F00B0D8B9 /* JSUIEventInit.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSUIEventInit.cpp; sourceTree = "<group>"; };
     10073                83E045EF1DAA104F00B0D8B9 /* JSUIEventInit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSUIEventInit.h; sourceTree = "<group>"; };
    1006810074                83E359A01BB1031D002CEB98 /* JSHTMLTimeElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSHTMLTimeElement.h; sourceTree = "<group>"; };
    1006910075                83E359A11BB1031D002CEB98 /* JSHTMLTimeElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLTimeElement.cpp; sourceTree = "<group>"; };
     
    1007410080                83F570AD1C53268E007FD6CB /* JSXMLDocument.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSXMLDocument.h; sourceTree = "<group>"; };
    1007510081                83F570AE1C53268E007FD6CB /* JSXMLDocument.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSXMLDocument.cpp; sourceTree = "<group>"; };
     10082                83FE7CA31DA9F1650037237C /* EventModifierInit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventModifierInit.h; sourceTree = "<group>"; };
     10083                83FE7CA41DA9F1660037237C /* UIEventInit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIEventInit.h; sourceTree = "<group>"; };
     10084                83FE7CA51DA9F1660037237C /* UIEventInit.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = UIEventInit.idl; sourceTree = "<group>"; };
     10085                83FE7CA61DA9F1660037237C /* EventModifierInit.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = EventModifierInit.idl; sourceTree = "<group>"; };
    1007610086                8419D2A4120D92D000141F8F /* SVGPathByteStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGPathByteStream.h; sourceTree = "<group>"; };
    1007710087                8419D2A5120D92D000141F8F /* SVGPathByteStreamBuilder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGPathByteStreamBuilder.cpp; sourceTree = "<group>"; };
     
    1970019710                                836D032B1DA8A13200FFD96B /* JSEventInit.cpp */,
    1970119711                                836D032C1DA8A13200FFD96B /* JSEventInit.h */,
     19712                                83E045EC1DAA104F00B0D8B9 /* JSEventModifierInit.cpp */,
     19713                                83E045ED1DAA104F00B0D8B9 /* JSEventModifierInit.h */,
    1970219714                                C6A703325C9D0B6CDCBC4D78 /* JSEventTarget.cpp */,
    1970319715                                5FC7DC26CFE2563200B85AE5 /* JSEventTarget.h */,
     
    1974219754                                A86629CA09DA2B47009633A5 /* JSUIEvent.cpp */,
    1974319755                                A86629C909DA2B47009633A5 /* JSUIEvent.h */,
     19756                                83E045EE1DAA104F00B0D8B9 /* JSUIEventInit.cpp */,
     19757                                83E045EF1DAA104F00B0D8B9 /* JSUIEventInit.h */,
    1974419758                                31C0FF390E4CEFAC007D6FE5 /* JSWebKitAnimationEvent.cpp */,
    1974519759                                31C0FF3A0E4CEFAC007D6FE5 /* JSWebKitAnimationEvent.h */,
     
    2312523139                                AD4495F1141FC08900541EDF /* EventListenerMap.cpp */,
    2312623140                                AD4495F2141FC08900541EDF /* EventListenerMap.h */,
     23141                                83FE7CA31DA9F1650037237C /* EventModifierInit.h */,
     23142                                83FE7CA61DA9F1660037237C /* EventModifierInit.idl */,
    2312723143                                939885C108B7E3D100E707C4 /* EventNames.cpp */,
    2312823144                                939885C208B7E3D100E707C4 /* EventNames.h */,
     
    2335123367                                85031B380A44EFC700F992E0 /* UIEvent.h */,
    2335223368                                141B94EE09EC425A000E9413 /* UIEvent.idl */,
     23369                                83FE7CA41DA9F1660037237C /* UIEventInit.h */,
     23370                                83FE7CA51DA9F1660037237C /* UIEventInit.idl */,
    2335323371                                93354A3B0B24F8C9003F6DEA /* UIEventWithKeyState.cpp */,
    2335423372                                85031B390A44EFC700F992E0 /* UIEventWithKeyState.h */,
     
    2420924227                                9DAC7C551AF2CAA200437C44 /* CSSContentDistributionValue.h in Headers */,
    2421024228                                2D8FEBDD143E3EF70072502B /* CSSCrossfadeValue.h in Headers */,
     24229                                83FE7CA71DA9F1A70037237C /* UIEventInit.h in Headers */,
    2421124230                                AA21ECCD0ABF0FC6002B834C /* CSSCursorImageValue.h in Headers */,
    2421224231                                BC779E141BB215BB00CAA8BF /* CSSCustomPropertyValue.h in Headers */,
     
    2436724386                                267725FF1A5B3AD9003C24DD /* DFANode.h in Headers */,
    2436824387                                CD19A2681A13E700008D650E /* DiagnosticLoggingClient.h in Headers */,
     24388                                83FE7CA81DA9F1B60037237C /* EventModifierInit.h in Headers */,
    2436924389                                46FCB6181A70820E00C5A21E /* DiagnosticLoggingKeys.h in Headers */,
    2437024390                                8372DB311A6780A800C697C5 /* DiagnosticLoggingResultType.h in Headers */,
  • trunk/Source/WebCore/dom/KeyboardEvent.cpp

    r206828 r206971  
    9696
    9797KeyboardEvent::KeyboardEvent(const PlatformKeyboardEvent& key, DOMWindow* view)
    98     : UIEventWithKeyState(eventTypeForKeyboardEventType(key.type()),
    99                           true, true, key.timestamp(), view, 0, key.ctrlKey(), key.altKey(), key.shiftKey(), key.metaKey())
     98    : UIEventWithKeyState(eventTypeForKeyboardEventType(key.type())
     99        , true, true, key.timestamp(), view, 0, key.ctrlKey(), key.altKey(), key.shiftKey()
     100        , key.metaKey(), false, key.modifiers().contains(PlatformEvent::Modifier::CapsLockKey))
    100101    , m_keyEvent(std::make_unique<PlatformKeyboardEvent>(key))
    101102#if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
     
    108109    , m_location(keyLocationCode(key))
    109110    , m_repeat(key.isAutoRepeat())
    110     , m_altGraphKey(false)
    111     , m_capsLockKey(key.modifiers().contains(PlatformEvent::Modifier::CapsLockKey))
    112111    , m_isComposing(view && view->frame() && view->frame()->editor().hasComposition())
    113112#if PLATFORM(COCOA)
     
    128127}
    129128
    130 KeyboardEvent::KeyboardEvent(const AtomicString& eventType, const KeyboardEventInit& initializer)
    131     : UIEventWithKeyState(eventType, initializer)
     129KeyboardEvent::KeyboardEvent(const AtomicString& eventType, const Init& initializer, IsTrusted isTrusted)
     130    : UIEventWithKeyState(eventType, initializer, isTrusted)
    132131#if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
    133132    , m_key(initializer.key)
     
    139138    , m_location(initializer.location)
    140139    , m_repeat(initializer.repeat)
    141     , m_altGraphKey(false) // FIXME: should be initialized from initializer.modifierAltGraph.
    142     , m_capsLockKey(false) // FIXME: should be initialized from initializer.modifierCapsLock.
    143140    , m_isComposing(initializer.isComposing)
    144141#if PLATFORM(COCOA)
     
    183180        return altGraphKey();
    184181    if (keyIdentifier == "CapsLock")
    185         return m_capsLockKey;
     182        return capsLockKey();
    186183    // FIXME: The specification also has Fn, FnLock, Hyper, NumLock, Super, ScrollLock, Symbol, SymbolLock.
    187184    return false;
  • trunk/Source/WebCore/dom/KeyboardEvent.h

    r206828 r206971  
    2424#pragma once
    2525
     26#include "EventModifierInit.h"
    2627#include "KeypressCommand.h"
    2728#include "UIEventWithKeyState.h"
     
    3334class Node;
    3435class PlatformKeyboardEvent;
    35 
    36 struct KeyboardEventInit : public UIEventWithKeyStateInit {
    37 #if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
    38     String key;
    39 #endif
    40 #if ENABLE(KEYBOARD_CODE_ATTRIBUTE)
    41     String code;
    42 #endif
    43     String keyIdentifier;
    44     unsigned location { 0 };
    45     bool repeat { false };
    46     bool isComposing { false };
    47 };
    4836
    4937class KeyboardEvent final : public UIEventWithKeyState {
     
    6654    }
    6755
    68     static Ref<KeyboardEvent> createForBindings(const AtomicString& type, const KeyboardEventInit& initializer)
     56    struct Init : public EventModifierInit {
     57        Init(bool bubbles, bool cancelable, bool composed, RefPtr<DOMWindow>&& view, int detail,
     58            bool ctrlKey, bool shiftKey, bool altKey, bool metaKey, bool modifierAltGraph, bool modifierCapsLock,
     59            String key, String code, Optional<unsigned> location, bool repeat, bool isComposing, String keyIdentifier,
     60            Optional<unsigned> keyLocation)
     61                : EventModifierInit(bubbles, cancelable, composed, WTFMove(view), detail, ctrlKey, shiftKey, altKey, metaKey, modifierAltGraph, modifierCapsLock)
     62                , key(key)
     63                , code(code)
     64                , location(location ? *location : keyLocation.valueOr(DOM_KEY_LOCATION_STANDARD))
     65                , repeat(repeat)
     66                , isComposing(isComposing)
     67                , keyIdentifier(keyIdentifier)
     68            { }
     69
     70        String key;
     71        String code;
     72        unsigned location;
     73        bool repeat;
     74        bool isComposing;
     75
     76        // Legacy.
     77        String keyIdentifier;
     78    };
     79
     80    static Ref<KeyboardEvent> create(const AtomicString& type, const Init& initializer, IsTrusted isTrusted = IsTrusted::No)
    6981    {
    70         return adoptRef(*new KeyboardEvent(type, initializer));
     82        return adoptRef(*new KeyboardEvent(type, initializer, isTrusted));
    7183    }
    7284
     
    96108
    97109    WEBCORE_EXPORT bool getModifierState(const String& keyIdentifier) const;
    98 
    99     bool altGraphKey() const { return m_altGraphKey; }
    100110   
    101111    const PlatformKeyboardEvent* keyEvent() const { return m_keyEvent.get(); }
     
    121131    WEBCORE_EXPORT KeyboardEvent();
    122132    WEBCORE_EXPORT KeyboardEvent(const PlatformKeyboardEvent&, DOMWindow*);
    123     KeyboardEvent(const AtomicString&, const KeyboardEventInit&);
     133    KeyboardEvent(const AtomicString&, const Init&, IsTrusted);
    124134    // FIXME: This method should be get rid of in the future.
    125135    // DO NOT USE IT!
     
    136146    unsigned m_location { DOM_KEY_LOCATION_STANDARD };
    137147    bool m_repeat { false };
    138     bool m_altGraphKey { false };
    139     bool m_capsLockKey { false };
    140148    bool m_isComposing { false };
    141149
  • trunk/Source/WebCore/dom/KeyboardEvent.idl

    r206803 r206971  
    2020
    2121[
    22     ConstructorConditional=DOM4_EVENTS_CONSTRUCTOR,
    23     ConstructorTemplate=Event,
     22    Constructor(DOMString type, optional KeyboardEventInit eventInitDict),
    2423] interface KeyboardEvent : UIEvent {
    2524
     
    2928    const unsigned long DOM_KEY_LOCATION_NUMPAD = 0x03;
    3029
    31     [InitializedByEventConstructor, Conditional=KEYBOARD_KEY_ATTRIBUTE] readonly attribute DOMString key;
    32     [InitializedByEventConstructor, Conditional=KEYBOARD_CODE_ATTRIBUTE] readonly attribute DOMString code;
    33     [InitializedByEventConstructor] readonly attribute unsigned long location;
     30    [Conditional=KEYBOARD_KEY_ATTRIBUTE] readonly attribute DOMString key;
     31    [Conditional=KEYBOARD_CODE_ATTRIBUTE] readonly attribute DOMString code;
     32    readonly attribute unsigned long location;
    3433
    35     [InitializedByEventConstructor] readonly attribute boolean ctrlKey;
    36     [InitializedByEventConstructor] readonly attribute boolean shiftKey;
    37     [InitializedByEventConstructor] readonly attribute boolean altKey;
    38     [InitializedByEventConstructor] readonly attribute boolean metaKey;
    39     [InitializedByEventConstructor] readonly attribute boolean repeat;
     34    readonly attribute boolean ctrlKey;
     35    readonly attribute boolean shiftKey;
     36    readonly attribute boolean altKey;
     37    readonly attribute boolean metaKey;
     38    readonly attribute boolean repeat;
    4039
    41     [InitializedByEventConstructor] readonly attribute boolean isComposing;
     40    readonly attribute boolean isComposing;
    4241
    4342    boolean getModifierState(DOMString keyArg);
    4443
    4544    // Everything below is legacy.
    46     [InitializedByEventConstructor] readonly attribute DOMString keyIdentifier;
    47     [InitializedByEventConstructor, ImplementedAs=location] readonly attribute unsigned long keyLocation;
     45    readonly attribute DOMString keyIdentifier;
     46    [ImplementedAs=location] readonly attribute unsigned long keyLocation;
    4847    readonly attribute boolean altGraphKey;
    4948
     
    5453        optional boolean ctrlKey = false, optional boolean altKey = false, optional boolean shiftKey = false, optional boolean metaKey = false, optional boolean altGraphKey = false);
    5554};
     55
     56dictionary KeyboardEventInit : EventModifierInit {
     57    DOMString key = "";
     58    DOMString code = "";
     59    unsigned long location;
     60    boolean repeat = false;
     61    boolean isComposing = false;
     62
     63    // This members are not in the specification but are needed to initialize the corresponding legacy
     64    // attributes we still support on KeyboardEvent for backward compatibility.
     65    DOMString keyIdentifier = "";
     66    unsigned long keyLocation;
     67};
  • trunk/Source/WebCore/dom/MouseRelatedEvent.cpp

    r204681 r206971  
    6262#endif
    6363                                     bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, bool isSimulated)
    64     : UIEventWithKeyState(eventType, canBubble, cancelable, timestamp, DOMWindow, detail, ctrlKey, altKey, shiftKey, metaKey)
     64    : UIEventWithKeyState(eventType, canBubble, cancelable, timestamp, DOMWindow, detail, ctrlKey, altKey, shiftKey, metaKey, false, false)
    6565    , m_screenLocation(screenLocation)
    6666#if ENABLE(POINTER_LOCK)
  • trunk/Source/WebCore/dom/MouseRelatedEvent.h

    r204717 r206971  
    2929namespace WebCore {
    3030
    31 struct MouseRelatedEventInit : public UIEventWithKeyStateInit {
     31struct MouseRelatedEventInit : public EventModifierInit {
    3232    int screenX { 0 };
    3333    int screenY { 0 };
  • trunk/Source/WebCore/dom/UIEvent.cpp

    r204681 r206971  
    4747}
    4848
    49 UIEvent::UIEvent(const AtomicString& eventType, const UIEventInit& initializer)
    50     : Event(eventType, initializer)
     49UIEvent::UIEvent(const AtomicString& eventType, const UIEventInit& initializer, IsTrusted isTrusted)
     50    : Event(eventType, initializer, isTrusted)
    5151    , m_view(initializer.view.get())
    5252    , m_detail(initializer.detail)
  • trunk/Source/WebCore/dom/UIEvent.h

    r204717 r206971  
    2626#include "DOMWindow.h"
    2727#include "Event.h"
     28#include "UIEventInit.h"
    2829
    2930namespace WebCore {
     
    3132// FIXME: Remove this when no one is depending on it anymore.
    3233typedef DOMWindow AbstractView;
    33 
    34 struct UIEventInit : public EventInit {
    35     RefPtr<DOMWindow> view;
    36     int detail { 0 };
    37 };
    3834
    3935class UIEvent : public Event {
     
    7571    UIEvent(const AtomicString& type, bool canBubble, bool cancelable, DOMWindow*, int detail);
    7672    UIEvent(const AtomicString& type, bool canBubble, bool cancelable, double timestamp, DOMWindow*, int detail);
    77     UIEvent(const AtomicString&, const UIEventInit&);
     73    UIEvent(const AtomicString&, const UIEventInit&, IsTrusted = IsTrusted::No);
    7874
    7975private:
  • trunk/Source/WebCore/dom/UIEventWithKeyState.h

    r204681 r206971  
    2525#define UIEventWithKeyState_h
    2626
     27#include "EventModifierInit.h"
    2728#include "UIEvent.h"
    2829
    2930namespace WebCore {
    30 
    31 struct UIEventWithKeyStateInit : public UIEventInit {
    32     bool ctrlKey { false };
    33     bool altKey { false };
    34     bool shiftKey { false };
    35     bool metaKey { false };
    36 };
    3731
    3832class UIEventWithKeyState : public UIEvent {
     
    4236    bool altKey() const { return m_altKey; }
    4337    bool metaKey() const { return m_metaKey; }
     38    bool altGraphKey() const { return m_altGraphKey; }
     39    bool capsLockKey() const { return m_capsLockKey; }
    4440
    4541protected:
    46     UIEventWithKeyState()
    47         : m_ctrlKey(false)
    48         , m_altKey(false)
    49         , m_shiftKey(false)
    50         , m_metaKey(false)
    51     {
    52     }
     42    UIEventWithKeyState() = default;
    5343
    5444    UIEventWithKeyState(const AtomicString& type, bool canBubble, bool cancelable, DOMWindow* view, int detail, bool ctrlKey, bool altKey, bool shiftKey, bool metaKey)
     
    6151    }
    6252
    63     UIEventWithKeyState(const AtomicString& type, bool canBubble, bool cancelable, double timestamp, DOMWindow* view, int detail, bool ctrlKey, bool altKey, bool shiftKey, bool metaKey)
    64         : UIEvent(type, canBubble, cancelable, timestamp, view, detail)
    65         , m_ctrlKey(ctrlKey)
    66         , m_altKey(altKey)
    67         , m_shiftKey(shiftKey)
    68         , m_metaKey(metaKey)
     53    UIEventWithKeyState(const AtomicString& type, bool canBubble, bool cancelable, double timestamp, DOMWindow* view,
     54        int detail, bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, bool altGraphKey, bool capsLockKey)
     55            : UIEvent(type, canBubble, cancelable, timestamp, view, detail)
     56            , m_ctrlKey(ctrlKey)
     57            , m_altKey(altKey)
     58            , m_shiftKey(shiftKey)
     59            , m_metaKey(metaKey)
     60            , m_altGraphKey(altGraphKey)
     61            , m_capsLockKey(capsLockKey)
    6962    {
    7063    }
    7164
    72     UIEventWithKeyState(const AtomicString& type, const UIEventWithKeyStateInit& initializer)
    73         : UIEvent(type, initializer)
     65    UIEventWithKeyState(const AtomicString& type, const EventModifierInit& initializer, IsTrusted isTrusted = IsTrusted::No)
     66        : UIEvent(type, initializer, isTrusted)
    7467        , m_ctrlKey(initializer.ctrlKey)
    7568        , m_altKey(initializer.altKey)
    7669        , m_shiftKey(initializer.shiftKey)
    7770        , m_metaKey(initializer.metaKey)
     71        , m_altGraphKey(initializer.modifierAltGraph)
     72        , m_capsLockKey(initializer.modifierCapsLock)
    7873    {
    7974    }
    8075
    8176    // Expose these so init functions can set them.
    82     bool m_ctrlKey : 1;
    83     bool m_altKey : 1;
    84     bool m_shiftKey : 1;
    85     bool m_metaKey : 1;
     77    bool m_ctrlKey { false };
     78    bool m_altKey { false };
     79    bool m_shiftKey { false };
     80    bool m_metaKey { false };
     81    bool m_altGraphKey { false };
     82    bool m_capsLockKey { false };
    8683};
    8784
Note: See TracChangeset for help on using the changeset viewer.