slotchange event should bubble and dispatched once
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 16 Nov 2016 23:06:47 +0000 (23:06 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 16 Nov 2016 23:06:47 +0000 (23:06 +0000)
commit4b67f260f706d6b0eb949e75738a50fc42d8bec3
tree4e1636e2592252afe5ca42a58eba94400b2e17f7
parent8d2d97ba35016e84505eaa2007688f288d61b37a
slotchange event should bubble and dispatched once
https://bugs.webkit.org/show_bug.cgi?id=164770

Reviewed by Antti Koivisto.

LayoutTests/imported/w3c:

Rebaselined the test. Some test cases fail as they do on Chrome because it's testing an outdated version of the spec.
Will fix the test upstream later.

* web-platform-tests/shadow-dom/slotchange-event-expected.txt:

Source/WebCore:

Updated our implementation of slotchange event to match the latest specification after:
https://github.com/w3c/webcomponents/issues/571
https://dom.spec.whatwg.org/#signal-a-slot-change
The new behavior matches that of Google Chrome Canary.

In the latest specification, we no longer dispatch a separate event on ancestor slots.
Instead, we fire a single slotchange event to which a new node is assigned or from which
an existing assigned node is removed. This patch mostly removes the code that existed to
locate ancestor slot elements, and makes the event bubble up by changing a single line in
HTMLSlotElement::dispatchSlotChangeEvent.

Test: fast/shadow-dom/slotchange-event-bubbling.html

* dom/ShadowRoot.h:
* dom/SlotAssignment.cpp:
(WebCore::recursivelyFireSlotChangeEvent): Deleted.
(WebCore::SlotAssignment::didChangeSlot): Removed ChangeType from the arguments since we
no longer notify the ancestor slot elements.
(WebCore::SlotAssignment::hostChildElementDidChange):
* dom/SlotAssignment.h:
(WebCore::ShadowRoot::didRemoveAllChildrenOfShadowHost):
(WebCore::ShadowRoot::didChangeDefaultSlot):
(WebCore::ShadowRoot::hostChildElementDidChangeSlotAttribute):
(WebCore::ShadowRoot::innerSlotDidChange): Deleted.
* html/HTMLDetailsElement.cpp:
(WebCore::DetailsSlotAssignment::hostChildElementDidChange):
* html/HTMLSlotElement.cpp:
(WebCore::HTMLSlotElement::dispatchSlotChangeEvent): Make slotchange event bubble.

LayoutTests:

* fast/shadow-dom/slotchange-event-bubbling-expected.txt: Added.
* fast/shadow-dom/slotchange-event-bubbling.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@208817 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/fast/shadow-dom/slotchange-event-bubbling-expected.txt [new file with mode: 0644]
LayoutTests/fast/shadow-dom/slotchange-event-bubbling.html [new file with mode: 0644]
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slotchange-event-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/dom/ShadowRoot.h
Source/WebCore/dom/SlotAssignment.cpp
Source/WebCore/dom/SlotAssignment.h
Source/WebCore/html/HTMLDetailsElement.cpp
Source/WebCore/html/HTMLSlotElement.cpp