Skip to content
Permalink
Browse files
MediaController should be an ContextDestructionObserver
https://bugs.webkit.org/show_bug.cgi?id=240749
<rdar://93525670>

Reviewed by Youenn Fablet.

* html/MediaController.cpp:
(WebCore::MediaController::MediaController):
* html/MediaController.h:

Canonical link: https://commits.webkit.org/250882@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@294664 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
jernoble committed May 23, 2022
1 parent 235f9b4 commit 0062ea642e7f7a7a666af3f2112351f4dda9d2aa
Showing 2 changed files with 9 additions and 5 deletions.
@@ -47,7 +47,8 @@ Ref<MediaController> MediaController::create(ScriptExecutionContext& context)
}

MediaController::MediaController(ScriptExecutionContext& context)
: m_paused(false)
: ContextDestructionObserver(&context)
, m_paused(false)
, m_defaultPlaybackRate(1)
, m_volume(1)
, m_position(MediaPlayer::invalidTime())
@@ -58,7 +59,6 @@ MediaController::MediaController(ScriptExecutionContext& context)
, m_clearPositionTimer(*this, &MediaController::clearPositionTimerFired)
, m_closedCaptionsVisible(false)
, m_clock(PAL::Clock::create())
, m_scriptExecutionContext(context)
, m_timeupdateTimer(*this, &MediaController::scheduleTimeupdateEvent)
{
}
@@ -27,6 +27,7 @@

#if ENABLE(VIDEO)

#include "ContextDestructionObserver.h"
#include "Event.h"
#include "EventTarget.h"
#include "MediaControllerInterface.h"
@@ -41,7 +42,11 @@ namespace WebCore {

class HTMLMediaElement;

class MediaController final : public RefCounted<MediaController>, public MediaControllerInterface, public EventTargetWithInlineData {
class MediaController final
: public RefCounted<MediaController>
, public MediaControllerInterface
, public ContextDestructionObserver
, public EventTargetWithInlineData {
WTF_MAKE_ISO_ALLOCATED(MediaController);
public:
static Ref<MediaController> create(ScriptExecutionContext&);
@@ -95,7 +100,7 @@ class MediaController final : public RefCounted<MediaController>, public MediaCo
void refEventTarget() final { ref(); }
void derefEventTarget() final { deref(); }
EventTargetInterface eventTargetInterface() const final { return MediaControllerEventTargetInterfaceType; }
ScriptExecutionContext* scriptExecutionContext() const final { return &m_scriptExecutionContext; };
ScriptExecutionContext* scriptExecutionContext() const final { return ContextDestructionObserver::scriptExecutionContext(); };

void addMediaElement(HTMLMediaElement&);
void removeMediaElement(HTMLMediaElement&);
@@ -147,7 +152,6 @@ class MediaController final : public RefCounted<MediaController>, public MediaCo
String m_mediaGroup;
bool m_closedCaptionsVisible;
std::unique_ptr<PAL::Clock> m_clock;
ScriptExecutionContext& m_scriptExecutionContext;
Timer m_timeupdateTimer;
MonotonicTime m_previousTimeupdateTime;
bool m_resetCurrentTimeInNextPlay { false };

0 comments on commit 0062ea6

Please sign in to comment.