haikuwebkit/Source/WebCore/dom/CustomElementRegistry.cpp

138 lines
5.1 KiB
C++
Raw Permalink Normal View History

Add document.defineCustomElement https://bugs.webkit.org/show_bug.cgi?id=153092 Reviewed by Chris Dumez. Source/WebCore: Added document.defineCustomElement and added a constructor to HTMLElement which can be called as "super" in a subclass of HTMLElement. This is a prototype of new custom elements API and willfully violates the current specification at http://w3c.github.io/webcomponents/spec/custom/ Each author defined class can define multiple elements using distinct tag names. In such cases, the super call must specify the tag name. e.g. class SomeCustomElement extends HTMLElement { constructor(name) { super(name); } } document.defineCustomElement('some-custom-element', SomeCustomElement); document.defineCustomElement('other-custom-element', SomeCustomElement); new SomeCustomElement('some-custom-element'); When a class is associated with exactly one tag name, the argument can be omitted. e.g. class AnotherCustomElement extends HTMLElement {} document.defineCustomElement('another-custom-element', AnotherCustomElement); new AnotherCustomElement(); We allow only subclassing of HTMLElement and only in (X)HTML namespace. Tests: fast/custom-elements/Document-defineCustomElement.html fast/custom-elements/HTMLElement-constructor.html * CMakeLists.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSCustomElementInterface.cpp: Added. Abstracts an author-defined class associated with a custom element. It's a Active DOM object and lives until the associated document dies. (WebCore::JSCustomElementInterface::JSCustomElementInterface): (WebCore::JSCustomElementInterface::~JSCustomElementInterface): * bindings/js/JSCustomElementInterface.h: Added. (WebCore::JSCustomElementInterface::create): (WebCore::JSCustomElementInterface::scriptExecutionContext): (WebCore::JSCustomElementInterface::constructor): * bindings/js/JSDocumentCustom.cpp: (WebCore::JSDocument::defineCustomElement): Added. Define a custom element by associating a tag name with an author defined JS class after validating arguments. * bindings/js/JSHTMLElementCustom.cpp: (WebCore::constructJSHTMLElement): Added. Look up the tag name based on new.target if one is not specified. If a tag name is specified, check that new.target is associated with the tag name. * dom/CustomElementDefinitions.cpp: Added. (WebCore::CustomElementDefinitions::checkName): Added. Restricts tag names similarly to http://w3c.github.io/webcomponents/spec/custom/#dfn-custom-element-type (WebCore::CustomElementDefinitions::defineElement): Added. Associates a JS class with a tag name. (WebCore::CustomElementDefinitions::findInterface): Added. Finds a JS class by a tag name. (WebCore::CustomElementDefinitions::findName): Added. Finds a tag name by a JS class. * dom/CustomElementDefinitions.h: Added. (WebCore::CustomElementDefinitions::CustomElementInfo): Added. * dom/Document.cpp: (WebCore::Document::ensureCustomElementDefinitions): Added. * dom/Document.h: (WebCore::Document::customElementDefinitions): Added. * dom/Document.idl: * html/HTMLElement.idl: LayoutTests: Added tests for document.defineCustomElement and instantiating custom elements. * TestExpectations: Skipped the tests on non-Mac ports. * fast/custom-elements: Added. * fast/custom-elements/Document-defineCustomElement-expected.txt: Added. * fast/custom-elements/Document-defineCustomElement.html: Added. * fast/custom-elements/HTMLElement-constructor-expected.txt: Added. * fast/custom-elements/HTMLElement-constructor.html: Added. * platform/mac/TestExpectations: Canonical link: https://commits.webkit.org/171208@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@195087 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-01-15 02:59:03 +00:00
/*
Move document.defineElement to customElements.define https://bugs.webkit.org/show_bug.cgi?id=160731 Reviewed by Chris Dumez. Source/WebCore: Replaced Document.prototype.defineElement by CustomElementsRegistry.prototype.define to match the latest HTML specification: https://html.spec.whatwg.org/#custom-elements-api This patch renames the existing CustomElementDefinitions to CustomElementsRegistry and exposes it on window.customElements. CustomElementDefinitions is now owned by DOMWindow instead of Document to match the spec's new semantics. No new tests. The existing tests have been updated to reflect the change. * DerivedSources.cpp: * DerivedSources.make: * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSCustomElementsRegistryCustom.cpp: Added. (WebCore::JSCustomElementsRegistry::define): Moved from JSDocumentCustom. Removed the check for the existence of DOMWindow since CustomElementsRegistry is an attribute on DOMWindow itself. * bindings/js/JSDocumentCustom.cpp: (WebCore::JSDocument::defineElement): Deleted. * bindings/js/JSHTMLElementCustom.cpp: Added the code to check the existence of DOMWindow since the registry is associated with DOMWindow, not Document. (WebCore::constructJSHTMLElement): * dom/CustomElementsRegistry.cpp: Renamed from Source/WebCore/dom/CustomElementDefinitions.cpp. (WebCore::CustomElementsRegistry::create): Added. (WebCore::CustomElementsRegistry::CustomElementsRegistry): Added. (WebCore::CustomElementsRegistry::~CustomElementsRegistry): Added. (WebCore::CustomElementsRegistry::addElementDefinition): Moved from CustomElementDefinitions. (WebCore::CustomElementsRegistry::addUpgradeCandidate): Ditto. (WebCore::CustomElementsRegistry::findInterface): Ditto. (WebCore::CustomElementsRegistry::containsConstructor): Ditto. * dom/CustomElementsRegistry.h: Renamed from Source/WebCore/dom/CustomElementDefinitions.h. * dom/CustomElementsRegistry.idl: Added. * dom/Document.cpp: (WebCore::createUpgradeCandidateElement): Extracted out of createHTMLElementWithNameValidation and createFallbackHTMLElement to share code. (WebCore::createHTMLElementWithNameValidation): (WebCore::createFallbackHTMLElement): This function was missing a check for the runtime flag. Sharing code with createHTMLElementWithNameValidation via createUpgradeCandidateElement fixes it. (WebCore::Document::ensureCustomElementDefinitions): Deleted. * dom/Document.h: (WebCore::Document::customElementDefinitions): Deleted. * dom/Document.idl: * dom/Element.cpp: (WebCore::Element::attributeChanged): * html/parser/HTMLConstructionSite.cpp: (WebCore::HTMLConstructionSite::createHTMLElementOrFindCustomElementInterface): * page/DOMWindow.cpp: (WebCore::DOMWindow::ensureCustomElementsRegistry): Added. Moved from Document. * page/DOMWindow.h: * page/DOMWindow.idl: Added customElements on DOMWindow. LayoutTests: Updated the tests and their expected results to reflect the move of Document.prototype.defineElement to CustomElementsRegistry.prototype.define. I'm going to rename tests in a follow up. * fast/custom-elements/Document-createElement.html: * fast/custom-elements/Document-defineElement-expected.txt: * fast/custom-elements/Document-defineElement.html: Removed test cases for testing defining elements in a viewless/windowless document since those documents don't have a corresponding window object. * fast/custom-elements/HTMLElement-constructor.html: * fast/custom-elements/attribute-changed-callback.html: * fast/custom-elements/defined-pseudo-class.html: * fast/custom-elements/defined-rule.html: * fast/custom-elements/lifecycle-callback-timing.html: * fast/custom-elements/parser/parser-constructs-custom-element-in-document-write.html: * fast/custom-elements/parser/parser-constructs-custom-element-synchronously.html: * fast/custom-elements/parser/parser-constructs-custom-elements-expected.txt: * fast/custom-elements/parser/parser-constructs-custom-elements.html: * fast/custom-elements/parser/parser-fallsback-to-unknown-element.html: * fast/custom-elements/parser/parser-sets-attributes-and-children.html: * fast/custom-elements/parser/parser-uses-constructed-element.html: * fast/custom-elements/parser/parser-uses-registry-of-owner-document.html: * fast/custom-elements/upgrading/Node-cloneNode.html: * fast/custom-elements/upgrading/upgrading-parser-created-element.html: * platform/mac/js/dom/global-constructors-attributes-expected.txt: Canonical link: https://commits.webkit.org/178878@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@204367 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-08-11 02:08:17 +00:00
* Copyright (C) 2015, 2016 Apple Inc. All rights reserved.
Add document.defineCustomElement https://bugs.webkit.org/show_bug.cgi?id=153092 Reviewed by Chris Dumez. Source/WebCore: Added document.defineCustomElement and added a constructor to HTMLElement which can be called as "super" in a subclass of HTMLElement. This is a prototype of new custom elements API and willfully violates the current specification at http://w3c.github.io/webcomponents/spec/custom/ Each author defined class can define multiple elements using distinct tag names. In such cases, the super call must specify the tag name. e.g. class SomeCustomElement extends HTMLElement { constructor(name) { super(name); } } document.defineCustomElement('some-custom-element', SomeCustomElement); document.defineCustomElement('other-custom-element', SomeCustomElement); new SomeCustomElement('some-custom-element'); When a class is associated with exactly one tag name, the argument can be omitted. e.g. class AnotherCustomElement extends HTMLElement {} document.defineCustomElement('another-custom-element', AnotherCustomElement); new AnotherCustomElement(); We allow only subclassing of HTMLElement and only in (X)HTML namespace. Tests: fast/custom-elements/Document-defineCustomElement.html fast/custom-elements/HTMLElement-constructor.html * CMakeLists.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSCustomElementInterface.cpp: Added. Abstracts an author-defined class associated with a custom element. It's a Active DOM object and lives until the associated document dies. (WebCore::JSCustomElementInterface::JSCustomElementInterface): (WebCore::JSCustomElementInterface::~JSCustomElementInterface): * bindings/js/JSCustomElementInterface.h: Added. (WebCore::JSCustomElementInterface::create): (WebCore::JSCustomElementInterface::scriptExecutionContext): (WebCore::JSCustomElementInterface::constructor): * bindings/js/JSDocumentCustom.cpp: (WebCore::JSDocument::defineCustomElement): Added. Define a custom element by associating a tag name with an author defined JS class after validating arguments. * bindings/js/JSHTMLElementCustom.cpp: (WebCore::constructJSHTMLElement): Added. Look up the tag name based on new.target if one is not specified. If a tag name is specified, check that new.target is associated with the tag name. * dom/CustomElementDefinitions.cpp: Added. (WebCore::CustomElementDefinitions::checkName): Added. Restricts tag names similarly to http://w3c.github.io/webcomponents/spec/custom/#dfn-custom-element-type (WebCore::CustomElementDefinitions::defineElement): Added. Associates a JS class with a tag name. (WebCore::CustomElementDefinitions::findInterface): Added. Finds a JS class by a tag name. (WebCore::CustomElementDefinitions::findName): Added. Finds a tag name by a JS class. * dom/CustomElementDefinitions.h: Added. (WebCore::CustomElementDefinitions::CustomElementInfo): Added. * dom/Document.cpp: (WebCore::Document::ensureCustomElementDefinitions): Added. * dom/Document.h: (WebCore::Document::customElementDefinitions): Added. * dom/Document.idl: * html/HTMLElement.idl: LayoutTests: Added tests for document.defineCustomElement and instantiating custom elements. * TestExpectations: Skipped the tests on non-Mac ports. * fast/custom-elements: Added. * fast/custom-elements/Document-defineCustomElement-expected.txt: Added. * fast/custom-elements/Document-defineCustomElement.html: Added. * fast/custom-elements/HTMLElement-constructor-expected.txt: Added. * fast/custom-elements/HTMLElement-constructor.html: Added. * platform/mac/TestExpectations: Canonical link: https://commits.webkit.org/171208@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@195087 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-01-15 02:59:03 +00:00
*
* 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.
*/
#include "config.h"
Rename CustomElementsRegistry to CustomElementRegistry https://bugs.webkit.org/show_bug.cgi?id=161028 Reviewed by Darin Adler. Source/JavaScriptCore: Added customElements and CustomElementRegistry to the common identifiers list as they're used on JSDOMWindow to hide window.customElements and CustomElementRegistry interface behind a runtime flag. * runtime/CommonIdentifiers.h: Source/WebCore: Renamed CustomElementsRegistry to CustomElementRegistry per https://github.com/w3c/webcomponents/issues/548. Also hide window.customElements and CustomElementRegistry interface behind a runtime enabled. * CMakeLists.txt: * DerivedSources.cpp: * DerivedSources.make: * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSCustomElementRegistryCustom.cpp: Renamed from JSCustomElementsRegistryCustom.cpp. (WebCore::getCustomElementCallback): (WebCore::JSCustomElementRegistry::define): * bindings/js/JSHTMLElementCustom.cpp: (WebCore::constructJSHTMLElement): * dom/CustomElementReactionQueue.cpp: (WebCore::findInterfaceForCustomElement): * dom/CustomElementRegistry.cpp: Renamed from CustomElementsRegistry.cpp. (WebCore::CustomElementRegistry::create): (WebCore::CustomElementRegistry::CustomElementRegistry): (WebCore::CustomElementRegistry::~CustomElementRegistry): (WebCore::CustomElementRegistry::addElementDefinition): (WebCore::CustomElementRegistry::addUpgradeCandidate): (WebCore::CustomElementRegistry::findInterface): (WebCore::CustomElementRegistry::containsConstructor): * dom/CustomElementRegistry.h: Renamed from CustomElementsRegistry.h. * dom/CustomElementRegistry.idl: Renamed from CustomElementsRegistry.idl. * dom/Document.cpp: (WebCore::createUpgradeCandidateElement): (WebCore::createHTMLElementWithNameValidation): (WebCore::createFallbackHTMLElement): * dom/Element.cpp: * html/parser/HTMLConstructionSite.cpp: (WebCore::HTMLConstructionSite::createHTMLElementOrFindCustomElementInterface): * page/DOMWindow.cpp: (WebCore::DOMWindow::ensureCustomElementRegistry): * page/DOMWindow.h: * page/DOMWindow.idl: LayoutTests: Updated the tests and expected results after the rename. * fast/custom-elements/CustomElementRegistry-expected.txt: Renamed from LayoutTests/fast/custom-elements/CustomElementsRegistry-expected.txt. * fast/custom-elements/CustomElementRegistry.html: Renamed from LayoutTests/fast/custom-elements/CustomElementsRegistry.html. * platform/efl/js/dom/global-constructors-attributes-expected.txt: * platform/gtk/js/dom/global-constructors-attributes-expected.txt: * platform/mac-wk1/js/dom/global-constructors-attributes-expected.txt: * platform/mac-yosemite/js/dom/global-constructors-attributes-expected.txt: * platform/mac/js/dom/global-constructors-attributes-expected.txt: * platform/win/js/dom/global-constructors-attributes-expected.txt: Canonical link: https://commits.webkit.org/179194@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@204732 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-08-22 19:45:01 +00:00
#include "CustomElementRegistry.h"
Add document.defineCustomElement https://bugs.webkit.org/show_bug.cgi?id=153092 Reviewed by Chris Dumez. Source/WebCore: Added document.defineCustomElement and added a constructor to HTMLElement which can be called as "super" in a subclass of HTMLElement. This is a prototype of new custom elements API and willfully violates the current specification at http://w3c.github.io/webcomponents/spec/custom/ Each author defined class can define multiple elements using distinct tag names. In such cases, the super call must specify the tag name. e.g. class SomeCustomElement extends HTMLElement { constructor(name) { super(name); } } document.defineCustomElement('some-custom-element', SomeCustomElement); document.defineCustomElement('other-custom-element', SomeCustomElement); new SomeCustomElement('some-custom-element'); When a class is associated with exactly one tag name, the argument can be omitted. e.g. class AnotherCustomElement extends HTMLElement {} document.defineCustomElement('another-custom-element', AnotherCustomElement); new AnotherCustomElement(); We allow only subclassing of HTMLElement and only in (X)HTML namespace. Tests: fast/custom-elements/Document-defineCustomElement.html fast/custom-elements/HTMLElement-constructor.html * CMakeLists.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSCustomElementInterface.cpp: Added. Abstracts an author-defined class associated with a custom element. It's a Active DOM object and lives until the associated document dies. (WebCore::JSCustomElementInterface::JSCustomElementInterface): (WebCore::JSCustomElementInterface::~JSCustomElementInterface): * bindings/js/JSCustomElementInterface.h: Added. (WebCore::JSCustomElementInterface::create): (WebCore::JSCustomElementInterface::scriptExecutionContext): (WebCore::JSCustomElementInterface::constructor): * bindings/js/JSDocumentCustom.cpp: (WebCore::JSDocument::defineCustomElement): Added. Define a custom element by associating a tag name with an author defined JS class after validating arguments. * bindings/js/JSHTMLElementCustom.cpp: (WebCore::constructJSHTMLElement): Added. Look up the tag name based on new.target if one is not specified. If a tag name is specified, check that new.target is associated with the tag name. * dom/CustomElementDefinitions.cpp: Added. (WebCore::CustomElementDefinitions::checkName): Added. Restricts tag names similarly to http://w3c.github.io/webcomponents/spec/custom/#dfn-custom-element-type (WebCore::CustomElementDefinitions::defineElement): Added. Associates a JS class with a tag name. (WebCore::CustomElementDefinitions::findInterface): Added. Finds a JS class by a tag name. (WebCore::CustomElementDefinitions::findName): Added. Finds a tag name by a JS class. * dom/CustomElementDefinitions.h: Added. (WebCore::CustomElementDefinitions::CustomElementInfo): Added. * dom/Document.cpp: (WebCore::Document::ensureCustomElementDefinitions): Added. * dom/Document.h: (WebCore::Document::customElementDefinitions): Added. * dom/Document.idl: * html/HTMLElement.idl: LayoutTests: Added tests for document.defineCustomElement and instantiating custom elements. * TestExpectations: Skipped the tests on non-Mac ports. * fast/custom-elements: Added. * fast/custom-elements/Document-defineCustomElement-expected.txt: Added. * fast/custom-elements/Document-defineCustomElement.html: Added. * fast/custom-elements/HTMLElement-constructor-expected.txt: Added. * fast/custom-elements/HTMLElement-constructor.html: Added. * platform/mac/TestExpectations: Canonical link: https://commits.webkit.org/171208@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@195087 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-01-15 02:59:03 +00:00
Only update connected custom elements https://bugs.webkit.org/show_bug.cgi?id=161480 Reviewed by Yusuke Suzuki. Source/WebCore: In the latest specs, creating an element only upgrades an element if the custom element had already been defined: https://dom.spec.whatwg.org/#concept-create-element Otherwise, an element remains unresolved until it gets connected to the document associated with the global object: https://dom.spec.whatwg.org/#concept-node-insert This patch removes the upgrade candidate map in CustomElementRegistry, and traverses the entire document associated with global object (DOMWindow) in addElementDefinition: https://html.spec.whatwg.org/#dom-customelementregistry-define The traversal is done in the shadow-including tree order (different from depth-first preorder traversal of flat tree) since it doesn't enter slots and children of shadow hosts are always visited even if they are not assigned to a slot: https://dom.spec.whatwg.org/#concept-shadow-including-tree-order Test: fast/custom-elements/enqueue-custom-element-upgrade-reaction.html * bindings/js/JSCustomElementInterface.cpp: (WebCore::JSCustomElementInterface::upgradeElement): Assert that the element being upgraded as the same qualified name as the custom element interface. * bindings/js/JSCustomElementRegistryCustom.cpp: (WebCore::JSCustomElementRegistry::define): Moved the code to resolve the promise from here to addElementDefinition. Also cleaned up the code to extract callbacks a little. * dom/CustomElementReactionQueue.cpp: (WebCore::CustomElementReactionQueue::enqueueElementUpgrade): Added an assertion. (WebCore::CustomElementReactionQueue::enqueueElementUpgradeIfDefined): Added. Upgrade an element if the custom element had already been defined. * dom/CustomElementReactionQueue.h: * dom/CustomElementRegistry.cpp: (WebCore::CustomElementRegistry::create): Stores the reference to DOMWindow to find its document in addElementDefinition. (WebCore::CustomElementRegistry::CustomElementRegistry): Ditto. (WebCore::enqueueUpgradeInShadowIncludingTreeOrder): Added. Enqueue upgrade reactions in shadow-including tree order. (WebCore::CustomElementRegistry::addElementDefinition): Upgrade all unresolved elements that matches this definition and resolve the the promise returned by "whenDefined" if there is any. (WebCore::CustomElementRegistry::addUpgradeCandidate): Deleted. (WebCore::CustomElementRegistry::findInterface): Added a new variant that takes an element. * dom/CustomElementRegistry.h: * dom/Document.cpp: (WebCore::createUpgradeCandidateElement): No longer takes DOMWindow since we don't upgrade synchronously here. It's also wrong not to mark the element as unresolved custom element in a document without a browsing context per new semantics. (WebCore::createHTMLElementWithNameValidation): Ditto. (WebCore::createFallbackHTMLElement): Ditto. * dom/Element.cpp: (WebCore::Element::insertedInto): Enqueue an upgrade reaction if this is an unsolved custom element and there is now a definition for it (the latter condition is checked in enqueueElementUpgradeIfDefined). * html/parser/HTMLConstructionSite.cpp: (WebCore::HTMLConstructionSite::createHTMLElementOrFindCustomElementInterface): Don't upgrade this element until it gets connected to a document in Element::insertedInto. * page/DOMWindow.cpp: (WebCore::DOMWindow::ensureCustomElementRegistry): LayoutTests: Added a W3c-style testharness.js test for https://html.spec.whatwg.org/#enqueue-a-custom-element-upgrade-reaction and added more test cases for :defined and customElements.define. * fast/custom-elements/CustomElementRegistry.html: Revised descriptions for "get" and "whenDefined" test cases consistent with ones for "define". * fast/custom-elements/defined-pseudo-class-expected.txt: * fast/custom-elements/defined-pseudo-class.html: * fast/custom-elements/enqueue-custom-element-upgrade-reaction-expected.txt: Added. * fast/custom-elements/enqueue-custom-element-upgrade-reaction.html: Added. * fast/custom-elements/resources/document-types.js: (create): Canonical link: https://commits.webkit.org/179676@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@205340 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-02 06:17:17 +00:00
#include "CustomElementReactionQueue.h"
#include "DOMWindow.h"
Add document.defineCustomElement https://bugs.webkit.org/show_bug.cgi?id=153092 Reviewed by Chris Dumez. Source/WebCore: Added document.defineCustomElement and added a constructor to HTMLElement which can be called as "super" in a subclass of HTMLElement. This is a prototype of new custom elements API and willfully violates the current specification at http://w3c.github.io/webcomponents/spec/custom/ Each author defined class can define multiple elements using distinct tag names. In such cases, the super call must specify the tag name. e.g. class SomeCustomElement extends HTMLElement { constructor(name) { super(name); } } document.defineCustomElement('some-custom-element', SomeCustomElement); document.defineCustomElement('other-custom-element', SomeCustomElement); new SomeCustomElement('some-custom-element'); When a class is associated with exactly one tag name, the argument can be omitted. e.g. class AnotherCustomElement extends HTMLElement {} document.defineCustomElement('another-custom-element', AnotherCustomElement); new AnotherCustomElement(); We allow only subclassing of HTMLElement and only in (X)HTML namespace. Tests: fast/custom-elements/Document-defineCustomElement.html fast/custom-elements/HTMLElement-constructor.html * CMakeLists.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSCustomElementInterface.cpp: Added. Abstracts an author-defined class associated with a custom element. It's a Active DOM object and lives until the associated document dies. (WebCore::JSCustomElementInterface::JSCustomElementInterface): (WebCore::JSCustomElementInterface::~JSCustomElementInterface): * bindings/js/JSCustomElementInterface.h: Added. (WebCore::JSCustomElementInterface::create): (WebCore::JSCustomElementInterface::scriptExecutionContext): (WebCore::JSCustomElementInterface::constructor): * bindings/js/JSDocumentCustom.cpp: (WebCore::JSDocument::defineCustomElement): Added. Define a custom element by associating a tag name with an author defined JS class after validating arguments. * bindings/js/JSHTMLElementCustom.cpp: (WebCore::constructJSHTMLElement): Added. Look up the tag name based on new.target if one is not specified. If a tag name is specified, check that new.target is associated with the tag name. * dom/CustomElementDefinitions.cpp: Added. (WebCore::CustomElementDefinitions::checkName): Added. Restricts tag names similarly to http://w3c.github.io/webcomponents/spec/custom/#dfn-custom-element-type (WebCore::CustomElementDefinitions::defineElement): Added. Associates a JS class with a tag name. (WebCore::CustomElementDefinitions::findInterface): Added. Finds a JS class by a tag name. (WebCore::CustomElementDefinitions::findName): Added. Finds a tag name by a JS class. * dom/CustomElementDefinitions.h: Added. (WebCore::CustomElementDefinitions::CustomElementInfo): Added. * dom/Document.cpp: (WebCore::Document::ensureCustomElementDefinitions): Added. * dom/Document.h: (WebCore::Document::customElementDefinitions): Added. * dom/Document.idl: * html/HTMLElement.idl: LayoutTests: Added tests for document.defineCustomElement and instantiating custom elements. * TestExpectations: Skipped the tests on non-Mac ports. * fast/custom-elements: Added. * fast/custom-elements/Document-defineCustomElement-expected.txt: Added. * fast/custom-elements/Document-defineCustomElement.html: Added. * fast/custom-elements/HTMLElement-constructor-expected.txt: Added. * fast/custom-elements/HTMLElement-constructor.html: Added. * platform/mac/TestExpectations: Canonical link: https://commits.webkit.org/171208@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@195087 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-01-15 02:59:03 +00:00
#include "Document.h"
#include "JSCustomElementInterface.h"
Clean up some includes to make the build a bit faster: DOMPromise https://bugs.webkit.org/show_bug.cgi?id=202570 Reviewed by Chris Dumez. No new tests, just reorganizing. Apply some profile-guided optimizations to our headers. Get JSDOMPromiseDeferred.h and DOMPromiseProxy.h out of WebCore headers. One remains (FetchBodyConsumer.h); I leave it as an exercise to the reader. In my testing, this is worth a reliable 5-6% on the WebCore Build Benchmark. * Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp: * Modules/encryptedmedia/MediaKeySession.cpp: * Modules/encryptedmedia/MediaKeySession.h: * Modules/encryptedmedia/MediaKeySystemAccess.cpp: * Modules/encryptedmedia/MediaKeySystemAccess.h: * Modules/encryptedmedia/MediaKeys.cpp: * Modules/encryptedmedia/MediaKeys.h: * Modules/encryptedmedia/NavigatorEME.cpp: * Modules/encryptedmedia/NavigatorEME.h: * Modules/fetch/DOMWindowFetch.cpp: * Modules/fetch/DOMWindowFetch.h: * Modules/fetch/FetchBody.cpp: * Modules/fetch/FetchBody.h: * Modules/fetch/FetchLoader.cpp: * Modules/fetch/FetchLoader.h: * Modules/fetch/WorkerGlobalScopeFetch.cpp: * Modules/fetch/WorkerGlobalScopeFetch.h: * Modules/mediacapabilities/MediaCapabilities.cpp: * Modules/mediacapabilities/MediaCapabilities.h: * Modules/mediastream/MediaDevices.cpp: * Modules/mediastream/MediaDevices.h: * Modules/mediastream/MediaStreamTrack.cpp: * Modules/mediastream/MediaStreamTrack.h: * Modules/mediastream/PeerConnectionBackend.cpp: * Modules/mediastream/PeerConnectionBackend.h: * Modules/mediastream/RTCPeerConnection.cpp: * Modules/mediastream/RTCRtpReceiver.h: * Modules/mediastream/RTCRtpSenderBackend.h: * Modules/mediastream/UserMediaRequest.cpp: * Modules/mediastream/UserMediaRequest.h: * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp: * Modules/mediastream/libwebrtc/LibWebRTCRtpSenderBackend.cpp: * Modules/mediastream/libwebrtc/LibWebRTCRtpTransceiverBackend.cpp: * Modules/paymentrequest/PaymentRequest.cpp: * Modules/paymentrequest/PaymentRequest.h: * Modules/paymentrequest/PaymentResponse.cpp: * Modules/paymentrequest/PaymentResponse.h: * Modules/streams/ReadableStreamSource.h: * Modules/webaudio/AudioContext.h: * Modules/webauthn/AuthenticatorCoordinator.cpp: * Modules/webauthn/AuthenticatorCoordinator.h: * Modules/webauthn/PublicKeyCredential.h: * Modules/webgpu/WHLSL/WHLSLPreserveVariableLifetimes.cpp: * Modules/webgpu/WHLSL/WHLSLStandardLibraryUtilities.cpp: * Modules/webgpu/WebGPU.cpp: * Modules/webgpu/WebGPU.h: * Modules/webgpu/WebGPUAdapter.cpp: * Modules/webgpu/WebGPUAdapter.h: * Modules/webgpu/WebGPUBuffer.cpp: * Modules/webgpu/WebGPUBuffer.h: * Modules/webgpu/WebGPUDevice.cpp: * Modules/webgpu/WebGPUDevice.h: * Modules/webvr/NavigatorWebVR.cpp: * Modules/webvr/NavigatorWebVR.h: * Modules/webvr/VRDisplay.cpp: * Modules/webvr/VRDisplay.h: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * animation/KeyframeEffect.cpp: * animation/WebAnimation.cpp: * animation/WebAnimation.h: * bindings/js/CachedModuleScriptLoader.cpp: * bindings/js/CachedModuleScriptLoaderClient.h: * bindings/js/JSDOMPromiseDeferred.h: * bindings/js/JSHTMLTemplateElementCustom.cpp: * bindings/js/JSImageDataCustom.cpp: * bindings/js/JSReadableStreamSourceCustom.cpp: * bindings/js/JSWebAnimationCustom.cpp: * bindings/js/JSWorkerGlobalScopeBase.cpp: * bindings/js/JSWorkerGlobalScopeCustom.cpp: * bindings/js/JSWorkletGlobalScopeBase.cpp: * bindings/js/ScriptModuleLoader.cpp: * css/FontFace.cpp: * css/FontFace.h: * css/FontFaceSet.cpp: * css/FontFaceSet.h: * dom/CustomElementRegistry.cpp: * dom/DeviceOrientationOrMotionEvent.cpp: * dom/DeviceOrientationOrMotionEvent.h: * dom/MouseEvent.cpp: * dom/MouseEvent.h: * html/CustomPaintCanvas.h: * html/ImageBitmap.cpp: * html/ImageBitmap.h: * html/OffscreenCanvas.cpp: * html/OffscreenCanvas.h: * loader/ImageLoader.cpp: * loader/ImageLoader.h: * page/DOMWindow.cpp: * page/Navigator.h: * platform/graphics/CustomPaintImage.cpp: * testing/Internals.cpp: * testing/Internals.h: * testing/ServiceWorkerInternals.h: * testing/ServiceWorkerInternals.mm: * workers/service/ServiceWorkerContainer.cpp: * workers/service/ServiceWorkerContainer.h: * workers/service/ServiceWorkerJob.h: * workers/service/ServiceWorkerRegistration.cpp: * workers/service/ServiceWorkerRegistration.h: * worklets/PaintWorkletGlobalScope.cpp: Canonical link: https://commits.webkit.org/216069@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@250735 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-10-04 19:07:22 +00:00
#include "JSDOMPromiseDeferred.h"
Add document.defineCustomElement https://bugs.webkit.org/show_bug.cgi?id=153092 Reviewed by Chris Dumez. Source/WebCore: Added document.defineCustomElement and added a constructor to HTMLElement which can be called as "super" in a subclass of HTMLElement. This is a prototype of new custom elements API and willfully violates the current specification at http://w3c.github.io/webcomponents/spec/custom/ Each author defined class can define multiple elements using distinct tag names. In such cases, the super call must specify the tag name. e.g. class SomeCustomElement extends HTMLElement { constructor(name) { super(name); } } document.defineCustomElement('some-custom-element', SomeCustomElement); document.defineCustomElement('other-custom-element', SomeCustomElement); new SomeCustomElement('some-custom-element'); When a class is associated with exactly one tag name, the argument can be omitted. e.g. class AnotherCustomElement extends HTMLElement {} document.defineCustomElement('another-custom-element', AnotherCustomElement); new AnotherCustomElement(); We allow only subclassing of HTMLElement and only in (X)HTML namespace. Tests: fast/custom-elements/Document-defineCustomElement.html fast/custom-elements/HTMLElement-constructor.html * CMakeLists.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSCustomElementInterface.cpp: Added. Abstracts an author-defined class associated with a custom element. It's a Active DOM object and lives until the associated document dies. (WebCore::JSCustomElementInterface::JSCustomElementInterface): (WebCore::JSCustomElementInterface::~JSCustomElementInterface): * bindings/js/JSCustomElementInterface.h: Added. (WebCore::JSCustomElementInterface::create): (WebCore::JSCustomElementInterface::scriptExecutionContext): (WebCore::JSCustomElementInterface::constructor): * bindings/js/JSDocumentCustom.cpp: (WebCore::JSDocument::defineCustomElement): Added. Define a custom element by associating a tag name with an author defined JS class after validating arguments. * bindings/js/JSHTMLElementCustom.cpp: (WebCore::constructJSHTMLElement): Added. Look up the tag name based on new.target if one is not specified. If a tag name is specified, check that new.target is associated with the tag name. * dom/CustomElementDefinitions.cpp: Added. (WebCore::CustomElementDefinitions::checkName): Added. Restricts tag names similarly to http://w3c.github.io/webcomponents/spec/custom/#dfn-custom-element-type (WebCore::CustomElementDefinitions::defineElement): Added. Associates a JS class with a tag name. (WebCore::CustomElementDefinitions::findInterface): Added. Finds a JS class by a tag name. (WebCore::CustomElementDefinitions::findName): Added. Finds a tag name by a JS class. * dom/CustomElementDefinitions.h: Added. (WebCore::CustomElementDefinitions::CustomElementInfo): Added. * dom/Document.cpp: (WebCore::Document::ensureCustomElementDefinitions): Added. * dom/Document.h: (WebCore::Document::customElementDefinitions): Added. * dom/Document.idl: * html/HTMLElement.idl: LayoutTests: Added tests for document.defineCustomElement and instantiating custom elements. * TestExpectations: Skipped the tests on non-Mac ports. * fast/custom-elements: Added. * fast/custom-elements/Document-defineCustomElement-expected.txt: Added. * fast/custom-elements/Document-defineCustomElement.html: Added. * fast/custom-elements/HTMLElement-constructor-expected.txt: Added. * fast/custom-elements/HTMLElement-constructor.html: Added. * platform/mac/TestExpectations: Canonical link: https://commits.webkit.org/171208@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@195087 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-01-15 02:59:03 +00:00
#include "MathMLNames.h"
#include "QualifiedName.h"
Only update connected custom elements https://bugs.webkit.org/show_bug.cgi?id=161480 Reviewed by Yusuke Suzuki. Source/WebCore: In the latest specs, creating an element only upgrades an element if the custom element had already been defined: https://dom.spec.whatwg.org/#concept-create-element Otherwise, an element remains unresolved until it gets connected to the document associated with the global object: https://dom.spec.whatwg.org/#concept-node-insert This patch removes the upgrade candidate map in CustomElementRegistry, and traverses the entire document associated with global object (DOMWindow) in addElementDefinition: https://html.spec.whatwg.org/#dom-customelementregistry-define The traversal is done in the shadow-including tree order (different from depth-first preorder traversal of flat tree) since it doesn't enter slots and children of shadow hosts are always visited even if they are not assigned to a slot: https://dom.spec.whatwg.org/#concept-shadow-including-tree-order Test: fast/custom-elements/enqueue-custom-element-upgrade-reaction.html * bindings/js/JSCustomElementInterface.cpp: (WebCore::JSCustomElementInterface::upgradeElement): Assert that the element being upgraded as the same qualified name as the custom element interface. * bindings/js/JSCustomElementRegistryCustom.cpp: (WebCore::JSCustomElementRegistry::define): Moved the code to resolve the promise from here to addElementDefinition. Also cleaned up the code to extract callbacks a little. * dom/CustomElementReactionQueue.cpp: (WebCore::CustomElementReactionQueue::enqueueElementUpgrade): Added an assertion. (WebCore::CustomElementReactionQueue::enqueueElementUpgradeIfDefined): Added. Upgrade an element if the custom element had already been defined. * dom/CustomElementReactionQueue.h: * dom/CustomElementRegistry.cpp: (WebCore::CustomElementRegistry::create): Stores the reference to DOMWindow to find its document in addElementDefinition. (WebCore::CustomElementRegistry::CustomElementRegistry): Ditto. (WebCore::enqueueUpgradeInShadowIncludingTreeOrder): Added. Enqueue upgrade reactions in shadow-including tree order. (WebCore::CustomElementRegistry::addElementDefinition): Upgrade all unresolved elements that matches this definition and resolve the the promise returned by "whenDefined" if there is any. (WebCore::CustomElementRegistry::addUpgradeCandidate): Deleted. (WebCore::CustomElementRegistry::findInterface): Added a new variant that takes an element. * dom/CustomElementRegistry.h: * dom/Document.cpp: (WebCore::createUpgradeCandidateElement): No longer takes DOMWindow since we don't upgrade synchronously here. It's also wrong not to mark the element as unresolved custom element in a document without a browsing context per new semantics. (WebCore::createHTMLElementWithNameValidation): Ditto. (WebCore::createFallbackHTMLElement): Ditto. * dom/Element.cpp: (WebCore::Element::insertedInto): Enqueue an upgrade reaction if this is an unsolved custom element and there is now a definition for it (the latter condition is checked in enqueueElementUpgradeIfDefined). * html/parser/HTMLConstructionSite.cpp: (WebCore::HTMLConstructionSite::createHTMLElementOrFindCustomElementInterface): Don't upgrade this element until it gets connected to a document in Element::insertedInto. * page/DOMWindow.cpp: (WebCore::DOMWindow::ensureCustomElementRegistry): LayoutTests: Added a W3c-style testharness.js test for https://html.spec.whatwg.org/#enqueue-a-custom-element-upgrade-reaction and added more test cases for :defined and customElements.define. * fast/custom-elements/CustomElementRegistry.html: Revised descriptions for "get" and "whenDefined" test cases consistent with ones for "define". * fast/custom-elements/defined-pseudo-class-expected.txt: * fast/custom-elements/defined-pseudo-class.html: * fast/custom-elements/enqueue-custom-element-upgrade-reaction-expected.txt: Added. * fast/custom-elements/enqueue-custom-element-upgrade-reaction.html: Added. * fast/custom-elements/resources/document-types.js: (create): Canonical link: https://commits.webkit.org/179676@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@205340 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-02 06:17:17 +00:00
#include "ShadowRoot.h"
Implement customElements.upgrade() https://bugs.webkit.org/show_bug.cgi?id=183397 Reviewed by Frédéric Wang. LayoutTests/imported/w3c: Rebaseline the test now that we're passing. * web-platform-tests/custom-elements/custom-element-registry/upgrade-expected.txt: Source/WebCore: Added the support to upgrade custom elements directly. Ordinarily, custom elements get upgraded as they are inserted / connected into a document but some script libraries and authors want to be able to upgrade them before that. Also see https://github.com/w3c/webcomponents/issues/710 Implemented the method as specified at: https://html.spec.whatwg.org/multipage/custom-elements.html#dom-customelementregistry-upgrade When invoked, the upgrade(root) method must run these steps: 1. Let candidates be a list of all of root's shadow-including inclusive descendant elements, in shadow-including tree order. 2. For each candidate of candidates, try to upgrade candidate. Tests: imported/w3c/web-platform-tests/custom-elements/custom-element-registry/upgrade.html * dom/CustomElementReactionQueue.cpp: (WebCore::CustomElementReactionQueue::enqueueElementUpgradeIfDefined): Removed the assertion that the upgraded element is connected since the whole point of this API is to upgrade a disconnected element. * dom/CustomElementRegistry.cpp: (WebCore::upgradeElementsInShadowIncludingdescendants): Added. (WebCore::CustomElementRegistry::upgrade): Added. * dom/CustomElementRegistry.h: Forward declare DeferredPromise instead of unnecessarily including JSDOMPromiseDeferred.h. * dom/CustomElementRegistry.idl: * dom/Element.cpp: (WebCore::Element::insertedIntoAncestor): Moved the assertion here. Canonical link: https://commits.webkit.org/203374@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234507 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-08-02 19:25:23 +00:00
#include "TypedElementDescendantIterator.h"
Remove WebCore/ForwardingHeaders directory https://bugs.webkit.org/show_bug.cgi?id=182347 Reviewed by Keith Miller. Source/ThirdParty: * gtest/CMakeLists.txt: * gtest/include/gtest/internal/gtest-port.h: Source/WebCore: No new tests. No change in behavior. * CMakeLists.txt: * ForwardingHeaders/bindings/ScriptFunctionCall.h: Removed. * ForwardingHeaders/bindings/ScriptObject.h: Removed. * ForwardingHeaders/bindings/ScriptValue.h: Removed. * ForwardingHeaders/builtins/BuiltinNames.h: Removed. * ForwardingHeaders/builtins/BuiltinUtils.h: Removed. * ForwardingHeaders/builtins/JSCBuiltins.h: Removed. * ForwardingHeaders/bytecode/CodeBlock.h: Removed. * ForwardingHeaders/bytecode/SpeculatedType.h: Removed. * ForwardingHeaders/bytecode/UnlinkedFunctionExecutable.h: Removed. * ForwardingHeaders/debugger/Debugger.h: Removed. * ForwardingHeaders/domjit/DOMJITAbstractHeap.h: Removed. * ForwardingHeaders/domjit/DOMJITEffect.h: Removed. * ForwardingHeaders/domjit/DOMJITGetterSetter.h: Removed. * ForwardingHeaders/domjit/DOMJITHeapRange.h: Removed. * ForwardingHeaders/domjit/DOMJITSignature.h: Removed. * ForwardingHeaders/heap/BlockDirectoryInlines.h: Removed. * ForwardingHeaders/heap/DeleteAllCodeEffort.h: Removed. * ForwardingHeaders/heap/FastMallocAlignedMemoryAllocator.h: Removed. * ForwardingHeaders/heap/GCActivityCallback.h: Removed. * ForwardingHeaders/heap/GCFinalizationCallback.h: Removed. * ForwardingHeaders/heap/HandleTypes.h: Removed. * ForwardingHeaders/heap/Heap.h: Removed. * ForwardingHeaders/heap/HeapInlines.h: Removed. * ForwardingHeaders/heap/HeapObserver.h: Removed. * ForwardingHeaders/heap/IncrementalSweeper.h: Removed. * ForwardingHeaders/heap/LockDuringMarking.h: Removed. * ForwardingHeaders/heap/MachineStackMarker.h: Removed. * ForwardingHeaders/heap/MarkedBlockInlines.h: Removed. * ForwardingHeaders/heap/MarkingConstraint.h: Removed. * ForwardingHeaders/heap/RunningScope.h: Removed. * ForwardingHeaders/heap/SimpleMarkingConstraint.h: Removed. * ForwardingHeaders/heap/SlotVisitor.h: Removed. * ForwardingHeaders/heap/SlotVisitorInlines.h: Removed. * ForwardingHeaders/heap/Strong.h: Removed. * ForwardingHeaders/heap/StrongInlines.h: Removed. * ForwardingHeaders/heap/SubspaceInlines.h: Removed. * ForwardingHeaders/heap/ThreadLocalCache.h: Removed. * ForwardingHeaders/heap/Weak.h: Removed. * ForwardingHeaders/heap/WeakInlines.h: Removed. * ForwardingHeaders/inspector/ConsoleMessage.h: Removed. * ForwardingHeaders/inspector/ContentSearchUtilities.h: Removed. * ForwardingHeaders/inspector/IdentifiersFactory.h: Removed. * ForwardingHeaders/inspector/InjectedScript.h: Removed. * ForwardingHeaders/inspector/InjectedScriptBase.h: Removed. * ForwardingHeaders/inspector/InjectedScriptHost.h: Removed. * ForwardingHeaders/inspector/InjectedScriptManager.h: Removed. * ForwardingHeaders/inspector/InjectedScriptModule.h: Removed. * ForwardingHeaders/inspector/InspectorAgentBase.h: Removed. * ForwardingHeaders/inspector/InspectorAgentRegistry.h: Removed. * ForwardingHeaders/inspector/InspectorBackendDispatcher.h: Removed. * ForwardingHeaders/inspector/InspectorBackendDispatchers.h: Removed. * ForwardingHeaders/inspector/InspectorEnvironment.h: Removed. * ForwardingHeaders/inspector/InspectorFrontendChannel.h: Removed. * ForwardingHeaders/inspector/InspectorFrontendDispatchers.h: Removed. * ForwardingHeaders/inspector/InspectorFrontendRouter.h: Removed. * ForwardingHeaders/inspector/InspectorProtocolObjects.h: Removed. * ForwardingHeaders/inspector/InspectorProtocolTypes.h: Removed. * ForwardingHeaders/inspector/PerGlobalObjectWrapperWorld.h: Removed. * ForwardingHeaders/inspector/ScriptArguments.h: Removed. * ForwardingHeaders/inspector/ScriptBreakpoint.h: Removed. * ForwardingHeaders/inspector/ScriptCallFrame.h: Removed. * ForwardingHeaders/inspector/ScriptCallStack.h: Removed. * ForwardingHeaders/inspector/ScriptCallStackFactory.h: Removed. * ForwardingHeaders/inspector/ScriptDebugListener.h: Removed. * ForwardingHeaders/inspector/ScriptDebugServer.h: Removed. * ForwardingHeaders/inspector/agents/InspectorAgent.h: Removed. * ForwardingHeaders/inspector/agents/InspectorConsoleAgent.h: Removed. * ForwardingHeaders/inspector/agents/InspectorDebuggerAgent.h: Removed. * ForwardingHeaders/inspector/agents/InspectorHeapAgent.h: Removed. * ForwardingHeaders/inspector/agents/InspectorRuntimeAgent.h: Removed. * ForwardingHeaders/inspector/agents/InspectorScriptProfilerAgent.h: Removed. * ForwardingHeaders/interpreter/CallFrame.h: Removed. * ForwardingHeaders/interpreter/FrameTracers.h: Removed. * ForwardingHeaders/interpreter/ShadowChicken.h: Removed. * ForwardingHeaders/interpreter/StackVisitor.h: Removed. * ForwardingHeaders/jit/JITCode.h: Removed. * ForwardingHeaders/jit/JITMathICForwards.h: Removed. * ForwardingHeaders/jit/Snippet.h: Removed. * ForwardingHeaders/jit/SnippetParams.h: Removed. * ForwardingHeaders/jit/SpillRegistersMode.h: Removed. * ForwardingHeaders/masm/X86Assembler.h: Removed. * ForwardingHeaders/parser/ParserError.h: Removed. * ForwardingHeaders/parser/SourceCode.h: Removed. * ForwardingHeaders/parser/SourceProvider.h: Removed. * ForwardingHeaders/parser/SourceProviderCache.h: Removed. * ForwardingHeaders/profiler/ProfilerDatabase.h: Removed. * ForwardingHeaders/runtime/ArgList.h: Removed. * ForwardingHeaders/runtime/ArrayBuffer.h: Removed. * ForwardingHeaders/runtime/ArrayBufferView.h: Removed. * ForwardingHeaders/runtime/ArrayPrototype.h: Removed. * ForwardingHeaders/runtime/AuxiliaryBarrierInlines.h: Removed. * ForwardingHeaders/runtime/BooleanObject.h: Removed. * ForwardingHeaders/runtime/CallData.h: Removed. * ForwardingHeaders/runtime/CatchScope.h: Removed. * ForwardingHeaders/runtime/CommonIdentifiers.h: Removed. * ForwardingHeaders/runtime/Completion.h: Removed. * ForwardingHeaders/runtime/ConfigFile.h: Removed. * ForwardingHeaders/runtime/ConsoleClient.h: Removed. * ForwardingHeaders/runtime/ConsoleTypes.h: Removed. * ForwardingHeaders/runtime/ConstructAbility.h: Removed. * ForwardingHeaders/runtime/ConstructData.h: Removed. * ForwardingHeaders/runtime/DataView.h: Removed. * ForwardingHeaders/runtime/DateInstance.h: Removed. * ForwardingHeaders/runtime/Error.h: Removed. * ForwardingHeaders/runtime/ErrorHandlingScope.h: Removed. * ForwardingHeaders/runtime/ErrorInstance.h: Removed. * ForwardingHeaders/runtime/ErrorPrototype.h: Removed. * ForwardingHeaders/runtime/Exception.h: Removed. * ForwardingHeaders/runtime/ExceptionHelpers.h: Removed. * ForwardingHeaders/runtime/Float32Array.h: Removed. * ForwardingHeaders/runtime/Float64Array.h: Removed. * ForwardingHeaders/runtime/FunctionConstructor.h: Removed. * ForwardingHeaders/runtime/FunctionExecutable.h: Removed. * ForwardingHeaders/runtime/FunctionPrototype.h: Removed. * ForwardingHeaders/runtime/HashMapImpl.h: Removed. * ForwardingHeaders/runtime/Identifier.h: Removed. * ForwardingHeaders/runtime/IdentifierInlines.h: Removed. * ForwardingHeaders/runtime/InitializeThreading.h: Removed. * ForwardingHeaders/runtime/Int16Array.h: Removed. * ForwardingHeaders/runtime/Int32Array.h: Removed. * ForwardingHeaders/runtime/Int8Array.h: Removed. * ForwardingHeaders/runtime/InternalFunction.h: Removed. * ForwardingHeaders/runtime/Intrinsic.h: Removed. * ForwardingHeaders/runtime/IterationKind.h: Removed. * ForwardingHeaders/runtime/IteratorOperations.h: Removed. * ForwardingHeaders/runtime/IteratorPrototype.h: Removed. * ForwardingHeaders/runtime/JSAPIValueWrapper.h: Removed. * ForwardingHeaders/runtime/JSArray.h: Removed. * ForwardingHeaders/runtime/JSArrayBuffer.h: Removed. * ForwardingHeaders/runtime/JSArrayBufferView.h: Removed. * ForwardingHeaders/runtime/JSCInlines.h: Removed. * ForwardingHeaders/runtime/JSCJSValue.h: Removed. * ForwardingHeaders/runtime/JSCJSValueInlines.h: Removed. * ForwardingHeaders/runtime/JSCallee.h: Removed. * ForwardingHeaders/runtime/JSCell.h: Removed. * ForwardingHeaders/runtime/JSCellInlines.h: Removed. * ForwardingHeaders/runtime/JSDataView.h: Removed. * ForwardingHeaders/runtime/JSDestructibleObject.h: Removed. * ForwardingHeaders/runtime/JSDestructibleObjectHeapCellType.h: Removed. * ForwardingHeaders/runtime/JSExportMacros.h: Removed. * ForwardingHeaders/runtime/JSFunction.h: Removed. * ForwardingHeaders/runtime/JSGlobalObject.h: Removed. * ForwardingHeaders/runtime/JSGlobalObjectInlines.h: Removed. * ForwardingHeaders/runtime/JSInternalPromise.h: Removed. * ForwardingHeaders/runtime/JSInternalPromiseDeferred.h: Removed. * ForwardingHeaders/runtime/JSLock.h: Removed. * ForwardingHeaders/runtime/JSMap.h: Removed. * ForwardingHeaders/runtime/JSMapIterator.h: Removed. * ForwardingHeaders/runtime/JSModuleLoader.h: Removed. * ForwardingHeaders/runtime/JSModuleRecord.h: Removed. * ForwardingHeaders/runtime/JSNativeStdFunction.h: Removed. * ForwardingHeaders/runtime/JSONObject.h: Removed. * ForwardingHeaders/runtime/JSObject.h: Removed. * ForwardingHeaders/runtime/JSObjectInlines.h: Removed. * ForwardingHeaders/runtime/JSPromise.h: Removed. * ForwardingHeaders/runtime/JSPromiseConstructor.h: Removed. * ForwardingHeaders/runtime/JSPromiseDeferred.h: Removed. * ForwardingHeaders/runtime/JSProxy.h: Removed. * ForwardingHeaders/runtime/JSRunLoopTimer.h: Removed. * ForwardingHeaders/runtime/JSScriptFetchParameters.h: Removed. * ForwardingHeaders/runtime/JSScriptFetcher.h: Removed. * ForwardingHeaders/runtime/JSSegmentedVariableObjectHeapCellType.h: Removed. * ForwardingHeaders/runtime/JSSet.h: Removed. * ForwardingHeaders/runtime/JSSetIterator.h: Removed. * ForwardingHeaders/runtime/JSSourceCode.h: Removed. * ForwardingHeaders/runtime/JSString.h: Removed. * ForwardingHeaders/runtime/JSTypedArrays.h: Removed. * ForwardingHeaders/runtime/JSWithScope.h: Removed. * ForwardingHeaders/runtime/Lookup.h: Removed. * ForwardingHeaders/runtime/MapBase.h: Removed. * ForwardingHeaders/runtime/MapData.h: Removed. * ForwardingHeaders/runtime/MapDataInlines.h: Removed. * ForwardingHeaders/runtime/MatchResult.h: Removed. * ForwardingHeaders/runtime/Microtask.h: Removed. * ForwardingHeaders/runtime/ObjectConstructor.h: Removed. * ForwardingHeaders/runtime/ObjectPrototype.h: Removed. * ForwardingHeaders/runtime/Operations.h: Removed. * ForwardingHeaders/runtime/PrivateName.h: Removed. * ForwardingHeaders/runtime/PromiseDeferredTimer.h: Removed. * ForwardingHeaders/runtime/PropertyNameArray.h: Removed. * ForwardingHeaders/runtime/Protect.h: Removed. * ForwardingHeaders/runtime/RegExp.h: Removed. * ForwardingHeaders/runtime/RegExpObject.h: Removed. * ForwardingHeaders/runtime/RuntimeFlags.h: Removed. * ForwardingHeaders/runtime/SamplingProfiler.h: Removed. * ForwardingHeaders/runtime/ScriptFetchParameters.h: Removed. * ForwardingHeaders/runtime/ScriptFetcher.h: Removed. * ForwardingHeaders/runtime/StringObject.h: Removed. * ForwardingHeaders/runtime/StringPrototype.h: Removed. * ForwardingHeaders/runtime/Structure.h: Removed. * ForwardingHeaders/runtime/StructureChain.h: Removed. * ForwardingHeaders/runtime/StructureInlines.h: Removed. * ForwardingHeaders/runtime/Symbol.h: Removed. * ForwardingHeaders/runtime/SymbolTable.h: Removed. * ForwardingHeaders/runtime/ThrowScope.h: Removed. * ForwardingHeaders/runtime/TypedArrayController.h: Removed. * ForwardingHeaders/runtime/TypedArrayInlines.h: Removed. * ForwardingHeaders/runtime/TypedArrays.h: Removed. * ForwardingHeaders/runtime/Uint16Array.h: Removed. * ForwardingHeaders/runtime/Uint32Array.h: Removed. * ForwardingHeaders/runtime/Uint8Array.h: Removed. * ForwardingHeaders/runtime/Uint8ClampedArray.h: Removed. * ForwardingHeaders/runtime/VM.h: Removed. * ForwardingHeaders/runtime/VMEntryScope.h: Removed. * ForwardingHeaders/runtime/Watchdog.h: Removed. * ForwardingHeaders/runtime/WeakGCMap.h: Removed. * ForwardingHeaders/runtime/WeakGCMapInlines.h: Removed. * ForwardingHeaders/runtime/WriteBarrier.h: Removed. * ForwardingHeaders/wasm/WasmModule.h: Removed. * ForwardingHeaders/wasm/js/JSWebAssemblyModule.h: Removed. * ForwardingHeaders/yarr/RegularExpression.h: Removed. * ForwardingHeaders/yarr/Yarr.h: Removed. * ForwardingHeaders/yarr/YarrInterpreter.h: Removed. * ForwardingHeaders/yarr/YarrJIT.h: Removed. * ForwardingHeaders/yarr/YarrPattern.h: Removed. * Modules/applepay/cocoa/PaymentMerchantSessionCocoa.mm: * Modules/encryptedmedia/MediaKeyMessageEvent.h: * Modules/encryptedmedia/MediaKeyMessageEventInit.h: * Modules/encryptedmedia/MediaKeyStatusMap.h: * Modules/encryptedmedia/legacy/LegacyCDM.h: * Modules/encryptedmedia/legacy/LegacyCDMSessionClearKey.cpp: * Modules/encryptedmedia/legacy/WebKitMediaKeyMessageEvent.cpp: * Modules/encryptedmedia/legacy/WebKitMediaKeyNeededEvent.cpp: * Modules/encryptedmedia/legacy/WebKitMediaKeySession.h: * Modules/encryptedmedia/legacy/WebKitMediaKeys.h: * Modules/fetch/FetchBody.cpp: * Modules/fetch/FetchRequestInit.h: * Modules/fetch/FetchResponse.h: * Modules/indexeddb/IDBCursor.cpp: * Modules/indexeddb/IDBCursor.h: * Modules/indexeddb/IDBCursorWithValue.cpp: * Modules/indexeddb/IDBDatabase.cpp: * Modules/indexeddb/IDBIndex.cpp: * Modules/indexeddb/IDBKey.cpp: * Modules/indexeddb/IDBKeyRange.cpp: * Modules/indexeddb/IDBObjectStore.cpp: * Modules/indexeddb/IDBRequest.cpp: * Modules/indexeddb/IDBRequest.h: * Modules/indexeddb/client/TransactionOperation.cpp: * Modules/indexeddb/server/MemoryObjectStore.cpp: * Modules/indexeddb/server/SQLiteIDBBackingStore.cpp: * Modules/indexeddb/server/UniqueIDBDatabase.cpp: * Modules/mediacontrols/MediaControlsHost.cpp: * Modules/mediasource/SourceBuffer.cpp: * Modules/mediastream/RTCDataChannel.cpp: * Modules/plugins/QuickTimePluginReplacement.mm: * Modules/webaudio/AsyncAudioDecoder.cpp: * Modules/webaudio/AudioBuffer.cpp: * Modules/webaudio/AudioBuffer.h: * Modules/webaudio/AudioContext.cpp: * Modules/webaudio/AudioContext.h: * Modules/webaudio/AudioParam.h: * Modules/webaudio/AudioParamTimeline.h: * Modules/webaudio/PeriodicWave.h: * Modules/webaudio/RealtimeAnalyser.cpp: * Modules/webaudio/RealtimeAnalyser.h: * Modules/webaudio/ScriptProcessorNode.cpp: * Modules/webaudio/WaveShaperProcessor.h: * Modules/webauthn/AuthenticatorResponse.h: * Modules/webauthn/PublicKeyCredential.h: * Modules/websockets/WebSocket.cpp: * Modules/websockets/WebSocketChannel.cpp: * Modules/websockets/WorkerThreadableWebSocketChannel.cpp: * Modules/webvr/VREyeParameters.h: * Modules/webvr/VRFrameData.h: * Modules/webvr/VRPose.h: * Modules/webvr/VRStageParameters.h: * PlatformWin.cmake: * bindings/IDLTypes.h: * bindings/js/BufferSource.h: * bindings/js/CachedScriptFetcher.h: * bindings/js/CachedScriptSourceProvider.h: * bindings/js/CallTracerTypes.h: * bindings/js/CommonVM.cpp: * bindings/js/DOMGCOutputConstraint.cpp: * bindings/js/DOMGCOutputConstraint.h: * bindings/js/GCController.cpp: * bindings/js/GCController.h: * bindings/js/IDBBindingUtilities.cpp: * bindings/js/JSCallbackData.cpp: * bindings/js/JSCallbackData.h: * bindings/js/JSCustomElementInterface.cpp: * bindings/js/JSCustomElementInterface.h: * bindings/js/JSCustomEventCustom.cpp: * bindings/js/JSCustomXPathNSResolver.cpp: * bindings/js/JSCustomXPathNSResolver.h: * bindings/js/JSDOMBinding.h: * bindings/js/JSDOMBuiltinConstructorBase.cpp: * bindings/js/JSDOMConstructorBase.cpp: * bindings/js/JSDOMConvertBase.h: * bindings/js/JSDOMConvertBufferSource.h: * bindings/js/JSDOMConvertDate.cpp: * bindings/js/JSDOMConvertInterface.h: * bindings/js/JSDOMConvertJSON.h: * bindings/js/JSDOMConvertNumbers.cpp: * bindings/js/JSDOMConvertNumbers.h: * bindings/js/JSDOMConvertObject.h: * bindings/js/JSDOMConvertRecord.h: * bindings/js/JSDOMConvertSequences.h: * bindings/js/JSDOMConvertStrings.cpp: * bindings/js/JSDOMConvertUnion.h: * bindings/js/JSDOMExceptionHandling.cpp: * bindings/js/JSDOMExceptionHandling.h: * bindings/js/JSDOMGlobalObject.cpp: * bindings/js/JSDOMGlobalObject.h: * bindings/js/JSDOMGlobalObjectTask.cpp: * bindings/js/JSDOMGuardedObject.h: * bindings/js/JSDOMIterator.cpp: * bindings/js/JSDOMIterator.h: * bindings/js/JSDOMMapLike.cpp: * bindings/js/JSDOMMapLike.h: * bindings/js/JSDOMPromise.cpp: * bindings/js/JSDOMPromise.h: * bindings/js/JSDOMPromiseDeferred.cpp: * bindings/js/JSDOMPromiseDeferred.h: * bindings/js/JSDOMWindowBase.cpp: * bindings/js/JSDOMWindowCustom.cpp: * bindings/js/JSDOMWindowProxy.cpp: * bindings/js/JSDOMWindowProxy.h: * bindings/js/JSDOMWrapper.cpp: * bindings/js/JSDOMWrapper.h: * bindings/js/JSDOMWrapperCache.cpp: * bindings/js/JSDOMWrapperCache.h: * bindings/js/JSDynamicDowncast.h: * bindings/js/JSErrorHandler.cpp: * bindings/js/JSEventCustom.cpp: * bindings/js/JSEventListener.cpp: * bindings/js/JSEventListener.h: * bindings/js/JSHTMLElementCustom.cpp: * bindings/js/JSHistoryCustom.cpp: * bindings/js/JSIDBCursorWithValueCustom.cpp: * bindings/js/JSIDBIndexCustom.cpp: * bindings/js/JSImageDataCustom.cpp: * bindings/js/JSLazyEventListener.cpp: * bindings/js/JSLocationCustom.cpp: * bindings/js/JSMainThreadExecState.h: * bindings/js/JSMainThreadExecStateInstrumentation.h: * bindings/js/JSMessageChannelCustom.cpp: * bindings/js/JSMessageEventCustom.cpp: * bindings/js/JSNodeIteratorCustom.cpp: * bindings/js/JSPopStateEventCustom.cpp: * bindings/js/JSReadableStreamPrivateConstructors.cpp: * bindings/js/JSTreeWalkerCustom.cpp: * bindings/js/JSWebGL2RenderingContextCustom.cpp: * bindings/js/JSWorkerGlobalScopeBase.cpp: * bindings/js/ReadableStreamDefaultController.cpp: * bindings/js/ReadableStreamDefaultController.h: * bindings/js/ScheduledAction.cpp: * bindings/js/ScheduledAction.h: * bindings/js/ScriptCachedFrameData.cpp: * bindings/js/ScriptCachedFrameData.h: * bindings/js/ScriptController.cpp: * bindings/js/ScriptController.h: * bindings/js/ScriptControllerMac.mm: * bindings/js/ScriptModuleLoader.cpp: * bindings/js/ScriptModuleLoader.h: * bindings/js/ScriptSourceCode.h: * bindings/js/ScriptState.cpp: * bindings/js/ScriptWrappable.h: * bindings/js/ScriptWrappableInlines.h: * bindings/js/SerializedScriptValue.cpp: * bindings/js/SerializedScriptValue.h: * bindings/js/StructuredClone.cpp: * bindings/js/WebCoreBuiltinNames.h: * bindings/js/WebCoreJSClientData.cpp: * bindings/js/WebCoreTypedArrayController.cpp: * bindings/js/WebCoreTypedArrayController.h: * bindings/js/WorkerScriptController.cpp: * bindings/js/WorkerScriptController.h: * bridge/NP_jsobject.cpp: * bridge/c/CRuntimeObject.cpp: * bridge/c/c_class.cpp: * bridge/c/c_instance.cpp: * bridge/c/c_runtime.cpp: * bridge/c/c_utility.cpp: * bridge/c/c_utility.h: * bridge/jsc/BridgeJSC.cpp: * bridge/jsc/BridgeJSC.h: * bridge/npruntime.cpp: * bridge/objc/ObjCRuntimeObject.mm: * bridge/objc/WebScriptObject.mm: * bridge/objc/WebScriptObjectPrivate.h: * bridge/objc/objc_instance.mm: * bridge/objc/objc_runtime.h: * bridge/objc/objc_runtime.mm: * bridge/objc/objc_utility.h: * bridge/objc/objc_utility.mm: * bridge/runtime_array.cpp: * bridge/runtime_array.h: * bridge/runtime_method.cpp: * bridge/runtime_method.h: * bridge/runtime_object.cpp: * bridge/runtime_object.h: * bridge/runtime_root.cpp: * bridge/runtime_root.h: * crypto/SubtleCrypto.cpp: * crypto/SubtleCrypto.h: * crypto/gcrypt/CryptoKeyRSAGCrypt.cpp: * crypto/keys/CryptoRsaKeyAlgorithm.h: * crypto/mac/CryptoKeyRSAMac.cpp: * crypto/parameters/CryptoAlgorithmEcdsaParams.h: * crypto/parameters/CryptoAlgorithmHkdfParams.h: * crypto/parameters/CryptoAlgorithmHmacKeyParams.h: * crypto/parameters/CryptoAlgorithmPbkdf2Params.h: * crypto/parameters/CryptoAlgorithmRsaHashedImportParams.h: * crypto/parameters/CryptoAlgorithmRsaHashedKeyGenParams.h: * crypto/parameters/CryptoAlgorithmRsaKeyGenParams.h: * css/CSSFontFaceSource.h: * css/DOMMatrixReadOnly.cpp: * css/DOMMatrixReadOnly.h: * css/FontFace.cpp: * dom/CustomElementReactionQueue.cpp: * dom/CustomElementRegistry.cpp: * dom/CustomEvent.cpp: * dom/CustomEvent.h: * dom/Document.cpp: * dom/Document.h: * dom/ErrorEvent.cpp: * dom/ErrorEvent.h: * dom/LoadableScript.h: * dom/MessageEvent.cpp: * dom/MessageEvent.h: * dom/ModuleFetchParameters.h: * dom/PopStateEvent.cpp: * dom/PopStateEvent.h: * dom/PromiseRejectionEvent.cpp: * dom/PromiseRejectionEvent.h: * dom/RejectedPromiseTracker.cpp: * dom/RejectedPromiseTracker.h: * dom/ScriptExecutionContext.cpp: * dom/ScriptExecutionContext.h: * dom/TextEncoder.cpp: * dom/TextEncoder.h: * domjit/DOMJITHelpers.h: * domjit/DOMJITIDLTypeFilter.h: * domjit/JSDocumentDOMJIT.cpp: * domjit/JSNodeDOMJIT.cpp: * fileapi/BlobBuilder.cpp: * fileapi/FileReader.cpp: * fileapi/FileReaderLoader.cpp: * fileapi/FileReaderSync.cpp: * html/BaseTextInputType.cpp: * html/EmailInputType.cpp: * html/HTMLAllCollection.cpp: * html/HTMLCanvasElement.cpp: * html/HTMLImageLoader.cpp: * html/HTMLMediaElement.cpp: * html/HTMLPlugInImageElement.cpp: * html/ImageData.cpp: * html/ImageData.h: * html/MediaEncryptedEventInit.h: * html/WebKitMediaKeyError.h: * html/canvas/WebGLAny.h: * html/canvas/WebGLRenderingContext.cpp: * html/canvas/WebGLRenderingContextBase.cpp: * html/canvas/WebGLRenderingContextBase.h: * html/canvas/WebGPUBuffer.cpp: * html/canvas/WebGPURenderingContext.cpp: * html/canvas/WebGPURenderingContext.h: * html/track/DataCue.cpp: * html/track/DataCue.h: * inspector/CommandLineAPIHost.cpp: * inspector/CommandLineAPIHost.h: * inspector/CommandLineAPIModule.cpp: * inspector/CommandLineAPIModule.h: * inspector/InspectorCanvas.cpp: * inspector/InspectorCanvas.h: * inspector/InspectorClient.cpp: * inspector/InspectorController.cpp: * inspector/InspectorController.h: * inspector/InspectorDatabaseResource.h: * inspector/InspectorFrontendClientLocal.cpp: * inspector/InspectorFrontendHost.cpp: * inspector/InspectorInstrumentation.cpp: * inspector/InspectorInstrumentation.h: * inspector/InspectorOverlay.cpp: * inspector/InspectorOverlay.h: * inspector/InspectorShaderProgram.cpp: * inspector/InspectorShaderProgram.h: * inspector/InspectorStyleSheet.cpp: * inspector/InspectorStyleSheet.h: * inspector/InspectorWebAgentBase.h: * inspector/InstrumentingAgents.h: * inspector/PageScriptDebugServer.cpp: * inspector/PageScriptDebugServer.h: * inspector/TimelineRecordFactory.cpp: * inspector/WebInjectedScriptHost.h: * inspector/WebInjectedScriptManager.h: * inspector/WorkerInspectorController.cpp: * inspector/WorkerInspectorController.h: * inspector/WorkerScriptDebugServer.cpp: * inspector/WorkerScriptDebugServer.h: * inspector/WorkerToPageFrontendChannel.h: * inspector/agents/InspectorApplicationCacheAgent.h: * inspector/agents/InspectorCSSAgent.cpp: * inspector/agents/InspectorCSSAgent.h: * inspector/agents/InspectorCanvasAgent.cpp: * inspector/agents/InspectorCanvasAgent.h: * inspector/agents/InspectorDOMAgent.cpp: * inspector/agents/InspectorDOMAgent.h: * inspector/agents/InspectorDOMDebuggerAgent.cpp: * inspector/agents/InspectorDOMDebuggerAgent.h: * inspector/agents/InspectorDOMStorageAgent.cpp: * inspector/agents/InspectorDOMStorageAgent.h: * inspector/agents/InspectorDatabaseAgent.cpp: * inspector/agents/InspectorDatabaseAgent.h: * inspector/agents/InspectorIndexedDBAgent.cpp: * inspector/agents/InspectorIndexedDBAgent.h: * inspector/agents/InspectorLayerTreeAgent.cpp: * inspector/agents/InspectorLayerTreeAgent.h: * inspector/agents/InspectorMemoryAgent.cpp: * inspector/agents/InspectorMemoryAgent.h: * inspector/agents/InspectorNetworkAgent.cpp: * inspector/agents/InspectorNetworkAgent.h: * inspector/agents/InspectorPageAgent.cpp: * inspector/agents/InspectorPageAgent.h: * inspector/agents/InspectorTimelineAgent.cpp: * inspector/agents/InspectorTimelineAgent.h: * inspector/agents/InspectorWorkerAgent.h: * inspector/agents/WebConsoleAgent.cpp: * inspector/agents/WebConsoleAgent.h: * inspector/agents/WebDebuggerAgent.h: * inspector/agents/WebHeapAgent.h: * inspector/agents/page/PageDebuggerAgent.cpp: * inspector/agents/page/PageRuntimeAgent.cpp: * inspector/agents/page/PageRuntimeAgent.h: * inspector/agents/worker/ServiceWorkerAgent.h: * inspector/agents/worker/WorkerDebuggerAgent.cpp: * inspector/agents/worker/WorkerRuntimeAgent.cpp: * inspector/agents/worker/WorkerRuntimeAgent.h: * loader/EmptyClients.cpp: * page/CaptionUserPreferences.cpp: * page/Chrome.cpp: * page/ChromeClient.h: * page/Crypto.cpp: * page/DOMWindow.cpp: * page/DOMWindow.h: * page/Frame.cpp: * page/OriginThreadLocalCache.h: * page/PageConsoleClient.cpp: * page/PageConsoleClient.h: * page/PageDebuggable.cpp: * page/PageGroup.cpp: * page/SettingsBase.h: * page/UserContentController.cpp: * page/cocoa/ResourceUsageThreadCocoa.mm: * page/csp/ContentSecurityPolicy.cpp: * page/ios/FrameIOS.mm: * page/linux/ResourceUsageOverlayLinux.cpp: * page/linux/ResourceUsageThreadLinux.cpp: * platform/MediaSample.h: * platform/SerializedPlatformRepresentation.h: * platform/SharedBuffer.h: * platform/audio/mac/CARingBuffer.h: * platform/cocoa/SharedBufferCocoa.mm: * platform/graphics/ImageBuffer.h: * platform/graphics/LegacyCDMSession.h: * platform/graphics/MediaPlayer.h: * platform/graphics/avfoundation/CDMFairPlayStreaming.cpp: * platform/graphics/avfoundation/CDMPrivateMediaSourceAVFObjC.mm: * platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp: * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp: * platform/graphics/avfoundation/MediaSampleAVFObjC.h: * platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp: * platform/graphics/avfoundation/objc/CDMSessionAVContentKeySession.mm: * platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.mm: * platform/graphics/avfoundation/objc/CDMSessionAVStreamSession.mm: * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: * platform/graphics/avfoundation/objc/MediaSampleAVFObjC.mm: * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm: * platform/graphics/cairo/ImageBufferCairo.cpp: * platform/graphics/cg/ImageBufferDataCG.cpp: * platform/graphics/cg/ImageBufferDataCG.h: * platform/graphics/cocoa/GPUDeviceMetal.mm: * platform/graphics/filters/FEBlend.cpp: * platform/graphics/filters/FEColorMatrix.cpp: * platform/graphics/filters/FEComponentTransfer.cpp: * platform/graphics/filters/FEComposite.cpp: * platform/graphics/filters/FEConvolveMatrix.cpp: * platform/graphics/filters/FEDisplacementMap.cpp: * platform/graphics/filters/FEDropShadow.cpp: * platform/graphics/filters/FEGaussianBlur.cpp: * platform/graphics/filters/FELighting.h: * platform/graphics/filters/FEMorphology.cpp: * platform/graphics/filters/FETurbulence.cpp: * platform/graphics/filters/FilterEffect.cpp: * platform/graphics/filters/FilterEffect.h: * platform/graphics/gpu/GPUBuffer.h: * platform/graphics/gpu/GPUDevice.h: * platform/graphics/iso/ISOBox.cpp: * platform/graphics/iso/ISOOriginalFormatBox.cpp: * platform/graphics/iso/ISOProtectionSchemeInfoBox.cpp: * platform/graphics/iso/ISOSchemeInformationBox.cpp: * platform/graphics/iso/ISOSchemeTypeBox.cpp: * platform/graphics/iso/ISOTrackEncryptionBox.cpp: * platform/graphics/iso/ISOVTTCue.cpp: * platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp: * platform/graphics/win/ImageBufferDataDirect2D.cpp: * platform/graphics/win/ImageBufferDataDirect2D.h: * platform/ios/wak/WebCoreThread.mm: * platform/mac/SerializedPlatformRepresentationMac.mm: * platform/mac/StringUtilities.mm: * platform/mock/mediasource/MockBox.cpp: * platform/mock/mediasource/MockSourceBufferPrivate.cpp: * svg/graphics/SVGImage.cpp: * testing/GCObservation.cpp: * testing/GCObservation.h: * testing/Internals.cpp: * testing/Internals.h: * testing/LegacyMockCDM.cpp: * testing/MockCDMFactory.cpp: * testing/js/WebCoreTestSupport.cpp: * workers/Worker.cpp: * workers/Worker.h: * workers/WorkerConsoleClient.cpp: * workers/WorkerConsoleClient.h: * workers/WorkerGlobalScope.cpp: * workers/WorkerGlobalScope.h: * workers/WorkerGlobalScopeProxy.h: * workers/WorkerInspectorProxy.cpp: * workers/WorkerMessagingProxy.cpp: * workers/WorkerThread.h: * workers/service/ExtendableEvent.cpp: * workers/service/ServiceWorker.cpp: * workers/service/ServiceWorker.h: * workers/service/ServiceWorkerClient.h: * workers/service/context/ServiceWorkerInspectorProxy.cpp: * workers/service/context/ServiceWorkerThread.cpp: * xml/XMLHttpRequest.cpp: Source/WebKit: * Platform/mac/StringUtilities.mm: * Shared/Cocoa/WebKit2InitializeCocoa.mm: * Shared/WebKit2Initialize.cpp: * Shared/linux/WebMemorySamplerLinux.cpp: * Shared/mac/WebMemorySampler.mac.mm: * UIProcess/WebProcessPool.cpp: * WebProcess/InjectedBundle/API/APIInjectedBundlePageUIClient.h: * WebProcess/InjectedBundle/API/glib/WebKitConsoleMessagePrivate.h: * WebProcess/Plugins/Netscape/NPRuntimeObjectMap.h: * WebProcess/Plugins/Netscape/NetscapePlugin.cpp: * WebProcess/Plugins/PluginProcessConnection.cpp: * WebProcess/Plugins/PluginView.cpp: * WebProcess/WebPage/WebInspector.h: * WebProcess/WebPage/WebPage.cpp: * WebProcess/cocoa/WebProcessCocoa.mm: Source/WebKitLegacy/ios: * Misc/WebUIKitSupport.mm: Source/WebKitLegacy/mac: * Carbon/CarbonWindowAdapter.mm: * DOM/WebDOMOperations.mm: * History/WebBackForwardList.mm: * History/WebHistoryItem.mm: * Misc/WebCache.mm: * Misc/WebElementDictionary.mm: * Misc/WebIconDatabase.mm: * Misc/WebStringTruncator.mm: * Plugins/Hosted/NetscapePluginInstanceProxy.mm: * Plugins/Hosted/ProxyInstance.mm: * Plugins/Hosted/ProxyRuntimeObject.mm: * Plugins/Hosted/WebHostedNetscapePluginView.mm: * Plugins/WebBaseNetscapePluginView.mm: * Plugins/WebBasePluginPackage.mm: * Plugins/WebNetscapePluginStream.mm: * Plugins/WebNetscapePluginView.mm: * Plugins/WebPluginController.mm: * WebCoreSupport/WebEditorClient.mm: * WebCoreSupport/WebFrameLoaderClient.mm: * WebCoreSupport/WebInspectorClient.h: * WebCoreSupport/WebInspectorClient.mm: * WebView/WebDataSource.mm: * WebView/WebFrame.mm: * WebView/WebHTMLRepresentation.mm: * WebView/WebHTMLView.mm: * WebView/WebPreferences.mm: * WebView/WebScriptDebugDelegate.mm: * WebView/WebScriptDebugger.h: * WebView/WebTextIterator.mm: * WebView/WebView.mm: * WebView/WebViewData.mm: Source/WebKitLegacy/win: * Plugins/PluginView.cpp: * Plugins/PluginViewWin.cpp: * WebCoreSupport/WebInspectorClient.cpp: * WebCoreSupport/WebInspectorClient.h: * WebFrame.cpp: * WebJavaScriptCollector.cpp: * WebView.cpp: Tools: * WebKitTestRunner/TestController.cpp: Canonical link: https://commits.webkit.org/198358@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@228218 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-02-07 05:20:34 +00:00
#include <JavaScriptCore/JSCJSValueInlines.h>
#include <wtf/text/AtomString.h>
Add document.defineCustomElement https://bugs.webkit.org/show_bug.cgi?id=153092 Reviewed by Chris Dumez. Source/WebCore: Added document.defineCustomElement and added a constructor to HTMLElement which can be called as "super" in a subclass of HTMLElement. This is a prototype of new custom elements API and willfully violates the current specification at http://w3c.github.io/webcomponents/spec/custom/ Each author defined class can define multiple elements using distinct tag names. In such cases, the super call must specify the tag name. e.g. class SomeCustomElement extends HTMLElement { constructor(name) { super(name); } } document.defineCustomElement('some-custom-element', SomeCustomElement); document.defineCustomElement('other-custom-element', SomeCustomElement); new SomeCustomElement('some-custom-element'); When a class is associated with exactly one tag name, the argument can be omitted. e.g. class AnotherCustomElement extends HTMLElement {} document.defineCustomElement('another-custom-element', AnotherCustomElement); new AnotherCustomElement(); We allow only subclassing of HTMLElement and only in (X)HTML namespace. Tests: fast/custom-elements/Document-defineCustomElement.html fast/custom-elements/HTMLElement-constructor.html * CMakeLists.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSCustomElementInterface.cpp: Added. Abstracts an author-defined class associated with a custom element. It's a Active DOM object and lives until the associated document dies. (WebCore::JSCustomElementInterface::JSCustomElementInterface): (WebCore::JSCustomElementInterface::~JSCustomElementInterface): * bindings/js/JSCustomElementInterface.h: Added. (WebCore::JSCustomElementInterface::create): (WebCore::JSCustomElementInterface::scriptExecutionContext): (WebCore::JSCustomElementInterface::constructor): * bindings/js/JSDocumentCustom.cpp: (WebCore::JSDocument::defineCustomElement): Added. Define a custom element by associating a tag name with an author defined JS class after validating arguments. * bindings/js/JSHTMLElementCustom.cpp: (WebCore::constructJSHTMLElement): Added. Look up the tag name based on new.target if one is not specified. If a tag name is specified, check that new.target is associated with the tag name. * dom/CustomElementDefinitions.cpp: Added. (WebCore::CustomElementDefinitions::checkName): Added. Restricts tag names similarly to http://w3c.github.io/webcomponents/spec/custom/#dfn-custom-element-type (WebCore::CustomElementDefinitions::defineElement): Added. Associates a JS class with a tag name. (WebCore::CustomElementDefinitions::findInterface): Added. Finds a JS class by a tag name. (WebCore::CustomElementDefinitions::findName): Added. Finds a tag name by a JS class. * dom/CustomElementDefinitions.h: Added. (WebCore::CustomElementDefinitions::CustomElementInfo): Added. * dom/Document.cpp: (WebCore::Document::ensureCustomElementDefinitions): Added. * dom/Document.h: (WebCore::Document::customElementDefinitions): Added. * dom/Document.idl: * html/HTMLElement.idl: LayoutTests: Added tests for document.defineCustomElement and instantiating custom elements. * TestExpectations: Skipped the tests on non-Mac ports. * fast/custom-elements: Added. * fast/custom-elements/Document-defineCustomElement-expected.txt: Added. * fast/custom-elements/Document-defineCustomElement.html: Added. * fast/custom-elements/HTMLElement-constructor-expected.txt: Added. * fast/custom-elements/HTMLElement-constructor.html: Added. * platform/mac/TestExpectations: Canonical link: https://commits.webkit.org/171208@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@195087 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-01-15 02:59:03 +00:00
namespace WebCore {
Ref<CustomElementRegistry> CustomElementRegistry::create(DOMWindow& window, ScriptExecutionContext* scriptExecutionContext)
Move document.defineElement to customElements.define https://bugs.webkit.org/show_bug.cgi?id=160731 Reviewed by Chris Dumez. Source/WebCore: Replaced Document.prototype.defineElement by CustomElementsRegistry.prototype.define to match the latest HTML specification: https://html.spec.whatwg.org/#custom-elements-api This patch renames the existing CustomElementDefinitions to CustomElementsRegistry and exposes it on window.customElements. CustomElementDefinitions is now owned by DOMWindow instead of Document to match the spec's new semantics. No new tests. The existing tests have been updated to reflect the change. * DerivedSources.cpp: * DerivedSources.make: * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSCustomElementsRegistryCustom.cpp: Added. (WebCore::JSCustomElementsRegistry::define): Moved from JSDocumentCustom. Removed the check for the existence of DOMWindow since CustomElementsRegistry is an attribute on DOMWindow itself. * bindings/js/JSDocumentCustom.cpp: (WebCore::JSDocument::defineElement): Deleted. * bindings/js/JSHTMLElementCustom.cpp: Added the code to check the existence of DOMWindow since the registry is associated with DOMWindow, not Document. (WebCore::constructJSHTMLElement): * dom/CustomElementsRegistry.cpp: Renamed from Source/WebCore/dom/CustomElementDefinitions.cpp. (WebCore::CustomElementsRegistry::create): Added. (WebCore::CustomElementsRegistry::CustomElementsRegistry): Added. (WebCore::CustomElementsRegistry::~CustomElementsRegistry): Added. (WebCore::CustomElementsRegistry::addElementDefinition): Moved from CustomElementDefinitions. (WebCore::CustomElementsRegistry::addUpgradeCandidate): Ditto. (WebCore::CustomElementsRegistry::findInterface): Ditto. (WebCore::CustomElementsRegistry::containsConstructor): Ditto. * dom/CustomElementsRegistry.h: Renamed from Source/WebCore/dom/CustomElementDefinitions.h. * dom/CustomElementsRegistry.idl: Added. * dom/Document.cpp: (WebCore::createUpgradeCandidateElement): Extracted out of createHTMLElementWithNameValidation and createFallbackHTMLElement to share code. (WebCore::createHTMLElementWithNameValidation): (WebCore::createFallbackHTMLElement): This function was missing a check for the runtime flag. Sharing code with createHTMLElementWithNameValidation via createUpgradeCandidateElement fixes it. (WebCore::Document::ensureCustomElementDefinitions): Deleted. * dom/Document.h: (WebCore::Document::customElementDefinitions): Deleted. * dom/Document.idl: * dom/Element.cpp: (WebCore::Element::attributeChanged): * html/parser/HTMLConstructionSite.cpp: (WebCore::HTMLConstructionSite::createHTMLElementOrFindCustomElementInterface): * page/DOMWindow.cpp: (WebCore::DOMWindow::ensureCustomElementsRegistry): Added. Moved from Document. * page/DOMWindow.h: * page/DOMWindow.idl: Added customElements on DOMWindow. LayoutTests: Updated the tests and their expected results to reflect the move of Document.prototype.defineElement to CustomElementsRegistry.prototype.define. I'm going to rename tests in a follow up. * fast/custom-elements/Document-createElement.html: * fast/custom-elements/Document-defineElement-expected.txt: * fast/custom-elements/Document-defineElement.html: Removed test cases for testing defining elements in a viewless/windowless document since those documents don't have a corresponding window object. * fast/custom-elements/HTMLElement-constructor.html: * fast/custom-elements/attribute-changed-callback.html: * fast/custom-elements/defined-pseudo-class.html: * fast/custom-elements/defined-rule.html: * fast/custom-elements/lifecycle-callback-timing.html: * fast/custom-elements/parser/parser-constructs-custom-element-in-document-write.html: * fast/custom-elements/parser/parser-constructs-custom-element-synchronously.html: * fast/custom-elements/parser/parser-constructs-custom-elements-expected.txt: * fast/custom-elements/parser/parser-constructs-custom-elements.html: * fast/custom-elements/parser/parser-fallsback-to-unknown-element.html: * fast/custom-elements/parser/parser-sets-attributes-and-children.html: * fast/custom-elements/parser/parser-uses-constructed-element.html: * fast/custom-elements/parser/parser-uses-registry-of-owner-document.html: * fast/custom-elements/upgrading/Node-cloneNode.html: * fast/custom-elements/upgrading/upgrading-parser-created-element.html: * platform/mac/js/dom/global-constructors-attributes-expected.txt: Canonical link: https://commits.webkit.org/178878@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@204367 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-08-11 02:08:17 +00:00
{
return adoptRef(*new CustomElementRegistry(window, scriptExecutionContext));
Move document.defineElement to customElements.define https://bugs.webkit.org/show_bug.cgi?id=160731 Reviewed by Chris Dumez. Source/WebCore: Replaced Document.prototype.defineElement by CustomElementsRegistry.prototype.define to match the latest HTML specification: https://html.spec.whatwg.org/#custom-elements-api This patch renames the existing CustomElementDefinitions to CustomElementsRegistry and exposes it on window.customElements. CustomElementDefinitions is now owned by DOMWindow instead of Document to match the spec's new semantics. No new tests. The existing tests have been updated to reflect the change. * DerivedSources.cpp: * DerivedSources.make: * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSCustomElementsRegistryCustom.cpp: Added. (WebCore::JSCustomElementsRegistry::define): Moved from JSDocumentCustom. Removed the check for the existence of DOMWindow since CustomElementsRegistry is an attribute on DOMWindow itself. * bindings/js/JSDocumentCustom.cpp: (WebCore::JSDocument::defineElement): Deleted. * bindings/js/JSHTMLElementCustom.cpp: Added the code to check the existence of DOMWindow since the registry is associated with DOMWindow, not Document. (WebCore::constructJSHTMLElement): * dom/CustomElementsRegistry.cpp: Renamed from Source/WebCore/dom/CustomElementDefinitions.cpp. (WebCore::CustomElementsRegistry::create): Added. (WebCore::CustomElementsRegistry::CustomElementsRegistry): Added. (WebCore::CustomElementsRegistry::~CustomElementsRegistry): Added. (WebCore::CustomElementsRegistry::addElementDefinition): Moved from CustomElementDefinitions. (WebCore::CustomElementsRegistry::addUpgradeCandidate): Ditto. (WebCore::CustomElementsRegistry::findInterface): Ditto. (WebCore::CustomElementsRegistry::containsConstructor): Ditto. * dom/CustomElementsRegistry.h: Renamed from Source/WebCore/dom/CustomElementDefinitions.h. * dom/CustomElementsRegistry.idl: Added. * dom/Document.cpp: (WebCore::createUpgradeCandidateElement): Extracted out of createHTMLElementWithNameValidation and createFallbackHTMLElement to share code. (WebCore::createHTMLElementWithNameValidation): (WebCore::createFallbackHTMLElement): This function was missing a check for the runtime flag. Sharing code with createHTMLElementWithNameValidation via createUpgradeCandidateElement fixes it. (WebCore::Document::ensureCustomElementDefinitions): Deleted. * dom/Document.h: (WebCore::Document::customElementDefinitions): Deleted. * dom/Document.idl: * dom/Element.cpp: (WebCore::Element::attributeChanged): * html/parser/HTMLConstructionSite.cpp: (WebCore::HTMLConstructionSite::createHTMLElementOrFindCustomElementInterface): * page/DOMWindow.cpp: (WebCore::DOMWindow::ensureCustomElementsRegistry): Added. Moved from Document. * page/DOMWindow.h: * page/DOMWindow.idl: Added customElements on DOMWindow. LayoutTests: Updated the tests and their expected results to reflect the move of Document.prototype.defineElement to CustomElementsRegistry.prototype.define. I'm going to rename tests in a follow up. * fast/custom-elements/Document-createElement.html: * fast/custom-elements/Document-defineElement-expected.txt: * fast/custom-elements/Document-defineElement.html: Removed test cases for testing defining elements in a viewless/windowless document since those documents don't have a corresponding window object. * fast/custom-elements/HTMLElement-constructor.html: * fast/custom-elements/attribute-changed-callback.html: * fast/custom-elements/defined-pseudo-class.html: * fast/custom-elements/defined-rule.html: * fast/custom-elements/lifecycle-callback-timing.html: * fast/custom-elements/parser/parser-constructs-custom-element-in-document-write.html: * fast/custom-elements/parser/parser-constructs-custom-element-synchronously.html: * fast/custom-elements/parser/parser-constructs-custom-elements-expected.txt: * fast/custom-elements/parser/parser-constructs-custom-elements.html: * fast/custom-elements/parser/parser-fallsback-to-unknown-element.html: * fast/custom-elements/parser/parser-sets-attributes-and-children.html: * fast/custom-elements/parser/parser-uses-constructed-element.html: * fast/custom-elements/parser/parser-uses-registry-of-owner-document.html: * fast/custom-elements/upgrading/Node-cloneNode.html: * fast/custom-elements/upgrading/upgrading-parser-created-element.html: * platform/mac/js/dom/global-constructors-attributes-expected.txt: Canonical link: https://commits.webkit.org/178878@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@204367 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-08-11 02:08:17 +00:00
}
CustomElementRegistry::CustomElementRegistry(DOMWindow& window, ScriptExecutionContext* scriptExecutionContext)
: ContextDestructionObserver(scriptExecutionContext)
, m_window(window)
Use "= default" to denote default constructor or destructor https://bugs.webkit.org/show_bug.cgi?id=178528 Rubber-stamped by Andy Estes. Source/WebCore: * Modules/airplay/WebKitPlaybackTargetAvailabilityEvent.h: * Modules/applepay/ApplePayError.cpp: * Modules/applepay/ApplePayPaymentAuthorizedEvent.cpp: * Modules/applepay/ApplePayPaymentMethodSelectedEvent.cpp: * Modules/applepay/ApplePaySession.cpp: * Modules/applepay/ApplePaySessionPaymentRequest.cpp: * Modules/applepay/ApplePayShippingContactSelectedEvent.cpp: * Modules/applepay/ApplePayShippingMethodSelectedEvent.cpp: * Modules/applepay/ApplePayValidateMerchantEvent.cpp: * Modules/applepay/Payment.h: * Modules/applepay/PaymentCoordinatorClient.h: * Modules/credentials/BasicCredential.cpp: * Modules/credentials/FederatedCredential.cpp: * Modules/credentials/NavigatorCredentials.cpp: * Modules/credentials/PasswordCredential.cpp: * Modules/encryptedmedia/CDMClient.h: * Modules/encryptedmedia/legacy/LegacyCDM.cpp: * Modules/encryptedmedia/legacy/LegacyCDM.h: * Modules/encryptedmedia/legacy/LegacyCDMPrivate.h: * Modules/encryptedmedia/legacy/LegacyCDMPrivateClearKey.h: * Modules/encryptedmedia/legacy/LegacyCDMPrivateMediaPlayer.h: * Modules/encryptedmedia/legacy/LegacyCDMSessionClearKey.cpp: * Modules/encryptedmedia/legacy/WebKitMediaKeyMessageEvent.cpp: * Modules/encryptedmedia/legacy/WebKitMediaKeyNeededEvent.cpp: * Modules/entriesapi/DOMFileSystem.cpp: * Modules/entriesapi/FileSystemDirectoryReader.cpp: * Modules/entriesapi/FileSystemEntry.cpp: * Modules/fetch/FetchLoaderClient.h: * Modules/gamepad/Gamepad.cpp: * Modules/gamepad/GamepadEvent.h: * Modules/gamepad/deprecated/Gamepad.cpp: [ truncated ] Source/WebCore/PAL: * pal/Logger.h: (PAL::Logger::Observer::~Observer): Deleted. * pal/crypto/gcrypt/CryptoDigestGCrypt.cpp: * pal/system/SleepDisabler.cpp: * pal/system/SystemSleepListener.h: Canonical link: https://commits.webkit.org/194740@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@223728 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-10-19 23:48:45 +00:00
{
}
Move document.defineElement to customElements.define https://bugs.webkit.org/show_bug.cgi?id=160731 Reviewed by Chris Dumez. Source/WebCore: Replaced Document.prototype.defineElement by CustomElementsRegistry.prototype.define to match the latest HTML specification: https://html.spec.whatwg.org/#custom-elements-api This patch renames the existing CustomElementDefinitions to CustomElementsRegistry and exposes it on window.customElements. CustomElementDefinitions is now owned by DOMWindow instead of Document to match the spec's new semantics. No new tests. The existing tests have been updated to reflect the change. * DerivedSources.cpp: * DerivedSources.make: * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSCustomElementsRegistryCustom.cpp: Added. (WebCore::JSCustomElementsRegistry::define): Moved from JSDocumentCustom. Removed the check for the existence of DOMWindow since CustomElementsRegistry is an attribute on DOMWindow itself. * bindings/js/JSDocumentCustom.cpp: (WebCore::JSDocument::defineElement): Deleted. * bindings/js/JSHTMLElementCustom.cpp: Added the code to check the existence of DOMWindow since the registry is associated with DOMWindow, not Document. (WebCore::constructJSHTMLElement): * dom/CustomElementsRegistry.cpp: Renamed from Source/WebCore/dom/CustomElementDefinitions.cpp. (WebCore::CustomElementsRegistry::create): Added. (WebCore::CustomElementsRegistry::CustomElementsRegistry): Added. (WebCore::CustomElementsRegistry::~CustomElementsRegistry): Added. (WebCore::CustomElementsRegistry::addElementDefinition): Moved from CustomElementDefinitions. (WebCore::CustomElementsRegistry::addUpgradeCandidate): Ditto. (WebCore::CustomElementsRegistry::findInterface): Ditto. (WebCore::CustomElementsRegistry::containsConstructor): Ditto. * dom/CustomElementsRegistry.h: Renamed from Source/WebCore/dom/CustomElementDefinitions.h. * dom/CustomElementsRegistry.idl: Added. * dom/Document.cpp: (WebCore::createUpgradeCandidateElement): Extracted out of createHTMLElementWithNameValidation and createFallbackHTMLElement to share code. (WebCore::createHTMLElementWithNameValidation): (WebCore::createFallbackHTMLElement): This function was missing a check for the runtime flag. Sharing code with createHTMLElementWithNameValidation via createUpgradeCandidateElement fixes it. (WebCore::Document::ensureCustomElementDefinitions): Deleted. * dom/Document.h: (WebCore::Document::customElementDefinitions): Deleted. * dom/Document.idl: * dom/Element.cpp: (WebCore::Element::attributeChanged): * html/parser/HTMLConstructionSite.cpp: (WebCore::HTMLConstructionSite::createHTMLElementOrFindCustomElementInterface): * page/DOMWindow.cpp: (WebCore::DOMWindow::ensureCustomElementsRegistry): Added. Moved from Document. * page/DOMWindow.h: * page/DOMWindow.idl: Added customElements on DOMWindow. LayoutTests: Updated the tests and their expected results to reflect the move of Document.prototype.defineElement to CustomElementsRegistry.prototype.define. I'm going to rename tests in a follow up. * fast/custom-elements/Document-createElement.html: * fast/custom-elements/Document-defineElement-expected.txt: * fast/custom-elements/Document-defineElement.html: Removed test cases for testing defining elements in a viewless/windowless document since those documents don't have a corresponding window object. * fast/custom-elements/HTMLElement-constructor.html: * fast/custom-elements/attribute-changed-callback.html: * fast/custom-elements/defined-pseudo-class.html: * fast/custom-elements/defined-rule.html: * fast/custom-elements/lifecycle-callback-timing.html: * fast/custom-elements/parser/parser-constructs-custom-element-in-document-write.html: * fast/custom-elements/parser/parser-constructs-custom-element-synchronously.html: * fast/custom-elements/parser/parser-constructs-custom-elements-expected.txt: * fast/custom-elements/parser/parser-constructs-custom-elements.html: * fast/custom-elements/parser/parser-fallsback-to-unknown-element.html: * fast/custom-elements/parser/parser-sets-attributes-and-children.html: * fast/custom-elements/parser/parser-uses-constructed-element.html: * fast/custom-elements/parser/parser-uses-registry-of-owner-document.html: * fast/custom-elements/upgrading/Node-cloneNode.html: * fast/custom-elements/upgrading/upgrading-parser-created-element.html: * platform/mac/js/dom/global-constructors-attributes-expected.txt: Canonical link: https://commits.webkit.org/178878@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@204367 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-08-11 02:08:17 +00:00
Use "= default" to denote default constructor or destructor https://bugs.webkit.org/show_bug.cgi?id=178528 Rubber-stamped by Andy Estes. Source/WebCore: * Modules/airplay/WebKitPlaybackTargetAvailabilityEvent.h: * Modules/applepay/ApplePayError.cpp: * Modules/applepay/ApplePayPaymentAuthorizedEvent.cpp: * Modules/applepay/ApplePayPaymentMethodSelectedEvent.cpp: * Modules/applepay/ApplePaySession.cpp: * Modules/applepay/ApplePaySessionPaymentRequest.cpp: * Modules/applepay/ApplePayShippingContactSelectedEvent.cpp: * Modules/applepay/ApplePayShippingMethodSelectedEvent.cpp: * Modules/applepay/ApplePayValidateMerchantEvent.cpp: * Modules/applepay/Payment.h: * Modules/applepay/PaymentCoordinatorClient.h: * Modules/credentials/BasicCredential.cpp: * Modules/credentials/FederatedCredential.cpp: * Modules/credentials/NavigatorCredentials.cpp: * Modules/credentials/PasswordCredential.cpp: * Modules/encryptedmedia/CDMClient.h: * Modules/encryptedmedia/legacy/LegacyCDM.cpp: * Modules/encryptedmedia/legacy/LegacyCDM.h: * Modules/encryptedmedia/legacy/LegacyCDMPrivate.h: * Modules/encryptedmedia/legacy/LegacyCDMPrivateClearKey.h: * Modules/encryptedmedia/legacy/LegacyCDMPrivateMediaPlayer.h: * Modules/encryptedmedia/legacy/LegacyCDMSessionClearKey.cpp: * Modules/encryptedmedia/legacy/WebKitMediaKeyMessageEvent.cpp: * Modules/encryptedmedia/legacy/WebKitMediaKeyNeededEvent.cpp: * Modules/entriesapi/DOMFileSystem.cpp: * Modules/entriesapi/FileSystemDirectoryReader.cpp: * Modules/entriesapi/FileSystemEntry.cpp: * Modules/fetch/FetchLoaderClient.h: * Modules/gamepad/Gamepad.cpp: * Modules/gamepad/GamepadEvent.h: * Modules/gamepad/deprecated/Gamepad.cpp: [ truncated ] Source/WebCore/PAL: * pal/Logger.h: (PAL::Logger::Observer::~Observer): Deleted. * pal/crypto/gcrypt/CryptoDigestGCrypt.cpp: * pal/system/SleepDisabler.cpp: * pal/system/SystemSleepListener.h: Canonical link: https://commits.webkit.org/194740@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@223728 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-10-19 23:48:45 +00:00
CustomElementRegistry::~CustomElementRegistry() = default;
Move document.defineElement to customElements.define https://bugs.webkit.org/show_bug.cgi?id=160731 Reviewed by Chris Dumez. Source/WebCore: Replaced Document.prototype.defineElement by CustomElementsRegistry.prototype.define to match the latest HTML specification: https://html.spec.whatwg.org/#custom-elements-api This patch renames the existing CustomElementDefinitions to CustomElementsRegistry and exposes it on window.customElements. CustomElementDefinitions is now owned by DOMWindow instead of Document to match the spec's new semantics. No new tests. The existing tests have been updated to reflect the change. * DerivedSources.cpp: * DerivedSources.make: * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSCustomElementsRegistryCustom.cpp: Added. (WebCore::JSCustomElementsRegistry::define): Moved from JSDocumentCustom. Removed the check for the existence of DOMWindow since CustomElementsRegistry is an attribute on DOMWindow itself. * bindings/js/JSDocumentCustom.cpp: (WebCore::JSDocument::defineElement): Deleted. * bindings/js/JSHTMLElementCustom.cpp: Added the code to check the existence of DOMWindow since the registry is associated with DOMWindow, not Document. (WebCore::constructJSHTMLElement): * dom/CustomElementsRegistry.cpp: Renamed from Source/WebCore/dom/CustomElementDefinitions.cpp. (WebCore::CustomElementsRegistry::create): Added. (WebCore::CustomElementsRegistry::CustomElementsRegistry): Added. (WebCore::CustomElementsRegistry::~CustomElementsRegistry): Added. (WebCore::CustomElementsRegistry::addElementDefinition): Moved from CustomElementDefinitions. (WebCore::CustomElementsRegistry::addUpgradeCandidate): Ditto. (WebCore::CustomElementsRegistry::findInterface): Ditto. (WebCore::CustomElementsRegistry::containsConstructor): Ditto. * dom/CustomElementsRegistry.h: Renamed from Source/WebCore/dom/CustomElementDefinitions.h. * dom/CustomElementsRegistry.idl: Added. * dom/Document.cpp: (WebCore::createUpgradeCandidateElement): Extracted out of createHTMLElementWithNameValidation and createFallbackHTMLElement to share code. (WebCore::createHTMLElementWithNameValidation): (WebCore::createFallbackHTMLElement): This function was missing a check for the runtime flag. Sharing code with createHTMLElementWithNameValidation via createUpgradeCandidateElement fixes it. (WebCore::Document::ensureCustomElementDefinitions): Deleted. * dom/Document.h: (WebCore::Document::customElementDefinitions): Deleted. * dom/Document.idl: * dom/Element.cpp: (WebCore::Element::attributeChanged): * html/parser/HTMLConstructionSite.cpp: (WebCore::HTMLConstructionSite::createHTMLElementOrFindCustomElementInterface): * page/DOMWindow.cpp: (WebCore::DOMWindow::ensureCustomElementsRegistry): Added. Moved from Document. * page/DOMWindow.h: * page/DOMWindow.idl: Added customElements on DOMWindow. LayoutTests: Updated the tests and their expected results to reflect the move of Document.prototype.defineElement to CustomElementsRegistry.prototype.define. I'm going to rename tests in a follow up. * fast/custom-elements/Document-createElement.html: * fast/custom-elements/Document-defineElement-expected.txt: * fast/custom-elements/Document-defineElement.html: Removed test cases for testing defining elements in a viewless/windowless document since those documents don't have a corresponding window object. * fast/custom-elements/HTMLElement-constructor.html: * fast/custom-elements/attribute-changed-callback.html: * fast/custom-elements/defined-pseudo-class.html: * fast/custom-elements/defined-rule.html: * fast/custom-elements/lifecycle-callback-timing.html: * fast/custom-elements/parser/parser-constructs-custom-element-in-document-write.html: * fast/custom-elements/parser/parser-constructs-custom-element-synchronously.html: * fast/custom-elements/parser/parser-constructs-custom-elements-expected.txt: * fast/custom-elements/parser/parser-constructs-custom-elements.html: * fast/custom-elements/parser/parser-fallsback-to-unknown-element.html: * fast/custom-elements/parser/parser-sets-attributes-and-children.html: * fast/custom-elements/parser/parser-uses-constructed-element.html: * fast/custom-elements/parser/parser-uses-registry-of-owner-document.html: * fast/custom-elements/upgrading/Node-cloneNode.html: * fast/custom-elements/upgrading/upgrading-parser-created-element.html: * platform/mac/js/dom/global-constructors-attributes-expected.txt: Canonical link: https://commits.webkit.org/178878@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@204367 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-08-11 02:08:17 +00:00
Only update connected custom elements https://bugs.webkit.org/show_bug.cgi?id=161480 Reviewed by Yusuke Suzuki. Source/WebCore: In the latest specs, creating an element only upgrades an element if the custom element had already been defined: https://dom.spec.whatwg.org/#concept-create-element Otherwise, an element remains unresolved until it gets connected to the document associated with the global object: https://dom.spec.whatwg.org/#concept-node-insert This patch removes the upgrade candidate map in CustomElementRegistry, and traverses the entire document associated with global object (DOMWindow) in addElementDefinition: https://html.spec.whatwg.org/#dom-customelementregistry-define The traversal is done in the shadow-including tree order (different from depth-first preorder traversal of flat tree) since it doesn't enter slots and children of shadow hosts are always visited even if they are not assigned to a slot: https://dom.spec.whatwg.org/#concept-shadow-including-tree-order Test: fast/custom-elements/enqueue-custom-element-upgrade-reaction.html * bindings/js/JSCustomElementInterface.cpp: (WebCore::JSCustomElementInterface::upgradeElement): Assert that the element being upgraded as the same qualified name as the custom element interface. * bindings/js/JSCustomElementRegistryCustom.cpp: (WebCore::JSCustomElementRegistry::define): Moved the code to resolve the promise from here to addElementDefinition. Also cleaned up the code to extract callbacks a little. * dom/CustomElementReactionQueue.cpp: (WebCore::CustomElementReactionQueue::enqueueElementUpgrade): Added an assertion. (WebCore::CustomElementReactionQueue::enqueueElementUpgradeIfDefined): Added. Upgrade an element if the custom element had already been defined. * dom/CustomElementReactionQueue.h: * dom/CustomElementRegistry.cpp: (WebCore::CustomElementRegistry::create): Stores the reference to DOMWindow to find its document in addElementDefinition. (WebCore::CustomElementRegistry::CustomElementRegistry): Ditto. (WebCore::enqueueUpgradeInShadowIncludingTreeOrder): Added. Enqueue upgrade reactions in shadow-including tree order. (WebCore::CustomElementRegistry::addElementDefinition): Upgrade all unresolved elements that matches this definition and resolve the the promise returned by "whenDefined" if there is any. (WebCore::CustomElementRegistry::addUpgradeCandidate): Deleted. (WebCore::CustomElementRegistry::findInterface): Added a new variant that takes an element. * dom/CustomElementRegistry.h: * dom/Document.cpp: (WebCore::createUpgradeCandidateElement): No longer takes DOMWindow since we don't upgrade synchronously here. It's also wrong not to mark the element as unresolved custom element in a document without a browsing context per new semantics. (WebCore::createHTMLElementWithNameValidation): Ditto. (WebCore::createFallbackHTMLElement): Ditto. * dom/Element.cpp: (WebCore::Element::insertedInto): Enqueue an upgrade reaction if this is an unsolved custom element and there is now a definition for it (the latter condition is checked in enqueueElementUpgradeIfDefined). * html/parser/HTMLConstructionSite.cpp: (WebCore::HTMLConstructionSite::createHTMLElementOrFindCustomElementInterface): Don't upgrade this element until it gets connected to a document in Element::insertedInto. * page/DOMWindow.cpp: (WebCore::DOMWindow::ensureCustomElementRegistry): LayoutTests: Added a W3c-style testharness.js test for https://html.spec.whatwg.org/#enqueue-a-custom-element-upgrade-reaction and added more test cases for :defined and customElements.define. * fast/custom-elements/CustomElementRegistry.html: Revised descriptions for "get" and "whenDefined" test cases consistent with ones for "define". * fast/custom-elements/defined-pseudo-class-expected.txt: * fast/custom-elements/defined-pseudo-class.html: * fast/custom-elements/enqueue-custom-element-upgrade-reaction-expected.txt: Added. * fast/custom-elements/enqueue-custom-element-upgrade-reaction.html: Added. * fast/custom-elements/resources/document-types.js: (create): Canonical link: https://commits.webkit.org/179676@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@205340 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-02 06:17:17 +00:00
// https://dom.spec.whatwg.org/#concept-shadow-including-tree-order
static void enqueueUpgradeInShadowIncludingTreeOrder(ContainerNode& node, JSCustomElementInterface& elementInterface)
{
for (Element* element = ElementTraversal::firstWithin(node); element; element = ElementTraversal::next(*element)) {
Update the semantics of defined-ness of custom elements per spec changes https://bugs.webkit.org/show_bug.cgi?id=161570 Reviewed by Darin Adler. Source/WebCore: This patch adds the notion of a custom element that failed to construct or upgrade so that :defined doesn't apply to such an element. We also set the defined flag inside the HTMLElement constructor in the case of synchronous construction instead of waiting for the custom element constructor to finish. https://dom.spec.whatwg.org/#concept-create-element Conceptually, there are four distinct states for an element: 1. The element is a built-in element 2. The element is a custom element yet to be defined (an upgrade candidate). 3. The element is a well-defined custom element (constructed or upgraded). 4. The element has failed to construct or upgrade as a custom element (because the custom element constructor threw an exception or returned an unexpected object). In the latest DOM/HTML specifications, these states are called as 1. "uncustomized", 2. "undefined", 3. "custom", and 4. "failed": https://dom.spec.whatwg.org/#concept-element-defined This patch refactors Node flags to introduce these distinct states as the following: 1. Neither IsCustomElement nor IsEditingTextOrUnresolvedCustomElementFlag is set. 2. IsCustomElement and IsEditingTextOrUnresolvedCustomElementFlag are set. isCustomElementUpgradeCandidate() and isUndefinedCustomElement() return true. 3. IsCustomElement is set and IsEditingTextOrUnresolvedCustomElementFlag is unset. isDefinedCustomElement() returns true. 4. IsCustomElement is unset and IsEditingTextOrUnresolvedCustomElementFlag is set. isFailedCustomElement() and isUndefinedCustomElement() return true. Per a spec change, this patch also makes :defined applied to a synchronously constructed custom element immediately after super() call in the constructor. When the constructor throws an exception or fails to return the right element, the HTML parser marks the fallback element with setIsUndefinedCustomElement. Tests: fast/custom-elements/defined-pseudo-class.html fast/custom-elements/defined-rule.html fast/custom-elements/upgrading/Node-cloneNode.html * bindings/js/JSCustomElementInterface.cpp: (WebCore::JSCustomElementInterface::constructElement): Don't set :defined flag here since that's done in the HTMLElement constructor now. (WebCore::JSCustomElementInterface::upgradeElement): Mark the element as failed-to-upgrade as needed. * bindings/js/JSElementCustom.cpp: (WebCore::toJSNewlyCreated): * bindings/js/JSHTMLElementCustom.cpp: (WebCore::constructJSHTMLElement): * css/SelectorCheckerTestFunctions.h: (WebCore::isDefinedElement): * dom/CustomElementReactionQueue.cpp: (WebCore::CustomElementReactionQueue::enqueueElementUpgradeIfDefined): Enqueue custom element reactions only if the element is well defined (successfully constructed or upgraded). (WebCore::CustomElementReactionQueue::enqueueConnectedCallbackIfNeeded): Ditto. (WebCore::CustomElementReactionQueue::enqueueDisconnectedCallbackIfNeeded): Ditto. (WebCore::CustomElementReactionQueue::enqueueAdoptedCallbackIfNeeded): Ditto. (WebCore::CustomElementReactionQueue::enqueueAttributeChangedCallbackIfNeeded): Ditto. * dom/CustomElementRegistry.cpp: (WebCore::enqueueUpgradeInShadowIncludingTreeOrder): * dom/Document.cpp: (WebCore::createUpgradeCandidateElement): (WebCore::createFallbackHTMLElement): * dom/Element.cpp: (WebCore::Element::attributeChanged): (WebCore::Element::didMoveToNewDocument): (WebCore::Element::insertedInto): (WebCore::Element::removedFrom): (WebCore::Element::setCustomElementIsResolved): Deleted. (WebCore::Element::setIsDefinedCustomElement): Renamed from setCustomElementIsResolved. (WebCore::Element::setIsFailedCustomElement): Added. (WebCore::Element::setIsCustomElementUpgradeCandidate): Added. (WebCore::Element::customElementInterface): * dom/Element.h: * dom/Node.h: (WebCore::Node::setIsCustomElement): Deleted. (WebCore::Node::isUndefinedCustomElement): Renamed from isUnresolvedCustomElement. (WebCore::Node::setIsUnresolvedCustomElement): Deleted. (WebCore::Node::isCustomElementUpgradeCandidate): Added. (WebCore::Node::isDefinedCustomElement): Renamed from isCustomElement. (WebCore::Node::isFailedCustomElement): Added. * dom/make_names.pl: (printWrapperFactoryCppFile): Use the HTMLElement wrapper on upgrade candidates. When a custom element failed to upgrade, the HTMLElement constructor would have created the wrapper so we never run this code. * html/parser/HTMLConstructionSite.cpp: (WebCore::HTMLConstructionSite::createHTMLElementOrFindCustomElementInterface): * html/parser/HTMLDocumentParser.cpp: (WebCore::HTMLDocumentParser::runScriptsForPausedTreeBuilder): Mark the HTMLUnknownElement created when the custom element constructor failed to run successfully as a failed custom element so that :define wouldn't apply to this element. LayoutTests: Added a new test cases to defined-pseudo-class.html, defined-rule.html, and Node-cloneNode.html and rebaselined the tests. * fast/custom-elements/defined-pseudo-class-expected.txt: * fast/custom-elements/defined-pseudo-class.html: (MyElement): Made matchInsideConstructor an instance variable so that there won't be inter-test dependency. Added test cases for :defined not being not applying to a failed-to-upgrade custom element. Finally, updated test expectation to reflect the fact :defined now applies inside custom element constructors immediately after super() call. * fast/custom-elements/defined-rule.html: Added a test case for :defined not applying to a failed-to-upgrade custom element. Also adjusted the height of the last box so that the green box is still 100px by 100px. * fast/custom-elements/upgrading/Node-cloneNode-expected.txt: * fast/custom-elements/upgrading/Node-cloneNode.html: Added a test to make sure we don't try to upgrade a custom element for the second time when the first attempt resulted in the constructor throwing an exception. Canonical link: https://commits.webkit.org/179748@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@205416 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-04 05:09:28 +00:00
if (element->isCustomElementUpgradeCandidate() && element->tagQName() == elementInterface.name())
Custom elements reactions should have a queue per element https://bugs.webkit.org/show_bug.cgi?id=163878 Reviewed by Antti Koivisto. Source/WebCore: This patch splits the custom elements reaction queue into per element to match the latest HTML specifications: https://html.spec.whatwg.org/multipage/scripting.html#custom-element-reaction-queue and introduces the backup element queue: https://html.spec.whatwg.org/multipage/scripting.html#backup-element-queue In terms of code changes, CustomElementReactionStack now holds onto ElementQueue, an ordered list of elements, and make each ElementRareData keep its own CustomElementReactionQueue. CustomElementReactionQueue is created for each custom element when it is synchronously constructed or enqueued to upgrade. Because each reaction queue is now specific to each element, CustomElementReactionQueue instead of CustomElementReactionQueueItem stores JSCustomElementInterface. The backup element queue is created as a singleton returned by CustomElementReactionStack's backupElementQueue, and ensureBackupQueue() schedules a new mirotask to process the backup queue when there isn't already one. ensureCurrentQueue() now returns a reference to CustomElementReactionQueue instead of a pointer since it can fallback to the backup queue when the stack is empty as specified: https://html.spec.whatwg.org/multipage/scripting.html#enqueue-an-element-on-the-appropriate-element-queue Note that ensureCurrentQueue() may insert the same element multiple times into the element queue for now since avoiding this duplication would require either doing O(n) iteration on m_elements or adding a HashSet. We can revisit this in the future if the reaction queue is found to grow beyond a few entries since elements in the element queue will have duplicates only when each reaction queue has more than one item. Tests: fast/custom-elements/backup-element-queue.html fast/custom-elements/custom-element-reaction-queue.html * bindings/js/JSCustomElementInterface.cpp: (WebCore::JSCustomElementInterface::upgradeElement): * dom/CustomElementReactionQueue.cpp: (WebCore::CustomElementReactionQueueItem::CustomElementReactionQueueItem): (WebCore::CustomElementReactionQueueItem::invoke): Removed the check for isFailedCustomElement since the queue is explicitly cleared in Element::setIsFailedCustomElement. (WebCore::CustomElementReactionQueue::CustomElementReactionQueue): Now takes JSCustomElementInterface since each item in the queue no longer stores Element or JSCustomElementInterface. (WebCore::CustomElementReactionQueue::clear): (WebCore::CustomElementReactionQueue::enqueueElementUpgrade): (WebCore::CustomElementReactionQueue::enqueueElementUpgradeIfDefined): (WebCore::CustomElementReactionQueue::enqueueConnectedCallbackIfNeeded): (WebCore::CustomElementReactionQueue::enqueueDisconnectedCallbackIfNeeded): (WebCore::CustomElementReactionQueue::enqueueAdoptedCallbackIfNeeded): (WebCore::CustomElementReactionQueue::enqueueAttributeChangedCallbackIfNeeded): (WebCore::CustomElementReactionQueue::enqueuePostUpgradeReactions): (WebCore::CustomElementReactionQueue::invokeAll): (WebCore::CustomElementReactionStack::ElementQueue::add): Added. (WebCore::CustomElementReactionStack::ElementQueue::invokeAll): Added. (WebCore::CustomElementReactionStack::ensureCurrentQueue): (WebCore::BackupElementQueueMicrotask): Added. (WebCore::CustomElementReactionStack::ensureBackupQueue): Added. (WebCore::CustomElementReactionStack::processBackupQueue): Added. (WebCore::CustomElementReactionStack::backupElementQueue): Added. * dom/CustomElementReactionQueue.h: * dom/CustomElementRegistry.cpp: (WebCore::enqueueUpgradeInShadowIncludingTreeOrder): * dom/Document.cpp: (WebCore::createFallbackHTMLElement): * dom/Element.cpp: (WebCore::Element::setIsDefinedCustomElement): Create a new reaction queue if there isn't already one; when this element had been upgraded, the reaction queue have already been created in Element::enqueueToUpgrade. (WebCore::Element::setIsFailedCustomElement): Clear the reaction queue when the upgrading had failed. (WebCore::Element::enqueueToUpgrade): Added. (WebCore::Element::reactionQueue): Added. * dom/Element.h: * dom/ElementRareData.h: (WebCore::ElementRareData::customElementReactionQueue): Replaced customElementInterface. (WebCore::ElementRareData::setCustomElementReactionQueue): Replaced setCustomElementReactionQueue. LayoutTests: Added a W3C style testharness.js test for making sure the custom element reaction queue exists per element, and added a WebKit style test for making sure that the backup element queue exists. * fast/custom-elements/backup-element-queue-expected.txt: Added. * fast/custom-elements/backup-element-queue.html: Added. * fast/custom-elements/custom-element-reaction-queue-expected.txt: Added. * fast/custom-elements/custom-element-reaction-queue.html: Added. Canonical link: https://commits.webkit.org/181667@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@207810 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-25 06:18:13 +00:00
element->enqueueToUpgrade(elementInterface);
Only update connected custom elements https://bugs.webkit.org/show_bug.cgi?id=161480 Reviewed by Yusuke Suzuki. Source/WebCore: In the latest specs, creating an element only upgrades an element if the custom element had already been defined: https://dom.spec.whatwg.org/#concept-create-element Otherwise, an element remains unresolved until it gets connected to the document associated with the global object: https://dom.spec.whatwg.org/#concept-node-insert This patch removes the upgrade candidate map in CustomElementRegistry, and traverses the entire document associated with global object (DOMWindow) in addElementDefinition: https://html.spec.whatwg.org/#dom-customelementregistry-define The traversal is done in the shadow-including tree order (different from depth-first preorder traversal of flat tree) since it doesn't enter slots and children of shadow hosts are always visited even if they are not assigned to a slot: https://dom.spec.whatwg.org/#concept-shadow-including-tree-order Test: fast/custom-elements/enqueue-custom-element-upgrade-reaction.html * bindings/js/JSCustomElementInterface.cpp: (WebCore::JSCustomElementInterface::upgradeElement): Assert that the element being upgraded as the same qualified name as the custom element interface. * bindings/js/JSCustomElementRegistryCustom.cpp: (WebCore::JSCustomElementRegistry::define): Moved the code to resolve the promise from here to addElementDefinition. Also cleaned up the code to extract callbacks a little. * dom/CustomElementReactionQueue.cpp: (WebCore::CustomElementReactionQueue::enqueueElementUpgrade): Added an assertion. (WebCore::CustomElementReactionQueue::enqueueElementUpgradeIfDefined): Added. Upgrade an element if the custom element had already been defined. * dom/CustomElementReactionQueue.h: * dom/CustomElementRegistry.cpp: (WebCore::CustomElementRegistry::create): Stores the reference to DOMWindow to find its document in addElementDefinition. (WebCore::CustomElementRegistry::CustomElementRegistry): Ditto. (WebCore::enqueueUpgradeInShadowIncludingTreeOrder): Added. Enqueue upgrade reactions in shadow-including tree order. (WebCore::CustomElementRegistry::addElementDefinition): Upgrade all unresolved elements that matches this definition and resolve the the promise returned by "whenDefined" if there is any. (WebCore::CustomElementRegistry::addUpgradeCandidate): Deleted. (WebCore::CustomElementRegistry::findInterface): Added a new variant that takes an element. * dom/CustomElementRegistry.h: * dom/Document.cpp: (WebCore::createUpgradeCandidateElement): No longer takes DOMWindow since we don't upgrade synchronously here. It's also wrong not to mark the element as unresolved custom element in a document without a browsing context per new semantics. (WebCore::createHTMLElementWithNameValidation): Ditto. (WebCore::createFallbackHTMLElement): Ditto. * dom/Element.cpp: (WebCore::Element::insertedInto): Enqueue an upgrade reaction if this is an unsolved custom element and there is now a definition for it (the latter condition is checked in enqueueElementUpgradeIfDefined). * html/parser/HTMLConstructionSite.cpp: (WebCore::HTMLConstructionSite::createHTMLElementOrFindCustomElementInterface): Don't upgrade this element until it gets connected to a document in Element::insertedInto. * page/DOMWindow.cpp: (WebCore::DOMWindow::ensureCustomElementRegistry): LayoutTests: Added a W3c-style testharness.js test for https://html.spec.whatwg.org/#enqueue-a-custom-element-upgrade-reaction and added more test cases for :defined and customElements.define. * fast/custom-elements/CustomElementRegistry.html: Revised descriptions for "get" and "whenDefined" test cases consistent with ones for "define". * fast/custom-elements/defined-pseudo-class-expected.txt: * fast/custom-elements/defined-pseudo-class.html: * fast/custom-elements/enqueue-custom-element-upgrade-reaction-expected.txt: Added. * fast/custom-elements/enqueue-custom-element-upgrade-reaction.html: Added. * fast/custom-elements/resources/document-types.js: (create): Canonical link: https://commits.webkit.org/179676@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@205340 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-02 06:17:17 +00:00
if (auto* shadowRoot = element->shadowRoot()) {
Merge Element::ShadowRootMode and ShadowRoot::Mode enumerations https://bugs.webkit.org/show_bug.cgi?id=164063 Reviewed by Sam Weinig. Merge Element::ShadowRootMode and ShadowRoot::Mode enumerations now that we support having IDL string enumerations in their own IDL file. No new tests, no Web-exposed behavior change. * CMakeLists.txt: * DerivedSources.cpp: * DerivedSources.make: * WebCore.xcodeproj/project.pbxproj: * css/ElementRuleCollector.cpp: (WebCore::ElementRuleCollector::collectMatchingRules): (WebCore::ElementRuleCollector::matchAuthorShadowPseudoElementRules): (WebCore::ElementRuleCollector::collectMatchingShadowPseudoElementRules): * css/SelectorChecker.cpp: (WebCore::SelectorChecker::matchRecursively): * dom/CustomElementRegistry.cpp: (WebCore::enqueueUpgradeInShadowIncludingTreeOrder): * dom/Element.cpp: (WebCore::Element::bindingsOffsetParent): (WebCore::Element::addShadowRoot): (WebCore::Element::attachShadow): (WebCore::Element::shadowRootForBindings): (WebCore::Element::userAgentShadowRoot): (WebCore::Element::ensureUserAgentShadowRoot): * dom/Element.h: * dom/Element.idl: * dom/InlineStyleSheetOwner.cpp: (WebCore::parserContextForElement): * dom/Node.cpp: (WebCore::Node::isUnclosedNode): (WebCore::Node::assignedSlotForBindings): (WebCore::Node::isInUserAgentShadowTree): * dom/ShadowRoot.cpp: (WebCore::ShadowRoot::ShadowRoot): * dom/ShadowRoot.h: * dom/ShadowRoot.idl: * dom/ShadowRootMode.h: Added. * dom/ShadowRootMode.idl: Copied from Source/WebCore/dom/ShadowRoot.idl. * dom/SlotAssignment.cpp: (WebCore::SlotAssignment::didChangeSlot): * html/HTMLSummaryElement.cpp: (WebCore::HTMLSummaryElement::create): * inspector/InspectorDOMAgent.cpp: (WebCore::shadowRootType): * rendering/HitTestResult.cpp: (WebCore::moveOutOfUserAgentShadowTree): * rendering/RenderElement.cpp: (WebCore::RenderElement::selectionPseudoStyle): * rendering/RenderLayer.cpp: (WebCore::rendererForScrollbar): * style/StyleScope.cpp: (WebCore::Style::Scope::shouldUseSharedUserAgentShadowTreeStyleResolver): (WebCore::Style::Scope::didChangeStyleSheetEnvironment): * svg/SVGElement.cpp: (WebCore::SVGElement::correspondingUseElement): * testing/Internals.cpp: (WebCore::Internals::shadowRootType): Canonical link: https://commits.webkit.org/181790@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@208001 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-27 20:23:06 +00:00
if (shadowRoot->mode() != ShadowRootMode::UserAgent)
Only update connected custom elements https://bugs.webkit.org/show_bug.cgi?id=161480 Reviewed by Yusuke Suzuki. Source/WebCore: In the latest specs, creating an element only upgrades an element if the custom element had already been defined: https://dom.spec.whatwg.org/#concept-create-element Otherwise, an element remains unresolved until it gets connected to the document associated with the global object: https://dom.spec.whatwg.org/#concept-node-insert This patch removes the upgrade candidate map in CustomElementRegistry, and traverses the entire document associated with global object (DOMWindow) in addElementDefinition: https://html.spec.whatwg.org/#dom-customelementregistry-define The traversal is done in the shadow-including tree order (different from depth-first preorder traversal of flat tree) since it doesn't enter slots and children of shadow hosts are always visited even if they are not assigned to a slot: https://dom.spec.whatwg.org/#concept-shadow-including-tree-order Test: fast/custom-elements/enqueue-custom-element-upgrade-reaction.html * bindings/js/JSCustomElementInterface.cpp: (WebCore::JSCustomElementInterface::upgradeElement): Assert that the element being upgraded as the same qualified name as the custom element interface. * bindings/js/JSCustomElementRegistryCustom.cpp: (WebCore::JSCustomElementRegistry::define): Moved the code to resolve the promise from here to addElementDefinition. Also cleaned up the code to extract callbacks a little. * dom/CustomElementReactionQueue.cpp: (WebCore::CustomElementReactionQueue::enqueueElementUpgrade): Added an assertion. (WebCore::CustomElementReactionQueue::enqueueElementUpgradeIfDefined): Added. Upgrade an element if the custom element had already been defined. * dom/CustomElementReactionQueue.h: * dom/CustomElementRegistry.cpp: (WebCore::CustomElementRegistry::create): Stores the reference to DOMWindow to find its document in addElementDefinition. (WebCore::CustomElementRegistry::CustomElementRegistry): Ditto. (WebCore::enqueueUpgradeInShadowIncludingTreeOrder): Added. Enqueue upgrade reactions in shadow-including tree order. (WebCore::CustomElementRegistry::addElementDefinition): Upgrade all unresolved elements that matches this definition and resolve the the promise returned by "whenDefined" if there is any. (WebCore::CustomElementRegistry::addUpgradeCandidate): Deleted. (WebCore::CustomElementRegistry::findInterface): Added a new variant that takes an element. * dom/CustomElementRegistry.h: * dom/Document.cpp: (WebCore::createUpgradeCandidateElement): No longer takes DOMWindow since we don't upgrade synchronously here. It's also wrong not to mark the element as unresolved custom element in a document without a browsing context per new semantics. (WebCore::createHTMLElementWithNameValidation): Ditto. (WebCore::createFallbackHTMLElement): Ditto. * dom/Element.cpp: (WebCore::Element::insertedInto): Enqueue an upgrade reaction if this is an unsolved custom element and there is now a definition for it (the latter condition is checked in enqueueElementUpgradeIfDefined). * html/parser/HTMLConstructionSite.cpp: (WebCore::HTMLConstructionSite::createHTMLElementOrFindCustomElementInterface): Don't upgrade this element until it gets connected to a document in Element::insertedInto. * page/DOMWindow.cpp: (WebCore::DOMWindow::ensureCustomElementRegistry): LayoutTests: Added a W3c-style testharness.js test for https://html.spec.whatwg.org/#enqueue-a-custom-element-upgrade-reaction and added more test cases for :defined and customElements.define. * fast/custom-elements/CustomElementRegistry.html: Revised descriptions for "get" and "whenDefined" test cases consistent with ones for "define". * fast/custom-elements/defined-pseudo-class-expected.txt: * fast/custom-elements/defined-pseudo-class.html: * fast/custom-elements/enqueue-custom-element-upgrade-reaction-expected.txt: Added. * fast/custom-elements/enqueue-custom-element-upgrade-reaction.html: Added. * fast/custom-elements/resources/document-types.js: (create): Canonical link: https://commits.webkit.org/179676@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@205340 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-02 06:17:17 +00:00
enqueueUpgradeInShadowIncludingTreeOrder(*shadowRoot, elementInterface);
}
}
}
RefPtr<DeferredPromise> CustomElementRegistry::addElementDefinition(Ref<JSCustomElementInterface>&& elementInterface)
Add document.defineCustomElement https://bugs.webkit.org/show_bug.cgi?id=153092 Reviewed by Chris Dumez. Source/WebCore: Added document.defineCustomElement and added a constructor to HTMLElement which can be called as "super" in a subclass of HTMLElement. This is a prototype of new custom elements API and willfully violates the current specification at http://w3c.github.io/webcomponents/spec/custom/ Each author defined class can define multiple elements using distinct tag names. In such cases, the super call must specify the tag name. e.g. class SomeCustomElement extends HTMLElement { constructor(name) { super(name); } } document.defineCustomElement('some-custom-element', SomeCustomElement); document.defineCustomElement('other-custom-element', SomeCustomElement); new SomeCustomElement('some-custom-element'); When a class is associated with exactly one tag name, the argument can be omitted. e.g. class AnotherCustomElement extends HTMLElement {} document.defineCustomElement('another-custom-element', AnotherCustomElement); new AnotherCustomElement(); We allow only subclassing of HTMLElement and only in (X)HTML namespace. Tests: fast/custom-elements/Document-defineCustomElement.html fast/custom-elements/HTMLElement-constructor.html * CMakeLists.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSCustomElementInterface.cpp: Added. Abstracts an author-defined class associated with a custom element. It's a Active DOM object and lives until the associated document dies. (WebCore::JSCustomElementInterface::JSCustomElementInterface): (WebCore::JSCustomElementInterface::~JSCustomElementInterface): * bindings/js/JSCustomElementInterface.h: Added. (WebCore::JSCustomElementInterface::create): (WebCore::JSCustomElementInterface::scriptExecutionContext): (WebCore::JSCustomElementInterface::constructor): * bindings/js/JSDocumentCustom.cpp: (WebCore::JSDocument::defineCustomElement): Added. Define a custom element by associating a tag name with an author defined JS class after validating arguments. * bindings/js/JSHTMLElementCustom.cpp: (WebCore::constructJSHTMLElement): Added. Look up the tag name based on new.target if one is not specified. If a tag name is specified, check that new.target is associated with the tag name. * dom/CustomElementDefinitions.cpp: Added. (WebCore::CustomElementDefinitions::checkName): Added. Restricts tag names similarly to http://w3c.github.io/webcomponents/spec/custom/#dfn-custom-element-type (WebCore::CustomElementDefinitions::defineElement): Added. Associates a JS class with a tag name. (WebCore::CustomElementDefinitions::findInterface): Added. Finds a JS class by a tag name. (WebCore::CustomElementDefinitions::findName): Added. Finds a tag name by a JS class. * dom/CustomElementDefinitions.h: Added. (WebCore::CustomElementDefinitions::CustomElementInfo): Added. * dom/Document.cpp: (WebCore::Document::ensureCustomElementDefinitions): Added. * dom/Document.h: (WebCore::Document::customElementDefinitions): Added. * dom/Document.idl: * html/HTMLElement.idl: LayoutTests: Added tests for document.defineCustomElement and instantiating custom elements. * TestExpectations: Skipped the tests on non-Mac ports. * fast/custom-elements: Added. * fast/custom-elements/Document-defineCustomElement-expected.txt: Added. * fast/custom-elements/Document-defineCustomElement.html: Added. * fast/custom-elements/HTMLElement-constructor-expected.txt: Added. * fast/custom-elements/HTMLElement-constructor.html: Added. * platform/mac/TestExpectations: Canonical link: https://commits.webkit.org/171208@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@195087 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-01-15 02:59:03 +00:00
{
AtomString localName = elementInterface->name().localName();
Move QualifiedName from CustomElementInfo to JSCustomElementInterface https://bugs.webkit.org/show_bug.cgi?id=155061 Reviewed by Antti Koivisto. Store QualifiedName of custom elements in JSCustomElementInterface instead of CustomElementInfo now that each interface is associated with exactly one custom element as of r197602. No new tests since this is a refactoring. * bindings/js/JSCustomElementInterface.cpp: (WebCore::JSCustomElementInterface::JSCustomElementInterface): Now takes QualifiedName as the first argument. * bindings/js/JSCustomElementInterface.h: (WebCore::JSCustomElementInterface::create): (WebCore::JSCustomElementInterface::name): Added. * bindings/js/JSDocumentCustom.cpp: (WebCore::JSDocument::defineElement): * bindings/js/JSHTMLElementCustom.cpp: (WebCore::constructJSHTMLElement): Use findInterface instead of the deleted findName. * dom/CustomElementDefinitions.cpp: (WebCore::CustomElementDefinitions::checkName): (WebCore::CustomElementDefinitions::addElementDefinition): Renamed from defineElement. (WebCore::CustomElementDefinitions::findInterface): Add a variant that finds the interface object by a JS constructor. (WebCore::CustomElementDefinitions::containsConstructor): (WebCore::CustomElementDefinitions::findName): Deleted. * dom/CustomElementDefinitions.h: (WebCore::CustomElementDefinitions::CustomElementInfo::CustomElementInfo): Deleted. Canonical link: https://commits.webkit.org/173146@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@197612 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-03-05 08:31:38 +00:00
ASSERT(!m_nameMap.contains(localName));
[Win] Custom elements tests are failing. https://bugs.webkit.org/show_bug.cgi?id=159139 Reviewed by Alex Christensen. .: Enable custom element API on Windows. * Source/cmake/OptionsWin.cmake: Source/WebCore: Fix compile errors after enabling custom element API. * bindings/js/JSHTMLElementCustom.cpp: (WebCore::constructJSHTMLElement): * dom/CustomElementDefinitions.cpp: (WebCore::CustomElementDefinitions::addElementDefinition): * dom/Document.cpp: (WebCore::createHTMLElementWithNameValidation): (WebCore::createFallbackHTMLElement): * dom/Element.cpp: (WebCore::Element::attributeChanged): * dom/LifecycleCallbackQueue.cpp: (WebCore::LifecycleQueueItem::LifecycleQueueItem): (WebCore::LifecycleCallbackQueue::enqueueElementUpgrade): (WebCore::LifecycleCallbackQueue::enqueueAttributeChangedCallback): * html/parser/HTMLConstructionSite.cpp: (WebCore::HTMLConstructionSite::insertHTMLElementOrFindCustomElementInterface): (WebCore::HTMLConstructionSite::createHTMLElementOrFindCustomElementInterface): * html/parser/HTMLDocumentParser.cpp: (WebCore::HTMLDocumentParser::runScriptsForPausedTreeBuilder): * html/parser/HTMLTreeBuilder.cpp: (WebCore::CustomElementConstructionData::CustomElementConstructionData): (WebCore::HTMLTreeBuilder::insertGenericHTMLElement): * html/parser/HTMLTreeBuilder.h: Source/WebKit/win: Add preference for enabling custom element API. * Interfaces/IWebPreferencesPrivate.idl: * WebPreferenceKeysPrivate.h: * WebPreferences.cpp: (WebPreferences::initializeDefaultSettings): (WebPreferences::customElementsEnabled): (WebPreferences::setCustomElementsEnabled): * WebPreferences.h: * WebView.cpp: (WebView::notifyPreferencesChanged): Tools: Enable custom element API when running tests. * DumpRenderTree/win/DumpRenderTree.cpp: (resetWebPreferencesToConsistentValues): LayoutTests: Update test expectations for passing custom elements tests. * platform/win/TestExpectations: Canonical link: https://commits.webkit.org/177306@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202559 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-28 11:49:21 +00:00
m_constructorMap.add(elementInterface->constructor(), elementInterface.ptr());
m_nameMap.add(localName, elementInterface.copyRef());
defineElement should upgrade existing unresolved custom elements https://bugs.webkit.org/show_bug.cgi?id=155107 Reviewed by Darin Adler. Source/WebCore: Added the support for upgrading existing unresolved custom elements when defineElement is called. The current implementation upgrades elements in the order they were created and has the issue that it keeps accumulating all elements with a hyphen in its name until defineElement is called as documented in https://github.com/w3c/webcomponents/issues/419 This patch re-purposes IsEditingTextFlag to indicate that the node is an unresolved custom element. Since isEditingText() is only called in textRendererIsNeeded only on Text nodes, it's mutually exclusive with isUnresolvedCustomElement(). The list of unresolved custom elements is kept in m_upgradeCandidatesMap, a hash map of element names to the list of unresolved elements with that name. In addition, added the logic to use HTMLElement as the interface for unresolved custom element instead of HTMLUnknownElement. Test: fast/custom-elements/upgrading/upgrading-parser-created-element.html * bindings/js/JSCustomElementInterface.cpp: (WebCore::JSCustomElementInterface::upgradeElement): Clear the flag. * bindings/js/JSDocumentCustom.cpp: (WebCore::JSDocument::defineElement): Set the unique private name to keep the interface alive before calling addElementDefinition as the call can now invoke author scripts. * dom/CustomElementDefinitions.cpp: (WebCore::CustomElementDefinitions::addElementDefinition): Upgrade existing unresolved elements kept in m_upgradeCandidatesMap. (WebCore::CustomElementDefinitions::addUpgradeCandidate): Added. * dom/CustomElementDefinitions.h: * dom/Document.cpp: (WebCore::createHTMLElementWithNameValidation): Added the code to add the unresolved custom elements to the upgrade candidates map. Also instantiate it as HTMLElement instead of HTMLUnknownElement. (WebCore::createFallbackHTMLElement): Ditto. * dom/Node.h: (WebCore::Node::setIsCustomElement): (WebCore::Node::isUnresolvedCustomElement): Added. (WebCore::Node::setIsUnresolvedCustomElement): Added. (WebCore::Node::setCustomElementIsResolved): Added. Clears IsEditingTextOrUnresolvedCustomElementFlag and sets IsCustomElement. (WebCore::Node::isEditingText): Check both IsEditingTextOrUnresolvedCustomElementFlag and IsTextFlag for safety even though it's currently only used in textRendererIsNeeded which takes Text&. * dom/make_names.pl: (defaultParametersHash): Added customElementInterfaceName as a parameter. (printWrapperFactoryCppFile): Generate the code to use customElementInterfaceName when the element for which the wrapper is created has isUnresolvedCustomElement flag set. * html/HTMLTagNames.in: Use HTMLElement for unresolved custom elements. * html/parser/HTMLConstructionSite.cpp: (WebCore::HTMLConstructionSite::createHTMLElementOrFindCustomElementInterface): Added the code to add the unresolved custom elements to the upgrade candidates map. Also instantiate it as HTMLElement instead of HTMLUnknownElement. LayoutTests: Added W3C style testharness.js tests for asynchronously defining custom elements. * fast/custom-elements/upgrading/Node-cloneNode.html: * fast/custom-elements/upgrading/upgrading-parser-created-element-expected.txt: Added. * fast/custom-elements/upgrading/upgrading-parser-created-element.html: Added. Canonical link: https://commits.webkit.org/173391@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@197917 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-03-10 02:33:12 +00:00
Only update connected custom elements https://bugs.webkit.org/show_bug.cgi?id=161480 Reviewed by Yusuke Suzuki. Source/WebCore: In the latest specs, creating an element only upgrades an element if the custom element had already been defined: https://dom.spec.whatwg.org/#concept-create-element Otherwise, an element remains unresolved until it gets connected to the document associated with the global object: https://dom.spec.whatwg.org/#concept-node-insert This patch removes the upgrade candidate map in CustomElementRegistry, and traverses the entire document associated with global object (DOMWindow) in addElementDefinition: https://html.spec.whatwg.org/#dom-customelementregistry-define The traversal is done in the shadow-including tree order (different from depth-first preorder traversal of flat tree) since it doesn't enter slots and children of shadow hosts are always visited even if they are not assigned to a slot: https://dom.spec.whatwg.org/#concept-shadow-including-tree-order Test: fast/custom-elements/enqueue-custom-element-upgrade-reaction.html * bindings/js/JSCustomElementInterface.cpp: (WebCore::JSCustomElementInterface::upgradeElement): Assert that the element being upgraded as the same qualified name as the custom element interface. * bindings/js/JSCustomElementRegistryCustom.cpp: (WebCore::JSCustomElementRegistry::define): Moved the code to resolve the promise from here to addElementDefinition. Also cleaned up the code to extract callbacks a little. * dom/CustomElementReactionQueue.cpp: (WebCore::CustomElementReactionQueue::enqueueElementUpgrade): Added an assertion. (WebCore::CustomElementReactionQueue::enqueueElementUpgradeIfDefined): Added. Upgrade an element if the custom element had already been defined. * dom/CustomElementReactionQueue.h: * dom/CustomElementRegistry.cpp: (WebCore::CustomElementRegistry::create): Stores the reference to DOMWindow to find its document in addElementDefinition. (WebCore::CustomElementRegistry::CustomElementRegistry): Ditto. (WebCore::enqueueUpgradeInShadowIncludingTreeOrder): Added. Enqueue upgrade reactions in shadow-including tree order. (WebCore::CustomElementRegistry::addElementDefinition): Upgrade all unresolved elements that matches this definition and resolve the the promise returned by "whenDefined" if there is any. (WebCore::CustomElementRegistry::addUpgradeCandidate): Deleted. (WebCore::CustomElementRegistry::findInterface): Added a new variant that takes an element. * dom/CustomElementRegistry.h: * dom/Document.cpp: (WebCore::createUpgradeCandidateElement): No longer takes DOMWindow since we don't upgrade synchronously here. It's also wrong not to mark the element as unresolved custom element in a document without a browsing context per new semantics. (WebCore::createHTMLElementWithNameValidation): Ditto. (WebCore::createFallbackHTMLElement): Ditto. * dom/Element.cpp: (WebCore::Element::insertedInto): Enqueue an upgrade reaction if this is an unsolved custom element and there is now a definition for it (the latter condition is checked in enqueueElementUpgradeIfDefined). * html/parser/HTMLConstructionSite.cpp: (WebCore::HTMLConstructionSite::createHTMLElementOrFindCustomElementInterface): Don't upgrade this element until it gets connected to a document in Element::insertedInto. * page/DOMWindow.cpp: (WebCore::DOMWindow::ensureCustomElementRegistry): LayoutTests: Added a W3c-style testharness.js test for https://html.spec.whatwg.org/#enqueue-a-custom-element-upgrade-reaction and added more test cases for :defined and customElements.define. * fast/custom-elements/CustomElementRegistry.html: Revised descriptions for "get" and "whenDefined" test cases consistent with ones for "define". * fast/custom-elements/defined-pseudo-class-expected.txt: * fast/custom-elements/defined-pseudo-class.html: * fast/custom-elements/enqueue-custom-element-upgrade-reaction-expected.txt: Added. * fast/custom-elements/enqueue-custom-element-upgrade-reaction.html: Added. * fast/custom-elements/resources/document-types.js: (create): Canonical link: https://commits.webkit.org/179676@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@205340 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-02 06:17:17 +00:00
if (auto* document = m_window.document())
enqueueUpgradeInShadowIncludingTreeOrder(*document, elementInterface.get());
HashMap<Ref<T>>::take should return RefPtr<T> https://bugs.webkit.org/show_bug.cgi?id=215830 Reviewed by Darin Adler. Source/WebCore: * Modules/indexeddb/client/IDBConnectionProxy.cpp: (WebCore::IDBClient::IDBConnectionProxy::didGetAllDatabaseNamesAndVersions): * accessibility/isolatedtree/AXIsolatedTree.cpp: (WebCore::AXIsolatedTree::removeTreeForPageID): * crypto/SubtleCrypto.cpp: (WebCore::getPromise): * dom/CustomElementRegistry.cpp: (WebCore::CustomElementRegistry::addElementDefinition): * dom/ScriptRunner.cpp: (WebCore::ScriptRunner::notifyFinished): * inspector/agents/InspectorCSSAgent.cpp: (WebCore::InspectorCSSAgent::didRemoveDOMNode): * page/PageOverlayController.cpp: (WebCore::PageOverlayController::uninstallPageOverlay): * workers/service/ServiceWorkerClients.cpp: (WebCore::ServiceWorkerClients::claim): * workers/service/context/ServiceWorkerThreadProxy.cpp: (WebCore::ServiceWorkerThreadProxy::cancelFetch): * workers/service/server/SWServer.cpp: (WebCore::SWServer::workerContextTerminated): Source/WebKit: * GPUProcess/media/RemoteAudioDestinationManager.cpp: (WebKit::RemoteAudioDestinationManager::deleteAudioDestination): * NetworkProcess/NetworkResourceLoadMap.cpp: (WebKit::NetworkResourceLoadMap::take): * UIProcess/Automation/WebAutomationSession.cpp: (WebKit::WebAutomationSession::willClosePage): * UIProcess/WebURLSchemeHandler.cpp: (WebKit::WebURLSchemeHandler::taskCompleted): * WebProcess/MediaStream/UserMediaPermissionRequestManager.cpp: (WebKit::UserMediaPermissionRequestManager::userMediaAccessWasGranted): (WebKit::UserMediaPermissionRequestManager::userMediaAccessWasDenied): Source/WebKitLegacy/mac: * WebCoreSupport/WebEditorClient.mm: (WebEditorClient::didCheckSucceed): Source/WTF: Updated the hash traits for Ref<T> to make HashMap<Ref<T>> and HashSet<Ref<T>> return RefPtr<T> instad of Optional<Ref<T>>. * wtf/HashTraits.h: (WTF::RefHashTraits::take): Tools: * TestWebKitAPI/Tests/WTF/HashMap.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/HashSet.cpp: (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/228626@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266157 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-08-26 02:25:04 +00:00
return m_promiseMap.take(localName);
defineElement should upgrade existing unresolved custom elements https://bugs.webkit.org/show_bug.cgi?id=155107 Reviewed by Darin Adler. Source/WebCore: Added the support for upgrading existing unresolved custom elements when defineElement is called. The current implementation upgrades elements in the order they were created and has the issue that it keeps accumulating all elements with a hyphen in its name until defineElement is called as documented in https://github.com/w3c/webcomponents/issues/419 This patch re-purposes IsEditingTextFlag to indicate that the node is an unresolved custom element. Since isEditingText() is only called in textRendererIsNeeded only on Text nodes, it's mutually exclusive with isUnresolvedCustomElement(). The list of unresolved custom elements is kept in m_upgradeCandidatesMap, a hash map of element names to the list of unresolved elements with that name. In addition, added the logic to use HTMLElement as the interface for unresolved custom element instead of HTMLUnknownElement. Test: fast/custom-elements/upgrading/upgrading-parser-created-element.html * bindings/js/JSCustomElementInterface.cpp: (WebCore::JSCustomElementInterface::upgradeElement): Clear the flag. * bindings/js/JSDocumentCustom.cpp: (WebCore::JSDocument::defineElement): Set the unique private name to keep the interface alive before calling addElementDefinition as the call can now invoke author scripts. * dom/CustomElementDefinitions.cpp: (WebCore::CustomElementDefinitions::addElementDefinition): Upgrade existing unresolved elements kept in m_upgradeCandidatesMap. (WebCore::CustomElementDefinitions::addUpgradeCandidate): Added. * dom/CustomElementDefinitions.h: * dom/Document.cpp: (WebCore::createHTMLElementWithNameValidation): Added the code to add the unresolved custom elements to the upgrade candidates map. Also instantiate it as HTMLElement instead of HTMLUnknownElement. (WebCore::createFallbackHTMLElement): Ditto. * dom/Node.h: (WebCore::Node::setIsCustomElement): (WebCore::Node::isUnresolvedCustomElement): Added. (WebCore::Node::setIsUnresolvedCustomElement): Added. (WebCore::Node::setCustomElementIsResolved): Added. Clears IsEditingTextOrUnresolvedCustomElementFlag and sets IsCustomElement. (WebCore::Node::isEditingText): Check both IsEditingTextOrUnresolvedCustomElementFlag and IsTextFlag for safety even though it's currently only used in textRendererIsNeeded which takes Text&. * dom/make_names.pl: (defaultParametersHash): Added customElementInterfaceName as a parameter. (printWrapperFactoryCppFile): Generate the code to use customElementInterfaceName when the element for which the wrapper is created has isUnresolvedCustomElement flag set. * html/HTMLTagNames.in: Use HTMLElement for unresolved custom elements. * html/parser/HTMLConstructionSite.cpp: (WebCore::HTMLConstructionSite::createHTMLElementOrFindCustomElementInterface): Added the code to add the unresolved custom elements to the upgrade candidates map. Also instantiate it as HTMLElement instead of HTMLUnknownElement. LayoutTests: Added W3C style testharness.js tests for asynchronously defining custom elements. * fast/custom-elements/upgrading/Node-cloneNode.html: * fast/custom-elements/upgrading/upgrading-parser-created-element-expected.txt: Added. * fast/custom-elements/upgrading/upgrading-parser-created-element.html: Added. Canonical link: https://commits.webkit.org/173391@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@197917 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-03-10 02:33:12 +00:00
}
Only update connected custom elements https://bugs.webkit.org/show_bug.cgi?id=161480 Reviewed by Yusuke Suzuki. Source/WebCore: In the latest specs, creating an element only upgrades an element if the custom element had already been defined: https://dom.spec.whatwg.org/#concept-create-element Otherwise, an element remains unresolved until it gets connected to the document associated with the global object: https://dom.spec.whatwg.org/#concept-node-insert This patch removes the upgrade candidate map in CustomElementRegistry, and traverses the entire document associated with global object (DOMWindow) in addElementDefinition: https://html.spec.whatwg.org/#dom-customelementregistry-define The traversal is done in the shadow-including tree order (different from depth-first preorder traversal of flat tree) since it doesn't enter slots and children of shadow hosts are always visited even if they are not assigned to a slot: https://dom.spec.whatwg.org/#concept-shadow-including-tree-order Test: fast/custom-elements/enqueue-custom-element-upgrade-reaction.html * bindings/js/JSCustomElementInterface.cpp: (WebCore::JSCustomElementInterface::upgradeElement): Assert that the element being upgraded as the same qualified name as the custom element interface. * bindings/js/JSCustomElementRegistryCustom.cpp: (WebCore::JSCustomElementRegistry::define): Moved the code to resolve the promise from here to addElementDefinition. Also cleaned up the code to extract callbacks a little. * dom/CustomElementReactionQueue.cpp: (WebCore::CustomElementReactionQueue::enqueueElementUpgrade): Added an assertion. (WebCore::CustomElementReactionQueue::enqueueElementUpgradeIfDefined): Added. Upgrade an element if the custom element had already been defined. * dom/CustomElementReactionQueue.h: * dom/CustomElementRegistry.cpp: (WebCore::CustomElementRegistry::create): Stores the reference to DOMWindow to find its document in addElementDefinition. (WebCore::CustomElementRegistry::CustomElementRegistry): Ditto. (WebCore::enqueueUpgradeInShadowIncludingTreeOrder): Added. Enqueue upgrade reactions in shadow-including tree order. (WebCore::CustomElementRegistry::addElementDefinition): Upgrade all unresolved elements that matches this definition and resolve the the promise returned by "whenDefined" if there is any. (WebCore::CustomElementRegistry::addUpgradeCandidate): Deleted. (WebCore::CustomElementRegistry::findInterface): Added a new variant that takes an element. * dom/CustomElementRegistry.h: * dom/Document.cpp: (WebCore::createUpgradeCandidateElement): No longer takes DOMWindow since we don't upgrade synchronously here. It's also wrong not to mark the element as unresolved custom element in a document without a browsing context per new semantics. (WebCore::createHTMLElementWithNameValidation): Ditto. (WebCore::createFallbackHTMLElement): Ditto. * dom/Element.cpp: (WebCore::Element::insertedInto): Enqueue an upgrade reaction if this is an unsolved custom element and there is now a definition for it (the latter condition is checked in enqueueElementUpgradeIfDefined). * html/parser/HTMLConstructionSite.cpp: (WebCore::HTMLConstructionSite::createHTMLElementOrFindCustomElementInterface): Don't upgrade this element until it gets connected to a document in Element::insertedInto. * page/DOMWindow.cpp: (WebCore::DOMWindow::ensureCustomElementRegistry): LayoutTests: Added a W3c-style testharness.js test for https://html.spec.whatwg.org/#enqueue-a-custom-element-upgrade-reaction and added more test cases for :defined and customElements.define. * fast/custom-elements/CustomElementRegistry.html: Revised descriptions for "get" and "whenDefined" test cases consistent with ones for "define". * fast/custom-elements/defined-pseudo-class-expected.txt: * fast/custom-elements/defined-pseudo-class.html: * fast/custom-elements/enqueue-custom-element-upgrade-reaction-expected.txt: Added. * fast/custom-elements/enqueue-custom-element-upgrade-reaction.html: Added. * fast/custom-elements/resources/document-types.js: (create): Canonical link: https://commits.webkit.org/179676@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@205340 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-02 06:17:17 +00:00
JSCustomElementInterface* CustomElementRegistry::findInterface(const Element& element) const
defineElement should upgrade existing unresolved custom elements https://bugs.webkit.org/show_bug.cgi?id=155107 Reviewed by Darin Adler. Source/WebCore: Added the support for upgrading existing unresolved custom elements when defineElement is called. The current implementation upgrades elements in the order they were created and has the issue that it keeps accumulating all elements with a hyphen in its name until defineElement is called as documented in https://github.com/w3c/webcomponents/issues/419 This patch re-purposes IsEditingTextFlag to indicate that the node is an unresolved custom element. Since isEditingText() is only called in textRendererIsNeeded only on Text nodes, it's mutually exclusive with isUnresolvedCustomElement(). The list of unresolved custom elements is kept in m_upgradeCandidatesMap, a hash map of element names to the list of unresolved elements with that name. In addition, added the logic to use HTMLElement as the interface for unresolved custom element instead of HTMLUnknownElement. Test: fast/custom-elements/upgrading/upgrading-parser-created-element.html * bindings/js/JSCustomElementInterface.cpp: (WebCore::JSCustomElementInterface::upgradeElement): Clear the flag. * bindings/js/JSDocumentCustom.cpp: (WebCore::JSDocument::defineElement): Set the unique private name to keep the interface alive before calling addElementDefinition as the call can now invoke author scripts. * dom/CustomElementDefinitions.cpp: (WebCore::CustomElementDefinitions::addElementDefinition): Upgrade existing unresolved elements kept in m_upgradeCandidatesMap. (WebCore::CustomElementDefinitions::addUpgradeCandidate): Added. * dom/CustomElementDefinitions.h: * dom/Document.cpp: (WebCore::createHTMLElementWithNameValidation): Added the code to add the unresolved custom elements to the upgrade candidates map. Also instantiate it as HTMLElement instead of HTMLUnknownElement. (WebCore::createFallbackHTMLElement): Ditto. * dom/Node.h: (WebCore::Node::setIsCustomElement): (WebCore::Node::isUnresolvedCustomElement): Added. (WebCore::Node::setIsUnresolvedCustomElement): Added. (WebCore::Node::setCustomElementIsResolved): Added. Clears IsEditingTextOrUnresolvedCustomElementFlag and sets IsCustomElement. (WebCore::Node::isEditingText): Check both IsEditingTextOrUnresolvedCustomElementFlag and IsTextFlag for safety even though it's currently only used in textRendererIsNeeded which takes Text&. * dom/make_names.pl: (defaultParametersHash): Added customElementInterfaceName as a parameter. (printWrapperFactoryCppFile): Generate the code to use customElementInterfaceName when the element for which the wrapper is created has isUnresolvedCustomElement flag set. * html/HTMLTagNames.in: Use HTMLElement for unresolved custom elements. * html/parser/HTMLConstructionSite.cpp: (WebCore::HTMLConstructionSite::createHTMLElementOrFindCustomElementInterface): Added the code to add the unresolved custom elements to the upgrade candidates map. Also instantiate it as HTMLElement instead of HTMLUnknownElement. LayoutTests: Added W3C style testharness.js tests for asynchronously defining custom elements. * fast/custom-elements/upgrading/Node-cloneNode.html: * fast/custom-elements/upgrading/upgrading-parser-created-element-expected.txt: Added. * fast/custom-elements/upgrading/upgrading-parser-created-element.html: Added. Canonical link: https://commits.webkit.org/173391@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@197917 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-03-10 02:33:12 +00:00
{
Only update connected custom elements https://bugs.webkit.org/show_bug.cgi?id=161480 Reviewed by Yusuke Suzuki. Source/WebCore: In the latest specs, creating an element only upgrades an element if the custom element had already been defined: https://dom.spec.whatwg.org/#concept-create-element Otherwise, an element remains unresolved until it gets connected to the document associated with the global object: https://dom.spec.whatwg.org/#concept-node-insert This patch removes the upgrade candidate map in CustomElementRegistry, and traverses the entire document associated with global object (DOMWindow) in addElementDefinition: https://html.spec.whatwg.org/#dom-customelementregistry-define The traversal is done in the shadow-including tree order (different from depth-first preorder traversal of flat tree) since it doesn't enter slots and children of shadow hosts are always visited even if they are not assigned to a slot: https://dom.spec.whatwg.org/#concept-shadow-including-tree-order Test: fast/custom-elements/enqueue-custom-element-upgrade-reaction.html * bindings/js/JSCustomElementInterface.cpp: (WebCore::JSCustomElementInterface::upgradeElement): Assert that the element being upgraded as the same qualified name as the custom element interface. * bindings/js/JSCustomElementRegistryCustom.cpp: (WebCore::JSCustomElementRegistry::define): Moved the code to resolve the promise from here to addElementDefinition. Also cleaned up the code to extract callbacks a little. * dom/CustomElementReactionQueue.cpp: (WebCore::CustomElementReactionQueue::enqueueElementUpgrade): Added an assertion. (WebCore::CustomElementReactionQueue::enqueueElementUpgradeIfDefined): Added. Upgrade an element if the custom element had already been defined. * dom/CustomElementReactionQueue.h: * dom/CustomElementRegistry.cpp: (WebCore::CustomElementRegistry::create): Stores the reference to DOMWindow to find its document in addElementDefinition. (WebCore::CustomElementRegistry::CustomElementRegistry): Ditto. (WebCore::enqueueUpgradeInShadowIncludingTreeOrder): Added. Enqueue upgrade reactions in shadow-including tree order. (WebCore::CustomElementRegistry::addElementDefinition): Upgrade all unresolved elements that matches this definition and resolve the the promise returned by "whenDefined" if there is any. (WebCore::CustomElementRegistry::addUpgradeCandidate): Deleted. (WebCore::CustomElementRegistry::findInterface): Added a new variant that takes an element. * dom/CustomElementRegistry.h: * dom/Document.cpp: (WebCore::createUpgradeCandidateElement): No longer takes DOMWindow since we don't upgrade synchronously here. It's also wrong not to mark the element as unresolved custom element in a document without a browsing context per new semantics. (WebCore::createHTMLElementWithNameValidation): Ditto. (WebCore::createFallbackHTMLElement): Ditto. * dom/Element.cpp: (WebCore::Element::insertedInto): Enqueue an upgrade reaction if this is an unsolved custom element and there is now a definition for it (the latter condition is checked in enqueueElementUpgradeIfDefined). * html/parser/HTMLConstructionSite.cpp: (WebCore::HTMLConstructionSite::createHTMLElementOrFindCustomElementInterface): Don't upgrade this element until it gets connected to a document in Element::insertedInto. * page/DOMWindow.cpp: (WebCore::DOMWindow::ensureCustomElementRegistry): LayoutTests: Added a W3c-style testharness.js test for https://html.spec.whatwg.org/#enqueue-a-custom-element-upgrade-reaction and added more test cases for :defined and customElements.define. * fast/custom-elements/CustomElementRegistry.html: Revised descriptions for "get" and "whenDefined" test cases consistent with ones for "define". * fast/custom-elements/defined-pseudo-class-expected.txt: * fast/custom-elements/defined-pseudo-class.html: * fast/custom-elements/enqueue-custom-element-upgrade-reaction-expected.txt: Added. * fast/custom-elements/enqueue-custom-element-upgrade-reaction.html: Added. * fast/custom-elements/resources/document-types.js: (create): Canonical link: https://commits.webkit.org/179676@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@205340 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-02 06:17:17 +00:00
return findInterface(element.tagQName());
Add document.defineCustomElement https://bugs.webkit.org/show_bug.cgi?id=153092 Reviewed by Chris Dumez. Source/WebCore: Added document.defineCustomElement and added a constructor to HTMLElement which can be called as "super" in a subclass of HTMLElement. This is a prototype of new custom elements API and willfully violates the current specification at http://w3c.github.io/webcomponents/spec/custom/ Each author defined class can define multiple elements using distinct tag names. In such cases, the super call must specify the tag name. e.g. class SomeCustomElement extends HTMLElement { constructor(name) { super(name); } } document.defineCustomElement('some-custom-element', SomeCustomElement); document.defineCustomElement('other-custom-element', SomeCustomElement); new SomeCustomElement('some-custom-element'); When a class is associated with exactly one tag name, the argument can be omitted. e.g. class AnotherCustomElement extends HTMLElement {} document.defineCustomElement('another-custom-element', AnotherCustomElement); new AnotherCustomElement(); We allow only subclassing of HTMLElement and only in (X)HTML namespace. Tests: fast/custom-elements/Document-defineCustomElement.html fast/custom-elements/HTMLElement-constructor.html * CMakeLists.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSCustomElementInterface.cpp: Added. Abstracts an author-defined class associated with a custom element. It's a Active DOM object and lives until the associated document dies. (WebCore::JSCustomElementInterface::JSCustomElementInterface): (WebCore::JSCustomElementInterface::~JSCustomElementInterface): * bindings/js/JSCustomElementInterface.h: Added. (WebCore::JSCustomElementInterface::create): (WebCore::JSCustomElementInterface::scriptExecutionContext): (WebCore::JSCustomElementInterface::constructor): * bindings/js/JSDocumentCustom.cpp: (WebCore::JSDocument::defineCustomElement): Added. Define a custom element by associating a tag name with an author defined JS class after validating arguments. * bindings/js/JSHTMLElementCustom.cpp: (WebCore::constructJSHTMLElement): Added. Look up the tag name based on new.target if one is not specified. If a tag name is specified, check that new.target is associated with the tag name. * dom/CustomElementDefinitions.cpp: Added. (WebCore::CustomElementDefinitions::checkName): Added. Restricts tag names similarly to http://w3c.github.io/webcomponents/spec/custom/#dfn-custom-element-type (WebCore::CustomElementDefinitions::defineElement): Added. Associates a JS class with a tag name. (WebCore::CustomElementDefinitions::findInterface): Added. Finds a JS class by a tag name. (WebCore::CustomElementDefinitions::findName): Added. Finds a tag name by a JS class. * dom/CustomElementDefinitions.h: Added. (WebCore::CustomElementDefinitions::CustomElementInfo): Added. * dom/Document.cpp: (WebCore::Document::ensureCustomElementDefinitions): Added. * dom/Document.h: (WebCore::Document::customElementDefinitions): Added. * dom/Document.idl: * html/HTMLElement.idl: LayoutTests: Added tests for document.defineCustomElement and instantiating custom elements. * TestExpectations: Skipped the tests on non-Mac ports. * fast/custom-elements: Added. * fast/custom-elements/Document-defineCustomElement-expected.txt: Added. * fast/custom-elements/Document-defineCustomElement.html: Added. * fast/custom-elements/HTMLElement-constructor-expected.txt: Added. * fast/custom-elements/HTMLElement-constructor.html: Added. * platform/mac/TestExpectations: Canonical link: https://commits.webkit.org/171208@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@195087 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-01-15 02:59:03 +00:00
}
Rename CustomElementsRegistry to CustomElementRegistry https://bugs.webkit.org/show_bug.cgi?id=161028 Reviewed by Darin Adler. Source/JavaScriptCore: Added customElements and CustomElementRegistry to the common identifiers list as they're used on JSDOMWindow to hide window.customElements and CustomElementRegistry interface behind a runtime flag. * runtime/CommonIdentifiers.h: Source/WebCore: Renamed CustomElementsRegistry to CustomElementRegistry per https://github.com/w3c/webcomponents/issues/548. Also hide window.customElements and CustomElementRegistry interface behind a runtime enabled. * CMakeLists.txt: * DerivedSources.cpp: * DerivedSources.make: * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSCustomElementRegistryCustom.cpp: Renamed from JSCustomElementsRegistryCustom.cpp. (WebCore::getCustomElementCallback): (WebCore::JSCustomElementRegistry::define): * bindings/js/JSHTMLElementCustom.cpp: (WebCore::constructJSHTMLElement): * dom/CustomElementReactionQueue.cpp: (WebCore::findInterfaceForCustomElement): * dom/CustomElementRegistry.cpp: Renamed from CustomElementsRegistry.cpp. (WebCore::CustomElementRegistry::create): (WebCore::CustomElementRegistry::CustomElementRegistry): (WebCore::CustomElementRegistry::~CustomElementRegistry): (WebCore::CustomElementRegistry::addElementDefinition): (WebCore::CustomElementRegistry::addUpgradeCandidate): (WebCore::CustomElementRegistry::findInterface): (WebCore::CustomElementRegistry::containsConstructor): * dom/CustomElementRegistry.h: Renamed from CustomElementsRegistry.h. * dom/CustomElementRegistry.idl: Renamed from CustomElementsRegistry.idl. * dom/Document.cpp: (WebCore::createUpgradeCandidateElement): (WebCore::createHTMLElementWithNameValidation): (WebCore::createFallbackHTMLElement): * dom/Element.cpp: * html/parser/HTMLConstructionSite.cpp: (WebCore::HTMLConstructionSite::createHTMLElementOrFindCustomElementInterface): * page/DOMWindow.cpp: (WebCore::DOMWindow::ensureCustomElementRegistry): * page/DOMWindow.h: * page/DOMWindow.idl: LayoutTests: Updated the tests and expected results after the rename. * fast/custom-elements/CustomElementRegistry-expected.txt: Renamed from LayoutTests/fast/custom-elements/CustomElementsRegistry-expected.txt. * fast/custom-elements/CustomElementRegistry.html: Renamed from LayoutTests/fast/custom-elements/CustomElementsRegistry.html. * platform/efl/js/dom/global-constructors-attributes-expected.txt: * platform/gtk/js/dom/global-constructors-attributes-expected.txt: * platform/mac-wk1/js/dom/global-constructors-attributes-expected.txt: * platform/mac-yosemite/js/dom/global-constructors-attributes-expected.txt: * platform/mac/js/dom/global-constructors-attributes-expected.txt: * platform/win/js/dom/global-constructors-attributes-expected.txt: Canonical link: https://commits.webkit.org/179194@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@204732 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-08-22 19:45:01 +00:00
JSCustomElementInterface* CustomElementRegistry::findInterface(const QualifiedName& name) const
document.createElement should be able to create a custom element https://bugs.webkit.org/show_bug.cgi?id=153173 Reviewed by Darin Adler. Source/WebCore: Added the support for constructing a custom element via document.createElement. Extracted HTMLElementFactory::createKnownElement, which returns nullptr when the specified name doesn't match any builtin element instead of out of HTMLUnknownElement, out of HTMLElementFactory::createElement. Test: fast/custom-elements/Document-createElement.html * bindings/js/JSCustomElementInterface.cpp: (WebCore::JSCustomElementInterface::constructHTMLElement): Added. Constructs a custom element by invoking its constructor. We allow exceptions to be thrown by the constructor so the caller is responsible for checking any exceptions in the ExecState before preceeding if the returned value is null. * bindings/js/JSCustomElementInterface.h: (WebCore::JSCustomElementInterface::constructSVGElement): Added. * bindings/js/JSElementCustom.cpp: (WebCore::toJSNewlyCreated): Exit early if the element is a custom element as the wrapper had already been created by super() call inside the custom element'c constructor. * bindings/js/JSMainThreadExecState.h: (WebCore::JSMainThreadExecState): * bindings/js/JSMainThreadExecStateInstrumentation.h: (WebCore::JSMainThreadExecState::instrumentFunctionInternal): Generalized from instrumentFunctionCall so that we can use it for both call and construct. (WebCore::JSMainThreadExecState::instrumentFunctionCall): Specialized the above function for call. (WebCore::JSMainThreadExecState::instrumentFunctionConstruct): Ditto for construct. * dom/CustomElementDefinitions.cpp: (WebCore::CustomElementDefinitions::findInterface): Added. * dom/CustomElementDefinitions.h: * dom/Document.cpp: (WebCore::createHTMLElementWithNameValidation): Extracted from createElement. (WebCore::Document::createElementForBindings): Renamed from createElement. Specifies ShouldCreateCustomElement::Create to create a custom element before using fallback elements. * dom/Document.h: * dom/Document.idl: * dom/Node.h: (WebCore::Node::isCustomElement): Added. This flag is used to identify a custom element. (WebCore::Node::setIsCustomElement): Added. * dom/make_names.pl: Extracted createKnownElement from createElement for createHTMLElementWithNameValidation. * inspector/InspectorCSSAgent.cpp: (WebCore::InspectorCSSAgent::createInspectorStyleSheetForDocument): Use qualified name object to instantiate a style element and set type content attribute. * inspector/InspectorDOMAgent.cpp: (WebCore::InspectorDOMAgent::setNodeName): Use createElementForBindings here since we might be creating an arbitrary element here. Also use RefPtr instead of raw pointers while mutating DOM for safety. Source/WebKit/win: Use createElementForBindings here since this is a C++ binding for Windows. * DOMCoreClasses.cpp: (DOMDocument::createElement): Source/WebKit2: Use createElementForBindings here since this is for SPI. * WebProcess/InjectedBundle/API/mac/WKDOMDocument.mm: (-[WKDOMDocument createElement:]): (-[WKDOMDocument createTextNode:]): LayoutTests: Add a test for creating a custom elemnet via document.createElement. The behavior is to be documented later. * fast/custom-elements/Document-createElement-expected.txt: Added. * fast/custom-elements/Document-createElement.html: Added. Canonical link: https://commits.webkit.org/171497@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@195538 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-01-25 17:23:42 +00:00
{
Only update connected custom elements https://bugs.webkit.org/show_bug.cgi?id=161480 Reviewed by Yusuke Suzuki. Source/WebCore: In the latest specs, creating an element only upgrades an element if the custom element had already been defined: https://dom.spec.whatwg.org/#concept-create-element Otherwise, an element remains unresolved until it gets connected to the document associated with the global object: https://dom.spec.whatwg.org/#concept-node-insert This patch removes the upgrade candidate map in CustomElementRegistry, and traverses the entire document associated with global object (DOMWindow) in addElementDefinition: https://html.spec.whatwg.org/#dom-customelementregistry-define The traversal is done in the shadow-including tree order (different from depth-first preorder traversal of flat tree) since it doesn't enter slots and children of shadow hosts are always visited even if they are not assigned to a slot: https://dom.spec.whatwg.org/#concept-shadow-including-tree-order Test: fast/custom-elements/enqueue-custom-element-upgrade-reaction.html * bindings/js/JSCustomElementInterface.cpp: (WebCore::JSCustomElementInterface::upgradeElement): Assert that the element being upgraded as the same qualified name as the custom element interface. * bindings/js/JSCustomElementRegistryCustom.cpp: (WebCore::JSCustomElementRegistry::define): Moved the code to resolve the promise from here to addElementDefinition. Also cleaned up the code to extract callbacks a little. * dom/CustomElementReactionQueue.cpp: (WebCore::CustomElementReactionQueue::enqueueElementUpgrade): Added an assertion. (WebCore::CustomElementReactionQueue::enqueueElementUpgradeIfDefined): Added. Upgrade an element if the custom element had already been defined. * dom/CustomElementReactionQueue.h: * dom/CustomElementRegistry.cpp: (WebCore::CustomElementRegistry::create): Stores the reference to DOMWindow to find its document in addElementDefinition. (WebCore::CustomElementRegistry::CustomElementRegistry): Ditto. (WebCore::enqueueUpgradeInShadowIncludingTreeOrder): Added. Enqueue upgrade reactions in shadow-including tree order. (WebCore::CustomElementRegistry::addElementDefinition): Upgrade all unresolved elements that matches this definition and resolve the the promise returned by "whenDefined" if there is any. (WebCore::CustomElementRegistry::addUpgradeCandidate): Deleted. (WebCore::CustomElementRegistry::findInterface): Added a new variant that takes an element. * dom/CustomElementRegistry.h: * dom/Document.cpp: (WebCore::createUpgradeCandidateElement): No longer takes DOMWindow since we don't upgrade synchronously here. It's also wrong not to mark the element as unresolved custom element in a document without a browsing context per new semantics. (WebCore::createHTMLElementWithNameValidation): Ditto. (WebCore::createFallbackHTMLElement): Ditto. * dom/Element.cpp: (WebCore::Element::insertedInto): Enqueue an upgrade reaction if this is an unsolved custom element and there is now a definition for it (the latter condition is checked in enqueueElementUpgradeIfDefined). * html/parser/HTMLConstructionSite.cpp: (WebCore::HTMLConstructionSite::createHTMLElementOrFindCustomElementInterface): Don't upgrade this element until it gets connected to a document in Element::insertedInto. * page/DOMWindow.cpp: (WebCore::DOMWindow::ensureCustomElementRegistry): LayoutTests: Added a W3c-style testharness.js test for https://html.spec.whatwg.org/#enqueue-a-custom-element-upgrade-reaction and added more test cases for :defined and customElements.define. * fast/custom-elements/CustomElementRegistry.html: Revised descriptions for "get" and "whenDefined" test cases consistent with ones for "define". * fast/custom-elements/defined-pseudo-class-expected.txt: * fast/custom-elements/defined-pseudo-class.html: * fast/custom-elements/enqueue-custom-element-upgrade-reaction-expected.txt: Added. * fast/custom-elements/enqueue-custom-element-upgrade-reaction.html: Added. * fast/custom-elements/resources/document-types.js: (create): Canonical link: https://commits.webkit.org/179676@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@205340 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-02 06:17:17 +00:00
if (name.namespaceURI() != HTMLNames::xhtmlNamespaceURI)
return nullptr;
document.createElementNS doesn't construct a custom element https://bugs.webkit.org/show_bug.cgi?id=164700 Reviewed by Darin Adler. Source/WebCore: Fixed the bug that document.createElementNS doesn't create a custom element or enqueue it to upgrade. Also made constructCustomElementSynchronously not call the custom element constructors with the element's local name as the first argument, which was a non-standard behavior added during prototyping. Test: fast/custom-elements/DOMImplementation-createDocument.html fast/custom-elements/document-createElementNS.html * bindings/js/JSCustomElementInterface.cpp: (WebCore::JSCustomElementInterface::constructElementWithFallback): Added a variant that takes QualifiedName instead of AtomicString. (WebCore::constructCustomElementSynchronously): Don't add the local name as an argument. * bindings/js/JSCustomElementInterface.h: * dom/CustomElementRegistry.cpp: (WebCore::CustomElementRegistry::findInterface): Just find the interface based on the local name after checking the namespace URI to be that of the XHTML. We need to ignore the prefix for the purpose of looking up the custom element definition as specified in the latest HTML specification: https://html.spec.whatwg.org/multipage/scripting.html#look-up-a-custom-element-definition * dom/DOMImplementation.cpp: (WebCore::DOMImplementation::createDocument): Added an assertion to make sure we don't invoke scripts while constructing the document element. * dom/Document.cpp: (WebCore::createUpgradeCandidateElement): Made this function create a HTMLUnknownElement instead of returning nullptr to share more code. Also added a variant which takes QualifiedName. (WebCore::isValidHTMLElementName): Added; helpers for createHTMLElementWithNameValidation to call isValidName on Document with the right argument. (WebCore::createHTMLElementWithNameValidation): Templatized the function to be called with either AtomicString or QualifiedName for the name. (WebCore::createFallbackHTMLElement): (WebCore::Document::createElementNS): Call createHTMLElementWithNameValidation to create a custom element if possible. This function ends up re-validating the element name before creating a HTMLUnknownElement but that shouldn't be a common scenario to matter. In fact, createElementNS is a rarely used API. LayoutTests: Added W3C style testharness.js tests for createElementNS and DOMImplementation's createDocument. * fast/custom-elements/DOMImplementation-createDocument-expected.txt: Added. * fast/custom-elements/DOMImplementation-createDocument.html: Added. * fast/custom-elements/document-createElementNS-expected.txt: Added. * fast/custom-elements/document-createElementNS.html: Added. Canonical link: https://commits.webkit.org/182432@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@208716 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-11-15 00:27:01 +00:00
return m_nameMap.get(name.localName());
document.createElement should be able to create a custom element https://bugs.webkit.org/show_bug.cgi?id=153173 Reviewed by Darin Adler. Source/WebCore: Added the support for constructing a custom element via document.createElement. Extracted HTMLElementFactory::createKnownElement, which returns nullptr when the specified name doesn't match any builtin element instead of out of HTMLUnknownElement, out of HTMLElementFactory::createElement. Test: fast/custom-elements/Document-createElement.html * bindings/js/JSCustomElementInterface.cpp: (WebCore::JSCustomElementInterface::constructHTMLElement): Added. Constructs a custom element by invoking its constructor. We allow exceptions to be thrown by the constructor so the caller is responsible for checking any exceptions in the ExecState before preceeding if the returned value is null. * bindings/js/JSCustomElementInterface.h: (WebCore::JSCustomElementInterface::constructSVGElement): Added. * bindings/js/JSElementCustom.cpp: (WebCore::toJSNewlyCreated): Exit early if the element is a custom element as the wrapper had already been created by super() call inside the custom element'c constructor. * bindings/js/JSMainThreadExecState.h: (WebCore::JSMainThreadExecState): * bindings/js/JSMainThreadExecStateInstrumentation.h: (WebCore::JSMainThreadExecState::instrumentFunctionInternal): Generalized from instrumentFunctionCall so that we can use it for both call and construct. (WebCore::JSMainThreadExecState::instrumentFunctionCall): Specialized the above function for call. (WebCore::JSMainThreadExecState::instrumentFunctionConstruct): Ditto for construct. * dom/CustomElementDefinitions.cpp: (WebCore::CustomElementDefinitions::findInterface): Added. * dom/CustomElementDefinitions.h: * dom/Document.cpp: (WebCore::createHTMLElementWithNameValidation): Extracted from createElement. (WebCore::Document::createElementForBindings): Renamed from createElement. Specifies ShouldCreateCustomElement::Create to create a custom element before using fallback elements. * dom/Document.h: * dom/Document.idl: * dom/Node.h: (WebCore::Node::isCustomElement): Added. This flag is used to identify a custom element. (WebCore::Node::setIsCustomElement): Added. * dom/make_names.pl: Extracted createKnownElement from createElement for createHTMLElementWithNameValidation. * inspector/InspectorCSSAgent.cpp: (WebCore::InspectorCSSAgent::createInspectorStyleSheetForDocument): Use qualified name object to instantiate a style element and set type content attribute. * inspector/InspectorDOMAgent.cpp: (WebCore::InspectorDOMAgent::setNodeName): Use createElementForBindings here since we might be creating an arbitrary element here. Also use RefPtr instead of raw pointers while mutating DOM for safety. Source/WebKit/win: Use createElementForBindings here since this is a C++ binding for Windows. * DOMCoreClasses.cpp: (DOMDocument::createElement): Source/WebKit2: Use createElementForBindings here since this is for SPI. * WebProcess/InjectedBundle/API/mac/WKDOMDocument.mm: (-[WKDOMDocument createElement:]): (-[WKDOMDocument createTextNode:]): LayoutTests: Add a test for creating a custom elemnet via document.createElement. The behavior is to be documented later. * fast/custom-elements/Document-createElement-expected.txt: Added. * fast/custom-elements/Document-createElement.html: Added. Canonical link: https://commits.webkit.org/171497@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@195538 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-01-25 17:23:42 +00:00
}
JSCustomElementInterface* CustomElementRegistry::findInterface(const AtomString& name) const
Add document.defineCustomElement https://bugs.webkit.org/show_bug.cgi?id=153092 Reviewed by Chris Dumez. Source/WebCore: Added document.defineCustomElement and added a constructor to HTMLElement which can be called as "super" in a subclass of HTMLElement. This is a prototype of new custom elements API and willfully violates the current specification at http://w3c.github.io/webcomponents/spec/custom/ Each author defined class can define multiple elements using distinct tag names. In such cases, the super call must specify the tag name. e.g. class SomeCustomElement extends HTMLElement { constructor(name) { super(name); } } document.defineCustomElement('some-custom-element', SomeCustomElement); document.defineCustomElement('other-custom-element', SomeCustomElement); new SomeCustomElement('some-custom-element'); When a class is associated with exactly one tag name, the argument can be omitted. e.g. class AnotherCustomElement extends HTMLElement {} document.defineCustomElement('another-custom-element', AnotherCustomElement); new AnotherCustomElement(); We allow only subclassing of HTMLElement and only in (X)HTML namespace. Tests: fast/custom-elements/Document-defineCustomElement.html fast/custom-elements/HTMLElement-constructor.html * CMakeLists.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSCustomElementInterface.cpp: Added. Abstracts an author-defined class associated with a custom element. It's a Active DOM object and lives until the associated document dies. (WebCore::JSCustomElementInterface::JSCustomElementInterface): (WebCore::JSCustomElementInterface::~JSCustomElementInterface): * bindings/js/JSCustomElementInterface.h: Added. (WebCore::JSCustomElementInterface::create): (WebCore::JSCustomElementInterface::scriptExecutionContext): (WebCore::JSCustomElementInterface::constructor): * bindings/js/JSDocumentCustom.cpp: (WebCore::JSDocument::defineCustomElement): Added. Define a custom element by associating a tag name with an author defined JS class after validating arguments. * bindings/js/JSHTMLElementCustom.cpp: (WebCore::constructJSHTMLElement): Added. Look up the tag name based on new.target if one is not specified. If a tag name is specified, check that new.target is associated with the tag name. * dom/CustomElementDefinitions.cpp: Added. (WebCore::CustomElementDefinitions::checkName): Added. Restricts tag names similarly to http://w3c.github.io/webcomponents/spec/custom/#dfn-custom-element-type (WebCore::CustomElementDefinitions::defineElement): Added. Associates a JS class with a tag name. (WebCore::CustomElementDefinitions::findInterface): Added. Finds a JS class by a tag name. (WebCore::CustomElementDefinitions::findName): Added. Finds a tag name by a JS class. * dom/CustomElementDefinitions.h: Added. (WebCore::CustomElementDefinitions::CustomElementInfo): Added. * dom/Document.cpp: (WebCore::Document::ensureCustomElementDefinitions): Added. * dom/Document.h: (WebCore::Document::customElementDefinitions): Added. * dom/Document.idl: * html/HTMLElement.idl: LayoutTests: Added tests for document.defineCustomElement and instantiating custom elements. * TestExpectations: Skipped the tests on non-Mac ports. * fast/custom-elements: Added. * fast/custom-elements/Document-defineCustomElement-expected.txt: Added. * fast/custom-elements/Document-defineCustomElement.html: Added. * fast/custom-elements/HTMLElement-constructor-expected.txt: Added. * fast/custom-elements/HTMLElement-constructor.html: Added. * platform/mac/TestExpectations: Canonical link: https://commits.webkit.org/171208@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@195087 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-01-15 02:59:03 +00:00
{
return m_nameMap.get(name);
Add document.defineCustomElement https://bugs.webkit.org/show_bug.cgi?id=153092 Reviewed by Chris Dumez. Source/WebCore: Added document.defineCustomElement and added a constructor to HTMLElement which can be called as "super" in a subclass of HTMLElement. This is a prototype of new custom elements API and willfully violates the current specification at http://w3c.github.io/webcomponents/spec/custom/ Each author defined class can define multiple elements using distinct tag names. In such cases, the super call must specify the tag name. e.g. class SomeCustomElement extends HTMLElement { constructor(name) { super(name); } } document.defineCustomElement('some-custom-element', SomeCustomElement); document.defineCustomElement('other-custom-element', SomeCustomElement); new SomeCustomElement('some-custom-element'); When a class is associated with exactly one tag name, the argument can be omitted. e.g. class AnotherCustomElement extends HTMLElement {} document.defineCustomElement('another-custom-element', AnotherCustomElement); new AnotherCustomElement(); We allow only subclassing of HTMLElement and only in (X)HTML namespace. Tests: fast/custom-elements/Document-defineCustomElement.html fast/custom-elements/HTMLElement-constructor.html * CMakeLists.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSCustomElementInterface.cpp: Added. Abstracts an author-defined class associated with a custom element. It's a Active DOM object and lives until the associated document dies. (WebCore::JSCustomElementInterface::JSCustomElementInterface): (WebCore::JSCustomElementInterface::~JSCustomElementInterface): * bindings/js/JSCustomElementInterface.h: Added. (WebCore::JSCustomElementInterface::create): (WebCore::JSCustomElementInterface::scriptExecutionContext): (WebCore::JSCustomElementInterface::constructor): * bindings/js/JSDocumentCustom.cpp: (WebCore::JSDocument::defineCustomElement): Added. Define a custom element by associating a tag name with an author defined JS class after validating arguments. * bindings/js/JSHTMLElementCustom.cpp: (WebCore::constructJSHTMLElement): Added. Look up the tag name based on new.target if one is not specified. If a tag name is specified, check that new.target is associated with the tag name. * dom/CustomElementDefinitions.cpp: Added. (WebCore::CustomElementDefinitions::checkName): Added. Restricts tag names similarly to http://w3c.github.io/webcomponents/spec/custom/#dfn-custom-element-type (WebCore::CustomElementDefinitions::defineElement): Added. Associates a JS class with a tag name. (WebCore::CustomElementDefinitions::findInterface): Added. Finds a JS class by a tag name. (WebCore::CustomElementDefinitions::findName): Added. Finds a tag name by a JS class. * dom/CustomElementDefinitions.h: Added. (WebCore::CustomElementDefinitions::CustomElementInfo): Added. * dom/Document.cpp: (WebCore::Document::ensureCustomElementDefinitions): Added. * dom/Document.h: (WebCore::Document::customElementDefinitions): Added. * dom/Document.idl: * html/HTMLElement.idl: LayoutTests: Added tests for document.defineCustomElement and instantiating custom elements. * TestExpectations: Skipped the tests on non-Mac ports. * fast/custom-elements: Added. * fast/custom-elements/Document-defineCustomElement-expected.txt: Added. * fast/custom-elements/Document-defineCustomElement.html: Added. * fast/custom-elements/HTMLElement-constructor-expected.txt: Added. * fast/custom-elements/HTMLElement-constructor.html: Added. * platform/mac/TestExpectations: Canonical link: https://commits.webkit.org/171208@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@195087 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-01-15 02:59:03 +00:00
}
Rename CustomElementsRegistry to CustomElementRegistry https://bugs.webkit.org/show_bug.cgi?id=161028 Reviewed by Darin Adler. Source/JavaScriptCore: Added customElements and CustomElementRegistry to the common identifiers list as they're used on JSDOMWindow to hide window.customElements and CustomElementRegistry interface behind a runtime flag. * runtime/CommonIdentifiers.h: Source/WebCore: Renamed CustomElementsRegistry to CustomElementRegistry per https://github.com/w3c/webcomponents/issues/548. Also hide window.customElements and CustomElementRegistry interface behind a runtime enabled. * CMakeLists.txt: * DerivedSources.cpp: * DerivedSources.make: * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSCustomElementRegistryCustom.cpp: Renamed from JSCustomElementsRegistryCustom.cpp. (WebCore::getCustomElementCallback): (WebCore::JSCustomElementRegistry::define): * bindings/js/JSHTMLElementCustom.cpp: (WebCore::constructJSHTMLElement): * dom/CustomElementReactionQueue.cpp: (WebCore::findInterfaceForCustomElement): * dom/CustomElementRegistry.cpp: Renamed from CustomElementsRegistry.cpp. (WebCore::CustomElementRegistry::create): (WebCore::CustomElementRegistry::CustomElementRegistry): (WebCore::CustomElementRegistry::~CustomElementRegistry): (WebCore::CustomElementRegistry::addElementDefinition): (WebCore::CustomElementRegistry::addUpgradeCandidate): (WebCore::CustomElementRegistry::findInterface): (WebCore::CustomElementRegistry::containsConstructor): * dom/CustomElementRegistry.h: Renamed from CustomElementsRegistry.h. * dom/CustomElementRegistry.idl: Renamed from CustomElementsRegistry.idl. * dom/Document.cpp: (WebCore::createUpgradeCandidateElement): (WebCore::createHTMLElementWithNameValidation): (WebCore::createFallbackHTMLElement): * dom/Element.cpp: * html/parser/HTMLConstructionSite.cpp: (WebCore::HTMLConstructionSite::createHTMLElementOrFindCustomElementInterface): * page/DOMWindow.cpp: (WebCore::DOMWindow::ensureCustomElementRegistry): * page/DOMWindow.h: * page/DOMWindow.idl: LayoutTests: Updated the tests and expected results after the rename. * fast/custom-elements/CustomElementRegistry-expected.txt: Renamed from LayoutTests/fast/custom-elements/CustomElementsRegistry-expected.txt. * fast/custom-elements/CustomElementRegistry.html: Renamed from LayoutTests/fast/custom-elements/CustomElementsRegistry.html. * platform/efl/js/dom/global-constructors-attributes-expected.txt: * platform/gtk/js/dom/global-constructors-attributes-expected.txt: * platform/mac-wk1/js/dom/global-constructors-attributes-expected.txt: * platform/mac-yosemite/js/dom/global-constructors-attributes-expected.txt: * platform/mac/js/dom/global-constructors-attributes-expected.txt: * platform/win/js/dom/global-constructors-attributes-expected.txt: Canonical link: https://commits.webkit.org/179194@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@204732 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-08-22 19:45:01 +00:00
JSCustomElementInterface* CustomElementRegistry::findInterface(const JSC::JSObject* constructor) const
Update defineCustomElement according to the spec rewrite https://bugs.webkit.org/show_bug.cgi?id=155010 <rdar://problem/24970878> Reviewed by Chris Dumez. Source/WebCore: Updated the implementation of defineCustomElement and HTMLConstructor per recent rewrite of the spec: https://w3c.github.io/webcomponents/spec/custom/#dom-document-defineelement https://w3c.github.io/webcomponents/spec/custom/#htmlelement-constructor defineCustomElement is now called defineElement and we disallow defining multiple custom elements with a single class and throw an exception in defineElement. Test: fast/custom-elements/Document-defineElement.html * bindings/js/JSDocumentCustom.cpp: (WebCore::JSDocument::defineElement): Renamed from defineCustomElement. Throw an exception when the interface already defines another custom element. Also added FIXME's for missing steps. * bindings/js/JSHTMLElementCustom.cpp: (WebCore::constructJSHTMLElement): Removed the support for specifying a tag name in the first argument when a single class defines multiple custom elements since that now results in an exception (in defineElement). * dom/CustomElementDefinitions.cpp: (WebCore::CustomElementDefinitions::containsConstructor): Added. * dom/CustomElementDefinitions.h: * dom/Document.idl: Renamed defineCustomElement to defineElement. * html/HTMLElement.idl: Removed the optional tag name from the constructor. LayoutTests: Update the tests for the rename and semantics change of defineCustomElement and HTMLElement constructor. * fast/custom-elements/Document-createElement.html: * fast/custom-elements/Document-defineCustomElement-expected.txt: Removed. * fast/custom-elements/Document-defineCustomElement.html: Removed. * fast/custom-elements/Document-defineElement-expected.txt: Renamed from LayoutTests/fast/custom-elements/Document-defineCustomElement-expected.txt. * fast/custom-elements/Document-defineElement.html: Renamed from LayoutTests/fast/custom-elements/Document-defineCustomElement.html. Also added a test case for defining multiple custom elements with a single class, which must throw. * fast/custom-elements/HTMLElement-constructor-expected.txt: * fast/custom-elements/HTMLElement-constructor.html: Removed test cases for the tag name in the first argument as well as ones that associate a single class with multiple tag names. * fast/custom-elements/parser/parser-constructs-custom-element-in-document-write.html: * fast/custom-elements/parser/parser-constructs-custom-element-synchronously.html: * fast/custom-elements/parser/parser-constructs-custom-elements.html: * fast/custom-elements/parser/parser-fallsback-to-unknown-element.html: * fast/custom-elements/parser/parser-sets-attributes-and-children.html: * fast/custom-elements/parser/parser-uses-constructed-element.html: * fast/custom-elements/parser/parser-uses-registry-of-owner-document.html: Canonical link: https://commits.webkit.org/173136@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@197602 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-03-05 01:23:42 +00:00
{
return m_constructorMap.get(constructor);
Update defineCustomElement according to the spec rewrite https://bugs.webkit.org/show_bug.cgi?id=155010 <rdar://problem/24970878> Reviewed by Chris Dumez. Source/WebCore: Updated the implementation of defineCustomElement and HTMLConstructor per recent rewrite of the spec: https://w3c.github.io/webcomponents/spec/custom/#dom-document-defineelement https://w3c.github.io/webcomponents/spec/custom/#htmlelement-constructor defineCustomElement is now called defineElement and we disallow defining multiple custom elements with a single class and throw an exception in defineElement. Test: fast/custom-elements/Document-defineElement.html * bindings/js/JSDocumentCustom.cpp: (WebCore::JSDocument::defineElement): Renamed from defineCustomElement. Throw an exception when the interface already defines another custom element. Also added FIXME's for missing steps. * bindings/js/JSHTMLElementCustom.cpp: (WebCore::constructJSHTMLElement): Removed the support for specifying a tag name in the first argument when a single class defines multiple custom elements since that now results in an exception (in defineElement). * dom/CustomElementDefinitions.cpp: (WebCore::CustomElementDefinitions::containsConstructor): Added. * dom/CustomElementDefinitions.h: * dom/Document.idl: Renamed defineCustomElement to defineElement. * html/HTMLElement.idl: Removed the optional tag name from the constructor. LayoutTests: Update the tests for the rename and semantics change of defineCustomElement and HTMLElement constructor. * fast/custom-elements/Document-createElement.html: * fast/custom-elements/Document-defineCustomElement-expected.txt: Removed. * fast/custom-elements/Document-defineCustomElement.html: Removed. * fast/custom-elements/Document-defineElement-expected.txt: Renamed from LayoutTests/fast/custom-elements/Document-defineCustomElement-expected.txt. * fast/custom-elements/Document-defineElement.html: Renamed from LayoutTests/fast/custom-elements/Document-defineCustomElement.html. Also added a test case for defining multiple custom elements with a single class, which must throw. * fast/custom-elements/HTMLElement-constructor-expected.txt: * fast/custom-elements/HTMLElement-constructor.html: Removed test cases for the tag name in the first argument as well as ones that associate a single class with multiple tag names. * fast/custom-elements/parser/parser-constructs-custom-element-in-document-write.html: * fast/custom-elements/parser/parser-constructs-custom-element-synchronously.html: * fast/custom-elements/parser/parser-constructs-custom-elements.html: * fast/custom-elements/parser/parser-fallsback-to-unknown-element.html: * fast/custom-elements/parser/parser-sets-attributes-and-children.html: * fast/custom-elements/parser/parser-uses-constructed-element.html: * fast/custom-elements/parser/parser-uses-registry-of-owner-document.html: Canonical link: https://commits.webkit.org/173136@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@197602 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-03-05 01:23:42 +00:00
}
Rename CustomElementsRegistry to CustomElementRegistry https://bugs.webkit.org/show_bug.cgi?id=161028 Reviewed by Darin Adler. Source/JavaScriptCore: Added customElements and CustomElementRegistry to the common identifiers list as they're used on JSDOMWindow to hide window.customElements and CustomElementRegistry interface behind a runtime flag. * runtime/CommonIdentifiers.h: Source/WebCore: Renamed CustomElementsRegistry to CustomElementRegistry per https://github.com/w3c/webcomponents/issues/548. Also hide window.customElements and CustomElementRegistry interface behind a runtime enabled. * CMakeLists.txt: * DerivedSources.cpp: * DerivedSources.make: * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSCustomElementRegistryCustom.cpp: Renamed from JSCustomElementsRegistryCustom.cpp. (WebCore::getCustomElementCallback): (WebCore::JSCustomElementRegistry::define): * bindings/js/JSHTMLElementCustom.cpp: (WebCore::constructJSHTMLElement): * dom/CustomElementReactionQueue.cpp: (WebCore::findInterfaceForCustomElement): * dom/CustomElementRegistry.cpp: Renamed from CustomElementsRegistry.cpp. (WebCore::CustomElementRegistry::create): (WebCore::CustomElementRegistry::CustomElementRegistry): (WebCore::CustomElementRegistry::~CustomElementRegistry): (WebCore::CustomElementRegistry::addElementDefinition): (WebCore::CustomElementRegistry::addUpgradeCandidate): (WebCore::CustomElementRegistry::findInterface): (WebCore::CustomElementRegistry::containsConstructor): * dom/CustomElementRegistry.h: Renamed from CustomElementsRegistry.h. * dom/CustomElementRegistry.idl: Renamed from CustomElementsRegistry.idl. * dom/Document.cpp: (WebCore::createUpgradeCandidateElement): (WebCore::createHTMLElementWithNameValidation): (WebCore::createFallbackHTMLElement): * dom/Element.cpp: * html/parser/HTMLConstructionSite.cpp: (WebCore::HTMLConstructionSite::createHTMLElementOrFindCustomElementInterface): * page/DOMWindow.cpp: (WebCore::DOMWindow::ensureCustomElementRegistry): * page/DOMWindow.h: * page/DOMWindow.idl: LayoutTests: Updated the tests and expected results after the rename. * fast/custom-elements/CustomElementRegistry-expected.txt: Renamed from LayoutTests/fast/custom-elements/CustomElementsRegistry-expected.txt. * fast/custom-elements/CustomElementRegistry.html: Renamed from LayoutTests/fast/custom-elements/CustomElementsRegistry.html. * platform/efl/js/dom/global-constructors-attributes-expected.txt: * platform/gtk/js/dom/global-constructors-attributes-expected.txt: * platform/mac-wk1/js/dom/global-constructors-attributes-expected.txt: * platform/mac-yosemite/js/dom/global-constructors-attributes-expected.txt: * platform/mac/js/dom/global-constructors-attributes-expected.txt: * platform/win/js/dom/global-constructors-attributes-expected.txt: Canonical link: https://commits.webkit.org/179194@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@204732 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-08-22 19:45:01 +00:00
bool CustomElementRegistry::containsConstructor(const JSC::JSObject* constructor) const
Add document.defineCustomElement https://bugs.webkit.org/show_bug.cgi?id=153092 Reviewed by Chris Dumez. Source/WebCore: Added document.defineCustomElement and added a constructor to HTMLElement which can be called as "super" in a subclass of HTMLElement. This is a prototype of new custom elements API and willfully violates the current specification at http://w3c.github.io/webcomponents/spec/custom/ Each author defined class can define multiple elements using distinct tag names. In such cases, the super call must specify the tag name. e.g. class SomeCustomElement extends HTMLElement { constructor(name) { super(name); } } document.defineCustomElement('some-custom-element', SomeCustomElement); document.defineCustomElement('other-custom-element', SomeCustomElement); new SomeCustomElement('some-custom-element'); When a class is associated with exactly one tag name, the argument can be omitted. e.g. class AnotherCustomElement extends HTMLElement {} document.defineCustomElement('another-custom-element', AnotherCustomElement); new AnotherCustomElement(); We allow only subclassing of HTMLElement and only in (X)HTML namespace. Tests: fast/custom-elements/Document-defineCustomElement.html fast/custom-elements/HTMLElement-constructor.html * CMakeLists.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSCustomElementInterface.cpp: Added. Abstracts an author-defined class associated with a custom element. It's a Active DOM object and lives until the associated document dies. (WebCore::JSCustomElementInterface::JSCustomElementInterface): (WebCore::JSCustomElementInterface::~JSCustomElementInterface): * bindings/js/JSCustomElementInterface.h: Added. (WebCore::JSCustomElementInterface::create): (WebCore::JSCustomElementInterface::scriptExecutionContext): (WebCore::JSCustomElementInterface::constructor): * bindings/js/JSDocumentCustom.cpp: (WebCore::JSDocument::defineCustomElement): Added. Define a custom element by associating a tag name with an author defined JS class after validating arguments. * bindings/js/JSHTMLElementCustom.cpp: (WebCore::constructJSHTMLElement): Added. Look up the tag name based on new.target if one is not specified. If a tag name is specified, check that new.target is associated with the tag name. * dom/CustomElementDefinitions.cpp: Added. (WebCore::CustomElementDefinitions::checkName): Added. Restricts tag names similarly to http://w3c.github.io/webcomponents/spec/custom/#dfn-custom-element-type (WebCore::CustomElementDefinitions::defineElement): Added. Associates a JS class with a tag name. (WebCore::CustomElementDefinitions::findInterface): Added. Finds a JS class by a tag name. (WebCore::CustomElementDefinitions::findName): Added. Finds a tag name by a JS class. * dom/CustomElementDefinitions.h: Added. (WebCore::CustomElementDefinitions::CustomElementInfo): Added. * dom/Document.cpp: (WebCore::Document::ensureCustomElementDefinitions): Added. * dom/Document.h: (WebCore::Document::customElementDefinitions): Added. * dom/Document.idl: * html/HTMLElement.idl: LayoutTests: Added tests for document.defineCustomElement and instantiating custom elements. * TestExpectations: Skipped the tests on non-Mac ports. * fast/custom-elements: Added. * fast/custom-elements/Document-defineCustomElement-expected.txt: Added. * fast/custom-elements/Document-defineCustomElement.html: Added. * fast/custom-elements/HTMLElement-constructor-expected.txt: Added. * fast/custom-elements/HTMLElement-constructor.html: Added. * platform/mac/TestExpectations: Canonical link: https://commits.webkit.org/171208@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@195087 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-01-15 02:59:03 +00:00
{
Move QualifiedName from CustomElementInfo to JSCustomElementInterface https://bugs.webkit.org/show_bug.cgi?id=155061 Reviewed by Antti Koivisto. Store QualifiedName of custom elements in JSCustomElementInterface instead of CustomElementInfo now that each interface is associated with exactly one custom element as of r197602. No new tests since this is a refactoring. * bindings/js/JSCustomElementInterface.cpp: (WebCore::JSCustomElementInterface::JSCustomElementInterface): Now takes QualifiedName as the first argument. * bindings/js/JSCustomElementInterface.h: (WebCore::JSCustomElementInterface::create): (WebCore::JSCustomElementInterface::name): Added. * bindings/js/JSDocumentCustom.cpp: (WebCore::JSDocument::defineElement): * bindings/js/JSHTMLElementCustom.cpp: (WebCore::constructJSHTMLElement): Use findInterface instead of the deleted findName. * dom/CustomElementDefinitions.cpp: (WebCore::CustomElementDefinitions::checkName): (WebCore::CustomElementDefinitions::addElementDefinition): Renamed from defineElement. (WebCore::CustomElementDefinitions::findInterface): Add a variant that finds the interface object by a JS constructor. (WebCore::CustomElementDefinitions::containsConstructor): (WebCore::CustomElementDefinitions::findName): Deleted. * dom/CustomElementDefinitions.h: (WebCore::CustomElementDefinitions::CustomElementInfo::CustomElementInfo): Deleted. Canonical link: https://commits.webkit.org/173146@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@197612 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-03-05 08:31:38 +00:00
return m_constructorMap.contains(constructor);
Add document.defineCustomElement https://bugs.webkit.org/show_bug.cgi?id=153092 Reviewed by Chris Dumez. Source/WebCore: Added document.defineCustomElement and added a constructor to HTMLElement which can be called as "super" in a subclass of HTMLElement. This is a prototype of new custom elements API and willfully violates the current specification at http://w3c.github.io/webcomponents/spec/custom/ Each author defined class can define multiple elements using distinct tag names. In such cases, the super call must specify the tag name. e.g. class SomeCustomElement extends HTMLElement { constructor(name) { super(name); } } document.defineCustomElement('some-custom-element', SomeCustomElement); document.defineCustomElement('other-custom-element', SomeCustomElement); new SomeCustomElement('some-custom-element'); When a class is associated with exactly one tag name, the argument can be omitted. e.g. class AnotherCustomElement extends HTMLElement {} document.defineCustomElement('another-custom-element', AnotherCustomElement); new AnotherCustomElement(); We allow only subclassing of HTMLElement and only in (X)HTML namespace. Tests: fast/custom-elements/Document-defineCustomElement.html fast/custom-elements/HTMLElement-constructor.html * CMakeLists.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSCustomElementInterface.cpp: Added. Abstracts an author-defined class associated with a custom element. It's a Active DOM object and lives until the associated document dies. (WebCore::JSCustomElementInterface::JSCustomElementInterface): (WebCore::JSCustomElementInterface::~JSCustomElementInterface): * bindings/js/JSCustomElementInterface.h: Added. (WebCore::JSCustomElementInterface::create): (WebCore::JSCustomElementInterface::scriptExecutionContext): (WebCore::JSCustomElementInterface::constructor): * bindings/js/JSDocumentCustom.cpp: (WebCore::JSDocument::defineCustomElement): Added. Define a custom element by associating a tag name with an author defined JS class after validating arguments. * bindings/js/JSHTMLElementCustom.cpp: (WebCore::constructJSHTMLElement): Added. Look up the tag name based on new.target if one is not specified. If a tag name is specified, check that new.target is associated with the tag name. * dom/CustomElementDefinitions.cpp: Added. (WebCore::CustomElementDefinitions::checkName): Added. Restricts tag names similarly to http://w3c.github.io/webcomponents/spec/custom/#dfn-custom-element-type (WebCore::CustomElementDefinitions::defineElement): Added. Associates a JS class with a tag name. (WebCore::CustomElementDefinitions::findInterface): Added. Finds a JS class by a tag name. (WebCore::CustomElementDefinitions::findName): Added. Finds a tag name by a JS class. * dom/CustomElementDefinitions.h: Added. (WebCore::CustomElementDefinitions::CustomElementInfo): Added. * dom/Document.cpp: (WebCore::Document::ensureCustomElementDefinitions): Added. * dom/Document.h: (WebCore::Document::customElementDefinitions): Added. * dom/Document.idl: * html/HTMLElement.idl: LayoutTests: Added tests for document.defineCustomElement and instantiating custom elements. * TestExpectations: Skipped the tests on non-Mac ports. * fast/custom-elements: Added. * fast/custom-elements/Document-defineCustomElement-expected.txt: Added. * fast/custom-elements/Document-defineCustomElement.html: Added. * fast/custom-elements/HTMLElement-constructor-expected.txt: Added. * fast/custom-elements/HTMLElement-constructor.html: Added. * platform/mac/TestExpectations: Canonical link: https://commits.webkit.org/171208@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@195087 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-01-15 02:59:03 +00:00
}
JSC::JSValue CustomElementRegistry::get(const AtomString& name)
{
if (auto* elementInterface = m_nameMap.get(name))
return elementInterface->constructor();
return JSC::jsUndefined();
}
Implement customElements.upgrade() https://bugs.webkit.org/show_bug.cgi?id=183397 Reviewed by Frédéric Wang. LayoutTests/imported/w3c: Rebaseline the test now that we're passing. * web-platform-tests/custom-elements/custom-element-registry/upgrade-expected.txt: Source/WebCore: Added the support to upgrade custom elements directly. Ordinarily, custom elements get upgraded as they are inserted / connected into a document but some script libraries and authors want to be able to upgrade them before that. Also see https://github.com/w3c/webcomponents/issues/710 Implemented the method as specified at: https://html.spec.whatwg.org/multipage/custom-elements.html#dom-customelementregistry-upgrade When invoked, the upgrade(root) method must run these steps: 1. Let candidates be a list of all of root's shadow-including inclusive descendant elements, in shadow-including tree order. 2. For each candidate of candidates, try to upgrade candidate. Tests: imported/w3c/web-platform-tests/custom-elements/custom-element-registry/upgrade.html * dom/CustomElementReactionQueue.cpp: (WebCore::CustomElementReactionQueue::enqueueElementUpgradeIfDefined): Removed the assertion that the upgraded element is connected since the whole point of this API is to upgrade a disconnected element. * dom/CustomElementRegistry.cpp: (WebCore::upgradeElementsInShadowIncludingdescendants): Added. (WebCore::CustomElementRegistry::upgrade): Added. * dom/CustomElementRegistry.h: Forward declare DeferredPromise instead of unnecessarily including JSDOMPromiseDeferred.h. * dom/CustomElementRegistry.idl: * dom/Element.cpp: (WebCore::Element::insertedIntoAncestor): Moved the assertion here. Canonical link: https://commits.webkit.org/203374@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234507 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-08-02 19:25:23 +00:00
static void upgradeElementsInShadowIncludingDescendants(ContainerNode& root)
{
for (auto& element : descendantsOfType<Element>(root)) {
if (element.isCustomElementUpgradeCandidate())
Prevent infinite recursion when upgrading custom elements https://bugs.webkit.org/show_bug.cgi?id=206605 Reviewed by Antti Koivisto. LayoutTests/imported/w3c: Rebaselined the test now that one more test case is passing. * web-platform-tests/custom-elements/upgrading-expected.txt: Source/WebCore: This patch updates our implementation of the concept to upgrade an element [1] and related algorithms to match the latest HTML5 specification. In particular, it incorporates the algorithmic change [2] to prevent infinite recursion an element is re-inserted into a document tree inside its constructor. The key code change is in JSCustomElementInterface::upgradeElement where this patch adds an early exit when custom element is not "undefined" or "uncustomized" and the custom element state is set to "failed" immediately before invoking the constructor. The rest of code changes deals with this "failed" state appearing during upgrades and updates various debug assertions. [1] https://html.spec.whatwg.org/multipage/custom-elements.html#concept-upgrade-an-element [2] https://github.com/whatwg/html/pull/5126 [3] https://html.spec.whatwg.org/multipage/custom-elements.html#concept-try-upgrade Test: imported/w3c/web-platform-tests/custom-elements/upgrading.html * bindings/js/JSCustomElementInterface.cpp: (WebCore::JSCustomElementInterface::constructElementWithFallback): (WebCore::JSCustomElementInterface::upgradeElement): Implements the new behavior. Note that we still need to clear the queue where we used to set the custom element state to "failed" to avoid memory leaks. * dom/CustomElementReactionQueue.cpp: (WebCore::CustomElementReactionQueue::hasJustUpgradeReaction const): Added. (WebCore::CustomElementReactionQueue::enqueueElementUpgrade): Enqueue the element to the element queue even if it had already been scheduled to upgrade previously. This makes the innermost attempt to upgrade to succeed instead of the outermost. Also updated debug assertions. (WebCore::CustomElementReactionQueue::tryToUpgradeElement): Renamed from enqueueElementUpgradeIfDefined to match the spec's name [3]. Unlike the concept in the spec, this function doesn't get called when the custom element state of the elemnt is either "undefined" or "uncustomized" to avoid unnecessary work. * dom/CustomElementReactionQueue.h: (WebCore::CustomElementReactionQueue::isEmpty const): Added. * dom/CustomElementRegistry.cpp: (WebCore::upgradeElementsInShadowIncludingDescendants): (WebCore::CustomElementRegistry::upgrade): * dom/Document.cpp: (WebCore::createFallbackHTMLElement): Call setIsCustomElementUpgradeCandidate on a newly created since we can no longer update node flags in enqueueToUpgrade * dom/Element.cpp: (WebCore::Element::insertedIntoAncestor): (WebCore::Element::setIsFailedCustomElement): Removed the unused function argument. (WebCore::Element::setIsFailedCustomElementWithoutClearingReactionQueue): Extracted from setIsFailedCustomElement. (WebCore::Element::clearReactionQueueFromFailedCustomElement): Ditto. (WebCore::Element::enqueueToUpgrade): No longer updates node flags as this would clear "failed" state from a custom element which is currently being upgraded and cause all sorts of issues. (WebCore::Element::reactionQueue const): Updated debug assertions. * dom/Element.h: LayoutTests: Removed the crash expectation from a test now that it's passing. * TestExpectations: Canonical link: https://commits.webkit.org/228719@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266269 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-08-28 02:55:21 +00:00
CustomElementReactionQueue::tryToUpgradeElement(element);
Implement customElements.upgrade() https://bugs.webkit.org/show_bug.cgi?id=183397 Reviewed by Frédéric Wang. LayoutTests/imported/w3c: Rebaseline the test now that we're passing. * web-platform-tests/custom-elements/custom-element-registry/upgrade-expected.txt: Source/WebCore: Added the support to upgrade custom elements directly. Ordinarily, custom elements get upgraded as they are inserted / connected into a document but some script libraries and authors want to be able to upgrade them before that. Also see https://github.com/w3c/webcomponents/issues/710 Implemented the method as specified at: https://html.spec.whatwg.org/multipage/custom-elements.html#dom-customelementregistry-upgrade When invoked, the upgrade(root) method must run these steps: 1. Let candidates be a list of all of root's shadow-including inclusive descendant elements, in shadow-including tree order. 2. For each candidate of candidates, try to upgrade candidate. Tests: imported/w3c/web-platform-tests/custom-elements/custom-element-registry/upgrade.html * dom/CustomElementReactionQueue.cpp: (WebCore::CustomElementReactionQueue::enqueueElementUpgradeIfDefined): Removed the assertion that the upgraded element is connected since the whole point of this API is to upgrade a disconnected element. * dom/CustomElementRegistry.cpp: (WebCore::upgradeElementsInShadowIncludingdescendants): Added. (WebCore::CustomElementRegistry::upgrade): Added. * dom/CustomElementRegistry.h: Forward declare DeferredPromise instead of unnecessarily including JSDOMPromiseDeferred.h. * dom/CustomElementRegistry.idl: * dom/Element.cpp: (WebCore::Element::insertedIntoAncestor): Moved the assertion here. Canonical link: https://commits.webkit.org/203374@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234507 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-08-02 19:25:23 +00:00
if (auto* shadowRoot = element.shadowRoot())
upgradeElementsInShadowIncludingDescendants(*shadowRoot);
}
}
void CustomElementRegistry::upgrade(Node& root)
{
if (!is<ContainerNode>(root))
return;
if (is<Element>(root) && downcast<Element>(root).isCustomElementUpgradeCandidate())
Prevent infinite recursion when upgrading custom elements https://bugs.webkit.org/show_bug.cgi?id=206605 Reviewed by Antti Koivisto. LayoutTests/imported/w3c: Rebaselined the test now that one more test case is passing. * web-platform-tests/custom-elements/upgrading-expected.txt: Source/WebCore: This patch updates our implementation of the concept to upgrade an element [1] and related algorithms to match the latest HTML5 specification. In particular, it incorporates the algorithmic change [2] to prevent infinite recursion an element is re-inserted into a document tree inside its constructor. The key code change is in JSCustomElementInterface::upgradeElement where this patch adds an early exit when custom element is not "undefined" or "uncustomized" and the custom element state is set to "failed" immediately before invoking the constructor. The rest of code changes deals with this "failed" state appearing during upgrades and updates various debug assertions. [1] https://html.spec.whatwg.org/multipage/custom-elements.html#concept-upgrade-an-element [2] https://github.com/whatwg/html/pull/5126 [3] https://html.spec.whatwg.org/multipage/custom-elements.html#concept-try-upgrade Test: imported/w3c/web-platform-tests/custom-elements/upgrading.html * bindings/js/JSCustomElementInterface.cpp: (WebCore::JSCustomElementInterface::constructElementWithFallback): (WebCore::JSCustomElementInterface::upgradeElement): Implements the new behavior. Note that we still need to clear the queue where we used to set the custom element state to "failed" to avoid memory leaks. * dom/CustomElementReactionQueue.cpp: (WebCore::CustomElementReactionQueue::hasJustUpgradeReaction const): Added. (WebCore::CustomElementReactionQueue::enqueueElementUpgrade): Enqueue the element to the element queue even if it had already been scheduled to upgrade previously. This makes the innermost attempt to upgrade to succeed instead of the outermost. Also updated debug assertions. (WebCore::CustomElementReactionQueue::tryToUpgradeElement): Renamed from enqueueElementUpgradeIfDefined to match the spec's name [3]. Unlike the concept in the spec, this function doesn't get called when the custom element state of the elemnt is either "undefined" or "uncustomized" to avoid unnecessary work. * dom/CustomElementReactionQueue.h: (WebCore::CustomElementReactionQueue::isEmpty const): Added. * dom/CustomElementRegistry.cpp: (WebCore::upgradeElementsInShadowIncludingDescendants): (WebCore::CustomElementRegistry::upgrade): * dom/Document.cpp: (WebCore::createFallbackHTMLElement): Call setIsCustomElementUpgradeCandidate on a newly created since we can no longer update node flags in enqueueToUpgrade * dom/Element.cpp: (WebCore::Element::insertedIntoAncestor): (WebCore::Element::setIsFailedCustomElement): Removed the unused function argument. (WebCore::Element::setIsFailedCustomElementWithoutClearingReactionQueue): Extracted from setIsFailedCustomElement. (WebCore::Element::clearReactionQueueFromFailedCustomElement): Ditto. (WebCore::Element::enqueueToUpgrade): No longer updates node flags as this would clear "failed" state from a custom element which is currently being upgraded and cause all sorts of issues. (WebCore::Element::reactionQueue const): Updated debug assertions. * dom/Element.h: LayoutTests: Removed the crash expectation from a test now that it's passing. * TestExpectations: Canonical link: https://commits.webkit.org/228719@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266269 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-08-28 02:55:21 +00:00
CustomElementReactionQueue::tryToUpgradeElement(downcast<Element>(root));
Implement customElements.upgrade() https://bugs.webkit.org/show_bug.cgi?id=183397 Reviewed by Frédéric Wang. LayoutTests/imported/w3c: Rebaseline the test now that we're passing. * web-platform-tests/custom-elements/custom-element-registry/upgrade-expected.txt: Source/WebCore: Added the support to upgrade custom elements directly. Ordinarily, custom elements get upgraded as they are inserted / connected into a document but some script libraries and authors want to be able to upgrade them before that. Also see https://github.com/w3c/webcomponents/issues/710 Implemented the method as specified at: https://html.spec.whatwg.org/multipage/custom-elements.html#dom-customelementregistry-upgrade When invoked, the upgrade(root) method must run these steps: 1. Let candidates be a list of all of root's shadow-including inclusive descendant elements, in shadow-including tree order. 2. For each candidate of candidates, try to upgrade candidate. Tests: imported/w3c/web-platform-tests/custom-elements/custom-element-registry/upgrade.html * dom/CustomElementReactionQueue.cpp: (WebCore::CustomElementReactionQueue::enqueueElementUpgradeIfDefined): Removed the assertion that the upgraded element is connected since the whole point of this API is to upgrade a disconnected element. * dom/CustomElementRegistry.cpp: (WebCore::upgradeElementsInShadowIncludingdescendants): Added. (WebCore::CustomElementRegistry::upgrade): Added. * dom/CustomElementRegistry.h: Forward declare DeferredPromise instead of unnecessarily including JSDOMPromiseDeferred.h. * dom/CustomElementRegistry.idl: * dom/Element.cpp: (WebCore::Element::insertedIntoAncestor): Moved the assertion here. Canonical link: https://commits.webkit.org/203374@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234507 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-08-02 19:25:23 +00:00
upgradeElementsInShadowIncludingDescendants(downcast<ContainerNode>(root));
}
Add document.defineCustomElement https://bugs.webkit.org/show_bug.cgi?id=153092 Reviewed by Chris Dumez. Source/WebCore: Added document.defineCustomElement and added a constructor to HTMLElement which can be called as "super" in a subclass of HTMLElement. This is a prototype of new custom elements API and willfully violates the current specification at http://w3c.github.io/webcomponents/spec/custom/ Each author defined class can define multiple elements using distinct tag names. In such cases, the super call must specify the tag name. e.g. class SomeCustomElement extends HTMLElement { constructor(name) { super(name); } } document.defineCustomElement('some-custom-element', SomeCustomElement); document.defineCustomElement('other-custom-element', SomeCustomElement); new SomeCustomElement('some-custom-element'); When a class is associated with exactly one tag name, the argument can be omitted. e.g. class AnotherCustomElement extends HTMLElement {} document.defineCustomElement('another-custom-element', AnotherCustomElement); new AnotherCustomElement(); We allow only subclassing of HTMLElement and only in (X)HTML namespace. Tests: fast/custom-elements/Document-defineCustomElement.html fast/custom-elements/HTMLElement-constructor.html * CMakeLists.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSCustomElementInterface.cpp: Added. Abstracts an author-defined class associated with a custom element. It's a Active DOM object and lives until the associated document dies. (WebCore::JSCustomElementInterface::JSCustomElementInterface): (WebCore::JSCustomElementInterface::~JSCustomElementInterface): * bindings/js/JSCustomElementInterface.h: Added. (WebCore::JSCustomElementInterface::create): (WebCore::JSCustomElementInterface::scriptExecutionContext): (WebCore::JSCustomElementInterface::constructor): * bindings/js/JSDocumentCustom.cpp: (WebCore::JSDocument::defineCustomElement): Added. Define a custom element by associating a tag name with an author defined JS class after validating arguments. * bindings/js/JSHTMLElementCustom.cpp: (WebCore::constructJSHTMLElement): Added. Look up the tag name based on new.target if one is not specified. If a tag name is specified, check that new.target is associated with the tag name. * dom/CustomElementDefinitions.cpp: Added. (WebCore::CustomElementDefinitions::checkName): Added. Restricts tag names similarly to http://w3c.github.io/webcomponents/spec/custom/#dfn-custom-element-type (WebCore::CustomElementDefinitions::defineElement): Added. Associates a JS class with a tag name. (WebCore::CustomElementDefinitions::findInterface): Added. Finds a JS class by a tag name. (WebCore::CustomElementDefinitions::findName): Added. Finds a tag name by a JS class. * dom/CustomElementDefinitions.h: Added. (WebCore::CustomElementDefinitions::CustomElementInfo): Added. * dom/Document.cpp: (WebCore::Document::ensureCustomElementDefinitions): Added. * dom/Document.h: (WebCore::Document::customElementDefinitions): Added. * dom/Document.idl: * html/HTMLElement.idl: LayoutTests: Added tests for document.defineCustomElement and instantiating custom elements. * TestExpectations: Skipped the tests on non-Mac ports. * fast/custom-elements: Added. * fast/custom-elements/Document-defineCustomElement-expected.txt: Added. * fast/custom-elements/Document-defineCustomElement.html: Added. * fast/custom-elements/HTMLElement-constructor-expected.txt: Added. * fast/custom-elements/HTMLElement-constructor.html: Added. * platform/mac/TestExpectations: Canonical link: https://commits.webkit.org/171208@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@195087 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-01-15 02:59:03 +00:00
}