Diff
Modified: branches/safari-604-branch/Source/WebCore/ChangeLog (220169 => 220170)
--- branches/safari-604-branch/Source/WebCore/ChangeLog 2017-08-03 01:33:06 UTC (rev 220169)
+++ branches/safari-604-branch/Source/WebCore/ChangeLog 2017-08-03 01:33:09 UTC (rev 220170)
@@ -1,5 +1,31 @@
2017-08-02 Jason Marcell <[email protected]>
+ Cherry-pick r220085. rdar://problem/33687398
+
+ 2017-07-31 Matt Rajca <[email protected]>
+
+ Support quirk for letting media autoplay if the user interacted with at least one media element.
+ https://bugs.webkit.org/show_bug.cgi?id=175005
+ <rdar://problem/33476038>
+
+ Reviewed by Eric Carlson.
+
+ If the user has interacted with at least one media element, let other media elements auto-play
+ as a quirk.
+
+ * dom/Document.cpp:
+ (WebCore::Document::updateIsPlayingMedia):
+ * dom/Document.h:
+ (WebCore::Document::noteUserInteractionWithMediaElement):
+ * html/HTMLMediaElement.cpp:
+ (WebCore::HTMLMediaElement::removeBehaviorsRestrictionsAfterFirstUserGesture):
+ * html/MediaElementSession.cpp:
+ (WebCore::needsDocumentLevelMediaUserGestureQuirk):
+ (WebCore::MediaElementSession::playbackPermitted const):
+ * page/MediaProducer.h:
+
+2017-08-02 Jason Marcell <[email protected]>
+
Cherry-pick r220084. rdar://problem/33687425
2017-07-31 Nan Wang <[email protected]>
Modified: branches/safari-604-branch/Source/WebCore/dom/Document.cpp (220169 => 220170)
--- branches/safari-604-branch/Source/WebCore/dom/Document.cpp 2017-08-03 01:33:06 UTC (rev 220169)
+++ branches/safari-604-branch/Source/WebCore/dom/Document.cpp 2017-08-03 01:33:09 UTC (rev 220170)
@@ -3625,6 +3625,9 @@
}
#endif
+ if (m_userHasInteractedWithMediaElement)
+ state |= MediaProducer::HasUserInteractedWithMediaElement;
+
if (state == m_mediaState)
return;
Modified: branches/safari-604-branch/Source/WebCore/dom/Document.h (220169 => 220170)
--- branches/safari-604-branch/Source/WebCore/dom/Document.h 2017-08-03 01:33:06 UTC (rev 220169)
+++ branches/safari-604-branch/Source/WebCore/dom/Document.h 2017-08-03 01:33:09 UTC (rev 220170)
@@ -1281,6 +1281,7 @@
WEBCORE_EXPORT void addAudioProducer(MediaProducer*);
WEBCORE_EXPORT void removeAudioProducer(MediaProducer*);
MediaProducer::MediaStateFlags mediaState() const { return m_mediaState; }
+ void noteUserInteractionWithMediaElement() { m_userHasInteractedWithMediaElement = true; }
bool isCapturing() const { return MediaProducer::isCapturing(m_mediaState); }
WEBCORE_EXPORT void updateIsPlayingMedia(uint64_t = HTMLMediaElementInvalidID);
void pageMutedStateDidChange();
@@ -1740,6 +1741,7 @@
InheritedBool m_designMode { inherit };
MediaProducer::MediaStateFlags m_mediaState { MediaProducer::IsNotPlaying };
+ bool m_userHasInteractedWithMediaElement { false };
PageCacheState m_pageCacheState { NotInPageCache };
ReferrerPolicy m_referrerPolicy { ReferrerPolicy::Default };
ReadyState m_readyState { Complete };
Modified: branches/safari-604-branch/Source/WebCore/html/HTMLMediaElement.cpp (220169 => 220170)
--- branches/safari-604-branch/Source/WebCore/html/HTMLMediaElement.cpp 2017-08-03 01:33:06 UTC (rev 220169)
+++ branches/safari-604-branch/Source/WebCore/html/HTMLMediaElement.cpp 2017-08-03 01:33:09 UTC (rev 220170)
@@ -6708,6 +6708,7 @@
| MediaElementSession::RequireUserGestureToControlControlsManager);
m_mediaSession->removeBehaviorRestriction(restrictionsToRemove);
+ document().topDocument().noteUserInteractionWithMediaElement();
}
void HTMLMediaElement::updateRateChangeRestrictions()
Modified: branches/safari-604-branch/Source/WebCore/html/MediaElementSession.cpp (220169 => 220170)
--- branches/safari-604-branch/Source/WebCore/html/MediaElementSession.cpp 2017-08-03 01:33:06 UTC (rev 220169)
+++ branches/safari-604-branch/Source/WebCore/html/MediaElementSession.cpp 2017-08-03 01:33:09 UTC (rev 220170)
@@ -148,6 +148,26 @@
m_restrictions &= ~restriction;
}
+#if PLATFORM(MAC)
+static bool needsDocumentLevelMediaUserGestureQuirk(Document& document)
+{
+ if (!document.settings().needsSiteSpecificQuirks())
+ return false;
+
+ String host = document.topDocument().url().host();
+ if (equalLettersIgnoringASCIICase(host, "slate.com") || host.endsWithIgnoringASCIICase(".slate.com"))
+ return true;
+
+ if (equalLettersIgnoringASCIICase(host, "ign.com") || host.endsWithIgnoringASCIICase(".ign.com"))
+ return true;
+
+ if (equalLettersIgnoringASCIICase(host, "washingtonpost.com") || host.endsWithIgnoringASCIICase(".washingtonpost.com"))
+ return true;
+
+ return false;
+}
+#endif // PLATFORM(MAC)
+
SuccessOr<MediaPlaybackDenialReason> MediaElementSession::playbackPermitted(const HTMLMediaElement& element) const
{
if (element.document().isMediaDocument() && !element.document().ownerElement())
@@ -173,6 +193,11 @@
}
#endif
+#if PLATFORM(MAC)
+ if (element.document().topDocument().mediaState() & MediaProducer::HasUserInteractedWithMediaElement && needsDocumentLevelMediaUserGestureQuirk(element.document()))
+ return { };
+#endif
+
if (m_restrictions & RequireUserGestureForVideoRateChange && element.isVideo() && !element.document().processingUserGestureForMedia()) {
RELEASE_LOG(Media, "MediaElementSession::playbackPermitted - returning FALSE because of video rate change restriction");
return MediaPlaybackDenialReason::UserGestureRequired;
Modified: branches/safari-604-branch/Source/WebCore/page/MediaProducer.h (220169 => 220170)
--- branches/safari-604-branch/Source/WebCore/page/MediaProducer.h 2017-08-03 01:33:06 UTC (rev 220169)
+++ branches/safari-604-branch/Source/WebCore/page/MediaProducer.h 2017-08-03 01:33:09 UTC (rev 220170)
@@ -48,6 +48,7 @@
HasMutedVideoCaptureDevice = 1 << 14,
HasInterruptedAudioCaptureDevice = 1 << 15,
HasInterruptedVideoCaptureDevice = 1 << 16,
+ HasUserInteractedWithMediaElement = 1 << 17,
AudioCaptureMask = HasActiveAudioCaptureDevice | HasMutedAudioCaptureDevice | HasInterruptedAudioCaptureDevice,
VideoCaptureMask = HasActiveVideoCaptureDevice | HasMutedVideoCaptureDevice | HasInterruptedVideoCaptureDevice,