Title: [187262] trunk/Source/WebCore
- Revision
- 187262
- Author
- [email protected]
- Date
- 2015-07-23 15:23:28 -0700 (Thu, 23 Jul 2015)
Log Message
Relax media playback restrictions if the allowsMediaDocumentInlinePlayback property is set.
https://bugs.webkit.org/show_bug.cgi?id=147234
Reviewed by Darin Adler.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::prepareForLoad): Moved restriction check into MediaElementSession.
* html/MediaElementSession.cpp:
(WebCore::MediaElementSession::playbackPermitted): Check if is a top-level media document and if
allowsMediaDocumentInilnePlayback is set, and return early.
(WebCore::MediaElementSession::effectivePreloadForElement): Ditto.
(WebCore::MediaElementSession::allowsAutomaticMediaDataLoading): Ditto.
* html/MediaElementSession.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (187261 => 187262)
--- trunk/Source/WebCore/ChangeLog 2015-07-23 22:19:31 UTC (rev 187261)
+++ trunk/Source/WebCore/ChangeLog 2015-07-23 22:23:28 UTC (rev 187262)
@@ -1,3 +1,19 @@
+2015-07-23 Jer Noble <[email protected]>
+
+ Relax media playback restrictions if the allowsMediaDocumentInlinePlayback property is set.
+ https://bugs.webkit.org/show_bug.cgi?id=147234
+
+ Reviewed by Darin Adler.
+
+ * html/HTMLMediaElement.cpp:
+ (WebCore::HTMLMediaElement::prepareForLoad): Moved restriction check into MediaElementSession.
+ * html/MediaElementSession.cpp:
+ (WebCore::MediaElementSession::playbackPermitted): Check if is a top-level media document and if
+ allowsMediaDocumentInilnePlayback is set, and return early.
+ (WebCore::MediaElementSession::effectivePreloadForElement): Ditto.
+ (WebCore::MediaElementSession::allowsAutomaticMediaDataLoading): Ditto.
+ * html/MediaElementSession.h:
+
2015-07-23 Matthew Daiter <[email protected]>
Bridged passing lists of devices between the UIProcess and the WebProcess
Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (187261 => 187262)
--- trunk/Source/WebCore/html/HTMLMediaElement.cpp 2015-07-23 22:19:31 UTC (rev 187261)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp 2015-07-23 22:23:28 UTC (rev 187262)
@@ -1042,8 +1042,7 @@
setShouldDelayLoadEvent(true);
#if PLATFORM(IOS)
- Settings* settings = document().settings();
- if (effectivePreload != MediaPlayer::None && settings && settings->mediaDataLoadsAutomatically())
+ if (effectivePreload != MediaPlayer::None && m_mediaSession->allowsAutomaticMediaDataLoading(*this))
prepareToPlay();
#endif
Modified: trunk/Source/WebCore/html/MediaElementSession.cpp (187261 => 187262)
--- trunk/Source/WebCore/html/MediaElementSession.cpp 2015-07-23 22:19:31 UTC (rev 187261)
+++ trunk/Source/WebCore/html/MediaElementSession.cpp 2015-07-23 22:23:28 UTC (rev 187262)
@@ -78,6 +78,13 @@
}
#endif
+static bool pageExplicitlyAllowsElementToAutoplayInline(const HTMLMediaElement& element)
+{
+ Document& document = element.document();
+ Page* page = document.page();
+ return document.isMediaDocument() && !document.ownerElement() && page && page->allowsMediaDocumentInlinePlayback();
+}
+
MediaElementSession::MediaElementSession(PlatformMediaSessionClient& client)
: PlatformMediaSession(client)
, m_restrictions(NoRestrictions)
@@ -119,6 +126,9 @@
bool MediaElementSession::playbackPermitted(const HTMLMediaElement& element) const
{
+ if (pageExplicitlyAllowsElementToAutoplayInline(element))
+ return true;
+
if (m_restrictions & RequireUserGestureForRateChange && !ScriptController::processingUserGesture()) {
LOG(Media, "MediaElementSession::playbackPermitted - returning FALSE");
return false;
@@ -331,6 +341,9 @@
PlatformMediaSessionManager::SessionRestrictions restrictions = PlatformMediaSessionManager::sharedManager().restrictions(mediaType());
MediaPlayer::Preload preload = element.preloadValue();
+ if (pageExplicitlyAllowsElementToAutoplayInline(element))
+ return preload;
+
if ((restrictions & PlatformMediaSessionManager::MetadataPreloadingNotPermitted) == PlatformMediaSessionManager::MetadataPreloadingNotPermitted)
return MediaPlayer::None;
@@ -344,8 +357,7 @@
bool MediaElementSession::requiresFullscreenForVideoPlayback(const HTMLMediaElement& element) const
{
- Page* page = element.document().page();
- if (element.document().isMediaDocument() && !element.document().ownerElement() && page && page->allowsMediaDocumentInlinePlayback())
+ if (pageExplicitlyAllowsElementToAutoplayInline(element))
return false;
if (!PlatformMediaSessionManager::sharedManager().sessionRestrictsInlineVideoPlayback(*this))
@@ -366,6 +378,18 @@
return true;
}
+bool MediaElementSession::allowsAutomaticMediaDataLoading(const HTMLMediaElement& element) const
+{
+ if (pageExplicitlyAllowsElementToAutoplayInline(element))
+ return true;
+
+ Settings* settings = element.document().settings();
+ if (settings && settings->mediaDataLoadsAutomatically())
+ return true;
+
+ return false;
+}
+
void MediaElementSession::mediaEngineUpdated(const HTMLMediaElement& element)
{
LOG(Media, "MediaElementSession::mediaEngineUpdated");
Modified: trunk/Source/WebCore/html/MediaElementSession.h (187261 => 187262)
--- trunk/Source/WebCore/html/MediaElementSession.h 2015-07-23 22:19:31 UTC (rev 187261)
+++ trunk/Source/WebCore/html/MediaElementSession.h 2015-07-23 22:23:28 UTC (rev 187262)
@@ -71,6 +71,7 @@
bool requiresFullscreenForVideoPlayback(const HTMLMediaElement&) const;
WEBCORE_EXPORT bool allowsPictureInPicture(const HTMLMediaElement&) const;
MediaPlayer::Preload effectivePreloadForElement(const HTMLMediaElement&) const;
+ bool allowsAutomaticMediaDataLoading(const HTMLMediaElement&) const;
void mediaEngineUpdated(const HTMLMediaElement&);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes