Title: [256716] trunk
Revision
256716
Author
[email protected]
Date
2020-02-16 17:41:27 -0800 (Sun, 16 Feb 2020)

Log Message

Implement EventTarget constructor
https://bugs.webkit.org/show_bug.cgi?id=174313

Reviewed by Darin Adler.

LayoutTests/imported/w3c:

* web-platform-tests/WebIDL/ecmascript-binding/constructors-expected.txt:
* web-platform-tests/dom/events/Event-subclasses-constructors-expected.txt:
* web-platform-tests/dom/events/EventTarget-constructible.any-expected.txt:
* web-platform-tests/dom/events/EventTarget-constructible.any.worker-expected.txt:
* web-platform-tests/dom/events/event-global-extra.window-expected.txt:
* web-platform-tests/dom/idlharness.any.worker-expected.txt:
* web-platform-tests/dom/idlharness.window-expected.txt:

Source/WebCore:

Currently, EventTarget can't be directly constructed or be subclassed in _javascript_.
The spec for EventTarget was updated (https://github.com/whatwg/dom/pull/467) to allow
constructing and subclassing EventTarget. This feature was shipped in Chrome 64 and Firefox 59.

This patch introduces EventTargetConcrete class, a user-constructable version of EventTarget,
exposed as "EventTarget" to _javascript_. We don't use EventTarget directly because it is an abstract
class and making it non-abstract is unfavorable due to size increase of EventTarget and all of its
subclasses with code that is mostly unnecessary for them, resulting in a performance decrease.

To prevent definition of specific to EventTargetConcrete `toJS` and `toJSNewlyCreated` functions,
we don't define EventTargetConcrete interface type, but rather tweak make_event_factory.pl to
default to base interface (like it does for Event).

To allow subclassing of all DOM constructors, non-custom ones replace structures of newly created
wrapper objects with ones returned by InternalFunction::createSubclassStructure. Per WebIDL spec [1],
`setSubclassStructureIfNeeded` helper uses realm of `newTarget` for default prototypes.

This approach was chosen because a) detecting [[Construct]] with callFrame->newTarget() is
unreliable outside constructor, and b) passing `newTarget` down to `createWrapper` via
`toJSNewlyCreated` is quite awkward and would result in massive code change.

[1] https://heycam.github.io/webidl/#internally-create-a-new-object-implementing-the-interface
(step 3.3.2)

Tests: fast/dom/dom-constructors.html
       imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/constructors.html
       imported/w3c/web-platform-tests/dom/events/Event-subclasses-constructors.html
       imported/w3c/web-platform-tests/dom/events/EventTarget-constructible.any.html
       imported/w3c/web-platform-tests/dom/idlharness.window.html

