forked from WebKit/WebKit-http
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 (whatwg/dom#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. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@256716 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
shvaikalesh@gmail.com
committed
Feb 17, 2020
1 parent
3c14cc0
commit e1b7274
Showing
35 changed files
with
336 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...sts/imported/w3c/web-platform-tests/dom/events/EventTarget-constructible.any-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
4 changes: 2 additions & 2 deletions
4
...orted/w3c/web-platform-tests/dom/events/EventTarget-constructible.any.worker-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
2 changes: 1 addition & 1 deletion
2
...utTests/imported/w3c/web-platform-tests/dom/events/event-global-extra.window-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 0 additions & 51 deletions
51
...ios/imported/w3c/web-platform-tests/dom/events/Event-subclasses-constructors-expected.txt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.