Overrides of ActiveDOMObject::hasPendingActivity() should not need to query the base...
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 31 Mar 2020 00:25:24 +0000 (00:25 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 31 Mar 2020 00:25:24 +0000 (00:25 +0000)
https://bugs.webkit.org/show_bug.cgi?id=209754

Reviewed by Geoff Garen and Darin Adler.

Overrides of ActiveDOMObject::hasPendingActivity() should not need to query the base
class's hasPendingActivity(). This is error-prone and leads to bad bugs.

To address the issue, ActiveDOMObject::hasPendingActivity() is no longer virtual and
checks both m_pendingActivityCount and a virtual virtualHasPendingActivity() function.
Subclasses now override virtualHasPendingActivity() and no longer need to query the
base class's virtualHasPendingActivity().

* Modules/encryptedmedia/MediaKeySession.cpp:
(WebCore::MediaKeySession::virtualHasPendingActivity const):
(WebCore::MediaKeySession::hasPendingActivity const): Deleted.
* Modules/encryptedmedia/MediaKeySession.h:
* Modules/encryptedmedia/legacy/WebKitMediaKeySession.cpp:
(WebCore::WebKitMediaKeySession::virtualHasPendingActivity const):
(WebCore::WebKitMediaKeySession::hasPendingActivity const): Deleted.
* Modules/encryptedmedia/legacy/WebKitMediaKeySession.h:
* Modules/indexeddb/IDBDatabase.cpp:
(WebCore::IDBDatabase::virtualHasPendingActivity const):
(WebCore::IDBDatabase::hasPendingActivity const): Deleted.
* Modules/indexeddb/IDBDatabase.h:
* Modules/indexeddb/IDBIndex.cpp:
(WebCore::IDBIndex::virtualHasPendingActivity const):
(WebCore::IDBIndex::hasPendingActivity const): Deleted.
* Modules/indexeddb/IDBIndex.h:
* Modules/indexeddb/IDBObjectStore.cpp:
(WebCore::IDBObjectStore::virtualHasPendingActivity const):
(WebCore::IDBObjectStore::hasPendingActivity const): Deleted.
* Modules/indexeddb/IDBObjectStore.h:
* Modules/indexeddb/IDBRequest.cpp:
(WebCore::IDBRequest::virtualHasPendingActivity const):
(WebCore::IDBRequest::hasPendingActivity const): Deleted.
* Modules/indexeddb/IDBRequest.h:
* Modules/indexeddb/IDBTransaction.cpp:
(WebCore::IDBTransaction::virtualHasPendingActivity const):
(WebCore::IDBTransaction::hasPendingActivity const): Deleted.
* Modules/indexeddb/IDBTransaction.h:
* Modules/mediarecorder/MediaRecorder.cpp:
(WebCore::MediaRecorder::virtualHasPendingActivity const):
(WebCore::MediaRecorder::hasPendingActivity const): Deleted.
* Modules/mediarecorder/MediaRecorder.h:
* Modules/mediasource/MediaSource.cpp:
(WebCore::MediaSource::virtualHasPendingActivity const):
(WebCore::MediaSource::hasPendingActivity const): Deleted.
* Modules/mediasource/MediaSource.h:
* Modules/mediasource/SourceBuffer.cpp:
(WebCore::SourceBuffer::virtualHasPendingActivity const):
(WebCore::SourceBuffer::hasPendingActivity const): Deleted.
* Modules/mediasource/SourceBuffer.h:
* Modules/mediastream/MediaDevices.cpp:
(WebCore::MediaDevices::virtualHasPendingActivity const):
(WebCore::MediaDevices::hasPendingActivity const): Deleted.
* Modules/mediastream/MediaDevices.h:
* Modules/mediastream/MediaStream.cpp:
(WebCore::MediaStream::virtualHasPendingActivity const):
(WebCore::MediaStream::hasPendingActivity const): Deleted.
* Modules/mediastream/MediaStream.h:
* Modules/mediastream/MediaStreamTrack.cpp:
(WebCore::MediaStreamTrack::virtualHasPendingActivity const):
(WebCore::MediaStreamTrack::hasPendingActivity const): Deleted.
* Modules/mediastream/MediaStreamTrack.h:
* Modules/mediastream/RTCPeerConnection.cpp:
(WebCore::RTCPeerConnection::virtualHasPendingActivity const):
(WebCore::RTCPeerConnection::hasPendingActivity const): Deleted.
* Modules/mediastream/RTCPeerConnection.h:
* animation/WebAnimation.cpp:
(WebCore::WebAnimation::virtualHasPendingActivity const):
(WebCore::WebAnimation::hasPendingActivity const): Deleted.
* animation/WebAnimation.h:
* css/FontFace.cpp:
(WebCore::FontFace::virtualHasPendingActivity const):
(WebCore::FontFace::hasPendingActivity const): Deleted.
* css/FontFace.h:
* dom/ActiveDOMObject.cpp:
(WebCore::ActiveDOMObject::hasPendingActivity const): Deleted.
* dom/ActiveDOMObject.h:
* dom/MessagePort.cpp:
(WebCore::MessagePort::virtualHasPendingActivity const):
(WebCore::MessagePort::hasPendingActivity const): Deleted.
* dom/MessagePort.h:
* fileapi/FileReader.cpp:
(WebCore::FileReader::virtualHasPendingActivity const):
(WebCore::FileReader::hasPendingActivity const): Deleted.
* fileapi/FileReader.h:
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::virtualHasPendingActivity const):
(WebCore::HTMLMediaElement::hasPendingActivity const): Deleted.
* html/HTMLMediaElement.h:
* html/HTMLTrackElement.cpp:
(WebCore::HTMLTrackElement::virtualHasPendingActivity const):
(WebCore::HTMLTrackElement::hasPendingActivity const): Deleted.
* html/HTMLTrackElement.h:
* html/canvas/WebGLRenderingContextBase.cpp:
(WebCore::WebGLRenderingContextBase::hasPendingActivity const): Deleted.
* html/canvas/WebGLRenderingContextBase.h:
* html/track/TrackListBase.cpp:
(WebCore::TrackListBase::virtualHasPendingActivity const):
(WebCore::TrackListBase::hasPendingActivity const): Deleted.
* html/track/TrackListBase.h:
* page/IntersectionObserver.cpp:
(WebCore::IntersectionObserver::virtualHasPendingActivity const):
(WebCore::IntersectionObserver::hasPendingActivity const): Deleted.
* page/IntersectionObserver.h:
* page/ResizeObserver.cpp:
(WebCore::ResizeObserver::virtualHasPendingActivity const):
(WebCore::ResizeObserver::hasPendingActivity const): Deleted.
* page/ResizeObserver.h:
* page/SuspendableTimer.cpp:
(WebCore::SuspendableTimerBase::virtualHasPendingActivity const):
(WebCore::SuspendableTimerBase::hasPendingActivity const): Deleted.
* page/SuspendableTimer.h:
* workers/Worker.cpp:
(WebCore::Worker::virtualHasPendingActivity const):
(WebCore::Worker::hasPendingActivity const): Deleted.
* workers/Worker.h:
* workers/service/ServiceWorkerRegistration.cpp:
(WebCore::ServiceWorkerRegistration::virtualHasPendingActivity const):
(WebCore::ServiceWorkerRegistration::hasPendingActivity const): Deleted.
* workers/service/ServiceWorkerRegistration.h:
* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::virtualHasPendingActivity const):
(WebCore::XMLHttpRequest::hasPendingActivity const): Deleted.
* xml/XMLHttpRequest.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@259252 268f45cc-cd09-0410-ab3c-d52691b4dbfc