* Headers.cmake:
* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSDOMWrapperCache.h:
(WebCore::setSubclassStructureIfNeeded):
* bindings/js/JSEventTargetCustom.cpp:
(WebCore::toJSNewlyCreated):
* bindings/scripts/CodeGeneratorJS.pm:
(GenerateConstructorDefinition):
* bindings/scripts/InFilesCompiler.pm:
(generateInterfacesHeader):
* bindings/scripts/test/JS/*: Adjust bindings expectations.
* dom/EventTarget.cpp:
(WebCore::EventTarget::create):
* dom/EventTarget.h:
* dom/EventTarget.idl:
* dom/EventTargetConcrete.cpp: Added.
* dom/EventTargetConcrete.h: Added.
* dom/make_event_factory.pl:
(generateImplementation):

LayoutTests:

* fast/dom/dom-constructors-expected.txt:
* fast/dom/dom-constructors.html:
* platform/ios/imported/w3c/web-platform-tests/dom/events/Event-subclasses-constructors-expected.txt: Removed.

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (256715 => 256716)


--- trunk/LayoutTests/ChangeLog	2020-02-17 01:35:18 UTC (rev 256715)
+++ trunk/LayoutTests/ChangeLog	2020-02-17 01:41:27 UTC (rev 256716)
@@ -1,3 +1,14 @@
+2020-02-16  Alexey Shvayka  <[email protected]>
+
+        Implement EventTarget constructor
+        https://bugs.webkit.org/show_bug.cgi?id=174313
+
+        Reviewed by Darin Adler.
+
+        * fast/dom/dom-constructors-expected.txt:
+        * fast/dom/dom-constructors.html:
+        * platform/ios/imported/w3c/web-platform-tests/dom/events/Event-subclasses-constructors-expected.txt: Removed.
+
 2020-02-16  Wenson Hsieh  <[email protected]>
 
         Add a layout test for <rdar://problem/59090510>

Modified: trunk/LayoutTests/fast/dom/dom-constructors-expected.txt (256715 => 256716)


--- trunk/LayoutTests/fast/dom/dom-constructors-expected.txt	2020-02-17 01:35:18 UTC (rev 256715)
+++ trunk/LayoutTests/fast/dom/dom-constructors-expected.txt	2020-02-17 01:41:27 UTC (rev 256716)
@@ -8,7 +8,6 @@
 PASS TryAllocate('CDATASection') is 'exception'
 PASS TryAllocate('DocumentType') is 'exception'
 PASS TryAllocate('Element') is 'exception'
-PASS TryAllocate('EventTarget') is 'exception'
 PASS TryAllocate('HTMLDocument') is 'exception'
 PASS TryAllocate('Node') is 'exception'
 PASS TryAllocate('ProcessingInstruction') is 'exception'
@@ -131,6 +130,9 @@
 PASS TryAllocate('DocumentFragment') is '[object DocumentFragment]'
 PASS TryAllocate('DocumentFragment') is '[object DocumentFragment]'
 PASS TryAllocate('DocumentFragment') is '[object DocumentFragment]'
+PASS TryAllocate('EventTarget') is '[object EventTarget]'
+PASS TryAllocate('EventTarget') is '[object EventTarget]'
+PASS TryAllocate('EventTarget') is '[object EventTarget]'
 PASS TryAllocate('Range') is '[object Range]'
 PASS TryAllocate('Range') is '[object Range]'
 PASS TryAllocate('Range') is '[object Range]'

Modified: trunk/LayoutTests/fast/dom/dom-constructors.html (256715 => 256716)


--- trunk/LayoutTests/fast/dom/dom-constructors.html	2020-02-17 01:35:18 UTC (rev 256715)
+++ trunk/LayoutTests/fast/dom/dom-constructors.html	2020-02-17 01:41:27 UTC (rev 256716)
@@ -18,7 +18,6 @@
     'CDATASection',
     'DocumentType',
     'Element',
-    'EventTarget',
     'HTMLDocument',
     'Node',
     'ProcessingInstruction',
@@ -132,6 +131,7 @@
     'DOMParser',
     'Document',
     'DocumentFragment',
+    'EventTarget',
     'Range',
     'Text',
     'XMLHttpRequest',

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (256715 => 256716)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2020-02-17 01:35:18 UTC (rev 256715)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2020-02-17 01:41:27 UTC (rev 256716)
@@ -1,3 +1,18 @@
+2020-02-16  Alexey Shvayka  <[email protected]>
+
+        Implement EventTarget constructor
+        https://bugs.webkit.org/show_bug.cgi?id=174313
+
+        Reviewed by Darin Adler.
+
+        * web-platform-tests/WebIDL/ecmascript-binding/constructors-expected.txt:
+        * web-platform-tests/dom/events/Event-subclasses-constructors-expected.txt:
+        * web-platform-tests/dom/events/EventTarget-constructible.any-expected.txt:
+        * web-platform-tests/dom/events/EventTarget-constructible.any.worker-expected.txt:
+        * web-platform-tests/dom/events/event-global-extra.window-expected.txt:
+        * web-platform-tests/dom/idlharness.any.worker-expected.txt:
+        * web-platform-tests/dom/idlharness.window-expected.txt:
+
 2020-02-14  Rossana Monteriso  <[email protected]>
 
         [css-grid] Move grid-gutters-and-alignment test to WPT folder

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/constructors-expected.txt (256715 => 256716)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/constructors-expected.txt	2020-02-17 01:35:18 UTC (rev 256715)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/constructors-expected.txt	2020-02-17 01:41:27 UTC (rev 256716)
@@ -2,14 +2,14 @@
 PASS Realm for constructed objects 
 PASS Normal constructor in parent window 
 PASS Normal constructor in child window 
-FAIL Constructor in child window with normal NewTarget from parent window assert_equals: expected object "[object DOMParserPrototype]" but got object "[object DOMParserPrototype]"
-FAIL Constructor in parent window with normal NewTarget from child window assert_equals: expected object "[object DOMParserPrototype]" but got object "[object DOMParserPrototype]"
-FAIL Subclass constructor in parent window assert_equals: expected object "[object Object]" but got object "[object DOMParserPrototype]"
-FAIL Subclass constructor in child window assert_equals: expected object "[object Object]" but got object "[object DOMParserPrototype]"
-FAIL Subclass constructor in parent window with parent class in child window assert_equals: expected object "[object Object]" but got object "[object DOMParserPrototype]"
-FAIL Subclass constructor in child window with parent class in parent window assert_equals: expected object "[object Object]" but got object "[object DOMParserPrototype]"
-FAIL Constructor in child window with bad NewTarget from parent window assert_equals: expected object "[object DOMParserPrototype]" but got object "[object DOMParserPrototype]"
-FAIL Constructor in parent window with bad NewTarget from child window assert_equals: expected object "[object DOMParserPrototype]" but got object "[object DOMParserPrototype]"
+PASS Constructor in child window with normal NewTarget from parent window 
+PASS Constructor in parent window with normal NewTarget from child window 
+PASS Subclass constructor in parent window 
+PASS Subclass constructor in child window 
+PASS Subclass constructor in parent window with parent class in child window 
+PASS Subclass constructor in child window with parent class in parent window 
+PASS Constructor in child window with bad NewTarget from parent window 
+PASS Constructor in parent window with bad NewTarget from child window 
 FAIL Constructor in parent window with bad NewTarget from parent window that's a bound child window function assert_equals: expected object "[object DOMParserPrototype]" but got object "[object DOMParserPrototype]"
 FAIL Constructor in child window with bad NewTarget from child window that's a bound parent window function assert_equals: expected object "[object DOMParserPrototype]" but got object "[object DOMParserPrototype]"
 FAIL Constructor in parent window with bad NewTarget from parent window that's a proxy for a child window function assert_equals: expected object "[object DOMParserPrototype]" but got object "[object DOMParserPrototype]"

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


--- trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-subclasses-constructors-expected.txt	2020-02-17 01:35:18 UTC (rev 256715)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-subclasses-constructors-expected.txt	2020-02-17 01:41:27 UTC (rev 256716)
@@ -41,11 +41,11 @@
 PASS CompositionEvent constructor (empty argument) 
 PASS CompositionEvent constructor (argument with default values) 
 PASS CompositionEvent constructor (argument with non-default values) 
-FAIL SubclassedEvent constructor (no argument) assert_true: expected true got false
-FAIL SubclassedEvent constructor (undefined argument) assert_true: expected true got false
-FAIL SubclassedEvent constructor (null argument) assert_true: expected true got false
-FAIL SubclassedEvent constructor (empty argument) assert_true: expected true got false
-FAIL SubclassedEvent constructor (argument with default values) assert_true: expected true got false
-FAIL SubclassedEvent constructor (argument with non-default values) assert_true: expected true got false
+PASS SubclassedEvent constructor (no argument) 
+PASS SubclassedEvent constructor (undefined argument) 
+PASS SubclassedEvent constructor (null argument) 
+PASS SubclassedEvent constructor (empty argument) 
+PASS SubclassedEvent constructor (argument with default values) 
+PASS SubclassedEvent constructor (argument with non-default values) 
 PASS UIEvent constructor (view argument with wrong type) 
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/EventTarget-constructible.any-expected.txt (256715 => 256716)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/EventTarget-constructible.any-expected.txt	2020-02-17 01:35:18 UTC (rev 256715)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/EventTarget-constructible.any-expected.txt	2020-02-17 01:41:27 UTC (rev 256716)
@@ -1,4 +1,4 @@
 
-FAIL A constructed EventTarget can be used as expected function is not a constructor (evaluating 'new EventTarget()')
-FAIL EventTarget can be subclassed function is not a constructor (evaluating 'super(...args)')
+PASS A constructed EventTarget can be used as expected 
+PASS EventTarget can be subclassed 
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/EventTarget-constructible.any.worker-expected.txt (256715 => 256716)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/EventTarget-constructible.any.worker-expected.txt	2020-02-17 01:35:18 UTC (rev 256715)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/EventTarget-constructible.any.worker-expected.txt	2020-02-17 01:41:27 UTC (rev 256716)
@@ -1,4 +1,4 @@
 
-FAIL A constructed EventTarget can be used as expected function is not a constructor (evaluating 'new EventTarget()')
-FAIL EventTarget can be subclassed function is not a constructor (evaluating 'super(...args)')
+PASS A constructed EventTarget can be used as expected 
+PASS EventTarget can be subclassed 
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/event-global-extra.window-expected.txt (256715 => 256716)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/event-global-extra.window-expected.txt	2020-02-17 01:35:18 UTC (rev 256715)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/event-global-extra.window-expected.txt	2020-02-17 01:41:27 UTC (rev 256716)
@@ -1,5 +1,5 @@
 
-FAIL window.event for constructors from another global: EventTarget function is not a constructor (evaluating 'new otherWindow[constructorName]()')
+FAIL window.event for constructors from another global: EventTarget assert_equals: expected (undefined) undefined but got (object) object "[object Event]"
 FAIL window.event for constructors from another global: XMLHttpRequest assert_equals: expected (undefined) undefined but got (object) object "[object Event]"
 PASS window.event and element from another document 
 FAIL window.event and moving an element post-dispatch assert_equals: expected (object) object "[object Event]" but got (undefined) undefined

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/dom/idlharness.any.worker-expected.txt (256715 => 256716)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/dom/idlharness.any.worker-expected.txt	2020-02-17 01:35:18 UTC (rev 256715)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/dom/idlharness.any.worker-expected.txt	2020-02-17 01:41:27 UTC (rev 256716)
@@ -133,14 +133,14 @@
 PASS EventTarget interface: operation addEventListener(DOMString, EventListener, [object Object],[object Object]) 
 PASS EventTarget interface: operation removeEventListener(DOMString, EventListener, [object Object],[object Object]) 
 PASS EventTarget interface: operation dispatchEvent(Event) 
-FAIL EventTarget must be primary interface of new EventTarget() assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new EventTarget()')"
-FAIL Stringification of new EventTarget() assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new EventTarget()')"
-FAIL EventTarget interface: new EventTarget() must inherit property "addEventListener(DOMString, EventListener, [object Object],[object Object])" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new EventTarget()')"
-FAIL EventTarget interface: calling addEventListener(DOMString, EventListener, [object Object],[object Object]) on new EventTarget() with too few arguments must throw TypeError assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new EventTarget()')"
-FAIL EventTarget interface: new EventTarget() must inherit property "removeEventListener(DOMString, EventListener, [object Object],[object Object])" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new EventTarget()')"
-FAIL EventTarget interface: calling removeEventListener(DOMString, EventListener, [object Object],[object Object]) on new EventTarget() with too few arguments must throw TypeError assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new EventTarget()')"
-FAIL EventTarget interface: new EventTarget() must inherit property "dispatchEvent(Event)" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new EventTarget()')"
-FAIL EventTarget interface: calling dispatchEvent(Event) on new EventTarget() with too few arguments must throw TypeError assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new EventTarget()')"
+PASS EventTarget must be primary interface of new EventTarget() 
+PASS Stringification of new EventTarget() 
+PASS EventTarget interface: new EventTarget() must inherit property "addEventListener(DOMString, EventListener, [object Object],[object Object])" with the proper type 
+PASS EventTarget interface: calling addEventListener(DOMString, EventListener, [object Object],[object Object]) on new EventTarget() with too few arguments must throw TypeError 
+PASS EventTarget interface: new EventTarget() must inherit property "removeEventListener(DOMString, EventListener, [object Object],[object Object])" with the proper type 
+PASS EventTarget interface: calling removeEventListener(DOMString, EventListener, [object Object],[object Object]) on new EventTarget() with too few arguments must throw TypeError 
+PASS EventTarget interface: new EventTarget() must inherit property "dispatchEvent(Event)" with the proper type 
+PASS EventTarget interface: calling dispatchEvent(Event) on new EventTarget() with too few arguments must throw TypeError 
 PASS EventListener interface: existence and properties of interface object 
 PASS AbortController interface: existence and properties of interface object 
 PASS AbortController interface object length 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/dom/idlharness.window-expected.txt (256715 => 256716)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/dom/idlharness.window-expected.txt	2020-02-17 01:35:18 UTC (rev 256715)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/dom/idlharness.window-expected.txt	2020-02-17 01:41:27 UTC (rev 256716)
@@ -158,14 +158,14 @@
 PASS EventTarget interface: operation addEventListener(DOMString, EventListener, [object Object],[object Object]) 
 PASS EventTarget interface: operation removeEventListener(DOMString, EventListener, [object Object],[object Object]) 
 PASS EventTarget interface: operation dispatchEvent(Event) 
-FAIL EventTarget must be primary interface of new EventTarget() assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new EventTarget()')"
-FAIL Stringification of new EventTarget() assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new EventTarget()')"
-FAIL EventTarget interface: new EventTarget() must inherit property "addEventListener(DOMString, EventListener, [object Object],[object Object])" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new EventTarget()')"
-FAIL EventTarget interface: calling addEventListener(DOMString, EventListener, [object Object],[object Object]) on new EventTarget() with too few arguments must throw TypeError assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new EventTarget()')"
-FAIL EventTarget interface: new EventTarget() must inherit property "removeEventListener(DOMString, EventListener, [object Object],[object Object])" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new EventTarget()')"
-FAIL EventTarget interface: calling removeEventListener(DOMString, EventListener, [object Object],[object Object]) on new EventTarget() with too few arguments must throw TypeError assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new EventTarget()')"
-FAIL EventTarget interface: new EventTarget() must inherit property "dispatchEvent(Event)" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new EventTarget()')"
-FAIL EventTarget interface: calling dispatchEvent(Event) on new EventTarget() with too few arguments must throw TypeError assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new EventTarget()')"
+PASS EventTarget must be primary interface of new EventTarget() 
+PASS Stringification of new EventTarget() 
+PASS EventTarget interface: new EventTarget() must inherit property "addEventListener(DOMString, EventListener, [object Object],[object Object])" with the proper type 
+PASS EventTarget interface: calling addEventListener(DOMString, EventListener, [object Object],[object Object]) on new EventTarget() with too few arguments must throw TypeError 
+PASS EventTarget interface: new EventTarget() must inherit property "removeEventListener(DOMString, EventListener, [object Object],[object Object])" with the proper type 
+PASS EventTarget interface: calling removeEventListener(DOMString, EventListener, [object Object],[object Object]) on new EventTarget() with too few arguments must throw TypeError 
+PASS EventTarget interface: new EventTarget() must inherit property "dispatchEvent(Event)" with the proper type 
+PASS EventTarget interface: calling dispatchEvent(Event) on new EventTarget() with too few arguments must throw TypeError 
 PASS EventListener interface: existence and properties of interface object 
 PASS EventListener interface: existence and properties of interface prototype object 
 PASS EventListener interface: existence and properties of interface prototype object's "constructor" property 

Deleted: trunk/LayoutTests/platform/ios/imported/w3c/web-platform-tests/dom/events/Event-subclasses-constructors-expected.txt (256715 => 256716)


--- trunk/LayoutTests/platform/ios/imported/w3c/web-platform-tests/dom/events/Event-subclasses-constructors-expected.txt	2020-02-17 01:35:18 UTC (rev 256715)
+++ trunk/LayoutTests/platform/ios/imported/w3c/web-platform-tests/dom/events/Event-subclasses-constructors-expected.txt	2020-02-17 01:41:27 UTC (rev 256716)
@@ -1,51 +0,0 @@
-
-PASS Event constructor (no argument) 
-PASS Event constructor (undefined argument) 
-PASS Event constructor (null argument) 
-PASS Event constructor (empty argument) 
-PASS Event constructor (argument with default values) 
-PASS Event constructor (argument with non-default values) 
-PASS UIEvent constructor (no argument) 
-PASS UIEvent constructor (undefined argument) 
-PASS UIEvent constructor (null argument) 
-PASS UIEvent constructor (empty argument) 
-PASS UIEvent constructor (argument with default values) 
-PASS UIEvent constructor (argument with non-default values) 
-PASS FocusEvent constructor (no argument) 
-PASS FocusEvent constructor (undefined argument) 
-PASS FocusEvent constructor (null argument) 
-PASS FocusEvent constructor (empty argument) 
-PASS FocusEvent constructor (argument with default values) 
-PASS FocusEvent constructor (argument with non-default values) 
-PASS MouseEvent constructor (no argument) 
-PASS MouseEvent constructor (undefined argument) 
-PASS MouseEvent constructor (null argument) 
-PASS MouseEvent constructor (empty argument) 
-PASS MouseEvent constructor (argument with default values) 
-PASS MouseEvent constructor (argument with non-default values) 
-PASS WheelEvent constructor (no argument) 
-PASS WheelEvent constructor (undefined argument) 
-PASS WheelEvent constructor (null argument) 
-PASS WheelEvent constructor (empty argument) 
-PASS WheelEvent constructor (argument with default values) 
-PASS WheelEvent constructor (argument with non-default values) 
-PASS KeyboardEvent constructor (no argument) 
-PASS KeyboardEvent constructor (undefined argument) 
-PASS KeyboardEvent constructor (null argument) 
-PASS KeyboardEvent constructor (empty argument) 
-PASS KeyboardEvent constructor (argument with default values) 
-PASS KeyboardEvent constructor (argument with non-default values) 
-PASS CompositionEvent constructor (no argument) 
-PASS CompositionEvent constructor (undefined argument) 
-PASS CompositionEvent constructor (null argument) 
-PASS CompositionEvent constructor (empty argument) 
-PASS CompositionEvent constructor (argument with default values) 
-PASS CompositionEvent constructor (argument with non-default values) 
-FAIL SubclassedEvent constructor (no argument) assert_true: expected true got false
-FAIL SubclassedEvent constructor (undefined argument) assert_true: expected true got false
-FAIL SubclassedEvent constructor (null argument) assert_true: expected true got false
-FAIL SubclassedEvent constructor (empty argument) assert_true: expected true got false
-FAIL SubclassedEvent constructor (argument with default values) assert_true: expected true got false
-FAIL SubclassedEvent constructor (argument with non-default values) assert_true: expected true got false
-PASS UIEvent constructor (view argument with wrong type) 
-

Modified: trunk/Source/WebCore/ChangeLog (256715 => 256716)


--- trunk/Source/WebCore/ChangeLog	2020-02-17 01:35:18 UTC (rev 256715)
+++ trunk/Source/WebCore/ChangeLog	2020-02-17 01:41:27 UTC (rev 256716)
@@ -1,3 +1,61 @@
+2020-02-16  Alexey Shvayka  <[email protected]>
+
+        Implement EventTarget constructor
+        https://bugs.webkit.org/show_bug.cgi?id=174313
+
+        Reviewed by Darin Adler.
+
+        Currently, EventTarget can't be directly constructed or be subclassed in _javascript_.
+        The spec for EventTarget was updated (https://github.com/whatwg/dom/pull/467) to allow
+        constructing and subclassing EventTarget. This feature was shipped in Chrome 64 and Firefox 59.
+
+        This patch introduces EventTargetConcrete class, a user-constructable version of EventTarget,
+        exposed as "EventTarget" to _javascript_. We don't use EventTarget directly because it is an abstract
+        class and making it non-abstract is unfavorable due to size increase of EventTarget and all of its
+        subclasses with code that is mostly unnecessary for them, resulting in a performance decrease.
+
+        To prevent definition of specific to EventTargetConcrete `toJS` and `toJSNewlyCreated` functions,
+        we don't define EventTargetConcrete interface type, but rather tweak make_event_factory.pl to
+        default to base interface (like it does for Event).
+
+        To allow subclassing of all DOM constructors, non-custom ones replace structures of newly created
+        wrapper objects with ones returned by InternalFunction::createSubclassStructure. Per WebIDL spec [1],
+        `setSubclassStructureIfNeeded` helper uses realm of `newTarget` for default prototypes.
+
+        This approach was chosen because a) detecting [[Construct]] with callFrame->newTarget() is
+        unreliable outside constructor, and b) passing `newTarget` down to `createWrapper` via
+        `toJSNewlyCreated` is quite awkward and would result in massive code change.
+
+        [1] https://heycam.github.io/webidl/#internally-create-a-new-object-implementing-the-interface
+        (step 3.3.2)
+
+        Tests: fast/dom/dom-constructors.html
+               imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/constructors.html
+               imported/w3c/web-platform-tests/dom/events/Event-subclasses-constructors.html
+               imported/w3c/web-platform-tests/dom/events/EventTarget-constructible.any.html
+               imported/w3c/web-platform-tests/dom/idlharness.window.html
+
+        * Headers.cmake:
+        * Sources.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/js/JSDOMWrapperCache.h:
+        (WebCore::setSubclassStructureIfNeeded):
+        * bindings/js/JSEventTargetCustom.cpp:
+        (WebCore::toJSNewlyCreated):
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateConstructorDefinition):
+        * bindings/scripts/InFilesCompiler.pm:
+        (generateInterfacesHeader):
+        * bindings/scripts/test/JS/*: Adjust bindings expectations.
+        * dom/EventTarget.cpp:
+        (WebCore::EventTarget::create):
+        * dom/EventTarget.h:
+        * dom/EventTarget.idl:
+        * dom/EventTargetConcrete.cpp: Added.
+        * dom/EventTargetConcrete.h: Added.
+        * dom/make_event_factory.pl:
+        (generateImplementation):
+
 2020-02-16  Brady Eidson  <[email protected]>
 
         Expose "allowsContentJavaScript" on WKWebpagePreferences

Modified: trunk/Source/WebCore/Headers.cmake (256715 => 256716)


--- trunk/Source/WebCore/Headers.cmake	2020-02-17 01:35:18 UTC (rev 256715)
+++ trunk/Source/WebCore/Headers.cmake	2020-02-17 01:41:27 UTC (rev 256716)
@@ -403,6 +403,7 @@
     dom/EventNames.h
     dom/EventQueue.h
     dom/EventTarget.h
+    dom/EventTargetConcrete.h
     dom/Exception.h
     dom/ExceptionCode.h
     dom/ExceptionData.h

Modified: trunk/Source/WebCore/Sources.txt (256715 => 256716)


--- trunk/Source/WebCore/Sources.txt	2020-02-17 01:35:18 UTC (rev 256715)
+++ trunk/Source/WebCore/Sources.txt	2020-02-17 01:41:27 UTC (rev 256716)
@@ -882,6 +882,7 @@
 dom/EventNames.cpp
 dom/EventPath.cpp
 dom/EventTarget.cpp
+dom/EventTargetConcrete.cpp
 dom/ExceptionData.cpp
 dom/ExtensionStyleSheets.cpp
 dom/FocusEvent.cpp

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (256715 => 256716)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2020-02-17 01:35:18 UTC (rev 256715)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2020-02-17 01:41:27 UTC (rev 256716)
@@ -2518,6 +2518,7 @@
 		849F77760EFEC6200090849D /* StrokeStyleApplier.h in Headers */ = {isa = PBXBuildFile; fileRef = 849F77750EFEC6200090849D /* StrokeStyleApplier.h */; };
 		84A81F3E0FC7DFF000955300 /* SourceAlpha.h in Headers */ = {isa = PBXBuildFile; fileRef = 84A81F3C0FC7DFF000955300 /* SourceAlpha.h */; };
 		84A81F420FC7E02700955300 /* SourceGraphic.h in Headers */ = {isa = PBXBuildFile; fileRef = 84A81F400FC7E02700955300 /* SourceGraphic.h */; };
+		84B349A222F86E7500D47BCF /* EventTargetConcrete.h in Headers */ = {isa = PBXBuildFile; fileRef = 84B349A022F86E7400D47BCF /* EventTargetConcrete.h */; };
 		84B6B978120F13E500B8EFAF /* SVGPathSegListSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 84B6B976120F13E500B8EFAF /* SVGPathSegListSource.h */; };
 		84C5B2FB1216DC810088B53A /* SVGPathTraversalStateBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = 84C5B2F91216DC810088B53A /* SVGPathTraversalStateBuilder.h */; };
 		84C6784D1214814700A92902 /* SVGPathBlender.h in Headers */ = {isa = PBXBuildFile; fileRef = 84C6784B1214814700A92902 /* SVGPathBlender.h */; };
@@ -10396,6 +10397,8 @@
 		84A81F3F0FC7E02700955300 /* SourceGraphic.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SourceGraphic.cpp; sourceTree = "<group>"; };
 		84A81F400FC7E02700955300 /* SourceGraphic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SourceGraphic.h; sourceTree = "<group>"; };
 		84B2B24F056BF15F00D2B771 /* SSLKeyGeneratorMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SSLKeyGeneratorMac.mm; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
+		84B349A022F86E7400D47BCF /* EventTargetConcrete.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventTargetConcrete.h; sourceTree = "<group>"; };
+		84B349A322F86E8200D47BCF /* EventTargetConcrete.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EventTargetConcrete.cpp; sourceTree = "<group>"; };
 		84B62684133138F90095A489 /* FontPlatformData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontPlatformData.cpp; sourceTree = "<group>"; };
 		84B6B975120F13E500B8EFAF /* SVGPathSegListSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGPathSegListSource.cpp; sourceTree = "<group>"; };
 		84B6B976120F13E500B8EFAF /* SVGPathSegListSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGPathSegListSource.h; sourceTree = "<group>"; };
@@ -28132,6 +28135,8 @@
 				E12EDBE90B308E0B002704B6 /* EventTarget.cpp */,
 				E12EDB7A0B308A78002704B6 /* EventTarget.h */,
 				85AFA7420AAF298400E84305 /* EventTarget.idl */,
