Diff
Modified: branches/safari-604-branch/Source/WebCore/ChangeLog (223968 => 223969)
--- branches/safari-604-branch/Source/WebCore/ChangeLog 2017-10-25 18:54:58 UTC (rev 223968)
+++ branches/safari-604-branch/Source/WebCore/ChangeLog 2017-10-25 19:01:41 UTC (rev 223969)
@@ -1,3 +1,36 @@
+2017-10-25 Jason Marcell <[email protected]>
+
+ Cherry-pick r223960. rdar://problem/35178892
+
+ 2017-10-25 Jer Noble <[email protected]>
+
+ Autoplay muted videos still stop playback of other streaming apps in the background
+ https://bugs.webkit.org/show_bug.cgi?id=177920
+
+ Reviewed by Eric Carlson.
+
+ When creating a new <video> or <audio> element, the global AudioSession can sometimes have
+ its sessionCategory() set to "MediaPlayback", even if the element does not yet have a
+ source. This is because the constructor for the MediaElementSession is called before
+ m_isPlayingToWirelessTarget is initialized, and so in the MediaElementSession constructor,
+ the media element's m_isPlayingToWirelessTarget ivar is sometimes (uninitialized) true.
+
+ We could move the MediaElementSession ivar to the very end of the header, so it's
+ initialized last, but that still leaves the possibility of the MediaElementSession et. all
+ calling into the HTMLMediaElement before it's subclass's constructors have a chance to
+ initialize their own ivars (much less their vtables). So instead, we'll create and set the
+ MediaElementSession in a finishInitialization() method called from the HTMLVideoElement and
+ HTMLAudioElement's create() factory methods.
+
+ * html/HTMLAudioElement.cpp:
+ (WebCore::HTMLAudioElement::create):
+ * html/HTMLMediaElement.cpp:
+ (WebCore::HTMLMediaElement::HTMLMediaElement):
+ (WebCore::HTMLMediaElement::finishInitialization):
+ * html/HTMLMediaElement.h:
+ * html/HTMLVideoElement.cpp:
+ (WebCore::HTMLVideoElement::create):
+
2017-10-21 Jason Marcell <[email protected]>
Cherry-pick r223578. rdar://problem/34891313
Modified: branches/safari-604-branch/Source/WebCore/html/HTMLAudioElement.cpp (223968 => 223969)
--- branches/safari-604-branch/Source/WebCore/html/HTMLAudioElement.cpp 2017-10-25 18:54:58 UTC (rev 223968)
+++ branches/safari-604-branch/Source/WebCore/html/HTMLAudioElement.cpp 2017-10-25 19:01:41 UTC (rev 223969)
@@ -44,6 +44,7 @@
Ref<HTMLAudioElement> HTMLAudioElement::create(const QualifiedName& tagName, Document& document, bool createdByParser)
{
auto element = adoptRef(*new HTMLAudioElement(tagName, document, createdByParser));
+ element->finishInitialization();
element->suspendIfNeeded();
return element;
}
Modified: branches/safari-604-branch/Source/WebCore/html/HTMLMediaElement.cpp (223968 => 223969)
--- branches/safari-604-branch/Source/WebCore/html/HTMLMediaElement.cpp 2017-10-25 18:54:58 UTC (rev 223968)
+++ branches/safari-604-branch/Source/WebCore/html/HTMLMediaElement.cpp 2017-10-25 19:01:41 UTC (rev 223969)
@@ -441,13 +441,17 @@
, m_haveVisibleTextTrack(false)
, m_processingPreferenceChange(false)
#endif
- , m_mediaSession(std::make_unique<MediaElementSession>(*this))
{
allMediaElements().add(this);
LOG(Media, "HTMLMediaElement::HTMLMediaElement(%p)", this);
setHasCustomStyleResolveCallbacks();
+}
+void HTMLMediaElement::finishInitialization()
+{
+ m_mediaSession = std::make_unique<MediaElementSession>(*this);
+
m_mediaSession->addBehaviorRestriction(MediaElementSession::RequireUserGestureForFullscreen);
m_mediaSession->addBehaviorRestriction(MediaElementSession::RequirePageConsentToLoadMedia);
#if ENABLE(WIRELESS_PLAYBACK_TARGET)
@@ -456,6 +460,7 @@
m_mediaSession->addBehaviorRestriction(MediaElementSession::RequireUserGestureToControlControlsManager);
m_mediaSession->addBehaviorRestriction(MediaElementSession::RequirePlaybackToControlControlsManager);
+ auto& document = this->document();
auto* page = document.page();
if (document.settings().invisibleAutoplayNotPermitted())
Modified: branches/safari-604-branch/Source/WebCore/html/HTMLMediaElement.h (223968 => 223969)
--- branches/safari-604-branch/Source/WebCore/html/HTMLMediaElement.h 2017-10-25 18:54:58 UTC (rev 223968)
+++ branches/safari-604-branch/Source/WebCore/html/HTMLMediaElement.h 2017-10-25 19:01:41 UTC (rev 223969)
@@ -525,6 +525,7 @@
protected:
HTMLMediaElement(const QualifiedName&, Document&, bool createdByParser);
+ virtual void finishInitialization();
virtual ~HTMLMediaElement();
void parseAttribute(const QualifiedName&, const AtomicString&) override;
Modified: branches/safari-604-branch/Source/WebCore/html/HTMLVideoElement.cpp (223968 => 223969)
--- branches/safari-604-branch/Source/WebCore/html/HTMLVideoElement.cpp 2017-10-25 18:54:58 UTC (rev 223968)
+++ branches/safari-604-branch/Source/WebCore/html/HTMLVideoElement.cpp 2017-10-25 19:01:41 UTC (rev 223969)
@@ -66,6 +66,7 @@
Ref<HTMLVideoElement> HTMLVideoElement::create(const QualifiedName& tagName, Document& document, bool createdByParser)
{
auto videoElement = adoptRef(*new HTMLVideoElement(tagName, document, createdByParser));
+ videoElement->finishInitialization();
videoElement->suspendIfNeeded();
return videoElement;
}