59 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Modules/encryptedmedia/MediaKeySession.cpp
Source/WebCore/Modules/encryptedmedia/MediaKeySession.h
Source/WebCore/Modules/encryptedmedia/legacy/WebKitMediaKeySession.cpp
Source/WebCore/Modules/encryptedmedia/legacy/WebKitMediaKeySession.h
Source/WebCore/Modules/indexeddb/IDBDatabase.cpp
Source/WebCore/Modules/indexeddb/IDBDatabase.h
Source/WebCore/Modules/indexeddb/IDBIndex.cpp
Source/WebCore/Modules/indexeddb/IDBIndex.h
Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp
Source/WebCore/Modules/indexeddb/IDBObjectStore.h
Source/WebCore/Modules/indexeddb/IDBRequest.cpp
Source/WebCore/Modules/indexeddb/IDBRequest.h
Source/WebCore/Modules/indexeddb/IDBTransaction.cpp
Source/WebCore/Modules/indexeddb/IDBTransaction.h
Source/WebCore/Modules/mediarecorder/MediaRecorder.cpp
Source/WebCore/Modules/mediarecorder/MediaRecorder.h
Source/WebCore/Modules/mediasource/MediaSource.cpp
Source/WebCore/Modules/mediasource/MediaSource.h
Source/WebCore/Modules/mediasource/SourceBuffer.cpp
Source/WebCore/Modules/mediasource/SourceBuffer.h
Source/WebCore/Modules/mediastream/MediaDevices.cpp
Source/WebCore/Modules/mediastream/MediaDevices.h
Source/WebCore/Modules/mediastream/MediaStream.cpp
Source/WebCore/Modules/mediastream/MediaStream.h
Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp
Source/WebCore/Modules/mediastream/MediaStreamTrack.h
Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp
Source/WebCore/Modules/mediastream/RTCPeerConnection.h
Source/WebCore/animation/WebAnimation.cpp
Source/WebCore/animation/WebAnimation.h
Source/WebCore/css/FontFace.cpp
Source/WebCore/css/FontFace.h
Source/WebCore/dom/ActiveDOMObject.cpp
Source/WebCore/dom/ActiveDOMObject.h
Source/WebCore/dom/MessagePort.cpp
Source/WebCore/dom/MessagePort.h
Source/WebCore/fileapi/FileReader.cpp
Source/WebCore/fileapi/FileReader.h
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLMediaElement.h
Source/WebCore/html/HTMLTrackElement.cpp
Source/WebCore/html/HTMLTrackElement.h
Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp
Source/WebCore/html/canvas/WebGLRenderingContextBase.h
Source/WebCore/html/track/TrackListBase.cpp
Source/WebCore/html/track/TrackListBase.h
Source/WebCore/page/IntersectionObserver.cpp
Source/WebCore/page/IntersectionObserver.h
Source/WebCore/page/ResizeObserver.cpp
Source/WebCore/page/ResizeObserver.h
Source/WebCore/page/SuspendableTimer.cpp
Source/WebCore/page/SuspendableTimer.h
Source/WebCore/workers/Worker.cpp
Source/WebCore/workers/Worker.h
Source/WebCore/workers/service/ServiceWorkerRegistration.cpp
Source/WebCore/workers/service/ServiceWorkerRegistration.h
Source/WebCore/xml/XMLHttpRequest.cpp
Source/WebCore/xml/XMLHttpRequest.h

