<!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>[193286] 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/193286">193286</a></dd>
<dt>Author</dt> <dd>weinig@apple.com</dd>
<dt>Date</dt> <dd>2015-12-03 11:06:45 -0800 (Thu, 03 Dec 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Promise callbacks should be called at microtask checkpoints
https://bugs.webkit.org/show_bug.cgi?id=147933
Reviewed by Chris Dumez.
Source/WebCore:
- Re-names MicroTaskQueue and MicroTask to MicrotaskQueue and Microtask to match the spec language.
- Re-implements MicrotaskQueue and Microtask support suspended Microtasks (via the new KeepInQueue
result value a Microtask can have when running) and correct behavior when Microtasks are added to
the queue during a Microtask checkpoint.
- MicrotaskQueue now has a mainThreadQueue() static function, replacing the old singleton() function,
which can be used for the Document (non-Worker) Microtasks. For Workers, the a MicrotaskQueue
can be separately allocated for each WorkerGlobalScope (though this was not done in this change).
- Adds a helper subclass of Microtask, ActiveDOMCallbackMicrotask, for Microtasks that are
per-ScriptExecutationContext, and need to act as ActiveDOMCallbacks.
- Re-implement Document (non-Worker) Promises on top of ActiveDOMCallbackMicrotask.
- Re-implement MutationObserver delivery on top of Microtask.
Layout Test:
fast/dom/microtask-promise-mutation-observer-order.html
* CMakeLists.txt:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.xcodeproj/project.pbxproj:
* dom/DOMAllInOne.cpp:
Add new files.
* bindings/js/JSDOMWindowBase.cpp:
(WebCore::JSDOMWindowBase::queueTaskToEventLoop):
Switch to using ActiveDOMCallbackMicrotask/MicrotaskQueue rather than ScriptExecutionContext's Task mechanism
for JavaScriptCore tasks.
* bindings/js/JSMainThreadExecState.cpp:
(WebCore::JSMainThreadExecState::didLeaveScriptContext):
Perform a microtask checkpoint rather than calling MutationObserver code explicitly now that mutation observers
use microtasks.
* dom/ActiveDOMCallbackMicrotask.cpp: Added.
(WebCore::ActiveDOMCallbackMicrotask::ActiveDOMCallbackMicrotask):
(WebCore::ActiveDOMCallbackMicrotask::~ActiveDOMCallbackMicrotask):
(WebCore::ActiveDOMCallbackMicrotask::run):
(WebCore::ActiveDOMCallbackMicrotask::contextDestroyed):
* dom/ActiveDOMCallbackMicrotask.h: Added.
Add a helper subclass of Microtask which behaves like a ActiveDOMCallback (e.g. supports suspension
and context destruction).
* dom/MicroTask.cpp: Renamed to Microtasks.cpp.
* dom/MicroTask.h: Renamed to Microtasks.h.
* dom/Microtasks.cpp: Renamed from Source/WebCore/dom/MicroTask.cpp.
(WebCore::Microtask::removeSelfFromQueue):
(WebCore::MicrotaskQueue::mainThreadQueue):
(WebCore::MicrotaskQueue::append):
(WebCore::MicrotaskQueue::remove):
(WebCore::MicrotaskQueue::performMicrotaskCheckpoint):
(WebCore::MicroTaskQueue::singleton): Deleted.
(WebCore::MicroTaskQueue::queueMicroTask): Deleted.
(WebCore::MicroTaskQueue::runMicroTasks): Deleted.
* dom/Microtasks.h: Renamed from Source/WebCore/dom/MicroTask.h.
(WebCore::Microtask::~Microtask):
(WebCore::MicrotaskQueue::MicrotaskQueue):
(WebCore::MicrotaskQueue::~MicrotaskQueue):
(WebCore::MicroTask::~MicroTask): Deleted.
(WebCore::MicroTaskQueue::~MicroTaskQueue): Deleted.
(WebCore::MicroTaskQueue::MicroTaskQueue): Deleted.
Re-implement MicrotaskQueue and Microtask to support Microtask suspension (via the KeepInQueue result
value) and correct behavior when Microtasks are queued during checkpoints.
* dom/MutationObserver.cpp:
(WebCore::suspendedMutationObservers):
(WebCore::MutationObserverMicrotask::MutationObserverMicrotask):
(WebCore::MutationObserverMicrotask::~MutationObserverMicrotask):
(WebCore::MutationObserverMicrotask::run):
(WebCore::queueMutationObserverCompoundMicrotask):
(WebCore::MutationObserver::enqueueMutationRecord):
(WebCore::MutationObserver::setHasTransientRegistration):
* dom/MutationObserver.h:
Re-implement MutationObserver delivery on top of Microtasks.
* dom/ScriptRunner.cpp:
(WebCore::ScriptRunner::timerFired):
Remove unnecessary call to runMicroTasks().
* html/parser/HTMLScriptRunner.cpp:
(WebCore::HTMLScriptRunner::executePendingScriptAndDispatchEvent):
(WebCore::HTMLScriptRunner::runScript):
Remove calls to MutationObserver::deliverAllMutations() now that the MicrotaskQueue will take care of it.
(WebCore::HTMLScriptRunner::executeScriptsWaitingForParsing):
Remove unnecessary call to runMicroTasks().
* testing/Internals.cpp:
(WebCore::Internals::queueMicroTask):
Use ActiveDOMCallbackMicrotask rather than a custom test subclass.
* testing/MicroTaskTest.cpp: Removed.
* testing/MicroTaskTest.h: Removed.
Remove custom test subclass of Microtask, just use ActiveDOMCallbackMicrotask directly.
LayoutTests:
* fast/dom/microtask-promise-mutation-observer-order-expected.txt: Added.
* fast/dom/microtask-promise-mutation-observer-order.html: Added.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreCMakeListstxt">trunk/Source/WebCore/CMakeLists.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCorevcxprojWebCorevcxproj">trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSDOMWindowBasecpp">trunk/Source/WebCore/bindings/js/JSDOMWindowBase.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSMainThreadExecStatecpp">trunk/Source/WebCore/bindings/js/JSMainThreadExecState.cpp</a></li>
<li><a href="#trunkSourceWebCoredomDOMAllInOnecpp">trunk/Source/WebCore/dom/DOMAllInOne.cpp</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="#trunkSourceWebCoredomScriptRunnercpp">trunk/Source/WebCore/dom/ScriptRunner.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlparserHTMLScriptRunnercpp">trunk/Source/WebCore/html/parser/HTMLScriptRunner.cpp</a></li>
<li><a href="#trunkSourceWebCoretestingInternalscpp">trunk/Source/WebCore/testing/Internals.cpp</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastdommicrotaskpromisemutationobserverorderexpectedtxt">trunk/LayoutTests/fast/dom/microtask-promise-mutation-observer-order-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastdommicrotaskpromisemutationobserverorderhtml">trunk/LayoutTests/fast/dom/microtask-promise-mutation-observer-order.html</a></li>
<li><a href="#trunkSourceWebCoredomActiveDOMCallbackMicrotaskcpp">trunk/Source/WebCore/dom/ActiveDOMCallbackMicrotask.cpp</a></li>
<li><a href="#trunkSourceWebCoredomActiveDOMCallbackMicrotaskh">trunk/Source/WebCore/dom/ActiveDOMCallbackMicrotask.h</a></li>
<li><a href="#trunkSourceWebCoredomMicrotaskscpp">trunk/Source/WebCore/dom/Microtasks.cpp</a></li>
<li><a href="#trunkSourceWebCoredomMicrotasksh">trunk/Source/WebCore/dom/Microtasks.h</a></li>
</ul>
<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoredomMicroTaskcpp">trunk/Source/WebCore/dom/MicroTask.cpp</a></li>
<li><a href="#trunkSourceWebCoredomMicroTaskh">trunk/Source/WebCore/dom/MicroTask.h</a></li>
<li><a href="#trunkSourceWebCoretestingMicroTaskTestcpp">trunk/Source/WebCore/testing/MicroTaskTest.cpp</a></li>
<li><a href="#trunkSourceWebCoretestingMicroTaskTesth">trunk/Source/WebCore/testing/MicroTaskTest.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (193285 => 193286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-12-03 19:06:40 UTC (rev 193285)
+++ trunk/LayoutTests/ChangeLog        2015-12-03 19:06:45 UTC (rev 193286)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2015-12-02 Sam Weinig <sam@webkit.org>
+
+ Promise callbacks should be called at microtask checkpoints
+ https://bugs.webkit.org/show_bug.cgi?id=147933
+
+ Reviewed by Chris Dumez.
+
+ * fast/dom/microtask-promise-mutation-observer-order-expected.txt: Added.
+ * fast/dom/microtask-promise-mutation-observer-order.html: Added.
+
</ins><span class="cx"> 2015-12-03 Daniel Bates <dabates@apple.com>
</span><span class="cx">
</span><span class="cx"> ASSERT_WITH_SECURITY_IMPLICATION in WebCore::DocumentOrderedMap::add()
</span></span></pre></div>
<a id="trunkLayoutTestsfastdommicrotaskpromisemutationobserverorderexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/microtask-promise-mutation-observer-order-expected.txt (0 => 193286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/microtask-promise-mutation-observer-order-expected.txt         (rev 0)
+++ trunk/LayoutTests/fast/dom/microtask-promise-mutation-observer-order-expected.txt        2015-12-03 19:06:45 UTC (rev 193286)
</span><span class="lines">@@ -0,0 +1,17 @@
</span><ins>+Test that promises and mutation observers are both delivered from the same microtask queue.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Expected result: promise,mutate,timeout
+Actual result: promise,mutate,timeout
+PASS actualResult is expectedResult
+
+Expected result: mutate,promise,timeout
+Actual result: mutate,promise,timeout
+PASS actualResult is expectedResult
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdommicrotaskpromisemutationobserverorderhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/microtask-promise-mutation-observer-order.html (0 => 193286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/microtask-promise-mutation-observer-order.html         (rev 0)
+++ trunk/LayoutTests/fast/dom/microtask-promise-mutation-observer-order.html        2015-12-03 19:06:45 UTC (rev 193286)
</span><span class="lines">@@ -0,0 +1,80 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script>
+
+description("Test that promises and mutation observers are both delivered from the same microtask queue.");
+var jsTestIsAsync = true;
+
+var actualResult = [];
+var expectedResult = [];
+var currentTest = 0;
+
+new MutationObserver(function() {
+ actualResult.push('mutate');
+ checkIfDone();
+}).observe(document.body, { attributes: true });
+function mutate()
+{
+ document.body.setAttribute('data-random', Math.random());
+}
+function promise()
+{
+ Promise.resolve().then(function() {
+ actualResult.push('promise');
+ checkIfDone();
+ });
+}
+function timeout()
+{
+ setTimeout(function() {
+ actualResult.push('timeout');
+ checkIfDone();
+ }, 0);
+}
+
+function checkIfDone()
+{
+ if (actualResult.length != expectedResult.length)
+ return;
+
+ debug("Expected result: " + expectedResult);
+ debug("Actual result: " + actualResult);
+ shouldBe("actualResult", "expectedResult");
+ debug("");
+
+ ++currentTest
+ runNextTest();
+}
+
+var tests = [
+ [[timeout, promise, mutate], ["promise", "mutate", "timeout"]],
+ [[timeout, mutate, promise], ["mutate", "promise", "timeout"]]
+];
+
+function runNextTest()
+{
+ if (currentTest >= tests.length) {
+ finishJSTest();
+ return;
+ }
+
+ actualResult = [];
+ tasks = tests[currentTest][0];
+ expectedResult = tests[currentTest][1];
+
+ for (task of tasks) {
+ task();
+ }
+}
+
+runNextTest()
+
+</script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkSourceWebCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/CMakeLists.txt (193285 => 193286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/CMakeLists.txt        2015-12-03 19:06:40 UTC (rev 193285)
+++ trunk/Source/WebCore/CMakeLists.txt        2015-12-03 19:06:45 UTC (rev 193286)
</span><span class="lines">@@ -1413,6 +1413,7 @@
</span><span class="cx">
</span><span class="cx"> cssjit/SelectorCompiler.cpp
</span><span class="cx">
</span><ins>+ dom/ActiveDOMCallbackMicrotask.cpp
</ins><span class="cx"> dom/ActiveDOMObject.cpp
</span><span class="cx"> dom/AnimationEvent.cpp
</span><span class="cx"> dom/Attr.cpp
</span><span class="lines">@@ -1485,7 +1486,7 @@
</span><span class="cx"> dom/MessageEvent.cpp
</span><span class="cx"> dom/MessagePort.cpp
</span><span class="cx"> dom/MessagePortChannel.cpp
</span><del>- dom/MicroTask.cpp
</del><ins>+ dom/Microtasks.cpp
</ins><span class="cx"> dom/MouseEvent.cpp
</span><span class="cx"> dom/MouseRelatedEvent.cpp
</span><span class="cx"> dom/MutationEvent.cpp
</span><span class="lines">@@ -3344,7 +3345,6 @@
</span><span class="cx">
</span><span class="cx"> testing/InternalSettings.cpp
</span><span class="cx"> testing/Internals.cpp
</span><del>- testing/MicroTaskTest.cpp
</del><span class="cx"> testing/MockPageOverlayClient.cpp
</span><span class="cx">
</span><span class="cx"> testing/js/WebCoreTestSupport.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (193285 => 193286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-12-03 19:06:40 UTC (rev 193285)
+++ trunk/Source/WebCore/ChangeLog        2015-12-03 19:06:45 UTC (rev 193286)
</span><span class="lines">@@ -1,3 +1,102 @@
</span><ins>+2015-12-02 Sam Weinig <sam@webkit.org>
+
+ Promise callbacks should be called at microtask checkpoints
+ https://bugs.webkit.org/show_bug.cgi?id=147933
+
+ Reviewed by Chris Dumez.
+
+ - Re-names MicroTaskQueue and MicroTask to MicrotaskQueue and Microtask to match the spec language.
+ - Re-implements MicrotaskQueue and Microtask support suspended Microtasks (via the new KeepInQueue
+ result value a Microtask can have when running) and correct behavior when Microtasks are added to
+ the queue during a Microtask checkpoint.
+ - MicrotaskQueue now has a mainThreadQueue() static function, replacing the old singleton() function,
+ which can be used for the Document (non-Worker) Microtasks. For Workers, the a MicrotaskQueue
+ can be separately allocated for each WorkerGlobalScope (though this was not done in this change).
+ - Adds a helper subclass of Microtask, ActiveDOMCallbackMicrotask, for Microtasks that are
+ per-ScriptExecutationContext, and need to act as ActiveDOMCallbacks.
+ - Re-implement Document (non-Worker) Promises on top of ActiveDOMCallbackMicrotask.
+ - Re-implement MutationObserver delivery on top of Microtask.
+
+ Layout Test:
+ fast/dom/microtask-promise-mutation-observer-order.html
+
+ * CMakeLists.txt:
+ * WebCore.vcxproj/WebCore.vcxproj:
+ * WebCore.xcodeproj/project.pbxproj:
+ * dom/DOMAllInOne.cpp:
+ Add new files.
+
+ * bindings/js/JSDOMWindowBase.cpp:
+ (WebCore::JSDOMWindowBase::queueTaskToEventLoop):
+ Switch to using ActiveDOMCallbackMicrotask/MicrotaskQueue rather than ScriptExecutionContext's Task mechanism
+ for JavaScriptCore tasks.
+
+ * bindings/js/JSMainThreadExecState.cpp:
+ (WebCore::JSMainThreadExecState::didLeaveScriptContext):
+ Perform a microtask checkpoint rather than calling MutationObserver code explicitly now that mutation observers
+ use microtasks.
+
+ * dom/ActiveDOMCallbackMicrotask.cpp: Added.
+ (WebCore::ActiveDOMCallbackMicrotask::ActiveDOMCallbackMicrotask):
+ (WebCore::ActiveDOMCallbackMicrotask::~ActiveDOMCallbackMicrotask):
+ (WebCore::ActiveDOMCallbackMicrotask::run):
+ (WebCore::ActiveDOMCallbackMicrotask::contextDestroyed):
+ * dom/ActiveDOMCallbackMicrotask.h: Added.
+ Add a helper subclass of Microtask which behaves like a ActiveDOMCallback (e.g. supports suspension
+ and context destruction).
+
+ * dom/MicroTask.cpp: Renamed to Microtasks.cpp.
+ * dom/MicroTask.h: Renamed to Microtasks.h.
+ * dom/Microtasks.cpp: Renamed from Source/WebCore/dom/MicroTask.cpp.
+ (WebCore::Microtask::removeSelfFromQueue):
+ (WebCore::MicrotaskQueue::mainThreadQueue):
+ (WebCore::MicrotaskQueue::append):
+ (WebCore::MicrotaskQueue::remove):
+ (WebCore::MicrotaskQueue::performMicrotaskCheckpoint):
+ (WebCore::MicroTaskQueue::singleton): Deleted.
+ (WebCore::MicroTaskQueue::queueMicroTask): Deleted.
+ (WebCore::MicroTaskQueue::runMicroTasks): Deleted.
+ * dom/Microtasks.h: Renamed from Source/WebCore/dom/MicroTask.h.
+ (WebCore::Microtask::~Microtask):
+ (WebCore::MicrotaskQueue::MicrotaskQueue):
+ (WebCore::MicrotaskQueue::~MicrotaskQueue):
+ (WebCore::MicroTask::~MicroTask): Deleted.
+ (WebCore::MicroTaskQueue::~MicroTaskQueue): Deleted.
+ (WebCore::MicroTaskQueue::MicroTaskQueue): Deleted.
+ Re-implement MicrotaskQueue and Microtask to support Microtask suspension (via the KeepInQueue result
+ value) and correct behavior when Microtasks are queued during checkpoints.
+
+ * dom/MutationObserver.cpp:
+ (WebCore::suspendedMutationObservers):
+ (WebCore::MutationObserverMicrotask::MutationObserverMicrotask):
+ (WebCore::MutationObserverMicrotask::~MutationObserverMicrotask):
+ (WebCore::MutationObserverMicrotask::run):
+ (WebCore::queueMutationObserverCompoundMicrotask):
+ (WebCore::MutationObserver::enqueueMutationRecord):
+ (WebCore::MutationObserver::setHasTransientRegistration):
+ * dom/MutationObserver.h:
+ Re-implement MutationObserver delivery on top of Microtasks.
+
+ * dom/ScriptRunner.cpp:
+ (WebCore::ScriptRunner::timerFired):
+ Remove unnecessary call to runMicroTasks().
+
+ * html/parser/HTMLScriptRunner.cpp:
+ (WebCore::HTMLScriptRunner::executePendingScriptAndDispatchEvent):
+ (WebCore::HTMLScriptRunner::runScript):
+ Remove calls to MutationObserver::deliverAllMutations() now that the MicrotaskQueue will take care of it.
+
+ (WebCore::HTMLScriptRunner::executeScriptsWaitingForParsing):
+ Remove unnecessary call to runMicroTasks().
+
+ * testing/Internals.cpp:
+ (WebCore::Internals::queueMicroTask):
+ Use ActiveDOMCallbackMicrotask rather than a custom test subclass.
+
+ * testing/MicroTaskTest.cpp: Removed.
+ * testing/MicroTaskTest.h: Removed.
+ Remove custom test subclass of Microtask, just use ActiveDOMCallbackMicrotask directly.
+
</ins><span class="cx"> 2015-12-03 Brady Eidson <beidson@apple.com>
</span><span class="cx">
</span><span class="cx"> Add GetterRaisesExceptionWithMessage and SetterRaisesExceptionWithMessage to the code generator.
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorevcxprojWebCorevcxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj (193285 => 193286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj        2015-12-03 19:06:40 UTC (rev 193285)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj        2015-12-03 19:06:45 UTC (rev 193286)
</span><span class="lines">@@ -13554,6 +13554,20 @@
</span><span class="cx"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
</span><span class="cx"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
</span><span class="cx"> </ClCompile>
</span><ins>+ <ClCompile Include="..\dom\ActiveDOMCallbackMicrotask.cpp">
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|x64'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|x64'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|x64'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
+ </ClCompile>
</ins><span class="cx"> <ClCompile Include="..\dom\ActiveDOMObject.cpp">
</span><span class="cx"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
</span><span class="cx"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
</span><span class="lines">@@ -14493,7 +14507,7 @@
</span><span class="cx"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
</span><span class="cx"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
</span><span class="cx"> </ClCompile>
</span><del>- <ClCompile Include="..\dom\MicroTask.cpp">
</del><ins>+ <ClCompile Include="..\dom\Microtasks.cpp">
</ins><span class="cx"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
</span><span class="cx"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
</span><span class="cx"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|Win32'">true</ExcludedFromBuild>
</span><span class="lines">@@ -22035,6 +22049,7 @@
</span><span class="cx"> <ClInclude Include="..\xml\parser\MarkupTokenizerInlines.h" />
</span><span class="cx"> <ClInclude Include="..\xml\parser\XMLDocumentParser.h" />
</span><span class="cx"> <ClInclude Include="..\xml\parser\XMLDocumentParserScope.h" />
</span><ins>+ <ClInclude Include="..\dom\ActiveDOMCallbackMicrotask.h" />
</ins><span class="cx"> <ClInclude Include="..\dom\ActiveDOMObject.h" />
</span><span class="cx"> <ClInclude Include="..\dom\AnimationEvent.h" />
</span><span class="cx"> <ClInclude Include="..\dom\Attr.h" />
</span><span class="lines">@@ -22126,7 +22141,7 @@
</span><span class="cx"> <ClInclude Include="..\dom\MessageEvent.h" />
</span><span class="cx"> <ClInclude Include="..\dom\MessagePort.h" />
</span><span class="cx"> <ClInclude Include="..\dom\MessagePortChannel.h" />
</span><del>- <ClInclude Include="..\dom\MicroTask.h" />
</del><ins>+ <ClInclude Include="..\dom\Microtasks.h" />
</ins><span class="cx"> <ClInclude Include="..\dom\MouseEvent.h" />
</span><span class="cx"> <ClInclude Include="..\dom\MouseRelatedEvent.h" />
</span><span class="cx"> <ClInclude Include="..\dom\MutationEvent.h" />
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (193285 => 193286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2015-12-03 19:06:40 UTC (rev 193285)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2015-12-03 19:06:45 UTC (rev 193286)
</span><span class="lines">@@ -2278,7 +2278,7 @@
</span><span class="cx">                 536D5A23193E8E0C00CE4CAB /* ParsingUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 536D5A22193E8E0C00CE4CAB /* ParsingUtilities.h */; };
</span><span class="cx">                 536D5A25193F40FC00CE4CAB /* SourceSizeList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 536D5A24193F40FC00CE4CAB /* SourceSizeList.cpp */; };
</span><span class="cx">                 536D5A27193F410B00CE4CAB /* SourceSizeList.h in Headers */ = {isa = PBXBuildFile; fileRef = 536D5A26193F410B00CE4CAB /* SourceSizeList.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><del>-                53B895AF19DC7ED9009CAA93 /* MicroTask.h in Headers */ = {isa = PBXBuildFile; fileRef = 53B895AD19DC7C37009CAA93 /* MicroTask.h */; };
</del><ins>+                53B895AF19DC7ED9009CAA93 /* Microtasks.h in Headers */ = {isa = PBXBuildFile; fileRef = 53B895AD19DC7C37009CAA93 /* Microtasks.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">                 53C8298D13D8D92700DE2DEB /* RenderFlexibleBox.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53C8298B13D8D92700DE2DEB /* RenderFlexibleBox.cpp */; };
</span><span class="cx">                 53C8298E13D8D92700DE2DEB /* RenderFlexibleBox.h in Headers */ = {isa = PBXBuildFile; fileRef = 53C8298C13D8D92700DE2DEB /* RenderFlexibleBox.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 53E29E5E167A8A1900586D3D /* InternalSettingsGenerated.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53E29E5C167A8A1900586D3D /* InternalSettingsGenerated.cpp */; };
</span><span class="lines">@@ -2753,6 +2753,8 @@
</span><span class="cx">                 7CC69940191EC5F500AF2270 /* JSWebKitNamespace.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CC6993E191EC5F500AF2270 /* JSWebKitNamespace.cpp */; };
</span><span class="cx">                 7CC69941191EC5F500AF2270 /* JSWebKitNamespace.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CC6993F191EC5F500AF2270 /* JSWebKitNamespace.h */; };
</span><span class="cx">                 7CC7E3D717208C0F003C5277 /* IDNScriptWhiteList.txt in Resources */ = {isa = PBXBuildFile; fileRef = 7CC7E3D617208C0F003C5277 /* IDNScriptWhiteList.txt */; };
</span><ins>+                7CD0BA041B8F79C9005CEBBE /* ActiveDOMCallbackMicrotask.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CD0BA021B8F79C9005CEBBE /* ActiveDOMCallbackMicrotask.cpp */; };
+                7CD0BA051B8F79C9005CEBBE /* ActiveDOMCallbackMicrotask.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CD0BA031B8F79C9005CEBBE /* ActiveDOMCallbackMicrotask.h */; };
</ins><span class="cx">                 7CD494CC1A86EB1D000A87EC /* RenderAttachment.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CD494CA1A86EB1D000A87EC /* RenderAttachment.cpp */; };
</span><span class="cx">                 7CD494CD1A86EB1D000A87EC /* RenderAttachment.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CD494CB1A86EB1D000A87EC /* RenderAttachment.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 7CDEEE1E197610D700E352CD /* ViewStateChangeObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CDEEE1D197610D700E352CD /* ViewStateChangeObserver.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="lines">@@ -5935,9 +5937,7 @@
</span><span class="cx">                 CA3BF67E10D99BAE00E6CE53 /* ScrollAnimator.h in Headers */ = {isa = PBXBuildFile; fileRef = CA3BF67D10D99BAE00E6CE53 /* ScrollAnimator.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 CAE9F90F146441F000C245B0 /* CSSAspectRatioValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CAE9F90D146441F000C245B0 /* CSSAspectRatioValue.cpp */; };
</span><span class="cx">                 CAE9F910146441F000C245B0 /* CSSAspectRatioValue.h in Headers */ = {isa = PBXBuildFile; fileRef = CAE9F90E146441F000C245B0 /* CSSAspectRatioValue.h */; };
</span><del>-                CB8CF0181A9358D4000D510B /* MicroTask.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CB8CF0151A934B43000D510B /* MicroTask.cpp */; };
-                CB8CF01D1A95DE42000D510B /* MicroTaskTest.h in Headers */ = {isa = PBXBuildFile; fileRef = CB8CF01C1A95DE42000D510B /* MicroTaskTest.h */; };
-                CB8CF01F1A95DE59000D510B /* MicroTaskTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CB8CF01E1A95DE59000D510B /* MicroTaskTest.cpp */; };
</del><ins>+                CB8CF0181A9358D4000D510B /* Microtasks.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CB8CF0151A934B43000D510B /* Microtasks.cpp */; };
</ins><span class="cx">                 CCC2B51415F613060048CDD6 /* DeviceClient.h in Headers */ = {isa = PBXBuildFile; fileRef = CCC2B51015F613060048CDD6 /* DeviceClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 CCC2B51515F613060048CDD6 /* DeviceController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CCC2B51115F613060048CDD6 /* DeviceController.cpp */; };
</span><span class="cx">                 CCC2B51615F613060048CDD6 /* DeviceController.h in Headers */ = {isa = PBXBuildFile; fileRef = CCC2B51215F613060048CDD6 /* DeviceController.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="lines">@@ -9745,7 +9745,7 @@
</span><span class="cx">                 536D5A22193E8E0C00CE4CAB /* ParsingUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParsingUtilities.h; sourceTree = "<group>"; };
</span><span class="cx">                 536D5A24193F40FC00CE4CAB /* SourceSizeList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SourceSizeList.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 536D5A26193F410B00CE4CAB /* SourceSizeList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SourceSizeList.h; sourceTree = "<group>"; };
</span><del>-                53B895AD19DC7C37009CAA93 /* MicroTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MicroTask.h; sourceTree = "<group>"; };
</del><ins>+                53B895AD19DC7C37009CAA93 /* Microtasks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Microtasks.h; sourceTree = "<group>"; };
</ins><span class="cx">                 53C8298B13D8D92700DE2DEB /* RenderFlexibleBox.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderFlexibleBox.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 53C8298C13D8D92700DE2DEB /* RenderFlexibleBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderFlexibleBox.h; sourceTree = "<group>"; };
</span><span class="cx">                 53E29E5C167A8A1900586D3D /* InternalSettingsGenerated.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InternalSettingsGenerated.cpp; sourceTree = "<group>"; };
</span><span class="lines">@@ -10288,6 +10288,8 @@
</span><span class="cx">                 7CC6993E191EC5F500AF2270 /* JSWebKitNamespace.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebKitNamespace.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 7CC6993F191EC5F500AF2270 /* JSWebKitNamespace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWebKitNamespace.h; sourceTree = "<group>"; };
</span><span class="cx">                 7CC7E3D617208C0F003C5277 /* IDNScriptWhiteList.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = IDNScriptWhiteList.txt; sourceTree = "<group>"; };
</span><ins>+                7CD0BA021B8F79C9005CEBBE /* ActiveDOMCallbackMicrotask.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ActiveDOMCallbackMicrotask.cpp; sourceTree = "<group>"; };
+                7CD0BA031B8F79C9005CEBBE /* ActiveDOMCallbackMicrotask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ActiveDOMCallbackMicrotask.h; sourceTree = "<group>"; };
</ins><span class="cx">                 7CD494CA1A86EB1D000A87EC /* RenderAttachment.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderAttachment.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 7CD494CB1A86EB1D000A87EC /* RenderAttachment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderAttachment.h; sourceTree = "<group>"; };
</span><span class="cx">                 7CDEEE1D197610D700E352CD /* ViewStateChangeObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewStateChangeObserver.h; sourceTree = "<group>"; };
</span><span class="lines">@@ -13776,9 +13778,7 @@
</span><span class="cx">                 CA3BF67D10D99BAE00E6CE53 /* ScrollAnimator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollAnimator.h; sourceTree = "<group>"; };
</span><span class="cx">                 CAE9F90D146441F000C245B0 /* CSSAspectRatioValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSAspectRatioValue.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 CAE9F90E146441F000C245B0 /* CSSAspectRatioValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSAspectRatioValue.h; sourceTree = "<group>"; };
</span><del>-                CB8CF0151A934B43000D510B /* MicroTask.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MicroTask.cpp; sourceTree = "<group>"; };
-                CB8CF01C1A95DE42000D510B /* MicroTaskTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MicroTaskTest.h; sourceTree = "<group>"; };
-                CB8CF01E1A95DE59000D510B /* MicroTaskTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MicroTaskTest.cpp; sourceTree = "<group>"; };
</del><ins>+                CB8CF0151A934B43000D510B /* Microtasks.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Microtasks.cpp; sourceTree = "<group>"; };
</ins><span class="cx">                 CCC2B51015F613060048CDD6 /* DeviceClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DeviceClient.h; sourceTree = "<group>"; };
</span><span class="cx">                 CCC2B51115F613060048CDD6 /* DeviceController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DeviceController.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 CCC2B51215F613060048CDD6 /* DeviceController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DeviceController.h; sourceTree = "<group>"; };
</span><span class="lines">@@ -16470,8 +16470,6 @@
</span><span class="cx">                                 A7BE7EDE14C9175A0014489D /* MallocStatistics.idl */,
</span><span class="cx">                                 CD5393CB175DCCE600C07123 /* MemoryInfo.h */,
</span><span class="cx">                                 CD5393CC175DCCE600C07123 /* MemoryInfo.idl */,
</span><del>-                                CB8CF01E1A95DE59000D510B /* MicroTaskTest.cpp */,
-                                CB8CF01C1A95DE42000D510B /* MicroTaskTest.h */,
</del><span class="cx">                                 CDC26B3C160A62B00026757B /* MockCDM.cpp */,
</span><span class="cx">                                 CDC26B3D160A62B00026757B /* MockCDM.h */,
</span><span class="cx">                                 A1BF6B801AA96C7D00AF4A8A /* MockContentFilter.cpp */,
</span><span class="lines">@@ -23783,6 +23781,8 @@
</span><span class="cx">                                 2D5036661BCDDDC400E20BB3 /* mac */,
</span><span class="cx">                                 E1C4DE6D0EA75C650023CCD6 /* ActiveDOMObject.cpp */,
</span><span class="cx">                                 E1C4DE680EA75C1E0023CCD6 /* ActiveDOMObject.h */,
</span><ins>+                                7CD0BA021B8F79C9005CEBBE /* ActiveDOMCallbackMicrotask.cpp */,
+                                7CD0BA031B8F79C9005CEBBE /* ActiveDOMCallbackMicrotask.h */,
</ins><span class="cx">                                 319847FE1A1D816700A13318 /* AnimationEvent.cpp */,
</span><span class="cx">                                 319847FF1A1D816700A13318 /* AnimationEvent.h */,
</span><span class="cx">                                 319848001A1D816700A13318 /* AnimationEvent.idl */,
</span><span class="lines">@@ -23999,8 +23999,8 @@
</span><span class="cx">                                 E1ADECBD0E76ACF1004A1A5E /* MessagePort.h */,
</span><span class="cx">                                 E1ADECC60E76AD1F004A1A5E /* MessagePort.idl */,
</span><span class="cx">                                 41BF700A0FE86F49005E8DEC /* MessagePortChannel.h */,
</span><del>-                                CB8CF0151A934B43000D510B /* MicroTask.cpp */,
-                                53B895AD19DC7C37009CAA93 /* MicroTask.h */,
</del><ins>+                                CB8CF0151A934B43000D510B /* Microtasks.cpp */,
+                                53B895AD19DC7C37009CAA93 /* Microtasks.h */,
</ins><span class="cx">                                 85031B2F0A44EFC700F992E0 /* MouseEvent.cpp */,
</span><span class="cx">                                 85031B300A44EFC700F992E0 /* MouseEvent.h */,
</span><span class="cx">                                 141B94E509EC4223000E9413 /* MouseEvent.idl */,
</span><span class="lines">@@ -24571,7 +24571,6 @@
</span><span class="cx">                                 CD5393D4175E018600C07123 /* JSMemoryInfo.h in Headers */,
</span><span class="cx">                                 A19AEA211AAA808600B52B25 /* JSMockContentFilterSettings.h in Headers */,
</span><span class="cx">                                 EBF5121D1696496C0056BD25 /* JSTypeConversions.h in Headers */,
</span><del>-                                CB8CF01D1A95DE42000D510B /* MicroTaskTest.h in Headers */,
</del><span class="cx">                                 CDC26B41160A8CCE0026757B /* MockCDM.h in Headers */,
</span><span class="cx">                                 A1BF6B831AA96C7D00AF4A8A /* MockContentFilter.h in Headers */,
</span><span class="cx">                                 A1B5B29F1AAA846F008B6042 /* MockContentFilterSettings.h in Headers */,
</span><span class="lines">@@ -26819,7 +26818,7 @@
</span><span class="cx">                                 A78E52701346BD1700AD9C31 /* MeterShadowElement.h in Headers */,
</span><span class="cx">                                 37DDCDA51384501C0008B793 /* MHTMLArchive.h in Headers */,
</span><span class="cx">                                 37DDCDA71384501C0008B793 /* MHTMLParser.h in Headers */,
</span><del>-                                53B895AF19DC7ED9009CAA93 /* MicroTask.h in Headers */,
</del><ins>+                                53B895AF19DC7ED9009CAA93 /* Microtasks.h in Headers */,
</ins><span class="cx">                                 37DDCD9513844FD50008B793 /* MIMEHeader.h in Headers */,
</span><span class="cx">                                 BC772C4F0C4EB3040083285F /* MIMETypeRegistry.h in Headers */,
</span><span class="cx">                                 52F10866162B6DA8009AC81E /* MixedContentChecker.h in Headers */,
</span><span class="lines">@@ -27500,6 +27499,7 @@
</span><span class="cx">                                 84730D931248F0B300D3A9C9 /* SpotLightSource.h in Headers */,
</span><span class="cx">                                 97BC6A3B1505F081001B74AC /* SQLCallbackWrapper.h in Headers */,
</span><span class="cx">                                 97BC6A3C1505F081001B74AC /* SQLError.h in Headers */,
</span><ins>+                                7CD0BA051B8F79C9005CEBBE /* ActiveDOMCallbackMicrotask.h in Headers */,
</ins><span class="cx">                                 97BC6A3F1505F081001B74AC /* SQLException.h in Headers */,
</span><span class="cx">                                 1A22464A0CC98DDB00C05240 /* SQLiteDatabase.h in Headers */,
</span><span class="cx">                                 7E474E1F12494DC900235364 /* SQLiteDatabaseTracker.h in Headers */,
</span><span class="lines">@@ -28510,7 +28510,6 @@
</span><span class="cx">                                 A19AEA221AAA808A00B52B25 /* JSMockContentFilterSettings.cpp in Sources */,
</span><span class="cx">                                 A1E5B31F1AAD1DA4006EBEFB /* JSMockContentFilterSettingsCustom.cpp in Sources */,
</span><span class="cx">                                 EBF5121C1696496C0056BD25 /* JSTypeConversions.cpp in Sources */,
</span><del>-                                CB8CF01F1A95DE59000D510B /* MicroTaskTest.cpp in Sources */,
</del><span class="cx">                                 CDC26B40160A8CC60026757B /* MockCDM.cpp in Sources */,
</span><span class="cx">                                 A1BF6B821AA96C7D00AF4A8A /* MockContentFilter.cpp in Sources */,
</span><span class="cx">                                 A1B5B29E1AAA846E008B6042 /* MockContentFilterSettings.cpp in Sources */,
</span><span class="lines">@@ -28968,6 +28967,7 @@
</span><span class="cx">                                 49FC7A501444AF5F00A5D864 /* DisplayRefreshMonitor.cpp in Sources */,
</span><span class="cx">                                 2D29ECC5192ECC8300984B78 /* DisplayRefreshMonitorClient.cpp in Sources */,
</span><span class="cx">                                 0F97A658155DA81E00FADD4C /* DisplayRefreshMonitorIOS.mm in Sources */,
</span><ins>+                                7CD0BA041B8F79C9005CEBBE /* ActiveDOMCallbackMicrotask.cpp in Sources */,
</ins><span class="cx">                                 49AF2D6C14435D210016A784 /* DisplayRefreshMonitorMac.cpp in Sources */,
</span><span class="cx">                                 2D29ECC7192ECC8300984B78 /* DisplayRefreshMonitorManager.cpp in Sources */,
</span><span class="cx">                                 CD52481A18E200ED0008A07D /* DisplaySleepDisabler.cpp in Sources */,
</span><span class="lines">@@ -30519,7 +30519,7 @@
</span><span class="cx">                                 75793E830D0CE0B3007FC0AC /* MessageEvent.cpp in Sources */,
</span><span class="cx">                                 E1ADECC00E76ACF1004A1A5E /* MessagePort.cpp in Sources */,
</span><span class="cx">                                 A78E526F1346BD1700AD9C31 /* MeterShadowElement.cpp in Sources */,
</span><del>-                                CB8CF0181A9358D4000D510B /* MicroTask.cpp in Sources */,
</del><ins>+                                CB8CF0181A9358D4000D510B /* Microtasks.cpp in Sources */,
</ins><span class="cx">                                 37DDCD9413844FD50008B793 /* MIMEHeader.cpp in Sources */,
</span><span class="cx">                                 BC772C4E0C4EB3040083285F /* MIMETypeRegistry.cpp in Sources */,
</span><span class="cx">                                 E453901D0EAFCACA003695C8 /* MIMETypeRegistryIOS.mm in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSDOMWindowBasecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSDOMWindowBase.cpp (193285 => 193286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSDOMWindowBase.cpp        2015-12-03 19:06:40 UTC (rev 193285)
+++ trunk/Source/WebCore/bindings/js/JSDOMWindowBase.cpp        2015-12-03 19:06:45 UTC (rev 193286)
</span><span class="lines">@@ -24,12 +24,14 @@
</span><span class="cx"> #include "config.h"
</span><span class="cx"> #include "JSDOMWindowBase.h"
</span><span class="cx">
</span><ins>+#include "ActiveDOMCallbackMicrotask.h"
</ins><span class="cx"> #include "Chrome.h"
</span><span class="cx"> #include "DOMWindow.h"
</span><span class="cx"> #include "Frame.h"
</span><span class="cx"> #include "InspectorController.h"
</span><span class="cx"> #include "JSDOMGlobalObjectTask.h"
</span><span class="cx"> #include "JSDOMWindowCustom.h"
</span><ins>+#include "JSMainThreadExecState.h"
</ins><span class="cx"> #include "JSModuleLoader.h"
</span><span class="cx"> #include "JSNode.h"
</span><span class="cx"> #include "Logging.h"
</span><span class="lines">@@ -39,6 +41,7 @@
</span><span class="cx"> #include "SecurityOrigin.h"
</span><span class="cx"> #include "Settings.h"
</span><span class="cx"> #include "WebCoreJSClientData.h"
</span><ins>+#include <heap/StrongInlines.h>
</ins><span class="cx"> #include <runtime/JSInternalPromiseDeferred.h>
</span><span class="cx"> #include <runtime/Microtask.h>
</span><span class="cx"> #include <wtf/MainThread.h>
</span><span class="lines">@@ -240,10 +243,46 @@
</span><span class="cx"> return frame->settings().javaScriptRuntimeFlags();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void JSDOMWindowBase::queueTaskToEventLoop(const JSGlobalObject* object, PassRefPtr<Microtask> task)
</del><ins>+class JSDOMWindowMicrotaskCallback : public RefCounted<JSDOMWindowMicrotaskCallback> {
+public:
+ static Ref<JSDOMWindowMicrotaskCallback> create(JSDOMWindowBase* globalObject, PassRefPtr<JSC::Microtask> task)
+ {
+ return adoptRef(*new JSDOMWindowMicrotaskCallback(globalObject, task));
+ }
+
+ void call()
+ {
+ Ref<JSDOMWindowMicrotaskCallback> protect(*this);
+ JSLockHolder lock(m_globalObject->vm());
+
+ ExecState* exec = m_globalObject->globalExec();
+
+ JSMainThreadExecState::runTask(exec, *m_task.get());
+
+ ASSERT(!exec->hadException());
+ }
+
+private:
+ JSDOMWindowMicrotaskCallback(JSDOMWindowBase* globalObject, PassRefPtr<JSC::Microtask> task)
+ : m_globalObject(globalObject->vm(), globalObject)
+ , m_task(task)
+ {
+ }
+
+ Strong<JSDOMWindowBase> m_globalObject;
+ RefPtr<JSC::Microtask> m_task;
+};
+
+void JSDOMWindowBase::queueTaskToEventLoop(const JSGlobalObject* object, PassRefPtr<JSC::Microtask> task)
</ins><span class="cx"> {
</span><span class="cx"> const JSDOMWindowBase* thisObject = static_cast<const JSDOMWindowBase*>(object);
</span><del>- thisObject->scriptExecutionContext()->postTask(JSGlobalObjectTask((JSDOMWindowBase*)thisObject, task));
</del><ins>+
+ RefPtr<JSDOMWindowMicrotaskCallback> callback = JSDOMWindowMicrotaskCallback::create((JSDOMWindowBase*)thisObject, task);
+ auto microtask = std::make_unique<ActiveDOMCallbackMicrotask>(MicrotaskQueue::mainThreadQueue(), *thisObject->scriptExecutionContext(), [callback]() mutable {
+ callback->call();
+ });
+
+ MicrotaskQueue::mainThreadQueue().append(WTF::move(microtask));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void JSDOMWindowBase::willRemoveFromWindowShell()
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSMainThreadExecStatecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSMainThreadExecState.cpp (193285 => 193286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSMainThreadExecState.cpp        2015-12-03 19:06:40 UTC (rev 193285)
+++ trunk/Source/WebCore/bindings/js/JSMainThreadExecState.cpp        2015-12-03 19:06:45 UTC (rev 193286)
</span><span class="lines">@@ -25,6 +25,8 @@
</span><span class="cx">
</span><span class="cx"> #include "config.h"
</span><span class="cx"> #include "JSMainThreadExecState.h"
</span><ins>+
+#include "Microtasks.h"
</ins><span class="cx"> #include "MutationObserver.h"
</span><span class="cx">
</span><span class="cx"> #if ENABLE(INDEXED_DATABASE)
</span><span class="lines">@@ -43,7 +45,7 @@
</span><span class="cx"> IDBPendingTransactionMonitor::deactivateNewTransactions();
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>- MutationObserver::deliverAllMutations();
</del><ins>+ MicrotaskQueue::mainThreadQueue().performMicrotaskCheckpoint();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> JSC::JSValue functionCallHandlerFromAnyThread(JSC::ExecState* exec, JSC::JSValue functionObject, JSC::CallType callType, const JSC::CallData& callData, JSC::JSValue thisValue, const JSC::ArgList& args, NakedPtr<JSC::Exception>& returnedException)
</span></span></pre></div>
<a id="trunkSourceWebCoredomActiveDOMCallbackMicrotaskcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/dom/ActiveDOMCallbackMicrotask.cpp (0 => 193286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/ActiveDOMCallbackMicrotask.cpp         (rev 0)
+++ trunk/Source/WebCore/dom/ActiveDOMCallbackMicrotask.cpp        2015-12-03 19:06:45 UTC (rev 193286)
</span><span class="lines">@@ -0,0 +1,57 @@
</span><ins>+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * 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. AND ITS CONTRIBUTORS ``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 ITS 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"
+#include "ActiveDOMCallbackMicrotask.h"
+
+namespace WebCore {
+
+ActiveDOMCallbackMicrotask::ActiveDOMCallbackMicrotask(MicrotaskQueue& queue, ScriptExecutionContext& scriptExecutionContext, std::function<void()>&& task)
+ : ActiveDOMCallback(&scriptExecutionContext)
+ , m_queue(queue)
+ , m_task(WTF::move(task))
+{
+}
+
+ActiveDOMCallbackMicrotask::~ActiveDOMCallbackMicrotask()
+{
+}
+
+Microtask::Result ActiveDOMCallbackMicrotask::run()
+{
+ if (!canInvokeCallback())
+ return Result::KeepInQueue;
+
+ m_task();
+ return Result::Done;
+}
+
+void ActiveDOMCallbackMicrotask::contextDestroyed()
+{
+ // NOTE: Calling the function below will cause this to be destroyed.
+ removeSelfFromQueue(m_queue);
+}
+
+} // namespace WebCore
</ins></span></pre></div>
<a id="trunkSourceWebCoredomActiveDOMCallbackMicrotaskh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/dom/ActiveDOMCallbackMicrotask.h (0 => 193286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/ActiveDOMCallbackMicrotask.h         (rev 0)
+++ trunk/Source/WebCore/dom/ActiveDOMCallbackMicrotask.h        2015-12-03 19:06:45 UTC (rev 193286)
</span><span class="lines">@@ -0,0 +1,54 @@
</span><ins>+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * 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. AND ITS CONTRIBUTORS ``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 ITS 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.
+ */
+
+#ifndef ActiveDOMCallbackMicrotask_h
+#define ActiveDOMCallbackMicrotask_h
+
+#include "ActiveDOMCallback.h"
+#include "Microtasks.h"
+#include <functional>
+
+namespace WebCore {
+
+class ActiveDOMCallbackMicrotask : public Microtask, public ActiveDOMCallback {
+public:
+ WEBCORE_EXPORT ActiveDOMCallbackMicrotask(MicrotaskQueue&, ScriptExecutionContext&, std::function<void()>&&);
+ virtual ~ActiveDOMCallbackMicrotask();
+
+ virtual Result run() override;
+
+private:
+ virtual void contextDestroyed() override;
+
+ // FIXME: It should not be necessary to have the queue as a member. Instead, it should
+ // be accessed via the ScriptExecutionContext, which should hold a reference to the relevent
+ // queue.
+ MicrotaskQueue& m_queue;
+ std::function<void()> m_task;
+};
+
+} // namespace WebCore
+
+#endif // ActiveDOMCallbackMicrotask_h
</ins></span></pre></div>
<a id="trunkSourceWebCoredomDOMAllInOnecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/DOMAllInOne.cpp (193285 => 193286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/DOMAllInOne.cpp        2015-12-03 19:06:40 UTC (rev 193285)
+++ trunk/Source/WebCore/dom/DOMAllInOne.cpp        2015-12-03 19:06:45 UTC (rev 193286)
</span><span class="lines">@@ -25,6 +25,7 @@
</span><span class="cx">
</span><span class="cx"> // This all-in-one cpp file cuts down on template bloat to allow us to build our Windows release build.
</span><span class="cx">
</span><ins>+#include "ActiveDOMCallbackMicrotask.cpp"
</ins><span class="cx"> #include "ActiveDOMObject.cpp"
</span><span class="cx"> #include "AnimationEvent.cpp"
</span><span class="cx"> #include "Attr.cpp"
</span><span class="lines">@@ -97,7 +98,7 @@
</span><span class="cx"> #include "MessageEvent.cpp"
</span><span class="cx"> #include "MessagePort.cpp"
</span><span class="cx"> #include "MessagePortChannel.cpp"
</span><del>-#include "MicroTask.cpp"
</del><ins>+#include "Microtasks.cpp"
</ins><span class="cx"> #include "MouseEvent.cpp"
</span><span class="cx"> #include "MouseRelatedEvent.cpp"
</span><span class="cx"> #include "MutationEvent.cpp"
</span></span></pre></div>
<a id="trunkSourceWebCoredomMicroTaskcpp"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/dom/MicroTask.cpp (193285 => 193286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/MicroTask.cpp        2015-12-03 19:06:40 UTC (rev 193285)
+++ trunk/Source/WebCore/dom/MicroTask.cpp        2015-12-03 19:06:45 UTC (rev 193286)
</span><span class="lines">@@ -1,51 +0,0 @@
</span><del>-/*
- * Copyright (C) 2014 Yoav Weiss (yoav@yoav.ws)
- * Copyright (C) 2015 Akamai Technologies Inc. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#include "config.h"
-#include "MicroTask.h"
-
-#include "Document.h"
-
-namespace WebCore {
-
-MicroTaskQueue& MicroTaskQueue::singleton()
-{
- ASSERT(isMainThread());
- static NeverDestroyed<MicroTaskQueue> queue;
- return queue;
-}
-
-void MicroTaskQueue::queueMicroTask(std::unique_ptr<MicroTask> task)
-{
- ASSERT(isMainThread());
- m_microTaskQueue.append(WTF::move(task));
-}
-
-void MicroTaskQueue::runMicroTasks()
-{
- ASSERT(isMainThread());
- for (auto& task : m_microTaskQueue)
- task->run();
- m_microTaskQueue.clear();
-}
-
-} // namespace WebCore
-
</del></span></pre></div>
<a id="trunkSourceWebCoredomMicroTaskh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/dom/MicroTask.h (193285 => 193286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/MicroTask.h        2015-12-03 19:06:40 UTC (rev 193285)
+++ trunk/Source/WebCore/dom/MicroTask.h        2015-12-03 19:06:45 UTC (rev 193286)
</span><span class="lines">@@ -1,55 +0,0 @@
</span><del>-/*
- * Copyright (C) 2014 Yoav Weiss (yoav@yoav.ws)
- * Copyright (C) 2015 Akamai Technologies Inc. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef MicroTask_h
-#define MicroTask_h
-
-#include <wtf/NeverDestroyed.h>
-#include <wtf/Vector.h>
-
-
-namespace WebCore {
-
-class MicroTask {
-public:
- virtual void run() = 0;
- virtual ~MicroTask() { }
-};
-
-class MicroTaskQueue {
- friend NeverDestroyed<MicroTaskQueue>;
-
-public:
- WEBCORE_EXPORT static MicroTaskQueue& singleton();
- ~MicroTaskQueue() { }
-
- WEBCORE_EXPORT void queueMicroTask(std::unique_ptr<MicroTask>);
-
- void runMicroTasks();
-
-private:
- MicroTaskQueue() { }
- Vector<std::unique_ptr<MicroTask>> m_microTaskQueue;
-};
-
-} // namespace WebCore
-
-#endif // MicroTask_h
</del></span></pre></div>
<a id="trunkSourceWebCoredomMicrotaskscppfromrev192969trunkSourceWebCoredomMicroTaskcpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/dom/Microtasks.cpp (from rev 192969, trunk/Source/WebCore/dom/MicroTask.cpp) (0 => 193286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Microtasks.cpp         (rev 0)
+++ trunk/Source/WebCore/dom/Microtasks.cpp        2015-12-03 19:06:45 UTC (rev 193286)
</span><span class="lines">@@ -0,0 +1,106 @@
</span><ins>+/*
+ * Copyright (C) 2014 Yoav Weiss (yoav@yoav.ws)
+ * Copyright (C) 2015 Akamai Technologies Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+#include "Microtasks.h"
+
+#include <wtf/MainThread.h>
+#include <wtf/TemporaryChange.h>
+
+namespace WebCore {
+
+void Microtask::removeSelfFromQueue(MicrotaskQueue& queue)
+{
+ queue.remove(*this);
+}
+
+MicrotaskQueue::MicrotaskQueue()
+ : m_timer(*this, &MicrotaskQueue::timerFired)
+{
+}
+
+MicrotaskQueue::~MicrotaskQueue()
+{
+}
+
+MicrotaskQueue& MicrotaskQueue::mainThreadQueue()
+{
+ ASSERT(isMainThread());
+ static NeverDestroyed<MicrotaskQueue> queue;
+ return queue;
+}
+
+void MicrotaskQueue::append(std::unique_ptr<Microtask>&& task)
+{
+ if (m_performingMicrotaskCheckpoint)
+ m_tasksAppendedDuringMicrotaskCheckpoint.append(WTF::move(task));
+ else
+ m_microtaskQueue.append(WTF::move(task));
+
+ m_timer.startOneShot(0);
+}
+
+void MicrotaskQueue::remove(const Microtask& task)
+{
+ for (size_t i = 0; i < m_microtaskQueue.size(); ++i) {
+ if (m_microtaskQueue[i].get() == &task) {
+ m_microtaskQueue.remove(i);
+ return;
+ }
+ }
+ for (size_t i = 0; i < m_tasksAppendedDuringMicrotaskCheckpoint.size(); ++i) {
+ if (m_tasksAppendedDuringMicrotaskCheckpoint[i].get() == &task) {
+ m_tasksAppendedDuringMicrotaskCheckpoint.remove(i);
+ return;
+ }
+ }
+}
+
+void MicrotaskQueue::timerFired()
+{
+ performMicrotaskCheckpoint();
+}
+
+void MicrotaskQueue::performMicrotaskCheckpoint()
+{
+ if (m_performingMicrotaskCheckpoint)
+ return;
+
+ TemporaryChange<bool> change(m_performingMicrotaskCheckpoint, true);
+
+ Vector<std::unique_ptr<Microtask>> queue = WTF::move(m_microtaskQueue);
+ for (auto& task : queue) {
+ auto result = task->run();
+ switch (result) {
+ case Microtask::Result::Done:
+ break;
+ case Microtask::Result::KeepInQueue:
+ m_microtaskQueue.append(WTF::move(task));
+ break;
+ }
+ }
+
+ for (auto& task : m_tasksAppendedDuringMicrotaskCheckpoint)
+ m_microtaskQueue.append(WTF::move(task));
+ m_tasksAppendedDuringMicrotaskCheckpoint.clear();
+}
+
+} // namespace WebCore
</ins></span></pre></div>
<a id="trunkSourceWebCoredomMicrotaskshfromrev192969trunkSourceWebCoredomMicroTaskh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/dom/Microtasks.h (from rev 192969, trunk/Source/WebCore/dom/MicroTask.h) (0 => 193286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Microtasks.h         (rev 0)
+++ trunk/Source/WebCore/dom/Microtasks.h        2015-12-03 19:06:45 UTC (rev 193286)
</span><span class="lines">@@ -0,0 +1,78 @@
</span><ins>+/*
+ * Copyright (C) 2014 Yoav Weiss (yoav@yoav.ws)
+ * Copyright (C) 2015 Akamai Technologies Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef Microtasks_h
+#define Microtasks_h
+
+#include "Timer.h"
+#include <wtf/NeverDestroyed.h>
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+class MicrotaskQueue;
+
+class Microtask {
+public:
+ virtual ~Microtask()
+ {
+ }
+
+ enum class Result {
+ Done,
+ KeepInQueue
+ };
+
+ virtual Result run() = 0;
+
+protected:
+ void removeSelfFromQueue(MicrotaskQueue&);
+};
+
+class MicrotaskQueue {
+ friend NeverDestroyed<MicrotaskQueue>;
+ friend class Microtask;
+public:
+ WEBCORE_EXPORT static MicrotaskQueue& mainThreadQueue();
+
+ WEBCORE_EXPORT MicrotaskQueue();
+ WEBCORE_EXPORT ~MicrotaskQueue();
+
+ WEBCORE_EXPORT void append(std::unique_ptr<Microtask>&&);
+ WEBCORE_EXPORT void performMicrotaskCheckpoint();
+
+private:
+ WEBCORE_EXPORT void remove(const Microtask&);
+
+ void timerFired();
+
+ bool m_performingMicrotaskCheckpoint = false;
+ Vector<std::unique_ptr<Microtask>> m_microtaskQueue;
+ Vector<std::unique_ptr<Microtask>> m_tasksAppendedDuringMicrotaskCheckpoint;
+
+ // FIXME: Instead of a Timer, we should have a centralized Event Loop that calls performMicrotaskCheckpoint()
+ // on every iteration, implementing https://html.spec.whatwg.org/multipage/webappapis.html#processing-model-9
+ Timer m_timer;
+};
+
+} // namespace WebCore
+
+#endif // Microtask_h
</ins></span></pre></div>
<a id="trunkSourceWebCoredomMutationObservercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/MutationObserver.cpp (193285 => 193286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/MutationObserver.cpp        2015-12-03 19:06:40 UTC (rev 193285)
+++ trunk/Source/WebCore/dom/MutationObserver.cpp        2015-12-03 19:06:45 UTC (rev 193286)
</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 "Microtasks.h"
</ins><span class="cx"> #include "MutationCallback.h"
</span><span class="cx"> #include "MutationObserverRegistration.h"
</span><span class="cx"> #include "MutationRecord.h"
</span><span class="lines">@@ -154,17 +155,54 @@
</span><span class="cx"> return suspendedObservers;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+static bool mutationObserverCompoundMicrotaskQueuedFlag;
+
+class MutationObserverMicrotask : public Microtask {
+public:
+ MutationObserverMicrotask()
+ {
+ }
+
+ virtual ~MutationObserverMicrotask()
+ {
+ }
+
+private:
+ virtual Result run()
+ {
+ mutationObserverCompoundMicrotaskQueuedFlag = false;
+
+ MutationObserver::deliverAllMutations();
+
+ return Result::Done;
+ }
+};
+
+static void queueMutationObserverCompoundMicrotask()
+{
+ if (mutationObserverCompoundMicrotaskQueuedFlag)
+ return;
+ mutationObserverCompoundMicrotaskQueuedFlag = true;
+
+ auto microtask = std::make_unique<MutationObserverMicrotask>();
+ MicrotaskQueue::mainThreadQueue().append(WTF::move(microtask));
+}
+
</ins><span class="cx"> void MutationObserver::enqueueMutationRecord(PassRefPtr<MutationRecord> mutation)
</span><span class="cx"> {
</span><span class="cx"> ASSERT(isMainThread());
</span><span class="cx"> m_records.append(mutation);
</span><span class="cx"> activeMutationObservers().add(this);
</span><ins>+
+ queueMutationObserverCompoundMicrotask();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void MutationObserver::setHasTransientRegistration()
</span><span class="cx"> {
</span><span class="cx"> ASSERT(isMainThread());
</span><span class="cx"> activeMutationObservers().add(this);
</span><ins>+
+ queueMutationObserverCompoundMicrotask();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> HashSet<Node*> MutationObserver::getObservedNodes() const
</span></span></pre></div>
<a id="trunkSourceWebCoredomMutationObserverh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/MutationObserver.h (193285 => 193286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/MutationObserver.h        2015-12-03 19:06:40 UTC (rev 193285)
+++ trunk/Source/WebCore/dom/MutationObserver.h        2015-12-03 19:06:45 UTC (rev 193286)
</span><span class="lines">@@ -53,6 +53,7 @@
</span><span class="cx"> typedef unsigned char MutationRecordDeliveryOptions;
</span><span class="cx">
</span><span class="cx"> class MutationObserver : public RefCounted<MutationObserver> {
</span><ins>+ friend class MutationObserverMicrotask;
</ins><span class="cx"> public:
</span><span class="cx"> enum MutationType {
</span><span class="cx"> ChildList = 1 << 0,
</span><span class="lines">@@ -73,7 +74,6 @@
</span><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> static Ref<MutationObserver> create(PassRefPtr<MutationCallback>);
</span><del>- static void deliverAllMutations();
</del><span class="cx">
</span><span class="cx"> ~MutationObserver();
</span><span class="cx">
</span><span class="lines">@@ -94,6 +94,7 @@
</span><span class="cx"> explicit MutationObserver(PassRefPtr<MutationCallback>);
</span><span class="cx"> void deliver();
</span><span class="cx">
</span><ins>+ static void deliverAllMutations();
</ins><span class="cx"> static bool validateOptions(MutationObserverOptions);
</span><span class="cx">
</span><span class="cx"> RefPtr<MutationCallback> m_callback;
</span></span></pre></div>
<a id="trunkSourceWebCoredomScriptRunnercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/ScriptRunner.cpp (193285 => 193286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/ScriptRunner.cpp        2015-12-03 19:06:40 UTC (rev 193285)
+++ trunk/Source/WebCore/dom/ScriptRunner.cpp        2015-12-03 19:06:45 UTC (rev 193286)
</span><span class="lines">@@ -28,7 +28,6 @@
</span><span class="cx">
</span><span class="cx"> #include "CachedScript.h"
</span><span class="cx"> #include "Element.h"
</span><del>-#include "MicroTask.h"
</del><span class="cx"> #include "PendingScript.h"
</span><span class="cx"> #include "ScriptElement.h"
</span><span class="cx">
</span><span class="lines">@@ -120,7 +119,6 @@
</span><span class="cx"> toScriptElementIfPossible(element.get())->execute(cachedScript);
</span><span class="cx"> m_document.decrementLoadEventDelayCount();
</span><span class="cx"> }
</span><del>- MicroTaskQueue::singleton().runMicroTasks();
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlparserHTMLScriptRunnercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/parser/HTMLScriptRunner.cpp (193285 => 193286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/parser/HTMLScriptRunner.cpp        2015-12-03 19:06:40 UTC (rev 193285)
+++ trunk/Source/WebCore/html/parser/HTMLScriptRunner.cpp        2015-12-03 19:06:45 UTC (rev 193286)
</span><span class="lines">@@ -35,7 +35,7 @@
</span><span class="cx"> #include "HTMLNames.h"
</span><span class="cx"> #include "HTMLScriptRunnerHost.h"
</span><span class="cx"> #include "IgnoreDestructiveWriteCountIncrementer.h"
</span><del>-#include "MicroTask.h"
</del><ins>+#include "Microtasks.h"
</ins><span class="cx"> #include "MutationObserver.h"
</span><span class="cx"> #include "NestingLevelIncrementer.h"
</span><span class="cx"> #include "NotImplemented.h"
</span><span class="lines">@@ -129,10 +129,8 @@
</span><span class="cx"> if (pendingScript.cachedScript() && pendingScript.watchingForLoad())
</span><span class="cx"> stopWatchingForLoad(pendingScript);
</span><span class="cx">
</span><del>- if (!isExecutingScript()) {
- MutationObserver::deliverAllMutations();
- MicroTaskQueue::singleton().runMicroTasks();
- }
</del><ins>+ if (!isExecutingScript())
+ MicrotaskQueue::mainThreadQueue().performMicrotaskCheckpoint();
</ins><span class="cx">
</span><span class="cx"> // Clear the pending script before possible rentrancy from executeScript()
</span><span class="cx"> RefPtr<Element> element = pendingScript.releaseElementAndClear();
</span><span class="lines">@@ -233,8 +231,6 @@
</span><span class="cx"> if (!m_document)
</span><span class="cx"> return false;
</span><span class="cx"> }
</span><del>- if (!isExecutingScript())
- MicroTaskQueue::singleton().runMicroTasks();
</del><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -297,10 +293,8 @@
</span><span class="cx"> // every script element, even if it's not ready to execute yet. There's
</span><span class="cx"> // unfortuantely no obvious way to tell if prepareScript is going to
</span><span class="cx"> // execute the script from out here.
</span><del>- if (!isExecutingScript()) {
- MutationObserver::deliverAllMutations();
- MicroTaskQueue::singleton().runMicroTasks();
- }
</del><ins>+ if (!isExecutingScript())
+ MicrotaskQueue::mainThreadQueue().performMicrotaskCheckpoint();
</ins><span class="cx">
</span><span class="cx"> InsertionPointRecord insertionPointRecord(m_host.inputStream());
</span><span class="cx"> NestingLevelIncrementer nestingLevelIncrementer(m_scriptNestingLevel);
</span></span></pre></div>
<a id="trunkSourceWebCoretestingInternalscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.cpp (193285 => 193286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/Internals.cpp        2015-12-03 19:06:40 UTC (rev 193285)
+++ trunk/Source/WebCore/testing/Internals.cpp        2015-12-03 19:06:45 UTC (rev 193286)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx"> #include "Internals.h"
</span><span class="cx">
</span><span class="cx"> #include "AXObjectCache.h"
</span><ins>+#include "ActiveDOMCallbackMicrotask.h"
</ins><span class="cx"> #include "AnimationController.h"
</span><span class="cx"> #include "ApplicationCacheStorage.h"
</span><span class="cx"> #include "BackForwardController.h"
</span><span class="lines">@@ -81,8 +82,6 @@
</span><span class="cx"> #include "MediaPlayer.h"
</span><span class="cx"> #include "MemoryCache.h"
</span><span class="cx"> #include "MemoryInfo.h"
</span><del>-#include "MicroTask.h"
-#include "MicroTaskTest.h"
</del><span class="cx"> #include "MockPageOverlayClient.h"
</span><span class="cx"> #include "Page.h"
</span><span class="cx"> #include "PageCache.h"
</span><span class="lines">@@ -3055,8 +3054,15 @@
</span><span class="cx">
</span><span class="cx"> void Internals::queueMicroTask(int testNumber)
</span><span class="cx"> {
</span><del>- if (contextDocument())
- MicroTaskQueue::singleton().queueMicroTask(std::make_unique<MicroTaskTest>(contextDocument()->createWeakPtr(), testNumber));
</del><ins>+ Document* document = contextDocument();
+ if (!document)
+ return;
+
+ auto microtask = std::make_unique<ActiveDOMCallbackMicrotask>(MicrotaskQueue::mainThreadQueue(), *document, [document, testNumber]() {
+ document->addConsoleMessage(MessageSource::JS, MessageLevel::Debug, makeString("MicroTask #", String::number(testNumber), " has run."));
+ });
+
+ MicrotaskQueue::mainThreadQueue().append(WTF::move(microtask));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #if ENABLE(CONTENT_FILTERING)
</span></span></pre></div>
<a id="trunkSourceWebCoretestingMicroTaskTestcpp"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/testing/MicroTaskTest.cpp (193285 => 193286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/MicroTaskTest.cpp        2015-12-03 19:06:40 UTC (rev 193285)
+++ trunk/Source/WebCore/testing/MicroTaskTest.cpp        2015-12-03 19:06:45 UTC (rev 193286)
</span><span class="lines">@@ -1,34 +0,0 @@
</span><del>-/*
- * Copyright (C) 2015 Akamai Technologies Inc. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#include "config.h"
-#include "MicroTaskTest.h"
-
-#include "Document.h"
-
-namespace WebCore {
-
-void MicroTaskTest::run()
-{
- if (m_document)
- m_document->addConsoleMessage(MessageSource::JS, MessageLevel::Debug, makeString("MicroTask #", String::number(m_testNumber), " has run."));
-}
-
-} // namespace WebCore
</del></span></pre></div>
<a id="trunkSourceWebCoretestingMicroTaskTesth"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/testing/MicroTaskTest.h (193285 => 193286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/MicroTaskTest.h        2015-12-03 19:06:40 UTC (rev 193285)
+++ trunk/Source/WebCore/testing/MicroTaskTest.h        2015-12-03 19:06:45 UTC (rev 193286)
</span><span class="lines">@@ -1,49 +0,0 @@
</span><del>-/*
- * Copyright (C) 2015 Akamai Technologies Inc. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef MicroTaskTest_h
-#define MicroTaskTest_h
-
-#include "MicroTask.h"
-#include <wtf/WeakPtr.h>
-
-namespace WebCore {
-
-class Document;
-
-class MicroTaskTest : public MicroTask {
-public:
- MicroTaskTest(WeakPtr<Document> document, int testNumber)
- : m_document(document)
- , m_testNumber(testNumber)
- {
- }
-
- virtual void run() override;
- WEBCORE_TESTSUPPORT_EXPORT static std::unique_ptr<MicroTaskTest> create(WeakPtr<Document>, int testNumber);
-
-private:
- WeakPtr<Document> m_document;
- int m_testNumber;
-};
-
-} // namespace WebCore
-
-#endif
</del></span></pre>
</div>
</div>
</body>
</html>