Update KeyboardEvent to stop using legacy [ConstructorTemplate=Event]
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 9 Oct 2016 23:11:56 +0000 (23:11 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 9 Oct 2016 23:11:56 +0000 (23:11 +0000)
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:
- https://www.w3.org/TR/uievents/#interface-keyboardevent

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:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206971 268f45cc-cd09-0410-ab3c-d52691b4dbfc

21 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/events/constructors/keyboard-event-constructor-expected.txt
LayoutTests/fast/events/constructors/keyboard-event-constructor.html
LayoutTests/platform/ios-simulator/fast/events/constructors/keyboard-event-constructor-expected.txt
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/DerivedSources.cpp
Source/WebCore/DerivedSources.make
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/dom/EventModifierInit.h [new file with mode: 0644]
Source/WebCore/dom/EventModifierInit.idl [new file with mode: 0644]
Source/WebCore/dom/KeyboardEvent.cpp
Source/WebCore/dom/KeyboardEvent.h
Source/WebCore/dom/KeyboardEvent.idl
Source/WebCore/dom/MouseRelatedEvent.cpp
Source/WebCore/dom/MouseRelatedEvent.h
Source/WebCore/dom/UIEvent.cpp
Source/WebCore/dom/UIEvent.h
Source/WebCore/dom/UIEventInit.h [new file with mode: 0644]
Source/WebCore/dom/UIEventInit.idl [new file with mode: 0644]
Source/WebCore/dom/UIEventWithKeyState.h

index 19ca421..628e898 100644 (file)
@@ -1,3 +1,17 @@
+2016-10-09  Chris Dumez  <cdumez@apple.com>
+
+        Update KeyboardEvent to stop using legacy [ConstructorTemplate=Event]
+        https://bugs.webkit.org/show_bug.cgi?id=163176
+
+        Reviewed by Darin Adler.
+
+        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:
+
 2016-10-09  Michael Catanzaro  <mcatanzaro@igalia.com>
 
         [GTK] Miscellaneous unreviewed test gardening
index d88596c..57406a4 100644 (file)
@@ -25,23 +25,23 @@ PASS new KeyboardEvent('eventType', { repeat: true }).repeat is true
 PASS new KeyboardEvent('eventType', { }).isComposing is false
 PASS new KeyboardEvent('eventType', { isComposing: false }).isComposing is false
 PASS new KeyboardEvent('eventType', { isComposing: true }).isComposing is true
-PASS new KeyboardEvent('eventType', { view: testObject }).view threw exception TypeError: Dictionary member is not of type Window.
-PASS new KeyboardEvent('eventType', { view: document }).view threw exception TypeError: Dictionary member is not of type Window.
+PASS new KeyboardEvent('eventType', { view: testObject }).view threw exception TypeError: Type error.
+PASS new KeyboardEvent('eventType', { view: document }).view threw exception TypeError: Type error.
 PASS new KeyboardEvent('eventType', { view: undefined }).view is null
 PASS new KeyboardEvent('eventType', { view: null }).view is null
-PASS new KeyboardEvent('eventType', { view: false }).view threw exception TypeError: Dictionary member is not of type Window.
-PASS new KeyboardEvent('eventType', { view: true }).view threw exception TypeError: Dictionary member is not of type Window.
-PASS new KeyboardEvent('eventType', { view: '' }).view threw exception TypeError: Dictionary member is not of type Window.
-PASS new KeyboardEvent('eventType', { view: 'chocolate' }).view threw exception TypeError: Dictionary member is not of type Window.
-PASS new KeyboardEvent('eventType', { view: 12345 }).view threw exception TypeError: Dictionary member is not of type Window.
-PASS new KeyboardEvent('eventType', { view: 18446744073709551615 }).view threw exception TypeError: Dictionary member is not of type Window.
-PASS new KeyboardEvent('eventType', { view: NaN }).view threw exception TypeError: Dictionary member is not of type Window.
-PASS new KeyboardEvent('eventType', { view: {valueOf: function () { return window; } } }).view threw exception TypeError: Dictionary member is not of type Window.
-PASS new KeyboardEvent('eventType', { get view() { return 123; } }).view threw exception TypeError: Dictionary member is not of type Window.
+PASS new KeyboardEvent('eventType', { view: false }).view threw exception TypeError: Type error.
+PASS new KeyboardEvent('eventType', { view: true }).view threw exception TypeError: Type error.
+PASS new KeyboardEvent('eventType', { view: '' }).view threw exception TypeError: Type error.
+PASS new KeyboardEvent('eventType', { view: 'chocolate' }).view threw exception TypeError: Type error.
+PASS new KeyboardEvent('eventType', { view: 12345 }).view threw exception TypeError: Type error.
+PASS new KeyboardEvent('eventType', { view: 18446744073709551615 }).view threw exception TypeError: Type error.
+PASS new KeyboardEvent('eventType', { view: NaN }).view threw exception TypeError: Type error.
+PASS new KeyboardEvent('eventType', { view: {valueOf: function () { return window; } } }).view threw exception TypeError: Type error.
+PASS new KeyboardEvent('eventType', { get view() { return 123; } }).view threw exception TypeError: Type error.
 PASS new KeyboardEvent('eventType', { get view() { throw 'KeyboardEvent Error'; } }) threw exception KeyboardEvent Error.
 PASS new KeyboardEvent('eventType', { keyIdentifier: 'koakuma' }).keyIdentifier is "koakuma"
 PASS new KeyboardEvent('eventType', { keyIdentifier: '' }).keyIdentifier is ""
-PASS new KeyboardEvent('eventType', { keyIdentifier: undefined }).keyIdentifier is "undefined"
+PASS new KeyboardEvent('eventType', { keyIdentifier: undefined }).keyIdentifier is ""
 PASS new KeyboardEvent('eventType', { keyIdentifier: null }).keyIdentifier is "null"
 PASS new KeyboardEvent('eventType', { keyIdentifier: false }).keyIdentifier is "false"
 PASS new KeyboardEvent('eventType', { keyIdentifier: true }).keyIdentifier is "true"
@@ -106,6 +106,8 @@ PASS new KeyboardEvent('eventType', { shiftKey: false }).shiftKey is false
 PASS new KeyboardEvent('eventType', { shiftKey: true }).shiftKey is true
 PASS new KeyboardEvent('eventType', { metaKey: false }).metaKey is false
 PASS new KeyboardEvent('eventType', { metaKey: true }).metaKey is true
+PASS new KeyboardEvent('eventType', { modifierAltGraph: true }).getModifierState('AltGraph') is true
+PASS new KeyboardEvent('eventType', { modifierCapsLock: true }).getModifierState('CapsLock') is true
 PASS new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, key: 'a', code: 'KeyA', keyIdentifier: 'chocolate', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true }).bubbles is true
 PASS new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, key: 'a', code: 'KeyA', keyIdentifier: 'chocolate', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true }).cancelable is true
 PASS new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, key: 'a', code: 'KeyA', keyIdentifier: 'chocolate', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true }).view is window