+				84B349A322F86E8200D47BCF /* EventTargetConcrete.cpp */,
+				84B349A022F86E7400D47BCF /* EventTargetConcrete.h */,
 				CDCE5CD014633BC900D47CCA /* EventTargetFactory.in */,
 				93D196321D6CAB8200FC7E47 /* Exception.h */,
 				935FBCF109BA143B00E230B1 /* ExceptionCode.h */,
@@ -29793,6 +29798,7 @@
 				E4A8D21622578DB700A8463C /* EventRegion.h in Headers */,
 				E0FEF372B17C53EAC1C1FBEE /* EventSource.h in Headers */,
 				E12EDB7B0B308A78002704B6 /* EventTarget.h in Headers */,
+				84B349A222F86E7500D47BCF /* EventTargetConcrete.h in Headers */,
 				97AA3CA5145237CC003E1DA6 /* EventTargetHeaders.h in Headers */,
 				97AA3CA6145237CC003E1DA6 /* EventTargetInterfaces.h in Headers */,
 				262EC41A1D078FB900BA78FC /* EventTrackingRegions.h in Headers */,

Modified: trunk/Source/WebCore/bindings/js/JSDOMWrapperCache.h (256715 => 256716)


--- trunk/Source/WebCore/bindings/js/JSDOMWrapperCache.h	2020-02-17 01:35:18 UTC (rev 256715)
+++ trunk/Source/WebCore/bindings/js/JSDOMWrapperCache.h	2020-02-17 01:41:27 UTC (rev 256716)
@@ -201,4 +201,23 @@
     return toJSNewlyCreated(lexicalGlobalObject, globalObject, Ref<DOMClass>(domObject));
 }
 
