Title: [203066] trunk/Source/WebCore
Revision
203066
Author
[email protected]
Date
2016-07-11 09:33:53 -0700 (Mon, 11 Jul 2016)

Log Message

Pause small video elements when returning to inline.
https://bugs.webkit.org/show_bug.cgi?id=159535

Patch by Jeremy Jones <[email protected]> on 2016-07-11
Reviewed by Jer Noble.

Will add a test in a later commit.

When exiting fullscreen, don't allow playback to continue inline if video is too small.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::isVideoTooSmallForInlinePlayback): Added.
(WebCore::HTMLMediaElement::exitFullscreen): Pause if video is too small.
* html/HTMLMediaElement.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (203065 => 203066)


--- trunk/Source/WebCore/ChangeLog	2016-07-11 16:26:00 UTC (rev 203065)
+++ trunk/Source/WebCore/ChangeLog	2016-07-11 16:33:53 UTC (rev 203066)
@@ -1,3 +1,19 @@
+2016-07-11  Jeremy Jones  <[email protected]>
+
+        Pause small video elements when returning to inline.
+        https://bugs.webkit.org/show_bug.cgi?id=159535
+
+        Reviewed by Jer Noble.
+
+        Will add a test in a later commit.
+
+        When exiting fullscreen, don't allow playback to continue inline if video is too small.
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::isVideoTooSmallForInlinePlayback): Added.
+        (WebCore::HTMLMediaElement::exitFullscreen): Pause if video is too small.
+        * html/HTMLMediaElement.h:
+
 2016-07-11  Nael Ouedraogo  <[email protected]>
 
         toNative functions in JSDOMBinding.h should take an ExecState reference instead of pointer

Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (203065 => 203066)


--- trunk/Source/WebCore/html/HTMLMediaElement.cpp	2016-07-11 16:26:00 UTC (rev 203065)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp	2016-07-11 16:33:53 UTC (rev 203066)
@@ -5454,7 +5454,7 @@
     if (hasMediaControls())
         mediaControls()->exitedFullscreen();
     if (document().page() && is<HTMLVideoElement>(*this)) {
-        if (m_mediaSession->requiresFullscreenForVideoPlayback(*this) && (!document().settings() || !document().settings()->allowsInlineMediaPlaybackAfterFullscreen()))
+        if (m_mediaSession->requiresFullscreenForVideoPlayback(*this) && (!document().settings() || !document().settings()->allowsInlineMediaPlaybackAfterFullscreen() || isVideoTooSmallForInlinePlayback()))
             pauseInternal();
 
 #if PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)
@@ -7068,6 +7068,17 @@
     if (potentiallyPlaying() && m_mediaSession->requiresFullscreenForVideoPlayback(*this) && !isFullscreen())
         enterFullscreen();
 }
+    
+bool HTMLMediaElement::isVideoTooSmallForInlinePlayback()
+{
+    auto* renderer = this->renderer();
+    
+    if (!renderer || !is<RenderVideo>(*renderer))
+        return true;
+    
+    IntRect videoBox = downcast<RenderVideo>(*renderer).videoBox();
+    return (videoBox.width() <= 1 || videoBox.height() <= 1);
+}
 
 static bool mediaElementIsAllowedToAutoplay(const HTMLMediaElement& element)
 {

Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (203065 => 203066)


--- trunk/Source/WebCore/html/HTMLMediaElement.h	2016-07-11 16:26:00 UTC (rev 203065)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h	2016-07-11 16:33:53 UTC (rev 203066)
@@ -779,6 +779,7 @@
     bool hasPlaybackTargetAvailabilityListeners() const { return m_hasPlaybackTargetAvailabilityListeners; }
 #endif
 
+    bool isVideoTooSmallForInlinePlayback();
     void isVisibleInViewportChanged() final;
     void updateShouldAutoplay();
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to