index b671af4..0b381c4 100644 (file)
@@ -68,7 +68,7 @@ shouldBeEqualToString("new KeyboardEvent('eventType', { keyIdentifier: 'koakuma'
 shouldBeEqualToString("new KeyboardEvent('eventType', { keyIdentifier: '' }).keyIdentifier", "");
 
 // Non-strings.
-shouldBeEqualToString("new KeyboardEvent('eventType', { keyIdentifier: undefined }).keyIdentifier", "undefined");
+shouldBeEqualToString("new KeyboardEvent('eventType', { keyIdentifier: undefined }).keyIdentifier", "");
 shouldBeEqualToString("new KeyboardEvent('eventType', { keyIdentifier: null }).keyIdentifier", "null");
 shouldBeEqualToString("new KeyboardEvent('eventType', { keyIdentifier: false }).keyIdentifier", "false");
 shouldBeEqualToString("new KeyboardEvent('eventType', { keyIdentifier: true }).keyIdentifier", "true");
@@ -121,6 +121,9 @@ shouldBe("new KeyboardEvent('eventType', { location: KeyboardEvent.DOM_KEY_LOCAT
     shouldBe("new KeyboardEvent('eventType', { " + attr + ": true })." + attr, "true");
 });
 
+shouldBeTrue("new KeyboardEvent('eventType', { modifierAltGraph: true }).getModifierState('AltGraph')");
+shouldBeTrue("new KeyboardEvent('eventType', { modifierCapsLock: true }).getModifierState('CapsLock')");
+
 // All initializers are passed.
 shouldBe("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, key: 'a', code: 'KeyA', keyIdentifier: 'chocolate', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true }).bubbles", "true");
 shouldBe("new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, key: 'a', code: 'KeyA', keyIdentifier: 'chocolate', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true }).cancelable", "true");
index a37a43b..5a57709 100644 (file)
@@ -25,23 +25,23 @@ PASS new KeyboardEvent('eventType', { repeat: true }).repeat is true
 PASS new KeyboardEvent('eventType', { }).isComposing is false
 PASS new KeyboardEvent('eventType', { isComposing: false }).isComposing is false
 PASS new KeyboardEvent('eventType', { isComposing: true }).isComposing is true
-PASS new KeyboardEvent('eventType', { view: testObject }).view threw exception TypeError: Dictionary member is not of type Window.
-PASS new KeyboardEvent('eventType', { view: document }).view threw exception TypeError: Dictionary member is not of type Window.
+PASS new KeyboardEvent('eventType', { view: testObject }).view threw exception TypeError: Type error.
+PASS new KeyboardEvent('eventType', { view: document }).view threw exception TypeError: Type error.
 PASS new KeyboardEvent('eventType', { view: undefined }).view is null
 PASS new KeyboardEvent('eventType', { view: null }).view is null
-PASS new KeyboardEvent('eventType', { view: false }).view threw exception TypeError: Dictionary member is not of type Window.
-PASS new KeyboardEvent('eventType', { view: true }).view threw exception TypeError: Dictionary member is not of type Window.
-PASS new KeyboardEvent('eventType', { view: '' }).view threw exception TypeError: Dictionary member is not of type Window.
-PASS new KeyboardEvent('eventType', { view: 'chocolate' }).view threw exception TypeError: Dictionary member is not of type Window.
-PASS new KeyboardEvent('eventType', { view: 12345 }).view threw exception TypeError: Dictionary member is not of type Window.
-PASS new KeyboardEvent('eventType', { view: 18446744073709551615 }).view threw exception TypeError: Dictionary member is not of type Window.
-PASS new KeyboardEvent('eventType', { view: NaN }).view threw exception TypeError: Dictionary member is not of type Window.
-PASS new KeyboardEvent('eventType', { view: {valueOf: function () { return window; } } }).view threw exception TypeError: Dictionary member is not of type Window.
-PASS new KeyboardEvent('eventType', { get view() { return 123; } }).view threw exception TypeError: Dictionary member is not of type Window.
+PASS new KeyboardEvent('eventType', { view: false }).view threw exception TypeError: Type error.
+PASS new KeyboardEvent('eventType', { view: true }).view threw exception TypeError: Type error.
+PASS new KeyboardEvent('eventType', { view: '' }).view threw exception TypeError: Type error.
+PASS new KeyboardEvent('eventType', { view: 'chocolate' }).view threw exception TypeError: Type error.
+PASS new KeyboardEvent('eventType', { view: 12345 }).view threw exception TypeError: Type error.
+PASS new KeyboardEvent('eventType', { view: 18446744073709551615 }).view threw exception TypeError: Type error.
+PASS new KeyboardEvent('eventType', { view: NaN }).view threw exception TypeError: Type error.
+PASS new KeyboardEvent('eventType', { view: {valueOf: function () { return window; } } }).view threw exception TypeError: Type error.
+PASS new KeyboardEvent('eventType', { get view() { return 123; } }).view threw exception TypeError: Type error.
 PASS new KeyboardEvent('eventType', { get view() { throw 'KeyboardEvent Error'; } }) threw exception KeyboardEvent Error.
 PASS new KeyboardEvent('eventType', { keyIdentifier: 'koakuma' }).keyIdentifier is "koakuma"
 PASS new KeyboardEvent('eventType', { keyIdentifier: '' }).keyIdentifier is ""