index 08ff012..30c1e42 100644 (file)
@@ -1,3 +1,133 @@
+2020-03-30  Chris Dumez  <cdumez@apple.com>
+
+        Overrides of ActiveDOMObject::hasPendingActivity() should not need to query the base class's hasPendingActivity()
+        https://bugs.webkit.org/show_bug.cgi?id=209754
+
+        Reviewed by Geoff Garen and Darin Adler.
+
+        Overrides of ActiveDOMObject::hasPendingActivity() should not need to query the base
+        class's hasPendingActivity(). This is error-prone and leads to bad bugs.
+
+        To address the issue, ActiveDOMObject::hasPendingActivity() is no longer virtual and
+        checks both m_pendingActivityCount and a virtual virtualHasPendingActivity() function.
+        Subclasses now override virtualHasPendingActivity() and no longer need to query the
+        base class's virtualHasPendingActivity().
+
+        * Modules/encryptedmedia/MediaKeySession.cpp:
+        (WebCore::MediaKeySession::virtualHasPendingActivity const):
+        (WebCore::MediaKeySession::hasPendingActivity const): Deleted.
+        * Modules/encryptedmedia/MediaKeySession.h:
+        * Modules/encryptedmedia/legacy/WebKitMediaKeySession.cpp:
+        (WebCore::WebKitMediaKeySession::virtualHasPendingActivity const):
+        (WebCore::WebKitMediaKeySession::hasPendingActivity const): Deleted.
+        * Modules/encryptedmedia/legacy/WebKitMediaKeySession.h:
+        * Modules/indexeddb/IDBDatabase.cpp:
+        (WebCore::IDBDatabase::virtualHasPendingActivity const):
+        (WebCore::IDBDatabase::hasPendingActivity const): Deleted.
+        * Modules/indexeddb/IDBDatabase.h:
+        * Modules/indexeddb/IDBIndex.cpp:
+        (WebCore::IDBIndex::virtualHasPendingActivity const):
+        (WebCore::IDBIndex::hasPendingActivity const): Deleted.
+        * Modules/indexeddb/IDBIndex.h:
+        * Modules/indexeddb/IDBObjectStore.cpp:
+        (WebCore::IDBObjectStore::virtualHasPendingActivity const):
+        (WebCore::IDBObjectStore::hasPendingActivity const): Deleted.
+        * Modules/indexeddb/IDBObjectStore.h:
+        * Modules/indexeddb/IDBRequest.cpp:
+        (WebCore::IDBRequest::virtualHasPendingActivity const):
+        (WebCore::IDBRequest::hasPendingActivity const): Deleted.
+        * Modules/indexeddb/IDBRequest.h:
+        * Modules/indexeddb/IDBTransaction.cpp:
+        (WebCore::IDBTransaction::virtualHasPendingActivity const):
+        (WebCore::IDBTransaction::hasPendingActivity const): Deleted.
+        * Modules/indexeddb/IDBTransaction.h:
+        * Modules/mediarecorder/MediaRecorder.cpp:
+        (WebCore::MediaRecorder::virtualHasPendingActivity const):
+        (WebCore::MediaRecorder::hasPendingActivity const): Deleted.
+        * Modules/mediarecorder/MediaRecorder.h:
+        * Modules/mediasource/MediaSource.cpp:
+        (WebCore::MediaSource::virtualHasPendingActivity const):
+        (WebCore::MediaSource::hasPendingActivity const): Deleted.
+        * Modules/mediasource/MediaSource.h:
+        * Modules/mediasource/SourceBuffer.cpp:
+        (WebCore::SourceBuffer::virtualHasPendingActivity const):
+        (WebCore::SourceBuffer::hasPendingActivity const): Deleted.
+        * Modules/mediasource/SourceBuffer.h:
+        * Modules/mediastream/MediaDevices.cpp:
+        (WebCore::MediaDevices::virtualHasPendingActivity const):
+        (WebCore::MediaDevices::hasPendingActivity const): Deleted.
+        * Modules/mediastream/MediaDevices.h:
+        * Modules/mediastream/MediaStream.cpp:
+        (WebCore::MediaStream::virtualHasPendingActivity const):
+        (WebCore::MediaStream::hasPendingActivity const): Deleted.
+        * Modules/mediastream/MediaStream.h:
+        * Modules/mediastream/MediaStreamTrack.cpp:
+        (WebCore::MediaStreamTrack::virtualHasPendingActivity const):
+        (WebCore::MediaStreamTrack::hasPendingActivity const): Deleted.
+        * Modules/mediastream/MediaStreamTrack.h:
+        * Modules/mediastream/RTCPeerConnection.cpp:
+        (WebCore::RTCPeerConnection::virtualHasPendingActivity const):
+        (WebCore::RTCPeerConnection::hasPendingActivity const): Deleted.
+        * Modules/mediastream/RTCPeerConnection.h:
+        * animation/WebAnimation.cpp:
+        (WebCore::WebAnimation::virtualHasPendingActivity const):
+        (WebCore::WebAnimation::hasPendingActivity const): Deleted.
+        * animation/WebAnimation.h:
+        * css/FontFace.cpp:
+        (WebCore::FontFace::virtualHasPendingActivity const):
+        (WebCore::FontFace::hasPendingActivity const): Deleted.
+        * css/FontFace.h:
+        * dom/ActiveDOMObject.cpp:
+        (WebCore::ActiveDOMObject::hasPendingActivity const): Deleted.
+        * dom/ActiveDOMObject.h:
+        * dom/MessagePort.cpp:
+        (WebCore::MessagePort::virtualHasPendingActivity const):
+        (WebCore::MessagePort::hasPendingActivity const): Deleted.
+        * dom/MessagePort.h:
+        * fileapi/FileReader.cpp:
+        (WebCore::FileReader::virtualHasPendingActivity const):
+        (WebCore::FileReader::hasPendingActivity const): Deleted.
+        * fileapi/FileReader.h:
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::virtualHasPendingActivity const):
+        (WebCore::HTMLMediaElement::hasPendingActivity const): Deleted.
+        * html/HTMLMediaElement.h:
+        * html/HTMLTrackElement.cpp:
+        (WebCore::HTMLTrackElement::virtualHasPendingActivity const):
+        (WebCore::HTMLTrackElement::hasPendingActivity const): Deleted.
+        * html/HTMLTrackElement.h:
+        * html/canvas/WebGLRenderingContextBase.cpp:
+        (WebCore::WebGLRenderingContextBase::hasPendingActivity const): Deleted.
+        * html/canvas/WebGLRenderingContextBase.h:
+        * html/track/TrackListBase.cpp:
+        (WebCore::TrackListBase::virtualHasPendingActivity const):
+        (WebCore::TrackListBase::hasPendingActivity const): Deleted.
+        * html/track/TrackListBase.h:
+        * page/IntersectionObserver.cpp:
+        (WebCore::IntersectionObserver::virtualHasPendingActivity const):
+        (WebCore::IntersectionObserver::hasPendingActivity const): Deleted.
+        * page/IntersectionObserver.h:
+        * page/ResizeObserver.cpp:
+        (WebCore::ResizeObserver::virtualHasPendingActivity const):
+        (WebCore::ResizeObserver::hasPendingActivity const): Deleted.
+        * page/ResizeObserver.h:
+        * page/SuspendableTimer.cpp:
+        (WebCore::SuspendableTimerBase::virtualHasPendingActivity const):
+        (WebCore::SuspendableTimerBase::hasPendingActivity const): Deleted.
+        * page/SuspendableTimer.h:
+        * workers/Worker.cpp:
+        (WebCore::Worker::virtualHasPendingActivity const):
+        (WebCore::Worker::hasPendingActivity const): Deleted.
+        * workers/Worker.h:
+        * workers/service/ServiceWorkerRegistration.cpp:
+        (WebCore::ServiceWorkerRegistration::virtualHasPendingActivity const):
+        (WebCore::ServiceWorkerRegistration::hasPendingActivity const): Deleted.
+        * workers/service/ServiceWorkerRegistration.h:
+        * xml/XMLHttpRequest.cpp:
+        (WebCore::XMLHttpRequest::virtualHasPendingActivity const):
+        (WebCore::XMLHttpRequest::hasPendingActivity const): Deleted.
+        * xml/XMLHttpRequest.h:
+
 2020-03-30  Simon Fraser  <simon.fraser@apple.com>
 
         scrollIntoView() erroneously scrolls non-containing block scrollers
index 5ff436f..58260c2 100644 (file)
@@ -772,10 +772,10 @@ String MediaKeySession::mediaKeysStorageDirectory() const
     return FileSystem::pathByAppendingComponent(storageDirectory, document->securityOrigin().data().databaseIdentifier());
 }
 
-bool MediaKeySession::hasPendingActivity() const
+bool MediaKeySession::virtualHasPendingActivity() const
 {
     // A MediaKeySession object SHALL NOT be destroyed and SHALL continue to receive events if it is not closed and the MediaKeys object that created it remains accessible.
-    return (!m_closed && m_keys) || ActiveDOMObject::hasPendingActivity();
+    return !m_closed && m_keys;
 }
 
 const char* MediaKeySession::activeDOMObjectName() const
index b6ace35..b2f31f3 100644 (file)
@@ -86,9 +86,6 @@ public:
 
     const Vector<std::pair<Ref<SharedBuffer>, MediaKeyStatus>>& statuses() const { return m_statuses; }
 
-    // ActiveDOMObject
-    bool hasPendingActivity() const override;
-
 private:
     MediaKeySession(Document&, WeakPtr<MediaKeys>&&, MediaKeySessionType, bool useDistinctiveIdentifier, Ref<CDM>&&, Ref<CDMInstanceSession>&&);
     void enqueueMessage(MediaKeyMessageType, const SharedBuffer&);
@@ -108,7 +105,8 @@ private:
     void derefEventTarget() override { deref(); }
 
     // ActiveDOMObject
-    const char* activeDOMObjectName() const override;
+    const char* activeDOMObjectName() const final;
+    bool virtualHasPendingActivity() const final;
 
 #if !RELEASE_LOG_DISABLED
     // LoggerHelper
index 3b6f743..fbec208 100644 (file)
@@ -234,9 +234,9 @@ String WebKitMediaKeySession::mediaKeysStorageDirectory() const
     return FileSystem::pathByAppendingComponent(storageDirectory, document->securityOrigin().data().databaseIdentifier());
 }
 
-bool WebKitMediaKeySession::hasPendingActivity() const
+bool WebKitMediaKeySession::virtualHasPendingActivity() const
 {
-    return (m_keys && m_session) || ActiveDOMObject::hasPendingActivity();
+    return m_keys && m_session;
 }
 
 void WebKitMediaKeySession::stop()
index a12f497..ff6169c 100644 (file)
@@ -62,8 +62,6 @@ public:
     using RefCounted::ref;
     using RefCounted::deref;
 
-    bool hasPendingActivity() const final;
-
 private:
     WebKitMediaKeySession(ScriptExecutionContext&, WebKitMediaKeys&, const String& keySystem);
     void keyRequestTimerFired();
@@ -76,8 +74,10 @@ private:
     void refEventTarget() final { ref(); }
     void derefEventTarget() final { deref(); }
 
+    // ActiveDOMObject.
     void stop() final;
     const char* activeDOMObjectName() const final;