+template<typename DOMClass> inline void setSubclassStructureIfNeeded(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, JSC::JSObject* jsObject)
+{
+    JSC::JSObject* newTarget = callFrame->newTarget().getObject();
+    JSC::JSObject* constructor = callFrame->jsCallee();
+    if (!newTarget || newTarget == constructor)
+        return;
+
+    using WrapperClass = typename JSDOMWrapperConverterTraits<DOMClass>::WrapperClass;
+
+    JSC::VM& vm = lexicalGlobalObject->vm();
+    auto scope = DECLARE_THROW_SCOPE(vm);
+
+    auto* newTargetGlobalObject = JSC::jsCast<JSDOMGlobalObject*>(newTarget->globalObject(vm));
+    auto* baseStructure = getDOMStructure<WrapperClass>(vm, *newTargetGlobalObject);
+    auto* subclassStructure = JSC::InternalFunction::createSubclassStructure(lexicalGlobalObject, constructor, newTarget, baseStructure);
+    RETURN_IF_EXCEPTION(scope, void());
+    jsObject->setStructure(vm, subclassStructure);
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/bindings/js/JSEventTargetCustom.cpp (256715 => 256716)


--- trunk/Source/WebCore/bindings/js/JSEventTargetCustom.cpp	2020-02-17 01:35:18 UTC (rev 256715)
+++ trunk/Source/WebCore/bindings/js/JSEventTargetCustom.cpp	2020-02-17 01:41:27 UTC (rev 256716)
@@ -43,6 +43,11 @@
 namespace WebCore {
 using namespace JSC;
 
+JSValue toJSNewlyCreated(JSGlobalObject*, JSDOMGlobalObject* globalObject, Ref<EventTarget>&& value)
+{
+    return createWrapper<EventTarget>(globalObject, WTFMove(value));
+}
+
 EventTarget* JSEventTarget::toWrapped(VM& vm, JSValue value)
 {
     if (value.inherits<JSWindowProxy>(vm))

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (256715 => 256716)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2020-02-17 01:35:18 UTC (rev 256715)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2020-02-17 01:41:27 UTC (rev 256716)
@@ -7333,7 +7333,6 @@
             push(@$outputArray, "{\n");
             push(@$outputArray, "    VM& vm = lexicalGlobalObject->vm();\n");
             push(@$outputArray, "    auto throwScope = DECLARE_THROW_SCOPE(vm);\n");
-            push(@$outputArray, "    UNUSED_PARAM(throwScope);\n");
             push(@$outputArray, "    auto* castedThis = jsCast<${constructorClassName}*>(callFrame->jsCallee());\n");
             push(@$outputArray, "    ASSERT(castedThis);\n");
 
@@ -7354,6 +7353,7 @@
             push(@$outputArray, "    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());\n") if $codeGenerator->ExtendedAttributeContains($interface->extendedAttributes->{ConstructorCallWith}, "ExecState");
 
             my $IDLType = GetIDLType($interface, $interface->type);
+            my $implType = GetImplClassName($interface);
 
             AddToImplIncludes("JSDOMConvertInterface.h");
 
@@ -7363,7 +7363,12 @@
             push(@constructionConversionArguments, "throwScope") if $interface->extendedAttributes->{ConstructorMayThrowException};
             push(@constructionConversionArguments, "WTFMove(object)");
 
-            push(@$outputArray, "    return JSValue::encode(toJSNewlyCreated<${IDLType}>(" . join(", ", @constructionConversionArguments) . "));\n");
+            # FIXME: toJSNewlyCreated should return JSObject* instead of JSValue.
+            push(@$outputArray, "    auto jsValue = toJSNewlyCreated<${IDLType}>(" . join(", ", @constructionConversionArguments) . ");\n");
+            push(@$outputArray, "    RETURN_IF_EXCEPTION(throwScope, { });\n") if $interface->extendedAttributes->{ConstructorMayThrowException};
+            push(@$outputArray, "    setSubclassStructureIfNeeded<${implType}>(lexicalGlobalObject, callFrame, asObject(jsValue));\n");
+            push(@$outputArray, "    RETURN_IF_EXCEPTION(throwScope, { });\n");
+            push(@$outputArray, "    return JSValue::encode(jsValue);\n");
             push(@$outputArray, "}\n\n");
         }
     }

Modified: trunk/Source/WebCore/bindings/scripts/InFilesCompiler.pm (256715 => 256716)


--- trunk/Source/WebCore/bindings/scripts/InFilesCompiler.pm	2020-02-17 01:35:18 UTC (rev 256715)
+++ trunk/Source/WebCore/bindings/scripts/InFilesCompiler.pm	2020-02-17 01:41:27 UTC (rev 256716)
@@ -243,6 +243,11 @@
         print F "#endif\n";
     }
 
