<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[201858] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/201858">201858</a></dd>
<dt>Author</dt> <dd>rniwa@webkit.org</dd>
<dt>Date</dt> <dd>2016-06-09 02:09:50 -0700 (Thu, 09 Jun 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>slotchange event should be fired at the end of microtask
https://bugs.webkit.org/show_bug.cgi?id=157374
<rdar://problem/26154024>
Reviewed by Antti Koivisto.
Source/WebCore:
Dispatch slotchange event at the end of every microtask after delivering records to mutation observers
as specified in: https://dom.spec.whatwg.org/#notify-mutation-observers
Test: fast/shadow-dom/slotchange-event.html
* dom/Document.cpp:
(WebCore::Document::enqueueSlotchangeEvent): Deleted.
* dom/Document.h:
* dom/MutationObserver.cpp:
(WebCore::signalSlotList): Added.
(WebCore::MutationObserverMicrotask::run): mutationObserverCompoundMicrotaskQueuedFlag is now unset in
notifyMutationObservers to better match the concept to "notify mutation observers".
(WebCore::MutationObserver::enqueueSlotChangeEvent): Added.
(WebCore::MutationObserver::notifyMutationObservers): Renamed from deliverAllMutations. Added the code
to dispatch slotchange events as spec'ed, and also added comments for each step.
* dom/MutationObserver.h:
* html/HTMLSlotElement.cpp:
(WebCore::HTMLSlotElement::enqueueSlotChangeEvent): Use MutationObserver::enqueueSlotChangeEvent. Don't
create an event here since that is only needed when dispatching the event, and to keep track of whether
we've already scheduled an event or not. Use a boolean flag instead for the latter.
(WebCore::HTMLSlotElement::dispatchSlotChangeEvent): Added. Creates and dispatches an event.
(WebCore::HTMLSlotElement::dispatchEvent): Deleted.
* html/HTMLSlotElement.h:
(WebCore::HTMLSlotElement::didRemoveFromSignalSlotList): Added.
LayoutTests:
Added a test case to ensure slotchange event is dispatched at the end of a microtask.
* fast/shadow-dom/slotchange-event-expected.txt:
* fast/shadow-dom/slotchange-event.html:</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsfastshadowdomslotchangeeventexpectedtxt">trunk/LayoutTests/fast/shadow-dom/slotchange-event-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastshadowdomslotchangeeventhtml">trunk/LayoutTests/fast/shadow-dom/slotchange-event.html</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoredomDocumentcpp">trunk/Source/WebCore/dom/Document.cpp</a></li>
<li><a href="#trunkSourceWebCoredomDocumenth">trunk/Source/WebCore/dom/Document.h</a></li>
<li><a href="#trunkSourceWebCoredomMutationObservercpp">trunk/Source/WebCore/dom/MutationObserver.cpp</a></li>
<li><a href="#trunkSourceWebCoredomMutationObserverh">trunk/Source/WebCore/dom/MutationObserver.h</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLSlotElementcpp">trunk/Source/WebCore/html/HTMLSlotElement.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLSlotElementh">trunk/Source/WebCore/html/HTMLSlotElement.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (201857 => 201858)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-06-09 08:41:54 UTC (rev 201857)
+++ trunk/LayoutTests/ChangeLog        2016-06-09 09:09:50 UTC (rev 201858)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2016-06-09 Ryosuke Niwa <rniwa@webkit.org>
+
+ slotchange event should be fired at the end of microtask
+ https://bugs.webkit.org/show_bug.cgi?id=157374
+ <rdar://problem/26154024>
+
+ Reviewed by Antti Koivisto.
+
+ Added a test case to ensure slotchange event is dispatched at the end of a microtask.
+
+ * fast/shadow-dom/slotchange-event-expected.txt:
+ * fast/shadow-dom/slotchange-event.html:
+
</ins><span class="cx"> 2016-06-08 Joseph Pecoraro <pecoraro@apple.com>
</span><span class="cx">
</span><span class="cx"> REGRESSION: Web Inspector: Should be able to evaluate "{a:1, b:2}" in the console
</span></span></pre></div>
<a id="trunkLayoutTestsfastshadowdomslotchangeeventexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/shadow-dom/slotchange-event-expected.txt (201857 => 201858)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/shadow-dom/slotchange-event-expected.txt        2016-06-09 08:41:54 UTC (rev 201857)
+++ trunk/LayoutTests/fast/shadow-dom/slotchange-event-expected.txt        2016-06-09 09:09:50 UTC (rev 201858)
</span><span class="lines">@@ -29,4 +29,8 @@
</span><span class="cx"> PASS slotchange event must fire on a slot element inside a closed shadow root in a document when nested slots's contents change
</span><span class="cx"> PASS slotchange event must fire on a slot element inside an open shadow root not in a document when nested slots's contents change
</span><span class="cx"> PASS slotchange event must fire on a slot element inside a closed shadow root not in a document when nested slots's contents change
</span><ins>+PASS slotchange event must fire at the end of current microtask after mutation observers are invoked inside an open shadow root in a document when slots's contents change
+PASS slotchange event must fire at the end of current microtask after mutation observers are invoked inside a closed shadow root in a document when slots's contents change
+PASS slotchange event must fire at the end of current microtask after mutation observers are invoked inside an open shadow root not in a document when slots's contents change
+PASS slotchange event must fire at the end of current microtask after mutation observers are invoked inside a closed shadow root not in a document when slots's contents change
</ins><span class="cx">
</span></span></pre></div>
<a id="trunkLayoutTestsfastshadowdomslotchangeeventhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/shadow-dom/slotchange-event.html (201857 => 201858)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/shadow-dom/slotchange-event.html        2016-06-09 08:41:54 UTC (rev 201857)
+++ trunk/LayoutTests/fast/shadow-dom/slotchange-event.html        2016-06-09 09:09:50 UTC (rev 201858)
</span><span class="lines">@@ -534,6 +534,86 @@
</span><span class="cx"> testSlotchangeFiresWhenNestedSlotChange('open', false);
</span><span class="cx"> testSlotchangeFiresWhenNestedSlotChange('closed', false);
</span><span class="cx">
</span><ins>+function testSlotchangeFiresAtEndOfMicroTask(mode, connectedToDocument)
+{
+ var test = async_test('slotchange event must fire at the end of current microtask after mutation observers are invoked inside '
+ + treeName(mode, connectedToDocument) + ' when slots\'s contents change');
+
+ var outerHost;
+ var innerHost;
+ var outerSlot;
+ var innerSlot;
+ var slotchangeEvents = [];
+
+ test.step(function () {
+ outerHost = document.createElement('div');
+ if (connectedToDocument)
+ document.body.appendChild(outerHost);
+
+ var outerShadow = outerHost.attachShadow({'mode': mode});
+ outerShadow.appendChild(document.createElement('span'));
+ outerSlot = document.createElement('slot');
+ outerSlot.addEventListener('slotchange', function (event) {
+ event.stopPropagation();
+ test.step(function () {
+ assert_equals(event.target, outerSlot, 'slotchange event\'s target must be the slot element');
+ });
+ slotchangeEvents.push('outer');
+ });
+
+ innerHost = document.createElement('div');
+ innerHost.appendChild(outerSlot);
+ outerShadow.appendChild(innerHost);
+
+ var innerShadow = innerHost.attachShadow({'mode': mode});
+ innerShadow.appendChild(document.createElement('span'));
+ innerSlot = document.createElement('slot');
+ innerSlot.addEventListener('slotchange', function (event) {
+ event.stopPropagation();
+ test.step(function () {
+ assert_equals(event.target, innerSlot, 'slotchange event\'s target must be the slot element');
+ });
+ slotchangeEvents.push('inner');
+ });
+ innerShadow.appendChild(innerSlot);
+
+ outerHost.appendChild(document.createElement('span'));
+
+ assert_equals(slotchangeEvents.length, 0, 'slotchange event must not be fired synchronously');
+ });
+
+ var element = document.createElement('div');
+
+ new MutationObserver(function () {
+ test.step(function () {
+ assert_equals(slotchangeEvents.length, 0, 'slotchange event must not be fired before mutation records are delivered');
+ });
+ element.setAttribute('title', 'bar');
+ innerHost.appendChild(document.createElement('span'));
+ }).observe(element, {attributes: true, attributeFilter: ['id']});
+
+ new MutationObserver(function () {
+ test.step(function () {
+ assert_array_equals(slotchangeEvents, ['outer', 'inner'], 'slotchange event must be fired during a single compound microtask');
+ });
+ }).observe(element, {attributes: true, attributeFilter: ['title']});
+
+ element.setAttribute('id', 'foo');
+
+ setTimeout(function () {
+ test.step(function () {
+ assert_array_equals(slotchangeEvents, ['outer', 'inner', 'inner'],
+ 'a distinct slotchange event must be enqueued for changes made during a mutation observer delivery');
+ });
+ test.done();
+ }, 0);
+}
+
+testSlotchangeFiresAtEndOfMicroTask('open', true);
+testSlotchangeFiresAtEndOfMicroTask('closed', true);
+testSlotchangeFiresAtEndOfMicroTask('open', false);
+testSlotchangeFiresAtEndOfMicroTask('closed', false);
+
</ins><span class="cx"> </script>
</span><span class="cx"> </body>
</span><span class="cx"> </html>
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (201857 => 201858)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-06-09 08:41:54 UTC (rev 201857)
+++ trunk/Source/WebCore/ChangeLog        2016-06-09 09:09:50 UTC (rev 201858)
</span><span class="lines">@@ -1,3 +1,36 @@
</span><ins>+2016-06-09 Ryosuke Niwa <rniwa@webkit.org>
+
+ slotchange event should be fired at the end of microtask
+ https://bugs.webkit.org/show_bug.cgi?id=157374
+ <rdar://problem/26154024>
+
+ Reviewed by Antti Koivisto.
+
+ Dispatch slotchange event at the end of every microtask after delivering records to mutation observers
+ as specified in: https://dom.spec.whatwg.org/#notify-mutation-observers
+
+ Test: fast/shadow-dom/slotchange-event.html
+
+ * dom/Document.cpp:
+ (WebCore::Document::enqueueSlotchangeEvent): Deleted.
+ * dom/Document.h:
+ * dom/MutationObserver.cpp:
+ (WebCore::signalSlotList): Added.
+ (WebCore::MutationObserverMicrotask::run): mutationObserverCompoundMicrotaskQueuedFlag is now unset in
+ notifyMutationObservers to better match the concept to "notify mutation observers".
+ (WebCore::MutationObserver::enqueueSlotChangeEvent): Added.
+ (WebCore::MutationObserver::notifyMutationObservers): Renamed from deliverAllMutations. Added the code
+ to dispatch slotchange events as spec'ed, and also added comments for each step.
+ * dom/MutationObserver.h:
+ * html/HTMLSlotElement.cpp:
+ (WebCore::HTMLSlotElement::enqueueSlotChangeEvent): Use MutationObserver::enqueueSlotChangeEvent. Don't
+ create an event here since that is only needed when dispatching the event, and to keep track of whether
+ we've already scheduled an event or not. Use a boolean flag instead for the latter.
+ (WebCore::HTMLSlotElement::dispatchSlotChangeEvent): Added. Creates and dispatches an event.
+ (WebCore::HTMLSlotElement::dispatchEvent): Deleted.
+ * html/HTMLSlotElement.h:
+ (WebCore::HTMLSlotElement::didRemoveFromSignalSlotList): Added.
+
</ins><span class="cx"> 2016-06-08 Youenn Fablet <youenn.fablet@crf.canon.fr>
</span><span class="cx">
</span><span class="cx"> Introduce ResourceErrorBase::type
</span></span></pre></div>
<a id="trunkSourceWebCoredomDocumentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Document.cpp (201857 => 201858)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Document.cpp        2016-06-09 08:41:54 UTC (rev 201857)
+++ trunk/Source/WebCore/dom/Document.cpp        2016-06-09 09:09:50 UTC (rev 201858)
</span><span class="lines">@@ -4250,11 +4250,6 @@
</span><span class="cx"> m_eventQueue.enqueueEvent(WTFMove(event));
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void Document::enqueueSlotchangeEvent(Ref<Event>&& event)
-{
- m_eventQueue.enqueueEvent(WTFMove(event));
-}
-
</del><span class="cx"> RefPtr<Event> Document::createEvent(const String& type, ExceptionCode& ec)
</span><span class="cx"> {
</span><span class="cx"> // Please do *not* add new event classes to this function unless they are
</span></span></pre></div>
<a id="trunkSourceWebCoredomDocumenth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Document.h (201857 => 201858)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Document.h        2016-06-09 08:41:54 UTC (rev 201857)
+++ trunk/Source/WebCore/dom/Document.h        2016-06-09 09:09:50 UTC (rev 201858)
</span><span class="lines">@@ -1089,7 +1089,6 @@
</span><span class="cx"> void enqueueWindowEvent(Ref<Event>&&);
</span><span class="cx"> void enqueueDocumentEvent(Ref<Event>&&);
</span><span class="cx"> void enqueueOverflowEvent(Ref<Event>&&);
</span><del>- void enqueueSlotchangeEvent(Ref<Event>&&);
</del><span class="cx"> void enqueuePageshowEvent(PageshowEventPersistence);
</span><span class="cx"> void enqueueHashchangeEvent(const String& oldURL, const String& newURL);
</span><span class="cx"> void enqueuePopstateEvent(RefPtr<SerializedScriptValue>&& stateObject);
</span></span></pre></div>
<a id="trunkSourceWebCoredomMutationObservercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/MutationObserver.cpp (201857 => 201858)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/MutationObserver.cpp        2016-06-09 08:41:54 UTC (rev 201857)
+++ trunk/Source/WebCore/dom/MutationObserver.cpp        2016-06-09 09:09:50 UTC (rev 201858)
</span><span class="lines">@@ -35,6 +35,7 @@
</span><span class="cx"> #include "Dictionary.h"
</span><span class="cx"> #include "Document.h"
</span><span class="cx"> #include "ExceptionCode.h"
</span><ins>+#include "HTMLSlotElement.h"
</ins><span class="cx"> #include "Microtasks.h"
</span><span class="cx"> #include "MutationCallback.h"
</span><span class="cx"> #include "MutationObserverRegistration.h"
</span><span class="lines">@@ -146,6 +147,13 @@
</span><span class="cx"> return suspendedObservers;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+// https://dom.spec.whatwg.org/#signal-slot-list
+static Vector<RefPtr<HTMLSlotElement>>& signalSlotList()
+{
+ static NeverDestroyed<Vector<RefPtr<HTMLSlotElement>>> list;
+ return list;
+}
+
</ins><span class="cx"> static bool mutationObserverCompoundMicrotaskQueuedFlag;
</span><span class="cx">
</span><span class="cx"> class MutationObserverMicrotask final : public Microtask {
</span><span class="lines">@@ -153,8 +161,7 @@
</span><span class="cx"> private:
</span><span class="cx"> Result run() final
</span><span class="cx"> {
</span><del>- mutationObserverCompoundMicrotaskQueuedFlag = false;
- MutationObserver::deliverAllMutations();
</del><ins>+ MutationObserver::notifyMutationObservers();
</ins><span class="cx"> return Result::Done;
</span><span class="cx"> }
</span><span class="cx"> };
</span><span class="lines">@@ -176,6 +183,15 @@
</span><span class="cx"> queueMutationObserverCompoundMicrotask();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void MutationObserver::enqueueSlotChangeEvent(HTMLSlotElement& slot)
+{
+ ASSERT(isMainThread());
+ ASSERT(!signalSlotList().contains(&slot));
+ signalSlotList().append(&slot);
+
+ queueMutationObserverCompoundMicrotask();
+}
+
</ins><span class="cx"> void MutationObserver::setHasTransientRegistration()
</span><span class="cx"> {
</span><span class="cx"> ASSERT(isMainThread());
</span><span class="lines">@@ -220,8 +236,12 @@
</span><span class="cx"> m_callback->call(records, this);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void MutationObserver::deliverAllMutations()
</del><ins>+void MutationObserver::notifyMutationObservers()
</ins><span class="cx"> {
</span><ins>+ // https://dom.spec.whatwg.org/#notify-mutation-observers
+ // 1. Unset mutation observer compound microtask queued flag.
+ mutationObserverCompoundMicrotaskQueuedFlag = false;
+
</ins><span class="cx"> ASSERT(isMainThread());
</span><span class="cx"> static bool deliveryInProgress = false;
</span><span class="cx"> if (deliveryInProgress)
</span><span class="lines">@@ -240,20 +260,35 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>- while (!activeMutationObservers().isEmpty()) {
- Vector<RefPtr<MutationObserver>> observers;
- copyToVector(activeMutationObservers(), observers);
</del><ins>+ while (!activeMutationObservers().isEmpty() || !signalSlotList().isEmpty()) {
+ // 2. Let notify list be a copy of unit of related similar-origin browsing contexts' list of MutationObserver objects.
+ Vector<RefPtr<MutationObserver>> notifyList;
+ copyToVector(activeMutationObservers(), notifyList);
</ins><span class="cx"> activeMutationObservers().clear();
</span><del>- std::sort(observers.begin(), observers.end(), [](auto& lhs, auto& rhs) {
</del><ins>+ std::sort(notifyList.begin(), notifyList.end(), [](auto& lhs, auto& rhs) {
</ins><span class="cx"> return lhs->m_priority < rhs->m_priority;
</span><span class="cx"> });
</span><span class="cx">
</span><del>- for (auto& observer : observers) {
</del><ins>+ // 3. Let signalList be a copy of unit of related similar-origin browsing contexts' signal slot list.
+ // 4. Empty unit of related similar-origin browsing contexts' signal slot list.
+ Vector<RefPtr<HTMLSlotElement>> slotList;
+ if (!signalSlotList().isEmpty()) {
+ slotList.swap(signalSlotList());
+ for (auto& slot : slotList)
+ slot->didRemoveFromSignalSlotList();
+ }
+
+ // 5. For each MutationObserver object mo in notify list, execute a compound microtask subtask
+ for (auto& observer : notifyList) {
</ins><span class="cx"> if (observer->canDeliver())
</span><span class="cx"> observer->deliver();
</span><span class="cx"> else
</span><span class="cx"> suspendedMutationObservers().add(observer);
</span><span class="cx"> }
</span><ins>+
+ // 6. For each slot slot in signalList, in order, fire an event named slotchange, with its bubbles attribute set to true, at slot.
+ for (auto& slot : slotList)
+ slot->dispatchSlotChangeEvent();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> deliveryInProgress = false;
</span></span></pre></div>
<a id="trunkSourceWebCoredomMutationObserverh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/MutationObserver.h (201857 => 201858)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/MutationObserver.h        2016-06-09 08:41:54 UTC (rev 201857)
+++ trunk/Source/WebCore/dom/MutationObserver.h        2016-06-09 09:09:50 UTC (rev 201858)
</span><span class="lines">@@ -39,6 +39,7 @@
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><ins>+class HTMLSlotElement;
</ins><span class="cx"> class MutationCallback;
</span><span class="cx"> class MutationObserverRegistration;
</span><span class="cx"> class MutationRecord;
</span><span class="lines">@@ -96,11 +97,13 @@
</span><span class="cx">
</span><span class="cx"> HashSet<Node*> observedNodes() const;
</span><span class="cx">
</span><ins>+ static void enqueueSlotChangeEvent(HTMLSlotElement&);
+
</ins><span class="cx"> private:
</span><span class="cx"> explicit MutationObserver(Ref<MutationCallback>&&);
</span><span class="cx"> void deliver();
</span><span class="cx">
</span><del>- static void deliverAllMutations();
</del><ins>+ static void notifyMutationObservers();
</ins><span class="cx"> static bool validateOptions(MutationObserverOptions);
</span><span class="cx">
</span><span class="cx"> Ref<MutationCallback> m_callback;
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLSlotElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLSlotElement.cpp (201857 => 201858)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLSlotElement.cpp        2016-06-09 08:41:54 UTC (rev 201857)
+++ trunk/Source/WebCore/html/HTMLSlotElement.cpp        2016-06-09 09:09:50 UTC (rev 201858)
</span><span class="lines">@@ -31,6 +31,7 @@
</span><span class="cx"> #include "Event.h"
</span><span class="cx"> #include "EventNames.h"
</span><span class="cx"> #include "HTMLNames.h"
</span><ins>+#include "MutationObserver.h"
</ins><span class="cx"> #include "ShadowRoot.h"
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -126,24 +127,24 @@
</span><span class="cx">
</span><span class="cx"> void HTMLSlotElement::enqueueSlotChangeEvent()
</span><span class="cx"> {
</span><del>- if (m_enqueuedSlotChangeEvent)
</del><ins>+ // https://dom.spec.whatwg.org/#signal-a-slot-change
+ if (m_inSignalSlotList)
</ins><span class="cx"> return;
</span><ins>+ m_inSignalSlotList = true;
+ MutationObserver::enqueueSlotChangeEvent(*this);
+}
</ins><span class="cx">
</span><ins>+void HTMLSlotElement::dispatchSlotChangeEvent()
+{
+ m_inSignalSlotList = false;
+
</ins><span class="cx"> bool bubbles = false;
</span><span class="cx"> bool cancelable = false;
</span><del>- auto event = Event::create(eventNames().slotchangeEvent, bubbles, cancelable);
</del><ins>+ Ref<Event> event = Event::create(eventNames().slotchangeEvent, bubbles, cancelable);
</ins><span class="cx"> event->setTarget(this);
</span><del>- m_enqueuedSlotChangeEvent = event.ptr();
- document().enqueueSlotchangeEvent(WTFMove(event));
</del><ins>+ dispatchEvent(event);
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-bool HTMLSlotElement::dispatchEvent(Event& event)
-{
- if (&event == m_enqueuedSlotChangeEvent)
- m_enqueuedSlotChangeEvent = nullptr;
- return HTMLElement::dispatchEvent(event);
</del><span class="cx"> }
</span><span class="cx">
</span><del>-}
-
</del><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLSlotElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLSlotElement.h (201857 => 201858)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLSlotElement.h        2016-06-09 08:41:54 UTC (rev 201857)
+++ trunk/Source/WebCore/html/HTMLSlotElement.h        2016-06-09 09:09:50 UTC (rev 201858)
</span><span class="lines">@@ -42,16 +42,18 @@
</span><span class="cx"> Vector<Node*> assignedNodes(const AssignedNodesOptions&) const;
</span><span class="cx">
</span><span class="cx"> void enqueueSlotChangeEvent();
</span><ins>+ void didRemoveFromSignalSlotList() { m_inSignalSlotList = false; }
</ins><span class="cx">
</span><ins>+ void dispatchSlotChangeEvent();
+
</ins><span class="cx"> private:
</span><span class="cx"> HTMLSlotElement(const QualifiedName&, Document&);
</span><span class="cx">
</span><span class="cx"> InsertionNotificationRequest insertedInto(ContainerNode&) final;
</span><span class="cx"> void removedFrom(ContainerNode&) final;
</span><span class="cx"> void attributeChanged(const QualifiedName&, const AtomicString& oldValue, const AtomicString& newValue, AttributeModificationReason) final;
</span><del>- bool dispatchEvent(Event&) final;
</del><span class="cx">
</span><del>- Event* m_enqueuedSlotChangeEvent { nullptr };
</del><ins>+ bool m_inSignalSlotList { false };
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> }
</span></span></pre>
</div>
</div>
</body>
</html>