-PASS new KeyboardEvent('eventType', { keyIdentifier: undefined }).keyIdentifier is "undefined"
+PASS new KeyboardEvent('eventType', { keyIdentifier: undefined }).keyIdentifier is ""
 PASS new KeyboardEvent('eventType', { keyIdentifier: null }).keyIdentifier is "null"
 PASS new KeyboardEvent('eventType', { keyIdentifier: false }).keyIdentifier is "false"
 PASS new KeyboardEvent('eventType', { keyIdentifier: true }).keyIdentifier is "true"
@@ -106,6 +106,8 @@ PASS new KeyboardEvent('eventType', { shiftKey: false }).shiftKey is false
 PASS new KeyboardEvent('eventType', { shiftKey: true }).shiftKey is true
 PASS new KeyboardEvent('eventType', { metaKey: false }).metaKey is false
 PASS new KeyboardEvent('eventType', { metaKey: true }).metaKey is true
+PASS new KeyboardEvent('eventType', { modifierAltGraph: true }).getModifierState('AltGraph') is true
+PASS new KeyboardEvent('eventType', { modifierCapsLock: true }).getModifierState('CapsLock') is true
 PASS new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, key: 'a', code: 'KeyA', keyIdentifier: 'chocolate', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true }).bubbles is true
 PASS new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, key: 'a', code: 'KeyA', keyIdentifier: 'chocolate', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true }).cancelable is true
 PASS new KeyboardEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, key: 'a', code: 'KeyA', keyIdentifier: 'chocolate', location: 222, ctrlKey: true, altKey: true, shiftKey: true, metaKey: true }).view is window
index ae8106d..ad3b618 100644 (file)
@@ -399,6 +399,7 @@ set(WebCore_NON_SVG_IDL_FILES
     dom/ErrorEvent.idl
     dom/Event.idl
     dom/EventInit.idl
+    dom/EventModifierInit.idl
     dom/EventTarget.idl
     dom/FocusEvent.idl
     dom/GlobalEventHandlers.idl
@@ -439,6 +440,7 @@ set(WebCore_NON_SVG_IDL_FILES
     dom/TransitionEvent.idl
     dom/TreeWalker.idl
     dom/UIEvent.idl
+    dom/UIEventInit.idl
     dom/WebKitAnimationEvent.idl
     dom/WebKitNamedFlow.idl
     dom/WebKitTransitionEvent.idl
index 04b7d55..d68a1c5 100644 (file)
@@ -1,3 +1,51 @@
+2016-10-09  Chris Dumez  <cdumez@apple.com>
+
+        Update KeyboardEvent to stop using legacy [ConstructorTemplate=Event]
+        https://bugs.webkit.org/show_bug.cgi?id=163176
+
+        Reviewed by Darin Adler.
+
+        Update KeyboardEvent to stop using legacy [ConstructorTemplate=Event]
+        and use a proper constructor instead, like in the specification:
+        - https://www.w3.org/TR/uievents/#interface-keyboardevent
+
+        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.
+
 2016-10-09  Youenn Fablet  <youenn@apple.com>
 
         Promise attribute getters should reject promises in case of casted-this errors
index 6126319..03e9b88 100644 (file)
 #include "JSErrorEvent.cpp"
 #include "JSEvent.cpp"
 #include "JSEventInit.cpp"
+#include "JSEventModifierInit.cpp"
 #include "JSEventSource.cpp"
 #include "JSEventTarget.cpp"
 #include "JSFetchBody.cpp"
 #include "JSTransitionEvent.cpp"
 #include "JSTreeWalker.cpp"
 #include "JSUIEvent.cpp"
+#include "JSUIEventInit.cpp"
 #include "JSUIRequestEvent.cpp"
 #include "JSURLUtils.cpp"
 #if ENABLE(USER_MESSAGE_HANDLERS)
index 895bc8d..d113181 100644 (file)
@@ -310,6 +310,7 @@ JS_BINDING_IDLS = \
     $(WebCore)/dom/Event.idl \
     $(WebCore)/dom/EventInit.idl \
     $(WebCore)/dom/EventListener.idl \
+    $(WebCore)/dom/EventModifierInit.idl \
     $(WebCore)/dom/EventTarget.idl \
     $(WebCore)/dom/FocusEvent.idl \
     $(WebCore)/dom/GlobalEventHandlers.idl \
@@ -348,6 +349,7 @@ JS_BINDING_IDLS = \
     $(WebCore)/dom/TransitionEvent.idl \
     $(WebCore)/dom/TreeWalker.idl \
     $(WebCore)/dom/UIEvent.idl \
+    $(WebCore)/dom/UIEventInit.idl \
     $(WebCore)/dom/WebKitAnimationEvent.idl \
     $(WebCore)/dom/WebKitNamedFlow.idl \
     $(WebCore)/dom/WebKitTransitionEvent.idl \
index 463455c..a595fe2 100644 (file)
                83E359A21BB1031D002CEB98 /* JSHTMLTimeElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 83E359A01BB1031D002CEB98 /* JSHTMLTimeElement.h */; };
                83E359A31BB1031D002CEB98 /* JSHTMLTimeElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83E359A11BB1031D002CEB98 /* JSHTMLTimeElement.cpp */; };
                83F1206B1B8C104700D75F63 /* JSNodeFilterCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83F1206A1B8C103600D75F63 /* JSNodeFilterCustom.cpp */; };
