Diff
Modified: trunk/Source/WTF/ChangeLog (244814 => 244815)
--- trunk/Source/WTF/ChangeLog 2019-05-01 00:12:51 UTC (rev 244814)
+++ trunk/Source/WTF/ChangeLog 2019-05-01 00:13:08 UTC (rev 244815)
@@ -1,3 +1,13 @@
+2019-04-30 Youenn Fablet <[email protected]>
+
+ Make Document audio producers use WeakPtr
+ https://bugs.webkit.org/show_bug.cgi?id=197382
+
+ Reviewed by Eric Carlson.
+
+ * wtf/WeakHashSet.h:
+ (WTF::WeakHashSet::hasNullReferences const):
+
2019-04-30 Commit Queue <[email protected]>
Unreviewed, rolling out r244773.
Modified: trunk/Source/WTF/wtf/WeakHashSet.h (244814 => 244815)
--- trunk/Source/WTF/wtf/WeakHashSet.h 2019-05-01 00:12:51 UTC (rev 244814)
+++ trunk/Source/WTF/wtf/WeakHashSet.h 2019-05-01 00:13:08 UTC (rev 244815)
@@ -25,6 +25,7 @@
#pragma once
+#include <wtf/Algorithms.h>
#include <wtf/HashSet.h>
#include <wtf/HashTraits.h>
#include <wtf/WeakPtr.h>
@@ -123,6 +124,11 @@
return true;
}
+ bool hasNullReferences() const
+ {
+ return WTF::anyOf(m_set, [] (auto& value) { return !value->get(); });
+ }
+
unsigned computeSize() const
{
const_cast<WeakReferenceSet&>(m_set).removeIf([] (auto& value) { return !value->get(); });
Modified: trunk/Source/WebCore/ChangeLog (244814 => 244815)
--- trunk/Source/WebCore/ChangeLog 2019-05-01 00:12:51 UTC (rev 244814)
+++ trunk/Source/WebCore/ChangeLog 2019-05-01 00:13:08 UTC (rev 244815)
@@ -1,5 +1,28 @@
2019-04-30 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-04-30 Youenn Fablet <[email protected]>
+
[macOS WK1] ASSERTION FAILED: formData in WebCore::ResourceRequest::doUpdateResourceHTTPBody()
https://bugs.webkit.org/show_bug.cgi?id=196864
<rdar://problem/49854497>
Modified: trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.h (244814 => 244815)
--- trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.h 2019-05-01 00:12:51 UTC (rev 244814)
+++ trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.h 2019-05-01 00:13:08 UTC (rev 244815)
@@ -51,8 +51,7 @@
: public RefCounted<MediaStreamTrack>
, public ActiveDOMObject
, public EventTargetWithInlineData
- , public CanMakeWeakPtr<MediaStreamTrack>
- , private MediaProducer
+ , public MediaProducer
, private MediaStreamTrackPrivate::Observer
#if !RELEASE_LOG_DISABLED
, private LoggerHelper
Modified: trunk/Source/WebCore/dom/Document.cpp (244814 => 244815)
--- trunk/Source/WebCore/dom/Document.cpp 2019-05-01 00:12:51 UTC (rev 244814)
+++ trunk/Source/WebCore/dom/Document.cpp 2019-05-01 00:13:08 UTC (rev 244815)
@@ -3902,13 +3902,13 @@
void Document::addAudioProducer(MediaProducer& audioProducer)
{
- m_audioProducers.add(&audioProducer);
+ m_audioProducers.add(audioProducer);
updateIsPlayingMedia();
}
void Document::removeAudioProducer(MediaProducer& audioProducer)
{
- m_audioProducers.remove(&audioProducer);
+ m_audioProducers.remove(audioProducer);
updateIsPlayingMedia();
}
@@ -3927,8 +3927,8 @@
void Document::updateIsPlayingMedia(uint64_t sourceElementID)
{
MediaProducer::MediaStateFlags state = MediaProducer::IsNotPlaying;
- for (auto* audioProducer : m_audioProducers)
- state |= audioProducer->mediaState();
+ for (auto& audioProducer : m_audioProducers)
+ state |= audioProducer.mediaState();
#if ENABLE(MEDIA_SESSION)
if (HTMLMediaElement* sourceElement = HTMLMediaElement::elementWithID(sourceElementID)) {
@@ -3969,8 +3969,8 @@
void Document::pageMutedStateDidChange()
{
- for (auto* audioProducer : m_audioProducers)
- audioProducer->pageMutedStateDidChange();
+ for (auto& audioProducer : m_audioProducers)
+ audioProducer.pageMutedStateDidChange();
}
static bool isNodeInSubtree(Node& node, Node& container, Document::NodeRemoval nodeRemoval)
Modified: trunk/Source/WebCore/dom/Document.h (244814 => 244815)
--- trunk/Source/WebCore/dom/Document.h 2019-05-01 00:12:51 UTC (rev 244814)
+++ trunk/Source/WebCore/dom/Document.h 2019-05-01 00:13:08 UTC (rev 244815)
@@ -66,6 +66,7 @@
#include <wtf/Logger.h>
#include <wtf/ObjectIdentifier.h>
#include <wtf/UniqueRef.h>
+#include <wtf/WeakHashSet.h>
#include <wtf/WeakPtr.h>
#include <wtf/text/AtomicStringHash.h>
@@ -1891,7 +1892,7 @@
Ref<CSSFontSelector> m_fontSelector;
- HashSet<MediaProducer*> m_audioProducers;
+ WeakHashSet<MediaProducer> m_audioProducers;
HashSet<ShadowRoot*> m_inDocumentShadowRoots;
Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (244814 => 244815)
--- trunk/Source/WebCore/html/HTMLMediaElement.cpp 2019-05-01 00:12:51 UTC (rev 244814)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp 2019-05-01 00:13:08 UTC (rev 244815)
@@ -1768,9 +1768,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: trunk/Source/WebCore/html/HTMLMediaElement.h (244814 => 244815)
--- trunk/Source/WebCore/html/HTMLMediaElement.h 2019-05-01 00:12:51 UTC (rev 244814)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h 2019-05-01 00:13:08 UTC (rev 244815)
@@ -573,6 +573,8 @@
enum class AutoplayEventPlaybackState { None, PreventedAutoplay, StartedWithUserGesture, StartedWithoutUserGesture };
+ using HTMLElement::weakPtrFactory;
+
protected:
HTMLMediaElement(const QualifiedName&, Document&, bool createdByParser);
virtual void finishInitialization();
Modified: trunk/Source/WebCore/page/MediaProducer.h (244814 => 244815)
--- trunk/Source/WebCore/page/MediaProducer.h 2019-05-01 00:12:51 UTC (rev 244814)
+++ trunk/Source/WebCore/page/MediaProducer.h 2019-05-01 00:13:08 UTC (rev 244815)
@@ -25,9 +25,11 @@
#pragma once
+#include <wtf/WeakPtr.h>
+
namespace WebCore {
-class MediaProducer {
+class MediaProducer : public CanMakeWeakPtr<MediaProducer> {
public:
enum MediaState {
IsNotPlaying = 0,