+    if ($namespace eq "EventTarget") {
+        print F "    ${suffix} = $count,\n";
+        $count++;
+    }
+
     for my $interface (sort keys %unconditionalInterfaces) {
         print F "    ${interface}${suffix} = $count,\n";
         $count++;

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestEventConstructor.cpp (256715 => 256716)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestEventConstructor.cpp	2020-02-17 01:35:18 UTC (rev 256715)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestEventConstructor.cpp	2020-02-17 01:41:27 UTC (rev 256716)
@@ -159,7 +159,6 @@
 {
     VM& vm = lexicalGlobalObject->vm();
     auto throwScope = DECLARE_THROW_SCOPE(vm);
-    UNUSED_PARAM(throwScope);
     auto* castedThis = jsCast<JSTestEventConstructorConstructor*>(callFrame->jsCallee());
     ASSERT(castedThis);
     if (UNLIKELY(callFrame->argumentCount() < 1))
@@ -169,7 +168,10 @@
     auto eventInitDict = convert<IDLDictionary<TestEventConstructor::Init>>(*lexicalGlobalObject, callFrame->argument(1));
     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     auto object = TestEventConstructor::create(WTFMove(type), WTFMove(eventInitDict));
-    return JSValue::encode(toJSNewlyCreated<IDLInterface<TestEventConstructor>>(*lexicalGlobalObject, *castedThis->globalObject(), WTFMove(object)));
+    auto jsValue = toJSNewlyCreated<IDLInterface<TestEventConstructor>>(*lexicalGlobalObject, *castedThis->globalObject(), WTFMove(object));
+    setSubclassStructureIfNeeded<TestEventConstructor>(lexicalGlobalObject, callFrame, asObject(jsValue));
+    RETURN_IF_EXCEPTION(throwScope, { });
+    return JSValue::encode(jsValue);
 }
 
 template<> JSValue JSTestEventConstructorConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp (256715 => 256716)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp	2020-02-17 01:35:18 UTC (rev 256715)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp	2020-02-17 01:41:27 UTC (rev 256716)
@@ -258,7 +258,6 @@
 {
     VM& vm = lexicalGlobalObject->vm();
     auto throwScope = DECLARE_THROW_SCOPE(vm);
-    UNUSED_PARAM(throwScope);
     auto* castedThis = jsCast<JSTestInterfaceConstructor*>(callFrame->jsCallee());
     ASSERT(castedThis);
     if (UNLIKELY(callFrame->argumentCount() < 1))
@@ -271,7 +270,11 @@
     auto str2 = callFrame->argument(1).isUndefined() ? "defaultString"_s : convert<IDLDOMString>(*lexicalGlobalObject, callFrame->uncheckedArgument(1));
     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     auto object = TestInterface::create(*context, WTFMove(str1), WTFMove(str2));
-    return JSValue::encode(toJSNewlyCreated<IDLInterface<TestInterface>>(*lexicalGlobalObject, *castedThis->globalObject(), throwScope, WTFMove(object)));
+    auto jsValue = toJSNewlyCreated<IDLInterface<TestInterface>>(*lexicalGlobalObject, *castedThis->globalObject(), throwScope, WTFMove(object));
+    RETURN_IF_EXCEPTION(throwScope, { });
+    setSubclassStructureIfNeeded<TestInterface>(lexicalGlobalObject, callFrame, asObject(jsValue));
+    RETURN_IF_EXCEPTION(throwScope, { });
+    return JSValue::encode(jsValue);
 }
 
 template<> JSValue JSTestInterfaceConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNamedConstructor.cpp (256715 => 256716)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNamedConstructor.cpp	2020-02-17 01:35:18 UTC (rev 256715)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNamedConstructor.cpp	2020-02-17 01:41:27 UTC (rev 256716)
@@ -94,7 +94,6 @@
 {
     VM& vm = lexicalGlobalObject->vm();
     auto throwScope = DECLARE_THROW_SCOPE(vm);
-    UNUSED_PARAM(throwScope);
     auto* castedThis = jsCast<JSTestNamedConstructorNamedConstructor*>(callFrame->jsCallee());
     ASSERT(castedThis);
     if (UNLIKELY(callFrame->argumentCount() < 1))
@@ -106,7 +105,11 @@
     auto str3 = callFrame->argument(2).isUndefined() ? String() : convert<IDLDOMString>(*lexicalGlobalObject, callFrame->uncheckedArgument(2));
     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     auto object = TestNamedConstructor::createForJSConstructor(WTFMove(str1), WTFMove(str2), WTFMove(str3));
-    return JSValue::encode(toJSNewlyCreated<IDLInterface<TestNamedConstructor>>(*lexicalGlobalObject, *castedThis->globalObject(), throwScope, WTFMove(object)));
+    auto jsValue = toJSNewlyCreated<IDLInterface<TestNamedConstructor>>(*lexicalGlobalObject, *castedThis->globalObject(), throwScope, WTFMove(object));
+    RETURN_IF_EXCEPTION(throwScope, { });
+    setSubclassStructureIfNeeded<TestNamedConstructor>(lexicalGlobalObject, callFrame, asObject(jsValue));
+    RETURN_IF_EXCEPTION(throwScope, { });
+    return JSValue::encode(jsValue);
 }
 
 template<> JSValue JSTestNamedConstructorNamedConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNode.cpp (256715 => 256716)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNode.cpp	2020-02-17 01:35:18 UTC (rev 256715)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNode.cpp	2020-02-17 01:41:27 UTC (rev 256716)
@@ -102,11 +102,13 @@
 {
     VM& vm = lexicalGlobalObject->vm();
     auto throwScope = DECLARE_THROW_SCOPE(vm);
-    UNUSED_PARAM(throwScope);
     auto* castedThis = jsCast<JSTestNodeConstructor*>(callFrame->jsCallee());
     ASSERT(castedThis);
     auto object = TestNode::create();
-    return JSValue::encode(toJSNewlyCreated<IDLInterface<TestNode>>(*lexicalGlobalObject, *castedThis->globalObject(), WTFMove(object)));
+    auto jsValue = toJSNewlyCreated<IDLInterface<TestNode>>(*lexicalGlobalObject, *castedThis->globalObject(), WTFMove(object));
+    setSubclassStructureIfNeeded<TestNode>(lexicalGlobalObject, callFrame, asObject(jsValue));
+    RETURN_IF_EXCEPTION(throwScope, { });
+    return JSValue::encode(jsValue);
 }
 
 template<> JSValue JSTestNodeConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp (256715 => 256716)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp	2020-02-17 01:35:18 UTC (rev 256715)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp	2020-02-17 01:41:27 UTC (rev 256716)
@@ -1948,7 +1948,6 @@
 {
     VM& vm = lexicalGlobalObject->vm();
     auto throwScope = DECLARE_THROW_SCOPE(vm);
-    UNUSED_PARAM(throwScope);
     auto* castedThis = jsCast<JSTestObjConstructor*>(callFrame->jsCallee());
     ASSERT(castedThis);
     if (UNLIKELY(callFrame->argumentCount() < 2))
@@ -1963,7 +1962,10 @@
     auto testCallbackFunction = convert<IDLCallbackFunction<JSTestCallbackFunction>>(*lexicalGlobalObject, callFrame->uncheckedArgument(1), *castedThis->globalObject(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeFunctionError(lexicalGlobalObject, scope, 1, "testCallbackFunction", "TestObject", nullptr); });
     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     auto object = TestObj::create(document, testCallback.releaseNonNull(), testCallbackFunction.releaseNonNull());
-    return JSValue::encode(toJSNewlyCreated<IDLInterface<TestObj>>(*lexicalGlobalObject, *castedThis->globalObject(), WTFMove(object)));
+    auto jsValue = toJSNewlyCreated<IDLInterface<TestObj>>(*lexicalGlobalObject, *castedThis->globalObject(), WTFMove(object));
+    setSubclassStructureIfNeeded<TestObj>(lexicalGlobalObject, callFrame, asObject(jsValue));
+    RETURN_IF_EXCEPTION(throwScope, { });
+    return JSValue::encode(jsValue);
 }
 
 template<> JSValue JSTestObjConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp (256715 => 256716)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp	2020-02-17 01:35:18 UTC (rev 256715)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp	2020-02-17 01:41:27 UTC (rev 256716)
@@ -81,13 +81,15 @@
 {
     VM& vm = lexicalGlobalObject->vm();
     auto throwScope = DECLARE_THROW_SCOPE(vm);
-    UNUSED_PARAM(throwScope);
     auto* castedThis = jsCast<JSTestOverloadedConstructorsConstructor*>(callFrame->jsCallee());
     ASSERT(castedThis);
     auto arrayBuffer = convert<IDLArrayBuffer>(*lexicalGlobalObject, callFrame->uncheckedArgument(0), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentTypeError(lexicalGlobalObject, scope, 0, "arrayBuffer", "TestOverloadedConstructors", nullptr, "ArrayBuffer"); });
     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     auto object = TestOverloadedConstructors::create(*arrayBuffer);
-    return JSValue::encode(toJSNewlyCreated<IDLInterface<TestOverloadedConstructors>>(*lexicalGlobalObject, *castedThis->globalObject(), WTFMove(object)));
+    auto jsValue = toJSNewlyCreated<IDLInterface<TestOverloadedConstructors>>(*lexicalGlobalObject, *castedThis->globalObject(), WTFMove(object));
+    setSubclassStructureIfNeeded<TestOverloadedConstructors>(lexicalGlobalObject, callFrame, asObject(jsValue));
+    RETURN_IF_EXCEPTION(throwScope, { });
+    return JSValue::encode(jsValue);
 }
 
 static inline EncodedJSValue constructJSTestOverloadedConstructors2(JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame)
@@ -94,13 +96,15 @@
 {
     VM& vm = lexicalGlobalObject->vm();
     auto throwScope = DECLARE_THROW_SCOPE(vm);
-    UNUSED_PARAM(throwScope);
     auto* castedThis = jsCast<JSTestOverloadedConstructorsConstructor*>(callFrame->jsCallee());
     ASSERT(castedThis);
     auto arrayBufferView = convert<IDLArrayBufferView>(*lexicalGlobalObject, callFrame->uncheckedArgument(0), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentTypeError(lexicalGlobalObject, scope, 0, "arrayBufferView", "TestOverloadedConstructors", nullptr, "ArrayBufferView"); });
     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     auto object = TestOverloadedConstructors::create(arrayBufferView.releaseNonNull());
-    return JSValue::encode(toJSNewlyCreated<IDLInterface<TestOverloadedConstructors>>(*lexicalGlobalObject, *castedThis->globalObject(), WTFMove(object)));
+    auto jsValue = toJSNewlyCreated<IDLInterface<TestOverloadedConstructors>>(*lexicalGlobalObject, *castedThis->globalObject(), WTFMove(object));
+    setSubclassStructureIfNeeded<TestOverloadedConstructors>(lexicalGlobalObject, callFrame, asObject(jsValue));
+    RETURN_IF_EXCEPTION(throwScope, { });
+    return JSValue::encode(jsValue);
 }
 
 static inline EncodedJSValue constructJSTestOverloadedConstructors3(JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame)
@@ -107,13 +111,15 @@
 {
     VM& vm = lexicalGlobalObject->vm();
     auto throwScope = DECLARE_THROW_SCOPE(vm);
-    UNUSED_PARAM(throwScope);
     auto* castedThis = jsCast<JSTestOverloadedConstructorsConstructor*>(callFrame->jsCallee());
     ASSERT(castedThis);
     auto blob = convert<IDLInterface<Blob>>(*lexicalGlobalObject, callFrame->uncheckedArgument(0), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentTypeError(lexicalGlobalObject, scope, 0, "blob", "TestOverloadedConstructors", nullptr, "Blob"); });
     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     auto object = TestOverloadedConstructors::create(*blob);