+               83FE7CA71DA9F1A70037237C /* UIEventInit.h in Headers */ = {isa = PBXBuildFile; fileRef = 83FE7CA41DA9F1660037237C /* UIEventInit.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               83FE7CA81DA9F1B60037237C /* EventModifierInit.h in Headers */ = {isa = PBXBuildFile; fileRef = 83FE7CA31DA9F1650037237C /* EventModifierInit.h */; settings = {ATTRIBUTES = (Private, ); }; };
                8419D2A7120D92D000141F8F /* SVGPathByteStream.h in Headers */ = {isa = PBXBuildFile; fileRef = 8419D2A4120D92D000141F8F /* SVGPathByteStream.h */; };
                8419D2A8120D92D000141F8F /* SVGPathByteStreamBuilder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8419D2A5120D92D000141F8F /* SVGPathByteStreamBuilder.cpp */; };
                8419D2A9120D92D000141F8F /* SVGPathByteStreamBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = 8419D2A6120D92D000141F8F /* SVGPathByteStreamBuilder.h */; };
                83D35AEB1C7187ED00F70D5A /* XMLHttpRequestEventTarget.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = XMLHttpRequestEventTarget.idl; sourceTree = "<group>"; };
                83D35AEF1C718D8400F70D5A /* JSXMLHttpRequestEventTarget.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSXMLHttpRequestEventTarget.cpp; sourceTree = "<group>"; };
                83D35AF01C718D8400F70D5A /* JSXMLHttpRequestEventTarget.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSXMLHttpRequestEventTarget.h; sourceTree = "<group>"; };
+               83E045EC1DAA104F00B0D8B9 /* JSEventModifierInit.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSEventModifierInit.cpp; sourceTree = "<group>"; };
+               83E045ED1DAA104F00B0D8B9 /* JSEventModifierInit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSEventModifierInit.h; sourceTree = "<group>"; };
+               83E045EE1DAA104F00B0D8B9 /* JSUIEventInit.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSUIEventInit.cpp; sourceTree = "<group>"; };
+               83E045EF1DAA104F00B0D8B9 /* JSUIEventInit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSUIEventInit.h; sourceTree = "<group>"; };
                83E359A01BB1031D002CEB98 /* JSHTMLTimeElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSHTMLTimeElement.h; sourceTree = "<group>"; };
                83E359A11BB1031D002CEB98 /* JSHTMLTimeElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLTimeElement.cpp; sourceTree = "<group>"; };
                83E959E11B8BC22B004D9385 /* NativeNodeFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NativeNodeFilter.h; sourceTree = "<group>"; };
                83F1206A1B8C103600D75F63 /* JSNodeFilterCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSNodeFilterCustom.cpp; sourceTree = "<group>"; };
                83F570AD1C53268E007FD6CB /* JSXMLDocument.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSXMLDocument.h; sourceTree = "<group>"; };
                83F570AE1C53268E007FD6CB /* JSXMLDocument.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSXMLDocument.cpp; sourceTree = "<group>"; };
+               83FE7CA31DA9F1650037237C /* EventModifierInit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventModifierInit.h; sourceTree = "<group>"; };
+               83FE7CA41DA9F1660037237C /* UIEventInit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIEventInit.h; sourceTree = "<group>"; };
+               83FE7CA51DA9F1660037237C /* UIEventInit.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = UIEventInit.idl; sourceTree = "<group>"; };
+               83FE7CA61DA9F1660037237C /* EventModifierInit.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = EventModifierInit.idl; sourceTree = "<group>"; };
                8419D2A4120D92D000141F8F /* SVGPathByteStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGPathByteStream.h; sourceTree = "<group>"; };
                8419D2A5120D92D000141F8F /* SVGPathByteStreamBuilder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGPathByteStreamBuilder.cpp; sourceTree = "<group>"; };
                8419D2A6120D92D000141F8F /* SVGPathByteStreamBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGPathByteStreamBuilder.h; sourceTree = "<group>"; };
                                14E8378D09F85D4F00B85AE4 /* JSEvent.h */,
                                836D032B1DA8A13200FFD96B /* JSEventInit.cpp */,
                                836D032C1DA8A13200FFD96B /* JSEventInit.h */,
+                               83E045EC1DAA104F00B0D8B9 /* JSEventModifierInit.cpp */,
+                               83E045ED1DAA104F00B0D8B9 /* JSEventModifierInit.h */,
                                C6A703325C9D0B6CDCBC4D78 /* JSEventTarget.cpp */,
                                5FC7DC26CFE2563200B85AE5 /* JSEventTarget.h */,
                                B6D9D27A14EAC0860090D75E /* JSFocusEvent.cpp */,
                                E17B491F16A9B8FF001C8839 /* JSTransitionEvent.h */,
                                A86629CA09DA2B47009633A5 /* JSUIEvent.cpp */,
                                A86629C909DA2B47009633A5 /* JSUIEvent.h */,
