<!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>[278543] trunk/Source</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/278543">278543</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2021-06-06 21:22:38 -0700 (Sun, 06 Jun 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>Stop using legacy EventLoopDeferrableTask
https://bugs.webkit.org/show_bug.cgi?id=226700

Reviewed by Darin Adler.

Source/WebCore:

Stop using legacy EventLoopDeferrableTask and drop the class entirely. Call sites are
now using the HTML event loop directly and using WTF::CancellableTask to wrap the task
they schedule. This achieves the same result as EventLoopDeferrableTask but is more
lightweight and flexible.

* animation/DocumentTimelinesController.cpp:
(WebCore::DocumentTimelinesController::DocumentTimelinesController):
(WebCore::DocumentTimelinesController::detachFromDocument):
(WebCore::DocumentTimelinesController::cacheCurrentTime):
* animation/DocumentTimelinesController.h:
* dom/ActiveDOMObject.h:
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::HTMLMediaElement):
(WebCore::HTMLMediaElement::~HTMLMediaElement):
(WebCore::HTMLMediaElement::scheduleCheckPlaybackTargetCompatability):
(WebCore::HTMLMediaElement::seekWithTolerance):
(WebCore::HTMLMediaElement::setVolume):
(WebCore::HTMLMediaElement::scheduleConfigureTextTracks):
(WebCore::HTMLMediaElement::scheduleMediaEngineWasUpdated):
(WebCore::HTMLMediaElement::scheduleUpdatePlayState):
(WebCore::HTMLMediaElement::cancelPendingTasks):
(WebCore::HTMLMediaElement::closeTaskQueues):
(WebCore::HTMLMediaElement::suspend):
(WebCore::HTMLMediaElement::resume):
(WebCore::HTMLMediaElement::markCaptionAndSubtitleTracksAsUnconfigured):
(WebCore::HTMLMediaElement::mediaPlayerBufferedTimeRangesChanged):
(WebCore::HTMLMediaElement::scheduleUpdateMediaState):
(WebCore::HTMLMediaElement::playbackControlsManagerBehaviorRestrictionsTimerFired):
* html/HTMLMediaElement.h:
* platform/DeferrableTask.h:

Source/WTF:

Introduce new WTF::CancellableTask type which is a wrapper around a WTF::Function.
It can create a handle for the task and this handle can be used to check if the
task is still pending and to cancel it. This is useful when scheduling tasks in the
event loop for example as there are cases where we need to know if a task we
scheduled is still pending (to avoid double scheduling) or where we need to cancel
a previously scheduled task.

* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
* wtf/CancellableTask.h: Added.
(WTF::CancellableTask::CancellableTask):
(WTF::CancellableTask::operator()):
(WTF::CancellableTask::isPending const):
(WTF::CancellableTask::cancel):
(WTF::CancellableTask::Handle::Handle):
(WTF::CancellableTask::Handle::isPending const):
(WTF::CancellableTask::Handle::cancel):
(WTF::CancellableTask::createHandle):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWTFChangeLog">trunk/Source/WTF/ChangeLog</a></li>
<li><a href="#trunkSourceWTFWTFxcodeprojprojectpbxproj">trunk/Source/WTF/WTF.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWTFwtfCMakeListstxt">trunk/Source/WTF/wtf/CMakeLists.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreanimationDocumentTimelinesControllercpp">trunk/Source/WebCore/animation/DocumentTimelinesController.cpp</a></li>
<li><a href="#trunkSourceWebCoreanimationDocumentTimelinesControllerh">trunk/Source/WebCore/animation/DocumentTimelinesController.h</a></li>
<li><a href="#trunkSourceWebCoredomActiveDOMObjecth">trunk/Source/WebCore/dom/ActiveDOMObject.h</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLMediaElementcpp">trunk/Source/WebCore/html/HTMLMediaElement.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLMediaElementh">trunk/Source/WebCore/html/HTMLMediaElement.h</a></li>
<li><a href="#trunkSourceWebCoreplatformDeferrableTaskh">trunk/Source/WebCore/platform/DeferrableTask.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWTFwtfCancellableTaskh">trunk/Source/WTF/wtf/CancellableTask.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWTFChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/ChangeLog (278542 => 278543)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/ChangeLog       2021-06-07 04:11:09 UTC (rev 278542)
+++ trunk/Source/WTF/ChangeLog  2021-06-07 04:22:38 UTC (rev 278543)
</span><span class="lines">@@ -1,3 +1,29 @@
</span><ins>+2021-06-06  Chris Dumez  <cdumez@apple.com>
+
+        Stop using legacy EventLoopDeferrableTask
+        https://bugs.webkit.org/show_bug.cgi?id=226700
+
+        Reviewed by Darin Adler.
+
+        Introduce new WTF::CancellableTask type which is a wrapper around a WTF::Function.
+        It can create a handle for the task and this handle can be used to check if the
+        task is still pending and to cancel it. This is useful when scheduling tasks in the
+        event loop for example as there are cases where we need to know if a task we
+        scheduled is still pending (to avoid double scheduling) or where we need to cancel
+        a previously scheduled task.
+
+        * WTF.xcodeproj/project.pbxproj:
+        * wtf/CMakeLists.txt:
+        * wtf/CancellableTask.h: Added.
+        (WTF::CancellableTask::CancellableTask):
+        (WTF::CancellableTask::operator()):
+        (WTF::CancellableTask::isPending const):
+        (WTF::CancellableTask::cancel):
+        (WTF::CancellableTask::Handle::Handle):
+        (WTF::CancellableTask::Handle::isPending const):
+        (WTF::CancellableTask::Handle::cancel):
+        (WTF::CancellableTask::createHandle):
+
</ins><span class="cx"> 2021-06-04  Chris Dumez  <cdumez@apple.com>
</span><span class="cx"> 
</span><span class="cx">         FileSystem::readFromFile() should return data as `void*`
</span></span></pre></div>
<a id="trunkSourceWTFWTFxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/WTF.xcodeproj/project.pbxproj (278542 => 278543)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/WTF.xcodeproj/project.pbxproj   2021-06-07 04:11:09 UTC (rev 278542)
+++ trunk/Source/WTF/WTF.xcodeproj/project.pbxproj      2021-06-07 04:22:38 UTC (rev 278543)
</span><span class="lines">@@ -378,6 +378,7 @@
</span><span class="cx">          430B47871AAAAC1A001223DA /* StringCommon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringCommon.h; sourceTree = "<group>"; };
</span><span class="cx">          4427C5A921F6D6C300A612A4 /* ASCIICType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ASCIICType.cpp; sourceTree = "<group>"; };
</span><span class="cx">          4468567225094FE8008CCA05 /* ThreadSanitizerSupport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThreadSanitizerSupport.h; sourceTree = "<group>"; };
</span><ins>+               46209A27266D543A007F8F4A /* CancellableTask.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CancellableTask.h; sourceTree = "<group>"; };
</ins><span class="cx">           46BA9EAB1F4CD61E009A2BBC /* CompletionHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CompletionHandler.h; sourceTree = "<group>"; };
</span><span class="cx">          46BEB6E922FFDDD500269867 /* RefCounted.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RefCounted.cpp; sourceTree = "<group>"; };
</span><span class="cx">          50DE35F3215BB01500B979C7 /* ExternalStringImpl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ExternalStringImpl.cpp; sourceTree = "<group>"; };
</span><span class="lines">@@ -653,8 +654,8 @@
</span><span class="cx">          A8A47322151A825B004123FF /* CString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CString.h; sourceTree = "<group>"; };
</span><span class="cx">          A8A47323151A825B004123FF /* StringBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringBuffer.h; sourceTree = "<group>"; };
</span><span class="cx">          A8A47324151A825B004123FF /* StringBuilder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StringBuilder.cpp; sourceTree = "<group>"; };
</span><ins>+               A8A47325151A825B004123EE /* StringBuilderInternals.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringBuilderInternals.h; sourceTree = "<group>"; };
</ins><span class="cx">           A8A47325151A825B004123FF /* StringBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringBuilder.h; sourceTree = "<group>"; };
</span><del>-               A8A47325151A825B004123EE /* StringBuilderInternals.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringBuilderInternals.h; sourceTree = "<group>"; };
</del><span class="cx">           A8A47326151A825B004123FF /* StringConcatenate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringConcatenate.h; sourceTree = "<group>"; };
</span><span class="cx">          A8A47327151A825B004123FF /* StringHash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringHash.h; sourceTree = "<group>"; };
</span><span class="cx">          A8A47328151A825B004123FF /* StringImpl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StringImpl.cpp; sourceTree = "<group>"; };
</span><span class="lines">@@ -983,6 +984,7 @@
</span><span class="cx">                          0FEC3C4F1F323C6800F59B6C /* CagedPtr.h */,
</span><span class="cx">                          0F5F3D681F3FEBA600B115A2 /* CagedUniquePtr.h */,
</span><span class="cx">                          413FE8F51F8D2EAB00F6D7D7 /* CallbackAggregator.h */,
</span><ins>+                               46209A27266D543A007F8F4A /* CancellableTask.h */,
</ins><span class="cx">                           A8A4726A151A825A004123FF /* CheckedArithmetic.h */,
</span><span class="cx">                          A8A4726B151A825A004123FF /* CheckedBoolean.h */,
</span><span class="cx">                          9BB91F512648EA4D00A56217 /* CheckedPtr.h */,
</span></span></pre></div>
<a id="trunkSourceWTFwtfCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/CMakeLists.txt (278542 => 278543)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/CMakeLists.txt      2021-06-07 04:11:09 UTC (rev 278542)
+++ trunk/Source/WTF/wtf/CMakeLists.txt 2021-06-07 04:22:38 UTC (rev 278543)
</span><span class="lines">@@ -26,6 +26,7 @@
</span><span class="cx">     CagedPtr.h
</span><span class="cx">     CagedUniquePtr.h
</span><span class="cx">     CallbackAggregator.h
</span><ins>+    CancellableTask.h
</ins><span class="cx">     CheckedArithmetic.h
</span><span class="cx">     CheckedBoolean.h
</span><span class="cx">     CheckedPtr.h
</span></span></pre></div>
<a id="trunkSourceWTFwtfCancellableTaskh"></a>
<div class="addfile"><h4>Added: trunk/Source/WTF/wtf/CancellableTask.h (0 => 278543)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/CancellableTask.h                           (rev 0)
+++ trunk/Source/WTF/wtf/CancellableTask.h      2021-06-07 04:22:38 UTC (rev 278543)
</span><span class="lines">@@ -0,0 +1,89 @@
</span><ins>+/*
+ * Copyright (C) 2021 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.
+ */
+
+#pragma once
+
+#include <wtf/Function.h>
+#include <wtf/UniqueRef.h>
+#include <wtf/WeakPtr.h>
+
+namespace WTF {
+
+namespace Detail {
+struct CancellableTaskImpl : public CanMakeWeakPtr<CancellableTaskImpl> {
+    WTF_MAKE_STRUCT_FAST_ALLOCATED;
+    explicit CancellableTaskImpl(Function<void()>&& task) : task(WTFMove(task)) { }
+    Function<void()> task;
+};
+}
+
+class CancellableTask {
+public:
+    explicit CancellableTask(Function<void()>&&);
+
+    void operator()();
+    bool isPending() const { return !!m_taskWrapper->task; }
+    void cancel() { m_taskWrapper->task = nullptr; }
+
+    class Handle {
+    public:
+        Handle() = default;
+        bool isPending() const { return m_taskWrapper && m_taskWrapper->task; }
+        void cancel();
+    private:
+        friend class CancellableTask;
+        explicit Handle(Detail::CancellableTaskImpl&);
+        WeakPtr<Detail::CancellableTaskImpl> m_taskWrapper;
+    };
+
+    Handle createHandle() { return Handle { m_taskWrapper.get() }; }
+
+private:
+    UniqueRef<Detail::CancellableTaskImpl> m_taskWrapper;
+};
+
+inline CancellableTask::CancellableTask(Function<void()>&& task)
+    : m_taskWrapper(makeUniqueRef<Detail::CancellableTaskImpl>(WTFMove(task)))
+{ }
+
+inline void CancellableTask::operator()()
+{
+    if (auto task = std::exchange(m_taskWrapper->task, nullptr))
+        task();
+}
+
+inline CancellableTask::Handle::Handle(Detail::CancellableTaskImpl& task)
+    : m_taskWrapper(makeWeakPtr(task))
+{ }
+
+inline void CancellableTask::Handle::cancel()
+{
+    if (m_taskWrapper)
+        m_taskWrapper->task = nullptr;
+}
+
+} // namespace WTF
+
+using WTF::CancellableTask;
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (278542 => 278543)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2021-06-07 04:11:09 UTC (rev 278542)
+++ trunk/Source/WebCore/ChangeLog      2021-06-07 04:22:38 UTC (rev 278543)
</span><span class="lines">@@ -1,3 +1,41 @@
</span><ins>+2021-06-06  Chris Dumez  <cdumez@apple.com>
+
+        Stop using legacy EventLoopDeferrableTask
+        https://bugs.webkit.org/show_bug.cgi?id=226700
+
+        Reviewed by Darin Adler.
+
+        Stop using legacy EventLoopDeferrableTask and drop the class entirely. Call sites are
+        now using the HTML event loop directly and using WTF::CancellableTask to wrap the task
+        they schedule. This achieves the same result as EventLoopDeferrableTask but is more
+        lightweight and flexible.
+
+        * animation/DocumentTimelinesController.cpp:
+        (WebCore::DocumentTimelinesController::DocumentTimelinesController):
+        (WebCore::DocumentTimelinesController::detachFromDocument):
+        (WebCore::DocumentTimelinesController::cacheCurrentTime):
+        * animation/DocumentTimelinesController.h:
+        * dom/ActiveDOMObject.h:
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::HTMLMediaElement):
+        (WebCore::HTMLMediaElement::~HTMLMediaElement):
+        (WebCore::HTMLMediaElement::scheduleCheckPlaybackTargetCompatability):
+        (WebCore::HTMLMediaElement::seekWithTolerance):
+        (WebCore::HTMLMediaElement::setVolume):
+        (WebCore::HTMLMediaElement::scheduleConfigureTextTracks):
+        (WebCore::HTMLMediaElement::scheduleMediaEngineWasUpdated):
+        (WebCore::HTMLMediaElement::scheduleUpdatePlayState):
+        (WebCore::HTMLMediaElement::cancelPendingTasks):
+        (WebCore::HTMLMediaElement::closeTaskQueues):
+        (WebCore::HTMLMediaElement::suspend):
+        (WebCore::HTMLMediaElement::resume):
+        (WebCore::HTMLMediaElement::markCaptionAndSubtitleTracksAsUnconfigured):
+        (WebCore::HTMLMediaElement::mediaPlayerBufferedTimeRangesChanged):
+        (WebCore::HTMLMediaElement::scheduleUpdateMediaState):
+        (WebCore::HTMLMediaElement::playbackControlsManagerBehaviorRestrictionsTimerFired):
+        * html/HTMLMediaElement.h:
+        * platform/DeferrableTask.h:
+
</ins><span class="cx"> 2021-06-06  Wenson Hsieh  <wenson_hsieh@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Turn TextIteratorBehaviorFlag into an enum class and wrap it in OptionSet
</span></span></pre></div>
<a id="trunkSourceWebCoreanimationDocumentTimelinesControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/animation/DocumentTimelinesController.cpp (278542 => 278543)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/animation/DocumentTimelinesController.cpp   2021-06-07 04:11:09 UTC (rev 278542)
+++ trunk/Source/WebCore/animation/DocumentTimelinesController.cpp      2021-06-07 04:22:38 UTC (rev 278543)
</span><span class="lines">@@ -43,8 +43,7 @@
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="cx"> DocumentTimelinesController::DocumentTimelinesController(Document& document)
</span><del>-    : m_currentTimeClearingTask(&document)
-    , m_document(document)
</del><ins>+    : m_document(document)
</ins><span class="cx"> {
</span><span class="cx">     if (auto* page = document.page()) {
</span><span class="cx">         if (page->settings().hiddenPageCSSAnimationSuspensionEnabled() && !page->isVisible())
</span><span class="lines">@@ -54,6 +53,7 @@
</span><span class="cx"> 
</span><span class="cx"> DocumentTimelinesController::~DocumentTimelinesController()
</span><span class="cx"> {
</span><ins>+    m_currentTimeClearingTask.cancel();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void DocumentTimelinesController::addTimeline(DocumentTimeline& timeline)
</span><span class="lines">@@ -73,7 +73,7 @@
</span><span class="cx"> 
</span><span class="cx"> void DocumentTimelinesController::detachFromDocument()
</span><span class="cx"> {
</span><del>-    m_currentTimeClearingTask.close();
</del><ins>+    m_currentTimeClearingTask.cancel();
</ins><span class="cx"> 
</span><span class="cx">     while (!m_timelines.computesEmpty())
</span><span class="cx">         m_timelines.begin()->detachFromDocument();
</span><span class="lines">@@ -233,8 +233,11 @@
</span><span class="cx">     // animations, so we schedule the invalidation task and register a whenIdle callback on the VM, which will
</span><span class="cx">     // fire syncronously if no JS is running.
</span><span class="cx">     m_waitingOnVMIdle = true;
</span><del>-    if (!m_currentTimeClearingTask.isPending())
-        m_currentTimeClearingTask.scheduleTask(std::bind(&DocumentTimelinesController::maybeClearCachedCurrentTime, this));
</del><ins>+    if (!m_currentTimeClearingTask.isPending()) {
+        CancellableTask task(std::bind(&DocumentTimelinesController::maybeClearCachedCurrentTime, this));
+        m_currentTimeClearingTask = task.createHandle();
+        m_document.eventLoop().queueTask(TaskSource::InternalAsyncTask, WTFMove(task));
+    }
</ins><span class="cx">     // We extent the associated Document's lifecycle until the VM became idle since the DocumentTimelinesController
</span><span class="cx">     // is owned by the Document.
</span><span class="cx">     m_document.vm().whenIdle([this, protectedDocument = makeRefPtr(m_document)]() {
</span></span></pre></div>
<a id="trunkSourceWebCoreanimationDocumentTimelinesControllerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/animation/DocumentTimelinesController.h (278542 => 278543)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/animation/DocumentTimelinesController.h     2021-06-07 04:11:09 UTC (rev 278542)
+++ trunk/Source/WebCore/animation/DocumentTimelinesController.h        2021-06-07 04:22:38 UTC (rev 278543)
</span><span class="lines">@@ -25,9 +25,9 @@
</span><span class="cx"> 
</span><span class="cx"> #pragma once
</span><span class="cx"> 
</span><del>-#include "DeferrableTask.h"
</del><span class="cx"> #include "ReducedResolutionSeconds.h"
</span><span class="cx"> #include "Timer.h"
</span><ins>+#include <wtf/CancellableTask.h>
</ins><span class="cx"> #include <wtf/Markable.h>
</span><span class="cx"> #include <wtf/Seconds.h>
</span><span class="cx"> #include <wtf/WeakHashSet.h>
</span><span class="lines">@@ -67,7 +67,7 @@
</span><span class="cx">     void maybeClearCachedCurrentTime();
</span><span class="cx"> 
</span><span class="cx">     WeakHashSet<DocumentTimeline> m_timelines;
</span><del>-    EventLoopDeferrableTask m_currentTimeClearingTask;
</del><ins>+    CancellableTask::Handle m_currentTimeClearingTask;
</ins><span class="cx">     Document& m_document;
</span><span class="cx">     Markable<Seconds, Seconds::MarkableTraits> m_cachedCurrentTime;
</span><span class="cx">     bool m_isSuspended { false };
</span></span></pre></div>
<a id="trunkSourceWebCoredomActiveDOMObjecth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/ActiveDOMObject.h (278542 => 278543)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/ActiveDOMObject.h       2021-06-07 04:11:09 UTC (rev 278542)
+++ trunk/Source/WebCore/dom/ActiveDOMObject.h  2021-06-07 04:22:38 UTC (rev 278543)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> #include "ContextDestructionObserver.h"
</span><span class="cx"> #include "TaskSource.h"
</span><span class="cx"> #include <wtf/Assertions.h>
</span><ins>+#include <wtf/CancellableTask.h>
</ins><span class="cx"> #include <wtf/Forward.h>
</span><span class="cx"> #include <wtf/Function.h>
</span><span class="cx"> #include <wtf/RefCounted.h>
</span><span class="lines">@@ -110,6 +111,17 @@
</span><span class="cx">         });
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    template<typename T>
+    static CancellableTask::Handle queueCancellableTaskKeepingObjectAlive(T& object, TaskSource source, Function<void()>&& task)
+    {
+        CancellableTask cancellableTask(WTFMove(task));
+        auto taskHandle = cancellableTask.createHandle();
+        object.queueTaskInEventLoop(source, [protectedObject = makeRef(object), activity = object.ActiveDOMObject::makePendingActivity(object), cancellableTask = WTFMove(cancellableTask)]() mutable {
+            cancellableTask();
+        });
+        return taskHandle;
+    }
+
</ins><span class="cx">     template<typename EventTargetType, typename EventType>
</span><span class="cx">     static void queueTaskToDispatchEvent(EventTargetType& target, TaskSource source, Ref<EventType>&& event)
</span><span class="cx">     {
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLMediaElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (278542 => 278543)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLMediaElement.cpp   2021-06-07 04:11:09 UTC (rev 278542)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp      2021-06-07 04:22:38 UTC (rev 278543)
</span><span class="lines">@@ -394,20 +394,8 @@
</span><span class="cx">     , m_scanTimer(*this, &HTMLMediaElement::scanTimerFired)
</span><span class="cx">     , m_playbackControlsManagerBehaviorRestrictionsTimer(*this, &HTMLMediaElement::playbackControlsManagerBehaviorRestrictionsTimerFired)
</span><span class="cx">     , m_seekToPlaybackPositionEndedTimer(*this, &HTMLMediaElement::seekToPlaybackPositionEndedTimerFired)
</span><del>-    , m_configureTextTracksTask(&document)
-    , m_checkPlaybackTargetCompatibilityTask(&document)
-    , m_updateMediaStateTask(&document)
-    , m_mediaEngineUpdatedTask(&document)
-    , m_updatePlayStateTask(&document)
-    , m_resumeTask(&document)
-    , m_seekTask(&document)
-    , m_playbackControlsManagerBehaviorRestrictionsTask(&document)
-    , m_bufferedTimeRangesChangedTask(&document)
</del><span class="cx">     , m_resourceSelectionTaskQueue(&document)
</span><span class="cx">     , m_asyncEventQueue(EventLoopEventQueue::create(*this))
</span><del>-#if PLATFORM(IOS_FAMILY)
-    , m_volumeRevertTask(&document)
-#endif
</del><span class="cx">     , m_lastTimeUpdateEventMovieTime(MediaTime::positiveInfiniteTime())
</span><span class="cx">     , m_firstTimePlaying(true)
</span><span class="cx">     , m_playing(false)
</span><span class="lines">@@ -579,9 +567,9 @@
</span><span class="cx">     if (m_isolatedWorld)
</span><span class="cx">         m_isolatedWorld->clearWrappers();
</span><span class="cx"> 
</span><del>-    m_seekTask.close();
-    m_resumeTask.close();
-    m_playbackControlsManagerBehaviorRestrictionsTask.close();
</del><ins>+    m_seekTask.cancel();
+    m_resumeTask.cancel();
+    m_playbackControlsManagerBehaviorRestrictionsTask.cancel();
</ins><span class="cx">     m_resourceSelectionTaskQueue.close();
</span><span class="cx"> 
</span><span class="cx">     m_completelyLoaded = true;
</span><span class="lines">@@ -996,7 +984,7 @@
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     ALWAYS_LOG(LOGIDENTIFIER);
</span><del>-    m_checkPlaybackTargetCompatibilityTask.scheduleTask([this] {
</del><ins>+    m_checkPlaybackTargetCompatibilityTask = queueCancellableTaskKeepingObjectAlive(*this, TaskSource::MediaElement, [this] {
</ins><span class="cx">         checkPlaybackTargetCompatibility();
</span><span class="cx">     });
</span><span class="cx"> }
</span><span class="lines">@@ -2975,7 +2963,7 @@
</span><span class="cx">     // it is running to complete.
</span><span class="cx">     if (m_seekTask.isPending()) {
</span><span class="cx">         INFO_LOG(LOGIDENTIFIER, "cancelling pending seeks");
</span><del>-        m_seekTask.cancelTask();
</del><ins>+        m_seekTask.cancel();
</ins><span class="cx">         if (m_pendingSeek) {
</span><span class="cx">             now = m_pendingSeek->now;
</span><span class="cx">             m_pendingSeek = nullptr;
</span><span class="lines">@@ -2997,7 +2985,7 @@
</span><span class="cx">     m_pendingSeek = makeUnique<PendingSeek>(now, time, negativeTolerance, positiveTolerance);
</span><span class="cx">     if (fromDOM) {
</span><span class="cx">         INFO_LOG(LOGIDENTIFIER, "enqueuing seek from ", now, " to ", time);
</span><del>-        m_seekTask.scheduleTask(std::bind(&HTMLMediaElement::seekTask, this));
</del><ins>+        m_seekTask = queueCancellableTaskKeepingObjectAlive(*this, TaskSource::MediaElement, std::bind(&HTMLMediaElement::seekTask, this));
</ins><span class="cx">     } else
</span><span class="cx">         seekTask();
</span><span class="cx"> 
</span><span class="lines">@@ -3712,7 +3700,7 @@
</span><span class="cx">     if (m_volumeRevertTask.isPending())
</span><span class="cx">         return { };
</span><span class="cx"> 
</span><del>-    m_volumeRevertTask.scheduleTask([this, oldVolume] {
</del><ins>+    m_volumeRevertTask = queueCancellableTaskKeepingObjectAlive(*this, TaskSource::MediaElement, [this, oldVolume] {
</ins><span class="cx">         m_volume = oldVolume;
</span><span class="cx">     });
</span><span class="cx"> 
</span><span class="lines">@@ -4502,7 +4490,7 @@
</span><span class="cx"> 
</span><span class="cx">     auto logSiteIdentifier = LOGIDENTIFIER;
</span><span class="cx">     ALWAYS_LOG(logSiteIdentifier, "task scheduled");
</span><del>-    m_configureTextTracksTask.scheduleTask([this, logSiteIdentifier] {
</del><ins>+    m_configureTextTracksTask = queueCancellableTaskKeepingObjectAlive(*this, TaskSource::MediaElement, [this, logSiteIdentifier] {
</ins><span class="cx">         UNUSED_PARAM(logSiteIdentifier);
</span><span class="cx">         ALWAYS_LOG(logSiteIdentifier, "lambda(), task fired");
</span><span class="cx">         Ref<HTMLMediaElement> protectedThis(*this); // configureTextTracks calls methods that can trigger arbitrary DOM mutations.
</span><span class="lines">@@ -5050,7 +5038,7 @@
</span><span class="cx"> 
</span><span class="cx">     auto logSiteIdentifier = LOGIDENTIFIER;
</span><span class="cx">     ALWAYS_LOG(logSiteIdentifier, "task scheduled");
</span><del>-    m_mediaEngineUpdatedTask.scheduleTask([this, logSiteIdentifier] {
</del><ins>+    m_mediaEngineUpdatedTask = queueCancellableTaskKeepingObjectAlive(*this, TaskSource::MediaElement, [this, logSiteIdentifier] {
</ins><span class="cx">         UNUSED_PARAM(logSiteIdentifier);
</span><span class="cx">         ALWAYS_LOG(logSiteIdentifier, "lambda(), task fired");
</span><span class="cx">         Ref<HTMLMediaElement> protectedThis(*this); // mediaEngineWasUpdated calls methods that can trigger arbitrary DOM mutations.
</span><span class="lines">@@ -5343,7 +5331,7 @@
</span><span class="cx"> 
</span><span class="cx">     auto logSiteIdentifier = LOGIDENTIFIER;
</span><span class="cx">     ALWAYS_LOG(logSiteIdentifier, "task scheduled");
</span><del>-    m_updatePlayStateTask.scheduleTask([this, logSiteIdentifier] {
</del><ins>+    m_updatePlayStateTask = queueCancellableTaskKeepingObjectAlive(*this, TaskSource::MediaElement, [this, logSiteIdentifier] {
</ins><span class="cx">         UNUSED_PARAM(logSiteIdentifier);
</span><span class="cx">         ALWAYS_LOG(logSiteIdentifier, "lambda(), task fired");
</span><span class="cx">         Ref<HTMLMediaElement> protectedThis(*this); // updatePlayState calls methods that can trigger arbitrary DOM mutations.
</span><span class="lines">@@ -5475,13 +5463,16 @@
</span><span class="cx"> 
</span><span class="cx"> void HTMLMediaElement::cancelPendingTasks()
</span><span class="cx"> {
</span><del>-    m_configureTextTracksTask.cancelTask();
-    m_checkPlaybackTargetCompatibilityTask.cancelTask();
-    m_updateMediaStateTask.cancelTask();
-    m_mediaEngineUpdatedTask.cancelTask();
-    m_updatePlayStateTask.cancelTask();
</del><ins>+    m_configureTextTracksTask.cancel();
+    m_checkPlaybackTargetCompatibilityTask.cancel();
+    m_updateMediaStateTask.cancel();
+    m_mediaEngineUpdatedTask.cancel();
+    m_updatePlayStateTask.cancel();
+    m_resumeTask.cancel();
+    m_seekTask.cancel();
+    m_playbackControlsManagerBehaviorRestrictionsTask.cancel();
</ins><span class="cx"> #if PLATFORM(IOS_FAMILY)
</span><del>-    m_volumeRevertTask.cancelTask();
</del><ins>+    m_volumeRevertTask.cancel();
</ins><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -5637,21 +5628,9 @@
</span><span class="cx"> 
</span><span class="cx"> void HTMLMediaElement::closeTaskQueues()
</span><span class="cx"> {
</span><del>-    m_configureTextTracksTask.close();
-    m_checkPlaybackTargetCompatibilityTask.close();
-    m_updateMediaStateTask.close();
-    m_mediaEngineUpdatedTask.close();
-    m_updatePlayStateTask.close();
-    m_resumeTask.close();
-    m_seekTask.close();
-    m_playbackControlsManagerBehaviorRestrictionsTask.close();
-    m_seekTask.close();
-    m_resumeTask.close();
</del><ins>+    cancelPendingTasks();
</ins><span class="cx">     m_resourceSelectionTaskQueue.close();
</span><span class="cx">     m_asyncEventQueue->close();
</span><del>-#if PLATFORM(IOS_FAMILY)
-    m_volumeRevertTask.close();
-#endif
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void HTMLMediaElement::contextDestroyed()
</span><span class="lines">@@ -5685,7 +5664,7 @@
</span><span class="cx">     ALWAYS_LOG(LOGIDENTIFIER);
</span><span class="cx">     Ref<HTMLMediaElement> protectedThis(*this);
</span><span class="cx"> 
</span><del>-    m_resumeTask.cancelTask();
</del><ins>+    m_resumeTask.cancel();
</ins><span class="cx"> 
</span><span class="cx">     switch (reason) {
</span><span class="cx">     case ReasonForSuspension::BackForwardCache:
</span><span class="lines">@@ -5724,7 +5703,7 @@
</span><span class="cx">         //  MEDIA_ERR_ABORTED while the abortEvent is being sent, but cleared immediately afterwards).
</span><span class="cx">         // This behavior is not specified but it seems like a sensible thing to do.
</span><span class="cx">         // As it is not safe to immedately start loading now, let's schedule a load.
</span><del>-        m_resumeTask.scheduleTask(std::bind(&HTMLMediaElement::prepareForLoad, this));
</del><ins>+        m_resumeTask = queueCancellableTaskKeepingObjectAlive(*this, TaskSource::MediaElement, std::bind(&HTMLMediaElement::prepareForLoad, this));
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     updateRenderer();
</span><span class="lines">@@ -6636,7 +6615,7 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     m_processingPreferenceChange = true;
</span><del>-    m_configureTextTracksTask.cancelTask();
</del><ins>+    m_configureTextTracksTask.cancel();
</ins><span class="cx">     if (mode == Immediately) {
</span><span class="cx">         Ref<HTMLMediaElement> protectedThis(*this); // configureTextTracks calls methods that can trigger arbitrary DOM mutations.
</span><span class="cx">         configureTextTracks();
</span><span class="lines">@@ -7157,7 +7136,7 @@
</span><span class="cx"> 
</span><span class="cx">     auto logSiteIdentifier = LOGIDENTIFIER;
</span><span class="cx">     ALWAYS_LOG(logSiteIdentifier, "task scheduled");
</span><del>-    m_bufferedTimeRangesChangedTask.scheduleTask([this, logSiteIdentifier] {
</del><ins>+    m_bufferedTimeRangesChangedTask = queueCancellableTaskKeepingObjectAlive(*this, TaskSource::MediaElement, [this, logSiteIdentifier] {
</ins><span class="cx">         UNUSED_PARAM(logSiteIdentifier);
</span><span class="cx">         ALWAYS_LOG(logSiteIdentifier, "lambda(), task fired");
</span><span class="cx">         if (!m_player || !m_textTracks)
</span><span class="lines">@@ -7788,7 +7767,7 @@
</span><span class="cx"> 
</span><span class="cx">     auto logSiteIdentifier = LOGIDENTIFIER;
</span><span class="cx">     ALWAYS_LOG(logSiteIdentifier, "task scheduled");
</span><del>-    m_updateMediaStateTask.scheduleTask([this, logSiteIdentifier] {
</del><ins>+    m_updateMediaStateTask = queueCancellableTaskKeepingObjectAlive(*this, TaskSource::MediaElement, [this, logSiteIdentifier] {
</ins><span class="cx">         UNUSED_PARAM(logSiteIdentifier);
</span><span class="cx">         ALWAYS_LOG(logSiteIdentifier, "lambda(), task fired");
</span><span class="cx">         Ref<HTMLMediaElement> protectedThis(*this); // updateMediaState calls methods that can trigger arbitrary DOM mutations.
</span><span class="lines">@@ -8062,14 +8041,13 @@
</span><span class="cx">     if (!mediaSession().hasBehaviorRestriction(MediaElementSession::RequireUserGestureToControlControlsManager))
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    RefPtr<HTMLMediaElement> protectedThis(this);
-    m_playbackControlsManagerBehaviorRestrictionsTask.scheduleTask([protectedThis] () {
-        auto& mediaElementSession = protectedThis->mediaSession();
-        if (protectedThis->isPlaying() || mediaElementSession.state() == PlatformMediaSession::Autoplaying || mediaElementSession.state() == PlatformMediaSession::Playing)
</del><ins>+    m_playbackControlsManagerBehaviorRestrictionsTask = queueCancellableTaskKeepingObjectAlive(*this, TaskSource::MediaElement, [this] () {
+        auto& mediaElementSession = mediaSession();
+        if (isPlaying() || mediaElementSession.state() == PlatformMediaSession::Autoplaying || mediaElementSession.state() == PlatformMediaSession::Playing)
</ins><span class="cx">             return;
</span><span class="cx"> 
</span><span class="cx">         mediaElementSession.addBehaviorRestriction(MediaElementSession::RequirePlaybackToControlControlsManager);
</span><del>-        protectedThis->schedulePlaybackControlsManagerUpdate();
</del><ins>+        schedulePlaybackControlsManagerUpdate();
</ins><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLMediaElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (278542 => 278543)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLMediaElement.h     2021-06-07 04:11:09 UTC (rev 278542)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h        2021-06-07 04:22:38 UTC (rev 278543)
</span><span class="lines">@@ -31,7 +31,6 @@
</span><span class="cx"> #include "AudioTrack.h"
</span><span class="cx"> #include "AutoplayEvent.h"
</span><span class="cx"> #include "CaptionUserPreferences.h"
</span><del>-#include "DeferrableTask.h"
</del><span class="cx"> #include "EventLoopEventQueue.h"
</span><span class="cx"> #include "HTMLElement.h"
</span><span class="cx"> #include "HTMLMediaElementEnums.h"
</span><span class="lines">@@ -941,20 +940,20 @@
</span><span class="cx">     Timer m_scanTimer;
</span><span class="cx">     Timer m_playbackControlsManagerBehaviorRestrictionsTimer;
</span><span class="cx">     Timer m_seekToPlaybackPositionEndedTimer;
</span><del>-    EventLoopDeferrableTask m_configureTextTracksTask;
-    EventLoopDeferrableTask m_checkPlaybackTargetCompatibilityTask;
-    EventLoopDeferrableTask m_updateMediaStateTask;
-    EventLoopDeferrableTask m_mediaEngineUpdatedTask;
-    EventLoopDeferrableTask m_updatePlayStateTask;
-    EventLoopDeferrableTask m_resumeTask;
-    EventLoopDeferrableTask m_seekTask;
-    EventLoopDeferrableTask m_playbackControlsManagerBehaviorRestrictionsTask;
-    EventLoopDeferrableTask m_bufferedTimeRangesChangedTask;
</del><ins>+    CancellableTask::Handle m_configureTextTracksTask;
+    CancellableTask::Handle m_checkPlaybackTargetCompatibilityTask;
+    CancellableTask::Handle m_updateMediaStateTask;
+    CancellableTask::Handle m_mediaEngineUpdatedTask;
+    CancellableTask::Handle m_updatePlayStateTask;
+    CancellableTask::Handle m_resumeTask;
+    CancellableTask::Handle m_seekTask;
+    CancellableTask::Handle m_playbackControlsManagerBehaviorRestrictionsTask;
+    CancellableTask::Handle m_bufferedTimeRangesChangedTask;
</ins><span class="cx">     EventLoopTaskQueue m_resourceSelectionTaskQueue;
</span><span class="cx">     RefPtr<TimeRanges> m_playedTimeRanges;
</span><span class="cx">     UniqueRef<EventLoopEventQueue> m_asyncEventQueue;
</span><span class="cx"> #if PLATFORM(IOS_FAMILY)
</span><del>-    EventLoopDeferrableTask m_volumeRevertTask;
</del><ins>+    CancellableTask::Handle m_volumeRevertTask;
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     PlayPromiseVector m_pendingPlayPromises;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformDeferrableTaskh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/DeferrableTask.h (278542 => 278543)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/DeferrableTask.h   2021-06-07 04:11:09 UTC (rev 278542)
+++ trunk/Source/WebCore/platform/DeferrableTask.h      2021-06-07 04:22:38 UTC (rev 278543)
</span><span class="lines">@@ -25,15 +25,14 @@
</span><span class="cx"> 
</span><span class="cx"> #pragma once
</span><span class="cx"> 
</span><del>-#include "ContextDestructionObserver.h"
-#include "EventLoop.h"
</del><span class="cx"> #include "GenericTaskQueue.h"
</span><del>-#include "ScriptExecutionContext.h"
</del><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-class DeferrableTaskBase : public CanMakeWeakPtr<DeferrableTaskBase> {
</del><ins>+class MainThreadDeferrableTask : public CanMakeWeakPtr<MainThreadDeferrableTask> {
</ins><span class="cx"> public:
</span><ins>+    MainThreadDeferrableTask() = default;
+
</ins><span class="cx">     void close()
</span><span class="cx">     {
</span><span class="cx">         cancelTask();
</span><span class="lines">@@ -48,35 +47,19 @@
</span><span class="cx"> 
</span><span class="cx">     bool isPending() const { return m_isPending; }
</span><span class="cx"> 
</span><del>-protected:
-    ~DeferrableTaskBase() = default;
-    bool isClosed() const { return m_isClosed; }
-    void setIsPending(bool isPending) { m_isPending = isPending; }
-
-private:
-    bool m_isPending { false };
-    bool m_isClosed { false };
-};
-
-class MainThreadDeferrableTask : public DeferrableTaskBase {
-public:
-    MainThreadDeferrableTask()
-        : m_dispatcher()
-    { }
-
</del><span class="cx">     void scheduleTask(Function<void()>&& task)
</span><span class="cx">     {
</span><del>-        if (isClosed())
</del><ins>+        if (m_isClosed)
</ins><span class="cx">             return;
</span><span class="cx"> 
</span><span class="cx">         cancelTask();
</span><span class="cx"> 
</span><del>-        setIsPending(true);
</del><ins>+        m_isPending = true;
</ins><span class="cx">         m_dispatcher.postTask([weakThis = makeWeakPtr(*this), task = WTFMove(task)] {
</span><span class="cx">             if (!weakThis)
</span><span class="cx">                 return;
</span><span class="cx">             ASSERT(weakThis->isPending());
</span><del>-            weakThis->setIsPending(false);
</del><ins>+            weakThis->m_isPending = false;
</ins><span class="cx">             task();
</span><span class="cx">         });
</span><span class="cx">     }
</span><span class="lines">@@ -83,32 +66,8 @@
</span><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     MainThreadTaskDispatcher m_dispatcher;
</span><ins>+    bool m_isPending { false };
+    bool m_isClosed { false };
</ins><span class="cx"> };
</span><span class="cx"> 
</span><del>-// Similar to DeferrableTask but based on the HTML event loop.
-class EventLoopDeferrableTask : public DeferrableTaskBase, private ContextDestructionObserver {
-public:
-    EventLoopDeferrableTask(ScriptExecutionContext* context)
-        : ContextDestructionObserver(context)
-    { }
-
-    // FIXME: Pass TaskSource instead of assuming TaskSource::MediaElement.
-    void scheduleTask(Function<void()>&& task)
-    {
-        if (isClosed() || !scriptExecutionContext())
-            return;
-
-        cancelTask();
-
-        setIsPending(true);
-        scriptExecutionContext()->eventLoop().queueTask(TaskSource::MediaElement, [weakThis = makeWeakPtr(*this), task = WTFMove(task)] {
-            if (!weakThis)
-                return;
-            ASSERT(weakThis->isPending());
-            weakThis->setIsPending(false);
-            task();
-        });
-    }
-};
-
-}
</del><ins>+} // namespace WebCore
</ins></span></pre>
</div>
</div>

</body>
</html>