+    bool virtualHasPendingActivity() const final;
 
     EventTargetInterface eventTargetInterface() const final { return WebKitMediaKeySessionEventTargetInterfaceType; }
     ScriptExecutionContext* scriptExecutionContext() const final { return ActiveDOMObject::scriptExecutionContext(); }
index eaffe8b..3a7b229 100644 (file)
@@ -75,7 +75,7 @@ IDBDatabase::~IDBDatabase()
     m_connectionProxy->unregisterDatabaseConnection(*this);
 }
 
-bool IDBDatabase::hasPendingActivity() const
+bool IDBDatabase::virtualHasPendingActivity() const
 {
     ASSERT(canCurrentThreadAccessThreadLocalData(originThread()) || Thread::mayBeGCThread());
 
index ec97257..44c9791 100644 (file)
@@ -81,9 +81,6 @@ public:
     using ThreadSafeRefCounted<IDBDatabase>::ref;
     using ThreadSafeRefCounted<IDBDatabase>::deref;
 
-    const char* activeDOMObjectName() const final;
-    void stop() final;
-
     IDBDatabaseInfo& info() { return m_info; }
     uint64_t databaseConnectionIdentifier() const { return m_databaseConnectionIdentifier; }
 
@@ -108,8 +105,6 @@ public:
 
     void dispatchEvent(Event&) final;
 
-    bool hasPendingActivity() const final;
-
     void setIsContextSuspended(bool isContextSuspended) { m_isContextSuspended = isContextSuspended; }
     bool isContextSuspended() const { return m_isContextSuspended; }
 
@@ -118,6 +113,11 @@ private:
 
     void didCommitOrAbortTransaction(IDBTransaction&);
 
+    // ActiveDOMObject.
+    bool virtualHasPendingActivity() const final;
+    const char* activeDOMObjectName() const final;
+    void stop() final;
+
     void maybeCloseInServer();
 
     Ref<IDBClient::IDBConnectionProxy> m_connectionProxy;
index 74b0f50..32bc7a9 100644 (file)
@@ -62,7 +62,7 @@ const char* IDBIndex::activeDOMObjectName() const
     return "IDBIndex";
 }
 
-bool IDBIndex::hasPendingActivity() const
+bool IDBIndex::virtualHasPendingActivity() const
 {
     return m_objectStore.hasPendingActivity();
 }
index fd3ef6f..ee7aac7 100644 (file)
@@ -86,8 +86,6 @@ public:
 
     void* objectStoreAsOpaqueRoot() { return &m_objectStore; }
 
-    bool hasPendingActivity() const final;
-
 private:
     ExceptionOr<Ref<IDBRequest>> doCount(JSC::JSGlobalObject&, const IDBKeyRangeData&);
     ExceptionOr<Ref<IDBRequest>> doGet(JSC::JSGlobalObject&, ExceptionOr<IDBKeyRangeData>);
@@ -97,7 +95,9 @@ private:
     ExceptionOr<Ref<IDBRequest>> doGetAll(JSC::JSGlobalObject&, Optional<uint32_t> count, WTF::Function<ExceptionOr<RefPtr<IDBKeyRange>>()> &&);
     ExceptionOr<Ref<IDBRequest>> doGetAllKeys(JSC::JSGlobalObject&, Optional<uint32_t> count, WTF::Function<ExceptionOr<RefPtr<IDBKeyRange>>()> &&);
 
+    // ActiveDOMObject.
     const char* activeDOMObjectName() const final;
+    bool virtualHasPendingActivity() const final;
 
     IDBIndexInfo m_info;
     IDBIndexInfo m_originalInfo;
index 30371dc..4d1617c 100644 (file)
@@ -75,7 +75,7 @@ const char* IDBObjectStore::activeDOMObjectName() const
     return "IDBObjectStore";
 }
 
-bool IDBObjectStore::hasPendingActivity() const
+bool IDBObjectStore::virtualHasPendingActivity() const
 {
     return m_transaction.hasPendingActivity();
 }
index 9ee1b48..4c148ba 100644 (file)
@@ -112,8 +112,6 @@ public:
     void visitReferencedIndexes(JSC::SlotVisitor&) const;
     void renameReferencedIndex(IDBIndex&, const String& newName);
 
-    bool hasPendingActivity() const final;
-
 private:
     enum class InlineKeyCheck { Perform, DoNotPerform };
     ExceptionOr<Ref<IDBRequest>> putOrAdd(JSC::JSGlobalObject&, JSC::JSValue, RefPtr<IDBKey>, IndexedDB::ObjectStoreOverwriteMode, InlineKeyCheck);
@@ -124,7 +122,9 @@ private:
     ExceptionOr<Ref<IDBRequest>> doGetAll(JSC::JSGlobalObject&, Optional<uint32_t> count, WTF::Function<ExceptionOr<RefPtr<IDBKeyRange>>()> &&);
     ExceptionOr<Ref<IDBRequest>> doGetAllKeys(JSC::JSGlobalObject&, Optional<uint32_t> count, WTF::Function<ExceptionOr<RefPtr<IDBKeyRange>>()> &&);
 
+    // ActiveDOMObject.
     const char* activeDOMObjectName() const final;
+    bool virtualHasPendingActivity() const final;
 
     IDBObjectStoreInfo m_info;
     IDBObjectStoreInfo m_originalInfo;
index 3d02119..5052433 100644 (file)
@@ -259,7 +259,7 @@ const char* IDBRequest::activeDOMObjectName() const
     return "IDBRequest";
 }
 
-bool IDBRequest::hasPendingActivity() const
+bool IDBRequest::virtualHasPendingActivity() const
 {
     ASSERT(canCurrentThreadAccessThreadLocalData(originThread()) || Thread::mayBeGCThread());
     return !m_contextStopped && m_hasPendingActivity;
index 2866134..2ceb5d3 100644 (file)
@@ -125,8 +125,6 @@ public:
 
     IndexedDB::RequestType requestType() const { return m_requestType; }
 
-    bool hasPendingActivity() const final;
-
     void setTransactionOperationID(uint64_t transactionOperationID) { m_currentTransactionOperationID = transactionOperationID; }
 
 protected:
@@ -158,8 +156,11 @@ private:
 
     EventTargetInterface eventTargetInterface() const override;
 
+    // ActiveDOMObject.
+    bool virtualHasPendingActivity() const final;
     const char* activeDOMObjectName() const final;
     void stop() final;
+
     virtual void cancelForStop();
 
     void refEventTarget() final { ref(); }
index 3d90b15..20d68e0 100644 (file)
@@ -315,12 +315,9 @@ const char* IDBTransaction::activeDOMObjectName() const
     return "IDBTransaction";
 }
 
-bool IDBTransaction::hasPendingActivity() const
+bool IDBTransaction::virtualHasPendingActivity() const
 {
     ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()) || Thread::mayBeGCThread());
-    if (ActiveDOMObject::hasPendingActivity())
-        return true;
-
     return !m_contextStopped && m_state != IndexedDB::TransactionState::Finished;
 }
 
index d41773c..55b0d10 100644 (file)
@@ -93,10 +93,6 @@ public:
     using ThreadSafeRefCounted<IDBTransaction>::ref;
     using ThreadSafeRefCounted<IDBTransaction>::deref;
 
-    const char* activeDOMObjectName() const final;
-    bool hasPendingActivity() const final;
-    void stop() final;
-
     const IDBTransactionInfo& info() const { return m_info; }
     IDBDatabase& database() { return m_database.get(); }
     const IDBDatabase& database() const { return m_database.get(); }