-    return JSValue::encode(toJSNewlyCreated<IDLInterface<TestOverloadedConstructors>>(*lexicalGlobalObject, *castedThis->globalObject(), WTFMove(object)));
+    auto jsValue = toJSNewlyCreated<IDLInterface<TestOverloadedConstructors>>(*lexicalGlobalObject, *castedThis->globalObject(), WTFMove(object));
+    setSubclassStructureIfNeeded<TestOverloadedConstructors>(lexicalGlobalObject, callFrame, asObject(jsValue));
+    RETURN_IF_EXCEPTION(throwScope, { });
+    return JSValue::encode(jsValue);
 }
 
 static inline EncodedJSValue constructJSTestOverloadedConstructors4(JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame)
@@ -120,13 +126,15 @@
 {
     VM& vm = lexicalGlobalObject->vm();
     auto throwScope = DECLARE_THROW_SCOPE(vm);
-    UNUSED_PARAM(throwScope);
     auto* castedThis = jsCast<JSTestOverloadedConstructorsConstructor*>(callFrame->jsCallee());
     ASSERT(castedThis);
     auto string = convert<IDLDOMString>(*lexicalGlobalObject, callFrame->uncheckedArgument(0));
     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     auto object = TestOverloadedConstructors::create(WTFMove(string));
-    return JSValue::encode(toJSNewlyCreated<IDLInterface<TestOverloadedConstructors>>(*lexicalGlobalObject, *castedThis->globalObject(), WTFMove(object)));
+    auto jsValue = toJSNewlyCreated<IDLInterface<TestOverloadedConstructors>>(*lexicalGlobalObject, *castedThis->globalObject(), WTFMove(object));
+    setSubclassStructureIfNeeded<TestOverloadedConstructors>(lexicalGlobalObject, callFrame, asObject(jsValue));
+    RETURN_IF_EXCEPTION(throwScope, { });
+    return JSValue::encode(jsValue);
 }
 
 static inline EncodedJSValue constructJSTestOverloadedConstructors5(JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame)
@@ -133,13 +141,15 @@
 {
     VM& vm = lexicalGlobalObject->vm();
     auto throwScope = DECLARE_THROW_SCOPE(vm);
-    UNUSED_PARAM(throwScope);
     auto* castedThis = jsCast<JSTestOverloadedConstructorsConstructor*>(callFrame->jsCallee());
     ASSERT(castedThis);
     auto longArgs = convertVariadicArguments<IDLLong>(*lexicalGlobalObject, *callFrame, 0);
     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     auto object = TestOverloadedConstructors::create(WTFMove(longArgs));
-    return JSValue::encode(toJSNewlyCreated<IDLInterface<TestOverloadedConstructors>>(*lexicalGlobalObject, *castedThis->globalObject(), WTFMove(object)));
+    auto jsValue = toJSNewlyCreated<IDLInterface<TestOverloadedConstructors>>(*lexicalGlobalObject, *castedThis->globalObject(), WTFMove(object));
+    setSubclassStructureIfNeeded<TestOverloadedConstructors>(lexicalGlobalObject, callFrame, asObject(jsValue));
+    RETURN_IF_EXCEPTION(throwScope, { });
+    return JSValue::encode(jsValue);
 }
 
 template<> EncodedJSValue JSC_HOST_CALL JSTestOverloadedConstructorsConstructor::construct(JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame)

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructorsWithSequence.cpp (256715 => 256716)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructorsWithSequence.cpp	2020-02-17 01:35:18 UTC (rev 256715)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructorsWithSequence.cpp	2020-02-17 01:41:27 UTC (rev 256716)
@@ -80,13 +80,15 @@
 {
     VM& vm = lexicalGlobalObject->vm();
     auto throwScope = DECLARE_THROW_SCOPE(vm);
-    UNUSED_PARAM(throwScope);
     auto* castedThis = jsCast<JSTestOverloadedConstructorsWithSequenceConstructor*>(callFrame->jsCallee());
     ASSERT(castedThis);
     auto sequenceOfStrings = callFrame->argument(0).isUndefined() ? Converter<IDLSequence<IDLDOMString>>::ReturnType{ } : convert<IDLSequence<IDLDOMString>>(*lexicalGlobalObject, callFrame->uncheckedArgument(0));
     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     auto object = TestOverloadedConstructorsWithSequence::create(WTFMove(sequenceOfStrings));
-    return JSValue::encode(toJSNewlyCreated<IDLInterface<TestOverloadedConstructorsWithSequence>>(*lexicalGlobalObject, *castedThis->globalObject(), WTFMove(object)));
+    auto jsValue = toJSNewlyCreated<IDLInterface<TestOverloadedConstructorsWithSequence>>(*lexicalGlobalObject, *castedThis->globalObject(), WTFMove(object));
+    setSubclassStructureIfNeeded<TestOverloadedConstructorsWithSequence>(lexicalGlobalObject, callFrame, asObject(jsValue));
+    RETURN_IF_EXCEPTION(throwScope, { });
+    return JSValue::encode(jsValue);
 }
 
 static inline EncodedJSValue constructJSTestOverloadedConstructorsWithSequence2(JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame)
@@ -93,13 +95,15 @@
 {
     VM& vm = lexicalGlobalObject->vm();
     auto throwScope = DECLARE_THROW_SCOPE(vm);
-    UNUSED_PARAM(throwScope);
     auto* castedThis = jsCast<JSTestOverloadedConstructorsWithSequenceConstructor*>(callFrame->jsCallee());
     ASSERT(castedThis);
     auto string = convert<IDLDOMString>(*lexicalGlobalObject, callFrame->uncheckedArgument(0));
     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     auto object = TestOverloadedConstructorsWithSequence::create(WTFMove(string));
-    return JSValue::encode(toJSNewlyCreated<IDLInterface<TestOverloadedConstructorsWithSequence>>(*lexicalGlobalObject, *castedThis->globalObject(), WTFMove(object)));
+    auto jsValue = toJSNewlyCreated<IDLInterface<TestOverloadedConstructorsWithSequence>>(*lexicalGlobalObject, *castedThis->globalObject(), WTFMove(object));
+    setSubclassStructureIfNeeded<TestOverloadedConstructorsWithSequence>(lexicalGlobalObject, callFrame, asObject(jsValue));
+    RETURN_IF_EXCEPTION(throwScope, { });
+    return JSValue::encode(jsValue);
 }
 
 template<> EncodedJSValue JSC_HOST_CALL JSTestOverloadedConstructorsWithSequenceConstructor::construct(JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame)

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestPromiseRejectionEvent.cpp (256715 => 256716)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestPromiseRejectionEvent.cpp	2020-02-17 01:35:18 UTC (rev 256715)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestPromiseRejectionEvent.cpp	2020-02-17 01:41:27 UTC (rev 256716)
@@ -160,7 +160,6 @@
 {
     VM& vm = lexicalGlobalObject->vm();
     auto throwScope = DECLARE_THROW_SCOPE(vm);
-    UNUSED_PARAM(throwScope);
     auto* castedThis = jsCast<JSTestPromiseRejectionEventConstructor*>(callFrame->jsCallee());
     ASSERT(castedThis);
     if (UNLIKELY(callFrame->argumentCount() < 2))
@@ -170,7 +169,10 @@
     auto eventInitDict = convert<IDLDictionary<TestPromiseRejectionEvent::Init>>(*lexicalGlobalObject, callFrame->uncheckedArgument(1));
     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     auto object = TestPromiseRejectionEvent::create(*castedThis->globalObject(), WTFMove(type), WTFMove(eventInitDict));
-    return JSValue::encode(toJSNewlyCreated<IDLInterface<TestPromiseRejectionEvent>>(*lexicalGlobalObject, *castedThis->globalObject(), WTFMove(object)));
+    auto jsValue = toJSNewlyCreated<IDLInterface<TestPromiseRejectionEvent>>(*lexicalGlobalObject, *castedThis->globalObject(), WTFMove(object));
+    setSubclassStructureIfNeeded<TestPromiseRejectionEvent>(lexicalGlobalObject, callFrame, asObject(jsValue));
+    RETURN_IF_EXCEPTION(throwScope, { });
+    return JSValue::encode(jsValue);
 }
 
 template<> JSValue JSTestPromiseRejectionEventConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp (256715 => 256716)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp	2020-02-17 01:35:18 UTC (rev 256715)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp	2020-02-17 01:41:27 UTC (rev 256716)
