Source/WebCore:
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 27 Aug 2016 22:13:44 +0000 (22:13 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 27 Aug 2016 22:13:44 +0000 (22:13 +0000)
commit87595c7386438306523718fc45ecd2ecf46b3df8
tree627352beb2da8f9816c7c36d08fc163240c2a8a7
parenta96ea0d30dc783f401081d6d9b56ea455744cbe7
Source/WebCore:
Add adopted callback for custom elements
https://bugs.webkit.org/show_bug.cgi?id=161284

Reviewed by Antti Koivisto.

Added the support for adoptedCallback: https://dom.spec.whatwg.org/#concept-node-adopt
For now, we only support this callback on appendChild.

Test: fast/custom-elements/adopted-callback.html

* bindings/js/JSCustomElementInterface.cpp:
(WebCore::JSCustomElementInterface::invokeCallback): Added JSDOMGlobalObject* as an argument to the callback so that
we can invoke toJS on Document in invokeAdoptedCallback.
(WebCore::JSCustomElementInterface::setAdoptedCallback): Added.
(WebCore::JSCustomElementInterface::invokeAdoptedCallback): Added.
(WebCore::JSCustomElementInterface::setAttributeChangedCallback):
* bindings/js/JSCustomElementInterface.h:
(WebCore::JSCustomElementInterface::hasConnectedCallback): Added.
(WebCore::JSCustomElementInterface::hasDisconnectedCallback): Added.
(WebCore::JSCustomElementInterface::hasAdoptedCallback): Added.
* bindings/js/JSCustomElementRegistryCustom.cpp:
(WebCore::JSCustomElementRegistry::define):
* dom/CustomElementReactionQueue.cpp:
(WebCore::CustomElementReactionQueueItem::CustomElementReactionQueueItem): Added a variant that takes two documents.
(WebCore::CustomElementReactionQueueItem::invoke):
(WebCore::CustomElementReactionQueue::enqueueConnectedCallbackIfNeeded): Fixed a bug that this function was always
enqueuing a callback even when the interface didn't have connectedCallback. Also, there is no need to check
the nullity of the interface since it should never be null.
(WebCore::CustomElementReactionQueue::enqueueDisconnectedCallbackIfNeeded): Ditto.
(WebCore::CustomElementReactionQueue::enqueueAdoptedCallbackIfNeeded): Added.
(WebCore::CustomElementReactionQueue::enqueueAttributeChangedCallbackIfNeeded): Assert that the interface is never
null instead of exiting early.
* dom/CustomElementReactionQueue.h:
* dom/Element.cpp:
(WebCore::Element::didMoveToNewDocument): Added a call to enqueueAdoptedCallbackIfNeeded.

LayoutTests:
adoptcallback

Add adopted callback for custom elements
https://bugs.webkit.org/show_bug.cgi?id=161284

Reviewed by Antti Koivisto.

* fast/custom-elements/adopted-callback-expected.txt: Added.
* fast/custom-elements/adopted-callback.html: Added.
* fast/custom-elements/resources/document-types.js:
(const.DocumentTypes.create):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@205085 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/fast/custom-elements/adopted-callback-expected.txt [new file with mode: 0644]
LayoutTests/fast/custom-elements/adopted-callback.html [new file with mode: 0644]
LayoutTests/fast/custom-elements/resources/document-types.js
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/JSCustomElementInterface.cpp
Source/WebCore/bindings/js/JSCustomElementInterface.h
Source/WebCore/bindings/js/JSCustomElementRegistryCustom.cpp
Source/WebCore/dom/CustomElementReactionQueue.cpp
Source/WebCore/dom/CustomElementReactionQueue.h
Source/WebCore/dom/Element.cpp