@@ -157,9 +153,16 @@ public:
 
     WEBCORE_EXPORT static std::atomic<unsigned> numberOfIDBTransactions;
 
+    // ActiveDOMObject.
+    void stop() final;
+
 private:
     IDBTransaction(IDBDatabase&, const IDBTransactionInfo&, IDBOpenDBRequest*);
 
+    // ActiveDOMObject.
+    const char* activeDOMObjectName() const final;
+    bool virtualHasPendingActivity() const final;
+
     void commit();
 
     void internalAbort();
index c7432b8..b5deb8b 100644 (file)
@@ -232,9 +232,9 @@ void MediaRecorder::audioSamplesAvailable(MediaStreamTrackPrivate& track, const
     m_private->audioSamplesAvailable(track, mediaTime, audioData, description, sampleCount);
 }
 
-bool MediaRecorder::hasPendingActivity() const
+bool MediaRecorder::virtualHasPendingActivity() const
 {
-    return ActiveDOMObject::hasPendingActivity() || m_state != RecordingState::Inactive;
+    return m_state != RecordingState::Inactive;
 }
 
 } // namespace WebCore
index 9f85490..e8bbb85 100644 (file)
@@ -75,8 +75,6 @@ public:
 
     MediaStream& stream() { return m_stream.get(); }
 
-    bool hasPendingActivity() const final;
-
 private:
     MediaRecorder(Document&, Ref<MediaStream>&&, std::unique_ptr<MediaRecorderPrivate>&&, Options&& = { });
 
@@ -94,6 +92,7 @@ private:
     void suspend(ReasonForSuspension) final;
     void stop() final;
     const char* activeDOMObjectName() const final;
+    bool virtualHasPendingActivity() const final;
     
     void stopRecordingInternal();
 
index 4e4193b..401a37f 100644 (file)
@@ -971,10 +971,9 @@ void MediaSource::openIfInEndedState()
     m_private->unmarkEndOfStream();
 }
 
-bool MediaSource::hasPendingActivity() const
+bool MediaSource::virtualHasPendingActivity() const
 {
-    return m_private || m_asyncEventQueue->hasPendingEvents()
-        || ActiveDOMObject::hasPendingActivity();
+    return m_private || m_asyncEventQueue->hasPendingEvents();
 }
 
 void MediaSource::stop()
index 425bf97..83d1c4f 100644 (file)
@@ -111,8 +111,6 @@ public:
     using RefCounted::ref;
     using RefCounted::deref;
 
-    bool hasPendingActivity() const final;
-
     static const MediaTime& currentTimeFudgeFactor();
     static bool contentTypeShouldGenerateTimestamps(const ContentType&);
 
@@ -127,8 +125,10 @@ public:
 private:
     explicit MediaSource(ScriptExecutionContext&);
 
+    // ActiveDOMObject.
     void stop() final;
     const char* activeDOMObjectName() const final;
+    bool virtualHasPendingActivity() const final;
 
     void setPrivateAndOpen(Ref<MediaSourcePrivate>&&) final;
     void seekToTime(const MediaTime&) final;
index e7222a0..8974462 100644 (file)
@@ -535,7 +535,7 @@ MediaTime SourceBuffer::sourceBufferPrivateFastSeekTimeForMediaTime(const MediaT
     return seekTime;
 }
 
-bool SourceBuffer::hasPendingActivity() const
+bool SourceBuffer::virtualHasPendingActivity() const
 {
     return m_source || m_asyncEventQueue->hasPendingEvents();
 }
index 119ffc8..c0de776 100644 (file)
@@ -130,8 +130,6 @@ public:
     MediaTime highestPresentationTimestamp() const;
     void readyStateChanged();
 
-    bool hasPendingActivity() const final;
-
     void trySignalAllSamplesEnqueued();
 
 #if !RELEASE_LOG_DISABLED
@@ -147,8 +145,10 @@ private:
     void refEventTarget() final { ref(); }
     void derefEventTarget() final { deref(); }
 
+    // ActiveDOMObject.
     void stop() final;
     const char* activeDOMObjectName() const final;
+    bool virtualHasPendingActivity() const final;
 
     void sourceBufferPrivateDidReceiveInitializationSegment(const InitializationSegment&) final;
     void sourceBufferPrivateDidReceiveSample(MediaSample&) final;
index 9b1803d..3b64dec 100644 (file)
@@ -248,7 +248,7 @@ void MediaDevices::scheduledEventTimerFired()
     dispatchEvent(Event::create(eventNames().devicechangeEvent, Event::CanBubble::No, Event::IsCancelable::No));
 }
 
-bool MediaDevices::hasPendingActivity() const
+bool MediaDevices::virtualHasPendingActivity() const
 {
     return !isContextStopped() && hasEventListeners(m_eventNames.devicechangeEvent);
 }
index af490ed..8207fc9 100644 (file)
@@ -106,7 +106,7 @@ private:
     // ActiveDOMObject
     const char* activeDOMObjectName() const final;
     void stop() final;
-    bool hasPendingActivity() const final;
+    bool virtualHasPendingActivity() const final;
 
     // EventTargetWithInlineData.
     EventTargetInterface eventTargetInterface() const final { return MediaDevicesEventTargetInterfaceType; }
index cc73464..493a400 100644 (file)
@@ -400,7 +400,7 @@ const char* MediaStream::activeDOMObjectName() const
     return "MediaStream";
 }
 
-bool MediaStream::hasPendingActivity() const
+bool MediaStream::virtualHasPendingActivity() const
 {
     return m_isActive;
 }
index 18e56e8..cb8f146 100644 (file)
@@ -105,9 +105,6 @@ public:
 
     Document* document() const;
 
-    // ActiveDOMObject API.
-    bool hasPendingActivity() const final;
-
     enum class StreamModifier { DomAPI, Platform };
     bool internalAddTrack(Ref<MediaStreamTrack>&&, StreamModifier);
     WEBCORE_EXPORT bool internalRemoveTrack(const String&, StreamModifier);
@@ -146,6 +143,7 @@ private:
     // ActiveDOMObject API.
     void stop() final;
     const char* activeDOMObjectName() const final;
+    bool virtualHasPendingActivity() const final;
 
     void updateActiveState();
     void activityEventTimerFired();
index 9fcb475..d0b2cb9 100644 (file)
@@ -597,9 +597,9 @@ void MediaStreamTrack::suspend(ReasonForSuspension reason)
     queueTaskToDispatchEvent(*this, TaskSource::Networking, Event::create(eventNames().endedEvent, Event::CanBubble::No, Event::IsCancelable::No));
 }
 
-bool MediaStreamTrack::hasPendingActivity() const
+bool MediaStreamTrack::virtualHasPendingActivity() const
 {
-    return !m_ended || ActiveDOMObject::hasPendingActivity();
+    return !m_ended;
 }
 
 AudioSourceProvider* MediaStreamTrack::audioSourceProvider()
index 53907ab..02fd454 100644 (file)
@@ -149,9 +149,6 @@ public:
     using RefCounted::ref;
     using RefCounted::deref;
 
-    // ActiveDOMObject API.
-    bool hasPendingActivity() const final;
-
     void setIdForTesting(String&& id) { m_private->setIdForTesting(WTFMove(id)); }
 
     Document* document() const;
@@ -177,6 +174,7 @@ private:
     void stop() final { stopTrack(); }
     const char* activeDOMObjectName() const override;
     void suspend(ReasonForSuspension) final;
+    bool virtualHasPendingActivity() const final;
 
     // EventTarget
     void refEventTarget() final { ref(); }
