Diff
Modified: branches/safari-607-branch/Source/WebCore/ChangeLog (245356 => 245357)
--- branches/safari-607-branch/Source/WebCore/ChangeLog 2019-05-15 21:45:04 UTC (rev 245356)
+++ branches/safari-607-branch/Source/WebCore/ChangeLog 2019-05-15 21:45:08 UTC (rev 245357)
@@ -1,3 +1,30 @@
+2019-05-15 Kocsen Chung <[email protected]>
+
+ Apply patch. rdar://problem/50352476
+
+ 2019-05-15 Youenn Fablet <[email protected]>
+
+ Make Document audio producers use WeakPtr
+ https://bugs.webkit.org/show_bug.cgi?id=197382
+
+ Reviewed by Eric Carlson.
+
+ Move from a hash set of raw pointers to a hash set of weak pointers.
+ This helps make the code cleaner.
+ No observable change of behavior.
+
+ * Modules/mediastream/MediaStreamTrack.h:
+ * dom/Document.cpp:
+ (WebCore::Document::addAudioProducer):
+ (WebCore::Document::removeAudioProducer):
+ (WebCore::Document::updateIsPlayingMedia):
+ (WebCore::Document::pageMutedStateDidChange):
+ * dom/Document.h:
+ * html/HTMLMediaElement.cpp:
+ (WebCore::HTMLMediaElement::updateActiveTextTrackCues):
+ * html/HTMLMediaElement.h:
+ * page/MediaProducer.h:
+
2019-05-14 Kocsen Chung <[email protected]>
Cherry-pick r245190. rdar://problem/50753948
Modified: branches/safari-607-branch/Source/WebCore/Modules/mediastream/MediaStreamTrack.h (245356 => 245357)
--- branches/safari-607-branch/Source/WebCore/Modules/mediastream/MediaStreamTrack.h 2019-05-15 21:45:04 UTC (rev 245356)
+++ branches/safari-607-branch/Source/WebCore/Modules/mediastream/MediaStreamTrack.h 2019-05-15 21:45:08 UTC (rev 245357)
@@ -50,8 +50,7 @@
public RefCounted<MediaStreamTrack>,
public ActiveDOMObject,
public EventTargetWithInlineData,
- public CanMakeWeakPtr<MediaStreamTrack>,
- private MediaProducer,
+ public MediaProducer,
private MediaStreamTrackPrivate::Observer {
public:
class Observer {
Modified: branches/safari-607-branch/Source/WebCore/dom/Document.cpp (245356 => 245357)
--- branches/safari-607-branch/Source/WebCore/dom/Document.cpp 2019-05-15 21:45:04 UTC (rev 245356)
+++ branches/safari-607-branch/Source/WebCore/dom/Document.cpp 2019-05-15 21:45:08 UTC (rev 245357)
@@ -3980,7 +3980,7 @@
void Document::addAudioProducer(MediaProducer* audioProducer)
{
- m_audioProducers.add(audioProducer);
+ m_audioProducers.add(audioProducer, makeWeakPtr(audioProducer));
updateIsPlayingMedia();
}
@@ -4005,8 +4005,13 @@
void Document::updateIsPlayingMedia(uint64_t sourceElementID)
{
MediaProducer::MediaStateFlags state = MediaProducer::IsNotPlaying;
- for (auto* audioProducer : m_audioProducers)
- state |= audioProducer->mediaState();
+ for (auto& audioProducer : m_audioProducers.values()) {
+ if (audioProducer)
+ state |= audioProducer.get()->mediaState();
+ }
+ m_audioProducers.removeIf([](auto iterator) {
+ return !iterator.value;
+ });
#if ENABLE(MEDIA_SESSION)
if (HTMLMediaElement* sourceElement = HTMLMediaElement::elementWithID(sourceElementID)) {
@@ -4047,8 +4052,13 @@
void Document::pageMutedStateDidChange()
{
- for (auto* audioProducer : m_audioProducers)
- audioProducer->pageMutedStateDidChange();
+ for (auto& audioProducer : m_audioProducers.values()) {
+ if (audioProducer)
+ audioProducer.get()->pageMutedStateDidChange();
+ }
+ m_audioProducers.removeIf([](auto iterator) {
+ return !iterator.value;
+ });
}
static bool isNodeInSubtree(Node& node, Node& container, Document::NodeRemoval nodeRemoval)
Modified: branches/safari-607-branch/Source/WebCore/dom/Document.h (245356 => 245357)
--- branches/safari-607-branch/Source/WebCore/dom/Document.h 2019-05-15 21:45:04 UTC (rev 245356)
+++ branches/safari-607-branch/Source/WebCore/dom/Document.h 2019-05-15 21:45:08 UTC (rev 245357)
@@ -1908,7 +1908,7 @@
Ref<CSSFontSelector> m_fontSelector;
- HashSet<MediaProducer*> m_audioProducers;
+ HashMap<MediaProducer*, WeakPtr<MediaProducer>> m_audioProducers;
HashSet<ShadowRoot*> m_inDocumentShadowRoots;
Modified: branches/safari-607-branch/Source/WebCore/html/HTMLMediaElement.cpp (245356 => 245357)
--- branches/safari-607-branch/Source/WebCore/html/HTMLMediaElement.cpp 2019-05-15 21:45:04 UTC (rev 245356)
+++ branches/safari-607-branch/Source/WebCore/html/HTMLMediaElement.cpp 2019-05-15 21:45:08 UTC (rev 245357)
@@ -1772,9 +1772,9 @@
if (!weakThis)
return;
- auto currentMediaTime = weakThis->currentMediaTime();
+ auto currentMediaTime = this->currentMediaTime();
INFO_LOG(LOGIDENTIFIER, " - lambda, currentMediaTime:", currentMediaTime);
- weakThis->updateActiveTextTrackCues(currentMediaTime);
+ this->updateActiveTextTrackCues(currentMediaTime);
}, nextInterestingTime);
}
Modified: branches/safari-607-branch/Source/WebCore/html/HTMLMediaElement.h (245356 => 245357)
--- branches/safari-607-branch/Source/WebCore/html/HTMLMediaElement.h 2019-05-15 21:45:04 UTC (rev 245356)
+++ branches/safari-607-branch/Source/WebCore/html/HTMLMediaElement.h 2019-05-15 21:45:08 UTC (rev 245357)
@@ -126,11 +126,10 @@
: public HTMLElement
, public ActiveDOMObject
, public MediaControllerInterface
- , public CanMakeWeakPtr<HTMLMediaElement>
, public PlatformMediaSessionClient
, private MediaCanStartListener
, private MediaPlayerClient
- , private MediaProducer
+ , public MediaProducer
, private VisibilityChangeClient
, private ApplicationStateChangeListener
#if ENABLE(VIDEO_TRACK)
Modified: branches/safari-607-branch/Source/WebCore/page/MediaProducer.h (245356 => 245357)
--- branches/safari-607-branch/Source/WebCore/page/MediaProducer.h 2019-05-15 21:45:04 UTC (rev 245356)
+++ branches/safari-607-branch/Source/WebCore/page/MediaProducer.h 2019-05-15 21:45:08 UTC (rev 245357)
@@ -25,9 +25,11 @@
#pragma once
+#include <wtf/WeakPtr.h>
+
namespace WebCore {
-class MediaProducer {
+class MediaProducer : public CanMakeWeakPtr<MediaProducer> {
public:
enum MediaState {
IsNotPlaying = 0,