@@ -148,7 +148,6 @@
 {
     VM& vm = lexicalGlobalObject->vm();
     auto throwScope = DECLARE_THROW_SCOPE(vm);
-    UNUSED_PARAM(throwScope);
     auto* castedThis = jsCast<JSTestTypedefsConstructor*>(callFrame->jsCallee());
     ASSERT(castedThis);
     if (UNLIKELY(callFrame->argumentCount() < 3))
@@ -160,7 +159,10 @@
     auto testCallbackInterface = convert<IDLCallbackInterface<JSTestCallbackInterface>>(*lexicalGlobalObject, callFrame->uncheckedArgument(2), *castedThis->globalObject(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeFunctionError(lexicalGlobalObject, scope, 2, "testCallbackInterface", "TestTypedefs", nullptr); });
     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     auto object = TestTypedefs::create(WTFMove(hello), testCallbackFunction.releaseNonNull(), testCallbackInterface.releaseNonNull());
-    return JSValue::encode(toJSNewlyCreated<IDLInterface<TestTypedefs>>(*lexicalGlobalObject, *castedThis->globalObject(), WTFMove(object)));
+    auto jsValue = toJSNewlyCreated<IDLInterface<TestTypedefs>>(*lexicalGlobalObject, *castedThis->globalObject(), WTFMove(object));
+    setSubclassStructureIfNeeded<TestTypedefs>(lexicalGlobalObject, callFrame, asObject(jsValue));
+    RETURN_IF_EXCEPTION(throwScope, { });
+    return JSValue::encode(jsValue);
 }
 
 template<> JSValue JSTestTypedefsConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)

Modified: trunk/Source/WebCore/dom/EventTarget.cpp (256715 => 256716)


--- trunk/Source/WebCore/dom/EventTarget.cpp	2020-02-17 01:35:18 UTC (rev 256715)
+++ trunk/Source/WebCore/dom/EventTarget.cpp	2020-02-17 01:41:27 UTC (rev 256716)
@@ -34,6 +34,7 @@
 
 #include "DOMWrapperWorld.h"
 #include "EventNames.h"
+#include "EventTargetConcrete.h"
 #include "HTMLBodyElement.h"
 #include "HTMLHtmlElement.h"
 #include "InspectorInstrumentation.h"
@@ -58,6 +59,11 @@
 WTF_MAKE_ISO_ALLOCATED_IMPL(EventTarget);
 WTF_MAKE_ISO_ALLOCATED_IMPL(EventTargetWithInlineData);
 
+Ref<EventTarget> EventTarget::create(ScriptExecutionContext& context)
+{
+    return EventTargetConcrete::create(context);
+}
+
 bool EventTarget::isNode() const
 {
     return false;

Modified: trunk/Source/WebCore/dom/EventTarget.h (256715 => 256716)


--- trunk/Source/WebCore/dom/EventTarget.h	2020-02-17 01:35:18 UTC (rev 256715)
+++ trunk/Source/WebCore/dom/EventTarget.h	2020-02-17 01:41:27 UTC (rev 256716)
@@ -54,6 +54,8 @@
 class EventTarget : public ScriptWrappable {
     WTF_MAKE_ISO_ALLOCATED(EventTarget);
 public:
+    static Ref<EventTarget> create(ScriptExecutionContext&);
+
     void ref() { refEventTarget(); }
     void deref() { derefEventTarget(); }
 

Modified: trunk/Source/WebCore/dom/EventTarget.idl (256715 => 256716)


--- trunk/Source/WebCore/dom/EventTarget.idl	2020-02-17 01:35:18 UTC (rev 256715)
+++ trunk/Source/WebCore/dom/EventTarget.idl	2020-02-17 01:41:27 UTC (rev 256716)
@@ -19,6 +19,8 @@
  */
 
 [
+    Constructor,
+    ConstructorCallWith=ScriptExecutionContext,
     CustomToJSObject,
     Exposed=(Window,Worker),
     IsImmutablePrototypeExoticObjectOnPrototype,

Added: trunk/Source/WebCore/dom/EventTargetConcrete.cpp (0 => 256716)


--- trunk/Source/WebCore/dom/EventTargetConcrete.cpp	                        (rev 0)
+++ trunk/Source/WebCore/dom/EventTargetConcrete.cpp	2020-02-17 01:41:27 UTC (rev 256716)
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2020 Alexey Shvayka <[email protected]>.
+ *
+ * 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.
+ */
+
+#include "config.h"
+#include "EventTargetConcrete.h"
+
+namespace WebCore {
+
+WTF_MAKE_ISO_ALLOCATED_IMPL(EventTargetConcrete);
+
+Ref<EventTargetConcrete> EventTargetConcrete::create(ScriptExecutionContext& context)
+{
+    return adoptRef(*new EventTargetConcrete(context));
+}
+
+EventTargetConcrete::EventTargetConcrete(ScriptExecutionContext& context)
+    : ContextDestructionObserver(&context)
+{
+}
+
+} // namespace WebCore

Added: trunk/Source/WebCore/dom/EventTargetConcrete.h (0 => 256716)


--- trunk/Source/WebCore/dom/EventTargetConcrete.h	                        (rev 0)
+++ trunk/Source/WebCore/dom/EventTargetConcrete.h	2020-02-17 01:41:27 UTC (rev 256716)
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2020 Alexey Shvayka <[email protected]>.
+ *
+ * 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 "ContextDestructionObserver.h"
+#include "EventTarget.h"
+#include "EventTargetInterfaces.h"
+#include "ScriptExecutionContext.h"
+#include <wtf/IsoMallocInlines.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+class EventTargetConcrete final : public RefCounted<EventTargetConcrete>, public EventTargetWithInlineData, private ContextDestructionObserver {
+    WTF_MAKE_ISO_ALLOCATED(EventTargetConcrete);
+public:
+    static Ref<EventTargetConcrete> create(ScriptExecutionContext&);
+
+    using RefCounted::ref;
+    using RefCounted::deref;
+
+private:
+    explicit EventTargetConcrete(ScriptExecutionContext&);
+
+    EventTargetInterface eventTargetInterface() const final { return EventTargetInterfaceType; }
+    ScriptExecutionContext* scriptExecutionContext() const final { return ContextDestructionObserver::scriptExecutionContext(); }
+
+    void refEventTarget() final { ref(); }
+    void derefEventTarget() final { deref(); }
+};
+
+} // namespace WebCore

Modified: trunk/Source/WebCore/dom/make_event_factory.pl (256715 => 256716)


--- trunk/Source/WebCore/dom/make_event_factory.pl	2020-02-17 01:35:18 UTC (rev 256715)
+++ trunk/Source/WebCore/dom/make_event_factory.pl	2020-02-17 01:41:27 UTC (rev 256716)
@@ -104,6 +104,8 @@
         print F "JSC::JSValue toJS(JSC::JSGlobalObject* state, JSDOMGlobalObject* globalObject, ${namespace}& impl)\n";
         print F "{\n";
         print F "    switch (impl.${interfaceMethodName}()) {\n";
+        print F "    case EventTargetInterfaceType:\n";
+        print F "        break;\n";
     }
 
     my %generatedInterfaceNames = ();
@@ -139,8 +141,7 @@
     if ($factoryFunction eq "toNewlyCreated") {
         print F "    return createWrapper<$namespace>(globalObject, WTFMove(impl));\n";
     } else {
-        print F "    ASSERT_NOT_REACHED();\n";
-        print F "    return JSC::jsNull();\n";
+        print F "    return wrap(state, globalObject, impl);\n";
     }
     print F "}\n";
     print F "\n";
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to