index aaabc09..0c2730f 100644 (file)
@@ -530,15 +530,11 @@ void RTCPeerConnection::resume()
     });
 }
 
-bool RTCPeerConnection::hasPendingActivity() const
+bool RTCPeerConnection::virtualHasPendingActivity() const
 {
     if (m_isStopped)
         return false;
 
-    // This returns true if we have pending promises to be resolved.
-    if (ActiveDOMObject::hasPendingActivity())
-        return true;
-
     // As long as the connection is not stopped and it has event listeners, it may dispatch events.
     return hasEventListeners();
 }
index 9ee7de6..ff0b686 100644 (file)
@@ -172,9 +172,6 @@ public:
 
     void clearController() { m_controller = nullptr; }
 
-    // ActiveDOMObject.
-    bool hasPendingActivity() const final;
-    
     Document* document();
 
     void doTask(Function<void()>&&);
@@ -212,6 +209,7 @@ private:
     const char* activeDOMObjectName() const final;
     void suspend(ReasonForSuspension) final;
     void resume() final;
+    bool virtualHasPendingActivity() const final;
 
     void updateConnectionState();
     bool doClose();
index 0d5f891..8fbd0fc 100644 (file)
@@ -1268,10 +1268,10 @@ void WebAnimation::stop()
     removeAllEventListeners();
 }
 
-bool WebAnimation::hasPendingActivity() const
+bool WebAnimation::virtualHasPendingActivity() const
 {
     // Keep the JS wrapper alive if the animation is considered relevant or could become relevant again by virtue of having a timeline.
-    return m_timeline || m_isRelevant || ActiveDOMObject::hasPendingActivity();
+    return m_timeline || m_isRelevant;
 }
 
 void WebAnimation::updateRelevance()
index d70c2f2..d1bd810 100644 (file)
@@ -139,8 +139,6 @@ public:
     uint64_t globalPosition() const { return m_globalPosition; }
     void setGlobalPosition(uint64_t globalPosition) { m_globalPosition = globalPosition; }
 
-    bool hasPendingActivity() const final;
-
     virtual bool canHaveGlobalPosition() { return true; }
 
     // ContextDestructionObserver.
@@ -212,6 +210,7 @@ private:
     void suspend(ReasonForSuspension) final;
     void resume() final;
     void stop() final;
+    bool virtualHasPendingActivity() const final;
 
     // EventTarget
     EventTargetInterface eventTargetInterface() const final { return WebAnimationEventTargetInterfaceType; }
index 65d9acd..a525061 100644 (file)
@@ -486,10 +486,8 @@ const char* FontFace::activeDOMObjectName() const
     return "FontFace";
 }
 
-bool FontFace::hasPendingActivity() const
+bool FontFace::virtualHasPendingActivity() const
 {
-    if (ActiveDOMObject::hasPendingActivity())
-        return true;
     return !isContextStopped() && m_mayLoadedPromiseBeScriptObservable && !m_loadedPromise->isFulfilled();
 }
 
index b65c2d5..44ca6d5 100644 (file)
@@ -92,13 +92,13 @@ public:
     void ref() final { RefCounted::ref(); }
     void deref() final { RefCounted::deref(); }
 
-    bool hasPendingActivity() const final;
-
 private:
     explicit FontFace(CSSFontSelector&);
     explicit FontFace(CSSFontFace&);
 
+    // ActiveDOMObject.
     const char* activeDOMObjectName() const final;
+    bool virtualHasPendingActivity() const final;
 
     // Callback for LoadedPromise.
     FontFace& loadedPromiseResolve();
index fd43fa9..4aae7e4 100644 (file)
@@ -106,11 +106,6 @@ void ActiveDOMObject::assertSuspendIfNeededWasCalled() const
 
 #endif // ASSERT_ENABLED
 
-bool ActiveDOMObject::hasPendingActivity() const
-{
-    return m_pendingActivityCount;
-}
-
 void ActiveDOMObject::suspend(ReasonForSuspension)
 {
 }
@@ -149,13 +144,13 @@ public:
         , m_target(target)
         , m_event(WTFMove(event))
     {
-        ++m_object.m_pendingActivityCount;
+        ++m_object.m_pendingActivityInstanceCount;
     }
 
     ~ActiveDOMObjectEventDispatchTask()
     {
-        ASSERT(m_object.m_pendingActivityCount);
-        --m_object.m_pendingActivityCount;
+        ASSERT(m_object.m_pendingActivityInstanceCount);
+        --m_object.m_pendingActivityInstanceCount;
     }
 
     void execute() final { m_target->dispatchEvent(m_event.get()); }
index 0d0ba15..7ad4da6 100644 (file)
@@ -55,7 +55,7 @@ public:
     void suspendIfNeeded();
     void assertSuspendIfNeededWasCalled() const;
 
-    virtual bool hasPendingActivity() const;
+    bool hasPendingActivity() const { return m_pendingActivityInstanceCount || virtualHasPendingActivity(); }
 
     // However, the suspend function will sometimes be called even if canSuspendForDocumentSuspension() returns false.
     // That happens in step-by-step JS debugging for example - in this case it would be incorrect
@@ -73,17 +73,21 @@ public:
     // It can, however, have a side effect of deleting an ActiveDOMObject.
     virtual void stop();
 
+    // FIXME: Drop this function.
+    // Call sites should be using makePendingActivity() or overriding virtualHasPendingActivity() instead.
     template<typename T> void setPendingActivity(T& thisObject)
     {
         ASSERT(&thisObject == this);
         thisObject.ref();
-        ++m_pendingActivityCount;
+        ++m_pendingActivityInstanceCount;
     }
 
+    // FIXME: Drop this function.
+    // Call sites should be using makePendingActivity() or overriding virtualHasPendingActivity() instead.
     template<typename T> void unsetPendingActivity(T& thisObject)
     {
-        ASSERT(m_pendingActivityCount > 0);
-        --m_pendingActivityCount;
+        ASSERT(m_pendingActivityInstanceCount > 0);
+        --m_pendingActivityInstanceCount;
         thisObject.deref();
     }
 
@@ -93,13 +97,13 @@ public:
         explicit PendingActivity(T& thisObject)
             : m_thisObject(thisObject)
         {
-            ++(m_thisObject->m_pendingActivityCount);
+            ++(m_thisObject->m_pendingActivityInstanceCount);
         }
 
         ~PendingActivity()
         {
-            ASSERT(m_thisObject->m_pendingActivityCount > 0);
-            --(m_thisObject->m_pendingActivityCount);
+            ASSERT(m_thisObject->m_pendingActivityInstanceCount > 0);
+            --(m_thisObject->m_pendingActivityInstanceCount);
         }
 
     private:
@@ -139,10 +143,14 @@ private:
     enum CheckedScriptExecutionContextType { CheckedScriptExecutionContext };
     ActiveDOMObject(ScriptExecutionContext*, CheckedScriptExecutionContextType);
 
+    // This is used by subclasses to indicate that they have pending activity, meaning that they would
+    // like the JS wrapper to stay alive (because they may still fire JS events).
+    virtual bool virtualHasPendingActivity() const { return false; }
+
     void queueTaskInEventLoop(TaskSource, Function<void ()>&&);
     void queueTaskToDispatchEventInternal(EventTarget&, TaskSource, Ref<Event>&&);
 
-    unsigned m_pendingActivityCount { 0 };
+    unsigned m_pendingActivityInstanceCount { 0 };
 #if ASSERT_ENABLED
     bool m_suspendIfNeededWasCalled { false };
     Ref<Thread> m_creationThread { Thread::current() };