+                               83E045EE1DAA104F00B0D8B9 /* JSUIEventInit.cpp */,
+                               83E045EF1DAA104F00B0D8B9 /* JSUIEventInit.h */,
                                31C0FF390E4CEFAC007D6FE5 /* JSWebKitAnimationEvent.cpp */,
                                31C0FF3A0E4CEFAC007D6FE5 /* JSWebKitAnimationEvent.h */,
                                31C0FF3B0E4CEFAC007D6FE5 /* JSWebKitTransitionEvent.cpp */,
                                85AFA7410AAF298400E84305 /* EventListener.idl */,
                                AD4495F1141FC08900541EDF /* EventListenerMap.cpp */,
                                AD4495F2141FC08900541EDF /* EventListenerMap.h */,
+                               83FE7CA31DA9F1650037237C /* EventModifierInit.h */,
+                               83FE7CA61DA9F1660037237C /* EventModifierInit.idl */,
                                939885C108B7E3D100E707C4 /* EventNames.cpp */,
                                939885C208B7E3D100E707C4 /* EventNames.h */,
                                BC9A6142146859D9006057FD /* EventNames.in */,
                                85031B370A44EFC700F992E0 /* UIEvent.cpp */,
                                85031B380A44EFC700F992E0 /* UIEvent.h */,
                                141B94EE09EC425A000E9413 /* UIEvent.idl */,
+                               83FE7CA41DA9F1660037237C /* UIEventInit.h */,
+                               83FE7CA51DA9F1660037237C /* UIEventInit.idl */,
                                93354A3B0B24F8C9003F6DEA /* UIEventWithKeyState.cpp */,
                                85031B390A44EFC700F992E0 /* UIEventWithKeyState.h */,
                                A769E96916689D0C005D4529 /* UserActionElementSet.cpp */,
                                BCEA4790097CAAC80094C9E4 /* CSSComputedStyleDeclaration.h in Headers */,
                                9DAC7C551AF2CAA200437C44 /* CSSContentDistributionValue.h in Headers */,
                                2D8FEBDD143E3EF70072502B /* CSSCrossfadeValue.h in Headers */,
+                               83FE7CA71DA9F1A70037237C /* UIEventInit.h in Headers */,
                                AA21ECCD0ABF0FC6002B834C /* CSSCursorImageValue.h in Headers */,
                                BC779E141BB215BB00CAA8BF /* CSSCustomPropertyValue.h in Headers */,
                                4A9CC81816BB9AC600EC645A /* CSSDefaultStyleSheets.h in Headers */,
                                26A517FE1AB92238006335DF /* DFAMinimizer.h in Headers */,
                                267725FF1A5B3AD9003C24DD /* DFANode.h in Headers */,
                                CD19A2681A13E700008D650E /* DiagnosticLoggingClient.h in Headers */,
+                               83FE7CA81DA9F1B60037237C /* EventModifierInit.h in Headers */,
                                46FCB6181A70820E00C5A21E /* DiagnosticLoggingKeys.h in Headers */,
                                8372DB311A6780A800C697C5 /* DiagnosticLoggingResultType.h in Headers */,
                                CECADFC7153778FF00E37068 /* DictationAlternative.h in Headers */,