index 689ff50..8bd3394 100644 (file)
@@ -308,7 +308,7 @@ void MessagePort::updateActivity(MessagePortChannelProvider::HasActivity hasActi
     m_isAskingRemoteAboutGC = false;
 }
 
-bool MessagePort::hasPendingActivity() const
+bool MessagePort::virtualHasPendingActivity() const
 {
     m_mightBeEligibleForGC = true;
 
index 668d5b4..aaca489 100644 (file)
@@ -82,12 +82,6 @@ public:
     WEBCORE_EXPORT void ref() const;
     WEBCORE_EXPORT void deref() const;
 
-    // ActiveDOMObject
-    const char* activeDOMObjectName() const final;
-    void contextDestroyed() final;
-    void stop() final { close(); }
-    bool hasPendingActivity() const final;
-
     WEBCORE_EXPORT bool isLocallyReachable() const;
 
     // EventTargetWithInlineData.
@@ -104,6 +98,12 @@ private:
     bool addEventListener(const AtomString& eventType, Ref<EventListener>&&, const AddEventListenerOptions&) final;
     bool removeEventListener(const AtomString& eventType, EventListener&, const ListenerOptions&) final;
 
+    // ActiveDOMObject
+    const char* activeDOMObjectName() const final;
+    void contextDestroyed() final;
+    void stop() final { close(); }
+    bool virtualHasPendingActivity() const final;
+
     void disentangle();
 
     void registerLocalActivity();
index 02925c3..374142a 100644 (file)
@@ -81,9 +81,9 @@ void FileReader::stop()
     m_state = DONE;
 }
 
-bool FileReader::hasPendingActivity() const
+bool FileReader::virtualHasPendingActivity() const
 {
-    return m_state == LOADING || ActiveDOMObject::hasPendingActivity();
+    return m_state == LOADING;
 }
 
 ExceptionOr<void> FileReader::readAsArrayBuffer(Blob* blob)
index e7c9222..190cc98 100644 (file)
@@ -76,15 +76,13 @@ public:
     using RefCounted::ref;
     using RefCounted::deref;
 
-    // ActiveDOMObject.
-    bool hasPendingActivity() const final;
-
 private:
     explicit FileReader(ScriptExecutionContext&);
 
     // ActiveDOMObject.
     const char* activeDOMObjectName() const final;
     void stop() final;
+    bool virtualHasPendingActivity() const final;
 
     EventTargetInterface eventTargetInterface() const final { return FileReaderEventTargetInterfaceType; }
     ScriptExecutionContext* scriptExecutionContext() const final { return ActiveDOMObject::scriptExecutionContext(); }
index d5e0cff..7420510 100644 (file)
@@ -5762,7 +5762,7 @@ void HTMLMediaElement::resume()
     updateRenderer();
 }
 
-bool HTMLMediaElement::hasPendingActivity() const
+bool HTMLMediaElement::virtualHasPendingActivity() const
 {
     return (hasAudio() && isPlaying()) || m_asyncEventQueue->hasPendingEvents() || m_playbackTargetIsWirelessQueue.hasPendingTasks() || m_creatingControls;
 }
index 8353807..fcd8edf 100644 (file)
@@ -462,8 +462,6 @@ public:
 
     bool isPlaying() const { return m_playing; }
 
-    bool hasPendingActivity() const override;
-
 #if ENABLE(WEB_AUDIO)
     MediaElementAudioSourceNode* audioSourceNode() { return m_audioSourceNode; }
     void setAudioSourceNode(MediaElementAudioSourceNode*);
@@ -644,6 +642,8 @@ private:
     void suspend(ReasonForSuspension) override;
     void resume() override;
     void stop() override;
+    bool virtualHasPendingActivity() const override;
+
     void stopWithoutDestroyingMediaPlayer();
     void contextDestroyed() override;
     
index 67f766e..afa7c66 100644 (file)
@@ -351,11 +351,8 @@ void HTMLTrackElement::eventListenersDidChange()
         || hasEventListeners(eventNames().loadEvent);
 }
 
-bool HTMLTrackElement::hasPendingActivity() const
+bool HTMLTrackElement::virtualHasPendingActivity() const
 {
-    if (ActiveDOMObject::hasPendingActivity())
-        return true;
-
     return m_hasRelevantLoadEventsListener && readyState() == HTMLTrackElement::LOADING;
 }
 
index 756903f..434f214 100644 (file)
@@ -62,15 +62,13 @@ public:
     RefPtr<HTMLMediaElement> mediaElement() const;
     const AtomString& mediaElementCrossOriginAttribute() const;
 
-    // ActiveDOMObject.
-    bool hasPendingActivity() const final;
-
 private:
     HTMLTrackElement(const QualifiedName&, Document&);
     virtual ~HTMLTrackElement();
 
     // ActiveDOMObject.
     const char* activeDOMObjectName() const final;
+    bool virtualHasPendingActivity() const final;
 
     void parseAttribute(const QualifiedName&, const AtomString&) final;
 
index 54a3384..94292e3 100644 (file)
@@ -5552,11 +5552,6 @@ void WebGLRenderingContextBase::detachAndRemoveAllObjects()
     }
 }
 
-bool WebGLRenderingContextBase::hasPendingActivity() const
-{
-    return false;
-}
-
 void WebGLRenderingContextBase::stop()
 {
     if (!isContextLost() && !m_isPendingPolicyResolution) {
index 20d95f9..d70cb25 100644 (file)
@@ -373,9 +373,6 @@ public:
     void recycleContext() override;
     void dispatchContextChangedNotification() override;
 
-    // ActiveDOMObject
-    bool hasPendingActivity() const final;
-
 protected:
     WebGLRenderingContextBase(CanvasBase&, WebGLContextAttributes);
     WebGLRenderingContextBase(CanvasBase&, Ref<GraphicsContextGLOpenGL>&&, WebGLContextAttributes);
index 5858cf3..98c057e 100644 (file)
@@ -177,9 +177,9 @@ bool TrackListBase::isAnyTrackEnabled() const
     return false;
 }
 
-bool TrackListBase::hasPendingActivity() const
+bool TrackListBase::virtualHasPendingActivity() const
 {
-    return ActiveDOMObject::hasPendingActivity() || m_asyncEventQueue->hasPendingEvents();
+    return m_asyncEventQueue->hasPendingEvents();
 }
 
 } // namespace WebCore
index a5c8878..4a3cc9a 100644 (file)
@@ -65,8 +65,6 @@ public:
 
     bool isAnyTrackEnabled() const;
 
-    bool hasPendingActivity() const override;
-
 protected:
     TrackListBase(WeakPtr<HTMLMediaElement>, ScriptExecutionContext*);
 
@@ -78,6 +76,9 @@ protected:
 private:
     void scheduleTrackEvent(const AtomString& eventName, Ref<TrackBase>&&);
 
+    // ActiveDOMObject.
+    bool virtualHasPendingActivity() const override;
+
     // EventTarget
     void refEventTarget() final { ref(); }
     void derefEventTarget() final { deref(); }
index 0ae910b..0c97565 100644 (file)
@@ -286,7 +286,7 @@ void IntersectionObserver::notify()
     InspectorInstrumentation::didFireObserverCallback(*context);
 }
 
-bool IntersectionObserver::hasPendingActivity() const
+bool IntersectionObserver::virtualHasPendingActivity() const
 {
     return (hasObservationTargets() && trackingDocument()) || !m_queuedEntries.isEmpty();
 }