diff --git a/Source/WebCore/dom/EventModifierInit.h b/Source/WebCore/dom/EventModifierInit.h
new file mode 100644 (file)
index 0000000..e3ee0e0
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "UIEventInit.h"
+
+namespace WebCore {
+
+struct EventModifierInit : public UIEventInit {
+    EventModifierInit() = default;
+
+    EventModifierInit(bool bubbles, bool cancelable, bool composed, RefPtr<DOMWindow>&& view, int detail,
+        bool ctrlKey, bool shiftKey, bool altKey, bool metaKey, bool modifierAltGraph, bool modifierCapsLock)
+            : UIEventInit(bubbles, cancelable, composed, WTFMove(view), detail)
+            , ctrlKey(ctrlKey)
+            , shiftKey(shiftKey)
+            , altKey(altKey)
+            , metaKey(metaKey)
+            , modifierAltGraph(modifierAltGraph)
+            , modifierCapsLock(modifierCapsLock)
+        { }
+
+    bool ctrlKey { false };
+    bool shiftKey { false };
+    bool altKey { false };
+    bool metaKey { false };
+
+    bool modifierAltGraph { false };
+    bool modifierCapsLock { false };
+};
+
+}
diff --git a/Source/WebCore/dom/EventModifierInit.idl b/Source/WebCore/dom/EventModifierInit.idl
new file mode 100644 (file)
index 0000000..e97d745
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+dictionary EventModifierInit : UIEventInit {
+    boolean ctrlKey = false;
+    boolean shiftKey = false;
+    boolean altKey = false;
+    boolean metaKey = false;
+
+    boolean modifierAltGraph = false;
+    boolean modifierCapsLock = false;
+
+    // FIXME: The following members are in the specification but are not implemented.
+    // boolean modifierFn = false;
+    // boolean modifierFnLock = false;
+    // boolean modifierHyper = false;
+    // boolean modifierNumLock = false;
+    // boolean modifierScrollLock = false;
+    // boolean modifierSuper = false;
+    // boolean modifierSymbol = false;
+    // boolean modifierSymbolLock = false;
+};
index 2276280..8452032 100644 (file)
@@ -95,8 +95,9 @@ static inline KeyboardEvent::KeyLocationCode keyLocationCode(const PlatformKeybo
 KeyboardEvent::KeyboardEvent() = default;
 
 KeyboardEvent::KeyboardEvent(const PlatformKeyboardEvent& key, DOMWindow* view)
-    : UIEventWithKeyState(eventTypeForKeyboardEventType(key.type()),
-                          true, true, key.timestamp(), view, 0, key.ctrlKey(), key.altKey(), key.shiftKey(), key.metaKey())
+    : UIEventWithKeyState(eventTypeForKeyboardEventType(key.type())
+        , true, true, key.timestamp(), view, 0, key.ctrlKey(), key.altKey(), key.shiftKey()
+        , key.metaKey(), false, key.modifiers().contains(PlatformEvent::Modifier::CapsLockKey))
     , m_keyEvent(std::make_unique<PlatformKeyboardEvent>(key))
 #if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
     , m_key(key.key())
@@ -107,8 +108,6 @@ KeyboardEvent::KeyboardEvent(const PlatformKeyboardEvent& key, DOMWindow* view)
     , m_keyIdentifier(key.keyIdentifier())
     , m_location(keyLocationCode(key))
     , m_repeat(key.isAutoRepeat())
-    , m_altGraphKey(false)
-    , m_capsLockKey(key.modifiers().contains(PlatformEvent::Modifier::CapsLockKey))
     , m_isComposing(view && view->frame() && view->frame()->editor().hasComposition())
 #if PLATFORM(COCOA)
 #if USE(APPKIT)
@@ -127,8 +126,8 @@ KeyboardEvent::KeyboardEvent(WTF::HashTableDeletedValueType)
 {
 }
 
-KeyboardEvent::KeyboardEvent(const AtomicString& eventType, const KeyboardEventInit& initializer)
-    : UIEventWithKeyState(eventType, initializer)
+KeyboardEvent::KeyboardEvent(const AtomicString& eventType, const Init& initializer, IsTrusted isTrusted)
+    : UIEventWithKeyState(eventType, initializer, isTrusted)
 #if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
     , m_key(initializer.key)
 #endif
@@ -138,8 +137,6 @@ KeyboardEvent::KeyboardEvent(const AtomicString& eventType, const KeyboardEventI
     , m_keyIdentifier(initializer.keyIdentifier)
     , m_location(initializer.location)
     , m_repeat(initializer.repeat)
-    , m_altGraphKey(false) // FIXME: should be initialized from initializer.modifierAltGraph.
-    , m_capsLockKey(false) // FIXME: should be initialized from initializer.modifierCapsLock.
     , m_isComposing(initializer.isComposing)
 #if PLATFORM(COCOA)
     , m_handledByInputMethod(false)
@@ -182,7 +179,7 @@ bool KeyboardEvent::getModifierState(const String& keyIdentifier) const
     if (keyIdentifier == "AltGraph")
         return altGraphKey();
     if (keyIdentifier == "CapsLock")
-        return m_capsLockKey;
+        return capsLockKey();
     // FIXME: The specification also has Fn, FnLock, Hyper, NumLock, Super, ScrollLock, Symbol, SymbolLock.
     return false;
 }
index 7b8a63e..8a1a754 100644 (file)
@@ -23,6 +23,7 @@
 
 #pragma once
 
+#include "EventModifierInit.h"
 #include "KeypressCommand.h"
 #include "UIEventWithKeyState.h"
 #include <memory>
@@ -33,19 +34,6 @@ namespace WebCore {
 class Node;
 class PlatformKeyboardEvent;
 
-struct KeyboardEventInit : public UIEventWithKeyStateInit {
-#if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
-    String key;
-#endif
-#if ENABLE(KEYBOARD_CODE_ATTRIBUTE)
-    String code;
-#endif
-    String keyIdentifier;
-    unsigned location { 0 };
-    bool repeat { false };
-    bool isComposing { false };
-};
-
 class KeyboardEvent final : public UIEventWithKeyState {
 public:
     enum KeyLocationCode {
@@ -65,9 +53,33 @@ public:
         return adoptRef(*new KeyboardEvent);
     }
 
-    static Ref<KeyboardEvent> createForBindings(const AtomicString& type, const KeyboardEventInit& initializer)
+    struct Init : public EventModifierInit {
+        Init(bool bubbles, bool cancelable, bool composed, RefPtr<DOMWindow>&& view, int detail,
+            bool ctrlKey, bool shiftKey, bool altKey, bool metaKey, bool modifierAltGraph, bool modifierCapsLock,
+            String key, String code, Optional<unsigned> location, bool repeat, bool isComposing, String keyIdentifier,
+            Optional<unsigned> keyLocation)
+                : EventModifierInit(bubbles, cancelable, composed, WTFMove(view), detail, ctrlKey, shiftKey, altKey, metaKey, modifierAltGraph, modifierCapsLock)
+                , key(key)
+                , code(code)
+                , location(location ? *location : keyLocation.valueOr(DOM_KEY_LOCATION_STANDARD))
+                , repeat(repeat)
+                , isComposing(isComposing)
+                , keyIdentifier(keyIdentifier)
+            { }
+
+        String key;
+        String code;
+        unsigned location;
+        bool repeat;
+        bool isComposing;
+
+        // Legacy.
+        String keyIdentifier;
+    };
+
+    static Ref<KeyboardEvent> create(const AtomicString& type, const Init& initializer, IsTrusted isTrusted = IsTrusted::No)
     {
-        return adoptRef(*new KeyboardEvent(type, initializer));
+        return adoptRef(*new KeyboardEvent(type, initializer, isTrusted));
     }
 
     // FIXME: This method should be get ride of in the future.
@@ -95,8 +107,6 @@ public:
     bool repeat() const { return m_repeat; }
 
     WEBCORE_EXPORT bool getModifierState(const String& keyIdentifier) const;
-
-    bool altGraphKey() const { return m_altGraphKey; }
     
     const PlatformKeyboardEvent* keyEvent() const { return m_keyEvent.get(); }
 
@@ -120,7 +130,7 @@ public:
 private:
     WEBCORE_EXPORT KeyboardEvent();
     WEBCORE_EXPORT KeyboardEvent(const PlatformKeyboardEvent&, DOMWindow*);
-    KeyboardEvent(const AtomicString&, const KeyboardEventInit&);
+    KeyboardEvent(const AtomicString&, const Init&, IsTrusted);
     // FIXME: This method should be get rid of in the future.
     // DO NOT USE IT!
     KeyboardEvent(WTF::HashTableDeletedValueType);
@@ -135,8 +145,6 @@ private:
     String m_keyIdentifier;
     unsigned m_location { DOM_KEY_LOCATION_STANDARD };
     bool m_repeat { false };
-    bool m_altGraphKey { false };
-    bool m_capsLockKey { false };
     bool m_isComposing { false };
 
 #if PLATFORM(COCOA)
index 22d8939..b23ec4d 100644 (file)
@@ -19,8 +19,7 @@
  */
 
 [
-    ConstructorConditional=DOM4_EVENTS_CONSTRUCTOR,
-    ConstructorTemplate=Event,
+    Constructor(DOMString type, optional KeyboardEventInit eventInitDict),
 ] interface KeyboardEvent : UIEvent {
 
     const unsigned long DOM_KEY_LOCATION_STANDARD = 0x00;
     const unsigned long DOM_KEY_LOCATION_RIGHT = 0x02;
     const unsigned long DOM_KEY_LOCATION_NUMPAD = 0x03;
 
-    [InitializedByEventConstructor, Conditional=KEYBOARD_KEY_ATTRIBUTE] readonly attribute DOMString key;
-    [InitializedByEventConstructor, Conditional=KEYBOARD_CODE_ATTRIBUTE] readonly attribute DOMString code;
-    [InitializedByEventConstructor] readonly attribute unsigned long location;
+    [Conditional=KEYBOARD_KEY_ATTRIBUTE] readonly attribute DOMString key;
+    [Conditional=KEYBOARD_CODE_ATTRIBUTE] readonly attribute DOMString code;
+    readonly attribute unsigned long location;
 
-    [InitializedByEventConstructor] readonly attribute boolean ctrlKey;
-    [InitializedByEventConstructor] readonly attribute boolean shiftKey;
-    [InitializedByEventConstructor] readonly attribute boolean altKey;
-    [InitializedByEventConstructor] readonly attribute boolean metaKey;
-    [InitializedByEventConstructor] readonly attribute boolean repeat;
+    readonly attribute boolean ctrlKey;
+    readonly attribute boolean shiftKey;
+    readonly attribute boolean altKey;
+    readonly attribute boolean metaKey;
+    readonly attribute boolean repeat;
 
-    [InitializedByEventConstructor] readonly attribute boolean isComposing;
+    readonly attribute boolean isComposing;
 
     boolean getModifierState(DOMString keyArg);
 
     // Everything below is legacy.
-    [InitializedByEventConstructor] readonly attribute DOMString keyIdentifier;
-    [InitializedByEventConstructor, ImplementedAs=location] readonly attribute unsigned long keyLocation;
+    readonly attribute DOMString keyIdentifier;
+    [ImplementedAs=location] readonly attribute unsigned long keyLocation;
     readonly attribute boolean altGraphKey;
 
     // FIXME: this does not match the version in the DOM spec.
         optional DOMWindow? view = null, optional DOMString keyIdentifier = "undefined", optional unsigned long location = 0,
         optional boolean ctrlKey = false, optional boolean altKey = false, optional boolean shiftKey = false, optional boolean metaKey = false, optional boolean altGraphKey = false);
 };
+
+dictionary KeyboardEventInit : EventModifierInit {
+    DOMString key = "";
+    DOMString code = "";
+    unsigned long location;
+    boolean repeat = false;
+    boolean isComposing = false;
+
+    // This members are not in the specification but are needed to initialize the corresponding legacy
+    // attributes we still support on KeyboardEvent for backward compatibility.
+    DOMString keyIdentifier = "";
+    unsigned long keyLocation;
+};
index f2d5a2a..35594e3 100644 (file)
@@ -61,7 +61,7 @@ MouseRelatedEvent::MouseRelatedEvent(const AtomicString& eventType, bool canBubb
                                      const IntPoint& movementDelta,
 #endif
                                      bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, bool isSimulated)
-    : UIEventWithKeyState(eventType, canBubble, cancelable, timestamp, DOMWindow, detail, ctrlKey, altKey, shiftKey, metaKey)
+    : UIEventWithKeyState(eventType, canBubble, cancelable, timestamp, DOMWindow, detail, ctrlKey, altKey, shiftKey, metaKey, false, false)
     , m_screenLocation(screenLocation)
 #if ENABLE(POINTER_LOCK)
     , m_movementDelta(movementDelta)
index f9e866f..6b05ce2 100644 (file)
@@ -28,7 +28,7 @@
 
 namespace WebCore {
 
-struct MouseRelatedEventInit : public UIEventWithKeyStateInit {
+struct MouseRelatedEventInit : public EventModifierInit {
     int screenX { 0 };
     int screenY { 0 };
 };
index ebaf05a..1c170f7 100644 (file)
@@ -46,8 +46,8 @@ UIEvent::UIEvent(const AtomicString& eventType, bool canBubbleArg, bool cancelab
 {
 }
 
-UIEvent::UIEvent(const AtomicString& eventType, const UIEventInit& initializer)
-    : Event(eventType, initializer)
+UIEvent::UIEvent(const AtomicString& eventType, const UIEventInit& initializer, IsTrusted isTrusted)
+    : Event(eventType, initializer, isTrusted)
     , m_view(initializer.view.get())
     , m_detail(initializer.detail)
 {
index e793b37..b6342c3 100644 (file)
 
 #include "DOMWindow.h"
 #include "Event.h"
+#include "UIEventInit.h"
 
 namespace WebCore {
 
 // FIXME: Remove this when no one is depending on it anymore.
 typedef DOMWindow AbstractView;
 
-struct UIEventInit : public EventInit {
-    RefPtr<DOMWindow> view;
-    int detail { 0 };
-};
-
 class UIEvent : public Event {
 public:
     static Ref<UIEvent> create(const AtomicString& type, bool canBubble, bool cancelable, DOMWindow* view, int detail)
@@ -74,7 +70,7 @@ protected:
     UIEvent();
     UIEvent(const AtomicString& type, bool canBubble, bool cancelable, DOMWindow*, int detail);
     UIEvent(const AtomicString& type, bool canBubble, bool cancelable, double timestamp, DOMWindow*, int detail);
-    UIEvent(const AtomicString&, const UIEventInit&);
+    UIEvent(const AtomicString&, const UIEventInit&, IsTrusted = IsTrusted::No);
 
 private:
     bool isUIEvent() const final;
diff --git a/Source/WebCore/dom/UIEventInit.h b/Source/WebCore/dom/UIEventInit.h
new file mode 100644 (file)
index 0000000..0a84bbc
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "DOMWindow.h"
+#include "EventInit.h"
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+struct UIEventInit : public EventInit {
+    UIEventInit() = default;
+    UIEventInit(bool bubbles, bool cancelable, bool composed, RefPtr<DOMWindow>&& view, int detail)
+        : EventInit(bubbles, cancelable, composed)
+        , view(WTFMove(view))
+        , detail(detail)
+    { }
+
+    RefPtr<DOMWindow> view;
+    int detail { 0 };
+};
+
+}
diff --git a/Source/WebCore/dom/UIEventInit.idl b/Source/WebCore/dom/UIEventInit.idl
new file mode 100644 (file)
index 0000000..0d7eb8e
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+dictionary UIEventInit : EventInit {
+    DOMWindow? view = null;
+    long detail = 0;
+};
index 7db03a2..19edf59 100644 (file)
 #ifndef UIEventWithKeyState_h
 #define UIEventWithKeyState_h
 
+#include "EventModifierInit.h"
 #include "UIEvent.h"
 
 namespace WebCore {
 
-struct UIEventWithKeyStateInit : public UIEventInit {
-    bool ctrlKey { false };
-    bool altKey { false };
-    bool shiftKey { false };
-    bool metaKey { false };
-};
-
 class UIEventWithKeyState : public UIEvent {
 public:
     bool ctrlKey() const { return m_ctrlKey; }
     bool shiftKey() const { return m_shiftKey; }
     bool altKey() const { return m_altKey; }
     bool metaKey() const { return m_metaKey; }
+    bool altGraphKey() const { return m_altGraphKey; }
+    bool capsLockKey() const { return m_capsLockKey; }
 
 protected:
-    UIEventWithKeyState()
-        : m_ctrlKey(false)
-        , m_altKey(false)
-        , m_shiftKey(false)
-        , m_metaKey(false)
-    {
-    }
+    UIEventWithKeyState() = default;
 
     UIEventWithKeyState(const AtomicString& type, bool canBubble, bool cancelable, DOMWindow* view, int detail, bool ctrlKey, bool altKey, bool shiftKey, bool metaKey)
         : UIEvent(type, canBubble, cancelable, view, detail)
@@ -60,29 +50,36 @@ protected:
     {
     }
 
-    UIEventWithKeyState(const AtomicString& type, bool canBubble, bool cancelable, double timestamp, DOMWindow* view, int detail, bool ctrlKey, bool altKey, bool shiftKey, bool metaKey)
-        : UIEvent(type, canBubble, cancelable, timestamp, view, detail)
-        , m_ctrlKey(ctrlKey)
-        , m_altKey(altKey)
-        , m_shiftKey(shiftKey)
-        , m_metaKey(metaKey)
+    UIEventWithKeyState(const AtomicString& type, bool canBubble, bool cancelable, double timestamp, DOMWindow* view,
+        int detail, bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, bool altGraphKey, bool capsLockKey)
+            : UIEvent(type, canBubble, cancelable, timestamp, view, detail)
+            , m_ctrlKey(ctrlKey)
+            , m_altKey(altKey)
+            , m_shiftKey(shiftKey)
+            , m_metaKey(metaKey)
+            , m_altGraphKey(altGraphKey)
+            , m_capsLockKey(capsLockKey)
     {
     }
 
-    UIEventWithKeyState(const AtomicString& type, const UIEventWithKeyStateInit& initializer)
-        : UIEvent(type, initializer)
+    UIEventWithKeyState(const AtomicString& type, const EventModifierInit& initializer, IsTrusted isTrusted = IsTrusted::No)
+        : UIEvent(type, initializer, isTrusted)
         , m_ctrlKey(initializer.ctrlKey)
         , m_altKey(initializer.altKey)
         , m_shiftKey(initializer.shiftKey)
         , m_metaKey(initializer.metaKey)
+        , m_altGraphKey(initializer.modifierAltGraph)
+        , m_capsLockKey(initializer.modifierCapsLock)
     {
     }
 
     // Expose these so init functions can set them.
-    bool m_ctrlKey : 1;
-    bool m_altKey : 1;
-    bool m_shiftKey : 1;
-    bool m_metaKey : 1;
+    bool m_ctrlKey { false };
+    bool m_altKey { false };
+    bool m_shiftKey { false };
+    bool m_metaKey { false };
+    bool m_altGraphKey { false };
+    bool m_capsLockKey { false };
 };
 
 WEBCORE_EXPORT UIEventWithKeyState* findEventWithKeyState(Event*);