index 17ac2fe..1c08a4e 100644 (file)
@@ -52,7 +52,7 @@ struct IntersectionObserverData {
     WTF_MAKE_STRUCT_FAST_ALLOCATED;
 
     // IntersectionObservers for which the node that owns this IntersectionObserverData is the root.
-    // An IntersectionObserver is only owned by a JavaScript wrapper. ActiveDOMObject::hasPendingActivity
+    // An IntersectionObserver is only owned by a JavaScript wrapper. ActiveDOMObject::virtualHasPendingActivity
     // is overridden to keep this wrapper alive while the observer has ongoing observations.
     Vector<WeakPtr<IntersectionObserver>> observers;
 
@@ -99,14 +99,14 @@ public:
     void appendQueuedEntry(Ref<IntersectionObserverEntry>&&);
     void notify();
 
+private:
+    IntersectionObserver(Document&, Ref<IntersectionObserverCallback>&&, ContainerNode* root, LengthBox&& parsedRootMargin, Vector<double>&& thresholds);
+
     // ActiveDOMObject.
-    bool hasPendingActivity() const override;
+    bool virtualHasPendingActivity() const override;
     const char* activeDOMObjectName() const override;
     void stop() override;
 
-private:
-    IntersectionObserver(Document&, Ref<IntersectionObserverCallback>&&, ContainerNode* root, LengthBox&& parsedRootMargin, Vector<double>&& thresholds);
-
     bool removeTargetRegistration(Element&);
     void removeAllTargets();
 
index 6507fae..01920b0 100644 (file)
@@ -169,7 +169,7 @@ bool ResizeObserver::removeObservation(const Element& target)
     });
 }
 
-bool ResizeObserver::hasPendingActivity() const
+bool ResizeObserver::virtualHasPendingActivity() const
 {
     return (hasObservations() && m_document) || !m_activeObservations.isEmpty();
 }
index 69cac88..609e70c 100644 (file)
@@ -64,14 +64,14 @@ public:
     bool hasSkippedObservations() const { return m_hasSkippedObservations; }
     void setHasSkippedObservations(bool skipped) { m_hasSkippedObservations = skipped; }
 
+private:
+    ResizeObserver(Document&, Ref<ResizeObserverCallback>&&);
+
     // ActiveDOMObject.
-    bool hasPendingActivity() const override;
+    bool virtualHasPendingActivity() const override;
     const char* activeDOMObjectName() const override;
     void stop() override;
 
-private:
-    ResizeObserver(Document&, Ref<ResizeObserverCallback>&&);
-
     bool removeTarget(Element&);
     void removeAllTargets();
     bool removeObservation(const Element&);
index 844e001..557f79c 100644 (file)
@@ -38,7 +38,7 @@ SuspendableTimerBase::SuspendableTimerBase(ScriptExecutionContext* context)
 
 SuspendableTimerBase::~SuspendableTimerBase() = default;
 
-bool SuspendableTimerBase::hasPendingActivity() const
+bool SuspendableTimerBase::virtualHasPendingActivity() const
 {
     return isActive();
 }
index 3be62e4..c59bb25 100644 (file)
@@ -65,7 +65,7 @@ private:
     void fired() override = 0;
 
     // ActiveDOMObject API.
-    bool hasPendingActivity() const final;
+    bool virtualHasPendingActivity() const final;
     void stop() final;
     void suspend(ReasonForSuspension) final;
     void resume() final;
index c3cbd93..808335d 100644 (file)
@@ -175,9 +175,9 @@ void Worker::resume()
     }
 }
 
-bool Worker::hasPendingActivity() const
+bool Worker::virtualHasPendingActivity() const
 {
-    return m_contextProxy.hasPendingActivity() || ActiveDOMObject::hasPendingActivity();
+    return m_contextProxy.hasPendingActivity();
 }
 
 void Worker::notifyNetworkStateChange(bool isOnLine)
index 66c68b5..ffb69c5 100644 (file)
@@ -63,8 +63,6 @@ public:
     void terminate();
     bool wasTerminated() const { return m_wasTerminated; }
 
-    bool hasPendingActivity() const final;
-
     String identifier() const { return m_identifier; }
 
     ScriptExecutionContext* scriptExecutionContext() const final { return ActiveDOMObject::scriptExecutionContext(); }
@@ -81,10 +79,12 @@ private:
     void didReceiveResponse(unsigned long identifier, const ResourceResponse&) final;
     void notifyFinished() final;
 
+    // ActiveDOMObject.
     void stop() final;
     void suspend(ReasonForSuspension) final;
     void resume() final;
     const char* activeDOMObjectName() const final;
+    bool virtualHasPendingActivity() const final;
 
     static void networkStateChanged(bool isOnLine);
 
index 466e9fc..d5fa327 100644 (file)
@@ -211,12 +211,9 @@ void ServiceWorkerRegistration::stop()
     removeAllEventListeners();
 }
 
-bool ServiceWorkerRegistration::hasPendingActivity() const
+bool ServiceWorkerRegistration::virtualHasPendingActivity() const
 {
-    if (!m_isStopped && getNewestWorker() && hasEventListeners())
-        return true;
-
-    return ActiveDOMObject::hasPendingActivity();
+    return !m_isStopped && getNewestWorker() && hasEventListeners();
 }
 
 } // namespace WebCore
index 514563d..e00cae9 100644 (file)
@@ -76,9 +76,6 @@ public:
     void updateStateFromServer(ServiceWorkerRegistrationState, RefPtr<ServiceWorker>&&);
     void queueTaskToFireUpdateFoundEvent();
 
-    // ActiveDOMObject.
-    bool hasPendingActivity() const final;
-
 private:
     ServiceWorkerRegistration(ScriptExecutionContext&, Ref<ServiceWorkerContainer>&&, ServiceWorkerRegistrationData&&);
 
@@ -90,6 +87,7 @@ private:
     // ActiveDOMObject.
     const char* activeDOMObjectName() const final;
     void stop() final;
+    bool virtualHasPendingActivity() const final;
 
     ServiceWorkerRegistrationData m_registrationData;
     Ref<ServiceWorkerContainer> m_container;
index 2b2f7d9..1528155 100644 (file)
@@ -1177,11 +1177,8 @@ void XMLHttpRequest::eventListenersDidChange()
 
 // An XMLHttpRequest object must not be garbage collected if its state is either opened with the send() flag set, headers received, or loading, and
 // it has one or more event listeners registered whose type is one of readystatechange, progress, abort, error, load, timeout, and loadend.
-bool XMLHttpRequest::hasPendingActivity() const
+bool XMLHttpRequest::virtualHasPendingActivity() const
 {
-    if (ActiveDOMObject::hasPendingActivity())
-        return true;
-
     if (!m_hasRelevantEventListener && !(m_upload && m_upload->hasRelevantEventListener()))
         return false;
 
index 6405fcd..d547c69 100644 (file)
@@ -130,8 +130,6 @@ public:
 
     WEBCORE_EXPORT void setMaximumIntervalForUserGestureForwarding(double);
 
-    bool hasPendingActivity() const final;
-
     using EventTarget::dispatchEvent;
     void dispatchEvent(Event&) override;
 
@@ -149,6 +147,7 @@ private:
     void resume() override;
     void stop() override;
     const char* activeDOMObjectName() const override;
+    bool virtualHasPendingActivity() const final;
 
     void refEventTarget() override { ref(); }
     void derefEventTarget() override { deref(); }