Title: [133606] trunk
Revision
133606
Author
commit-qu...@webkit.org
Date
2012-11-06 07:27:54 -0800 (Tue, 06 Nov 2012)

Log Message

[BlackBerry] Automatically go fullscreen on video play
https://bugs.webkit.org/show_bug.cgi?id=101100

Patch by Max Feil <mf...@rim.com> on 2012-11-06
Reviewed by Eric Carlson.

Source/WebCore:

There is a requirement to have HTML5 video automatically enter
fullscreen when a video starts playing (PR131774). This change
implements this feature, with restrictions. The main restriction
is adherence to WebKit's philosophy of only entering fullscreen
due to a user gesture. This is important in order to avoid
pop-up advertisements and other unwanted fullscreen content.
One consequence of this is that video elements with the autoplay
attribute will not automatically enter fullscreen.

Other caveats:
- This feature applies only to "small screen" devices where
automatically going fullscreen makes more sense.
- Fullscreen will only be entered automatically when the
video is played from the beginning (current time is zero).
It is assumed that if the user is resuming play from a paused
state and is not in fullscreen mode, then they exited fullscreen
mode intentionally.

Test: platform/blackberry/media/video-automatic-fullscreen.html

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::mediaPlayerEnterFullscreen):
(WebCore):
(WebCore::HTMLMediaElement::mediaPlayerIsFullscreen):
(WebCore::HTMLMediaElement::mediaPlayerIsFullscreenPermitted):
* html/HTMLMediaElement.h:
(HTMLMediaElement):
* platform/graphics/MediaPlayer.h:
(WebCore::MediaPlayerClient::mediaPlayerEnterFullscreen):
(WebCore::MediaPlayerClient::mediaPlayerIsFullscreen):
(WebCore::MediaPlayerClient::mediaPlayerIsFullscreenPermitted):
* platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.cpp:
(WebCore::MediaPlayerPrivate::play):
(WebCore::MediaPlayerPrivate::waitMetadataTimerFired):
(WebCore::MediaPlayerPrivate::conditionallyGoFullscreenAfterPlay):
(WebCore):
* platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.h:
(MediaPlayerPrivate):

LayoutTests:

Test that fullscreen is entered automatically when play is
pressed (PR131774). This test applies to handheld (small screen)
devices only, not tablets. The html code for this test was based
on video-controls-fullscreen-volume.html and modified.

* platform/blackberry/media/video-automatic-fullscreen-expected.txt: Added.
* platform/blackberry/media/video-automatic-fullscreen.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (133605 => 133606)


--- trunk/LayoutTests/ChangeLog	2012-11-06 15:20:42 UTC (rev 133605)
+++ trunk/LayoutTests/ChangeLog	2012-11-06 15:27:54 UTC (rev 133606)
@@ -1,3 +1,18 @@
+2012-11-06  Max Feil  <mf...@rim.com>
+
+        [BlackBerry] Automatically go fullscreen on video play
+        https://bugs.webkit.org/show_bug.cgi?id=101100
+
+        Reviewed by Eric Carlson.
+
+        Test that fullscreen is entered automatically when play is
+        pressed (PR131774). This test applies to handheld (small screen)
+        devices only, not tablets. The html code for this test was based
+        on video-controls-fullscreen-volume.html and modified.
+
+        * platform/blackberry/media/video-automatic-fullscreen-expected.txt: Added.
+        * platform/blackberry/media/video-automatic-fullscreen.html: Added.
+
 2012-11-06  Vsevolod Vlasov  <vse...@chromium.org>
 
         Unreviewed unskip passing tests.

Added: trunk/LayoutTests/platform/blackberry/media/video-automatic-fullscreen-expected.txt (0 => 133606)


--- trunk/LayoutTests/platform/blackberry/media/video-automatic-fullscreen-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/blackberry/media/video-automatic-fullscreen-expected.txt	2012-11-06 15:27:54 UTC (rev 133606)
@@ -0,0 +1,4 @@
+EVENT(canplay)
+EVENT(webkitfullscreenchange)
+END OF TEST
+

Added: trunk/LayoutTests/platform/blackberry/media/video-automatic-fullscreen.html (0 => 133606)


--- trunk/LayoutTests/platform/blackberry/media/video-automatic-fullscreen.html	                        (rev 0)
+++ trunk/LayoutTests/platform/blackberry/media/video-automatic-fullscreen.html	2012-11-06 15:27:54 UTC (rev 133606)
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <title>Video Element - Test automatic Enter Fullscreen on play</title>
+    <script src=""
+    <script src=""
+    <script src=""
+    <script src=""
+    <script>
+        var volumeSlider;
+
+        var startTest = function() {
+            findMediaElement();
+            waitForEvent(video, 'canplay', oncanplay);
+            video.src = "" '../../../media/content/test');
+        };
+
+        var _oncanplay_ = function() {
+            waitForEvent(video, 'webkitfullscreenchange', onfullscreenchange);
+            runWithKeyDown(function(){ video.play(); })
+        };
+
+        var _onfullscreenchange_ = function() {
+            endTest();
+        };
+    </script>
+</head>
+<body _onload_="startTest()">
+    
+    <video controls></video>    
+    
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (133605 => 133606)


--- trunk/Source/WebCore/ChangeLog	2012-11-06 15:20:42 UTC (rev 133605)
+++ trunk/Source/WebCore/ChangeLog	2012-11-06 15:27:54 UTC (rev 133606)
@@ -1,3 +1,49 @@
+2012-11-06  Max Feil  <mf...@rim.com>
+
+        [BlackBerry] Automatically go fullscreen on video play
+        https://bugs.webkit.org/show_bug.cgi?id=101100
+
+        Reviewed by Eric Carlson.
+
+        There is a requirement to have HTML5 video automatically enter
+        fullscreen when a video starts playing (PR131774). This change
+        implements this feature, with restrictions. The main restriction
+        is adherence to WebKit's philosophy of only entering fullscreen
+        due to a user gesture. This is important in order to avoid
+        pop-up advertisements and other unwanted fullscreen content.
+        One consequence of this is that video elements with the autoplay
+        attribute will not automatically enter fullscreen.
+
+        Other caveats:
+        - This feature applies only to "small screen" devices where
+        automatically going fullscreen makes more sense.
+        - Fullscreen will only be entered automatically when the
+        video is played from the beginning (current time is zero).
+        It is assumed that if the user is resuming play from a paused
+        state and is not in fullscreen mode, then they exited fullscreen
+        mode intentionally.
+
+        Test: platform/blackberry/media/video-automatic-fullscreen.html
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::mediaPlayerEnterFullscreen):
+        (WebCore):
+        (WebCore::HTMLMediaElement::mediaPlayerIsFullscreen):
+        (WebCore::HTMLMediaElement::mediaPlayerIsFullscreenPermitted):
+        * html/HTMLMediaElement.h:
+        (HTMLMediaElement):
+        * platform/graphics/MediaPlayer.h:
+        (WebCore::MediaPlayerClient::mediaPlayerEnterFullscreen):
+        (WebCore::MediaPlayerClient::mediaPlayerIsFullscreen):
+        (WebCore::MediaPlayerClient::mediaPlayerIsFullscreenPermitted):
+        * platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.cpp:
+        (WebCore::MediaPlayerPrivate::play):
+        (WebCore::MediaPlayerPrivate::waitMetadataTimerFired):
+        (WebCore::MediaPlayerPrivate::conditionallyGoFullscreenAfterPlay):
+        (WebCore):
+        * platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.h:
+        (MediaPlayerPrivate):
+
 2012-11-06  Grzegorz Czajkowski  <g.czajkow...@samsung.com>
 
         [WK2][EFL][GTK] early return of checkSpellingOfString treats correct words as misspelled

Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (133605 => 133606)


--- trunk/Source/WebCore/html/HTMLMediaElement.cpp	2012-11-06 15:20:42 UTC (rev 133605)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp	2012-11-06 15:27:54 UTC (rev 133606)
@@ -4523,11 +4523,26 @@
     return document()->url().host();
 }
 
+void HTMLMediaElement::mediaPlayerEnterFullscreen()
+{
+    enterFullscreen();
+}
+
 void HTMLMediaElement::mediaPlayerExitFullscreen()
 {
     exitFullscreen();
 }
 
+bool HTMLMediaElement::mediaPlayerIsFullscreen() const
+{
+    return isFullscreen();
+}
+
+bool HTMLMediaElement::mediaPlayerIsFullscreenPermitted() const
+{
+    return !userGestureRequiredForFullscreen() || ScriptController::processingUserGesture();
+}
+
 bool HTMLMediaElement::mediaPlayerIsVideo() const
 {
     return isVideo();

Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (133605 => 133606)


--- trunk/Source/WebCore/html/HTMLMediaElement.h	2012-11-06 15:20:42 UTC (rev 133605)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h	2012-11-06 15:27:54 UTC (rev 133606)
@@ -428,7 +428,10 @@
     virtual bool mediaPlayerNeedsSiteSpecificHacks() const OVERRIDE;
     virtual String mediaPlayerDocumentHost() const OVERRIDE;
 
+    virtual void mediaPlayerEnterFullscreen() OVERRIDE;
     virtual void mediaPlayerExitFullscreen() OVERRIDE;
+    virtual bool mediaPlayerIsFullscreen() const OVERRIDE;
+    virtual bool mediaPlayerIsFullscreenPermitted() const OVERRIDE;
     virtual bool mediaPlayerIsVideo() const OVERRIDE;
     virtual LayoutRect mediaPlayerContentBoxRect() const OVERRIDE;
     virtual void mediaPlayerSetSize(const IntSize&) OVERRIDE;

Modified: trunk/Source/WebCore/platform/graphics/MediaPlayer.h (133605 => 133606)


--- trunk/Source/WebCore/platform/graphics/MediaPlayer.h	2012-11-06 15:20:42 UTC (rev 133605)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayer.h	2012-11-06 15:27:54 UTC (rev 133606)
@@ -193,7 +193,10 @@
     virtual String mediaPlayerReferrer() const { return String(); }
     virtual String mediaPlayerUserAgent() const { return String(); }
     virtual CORSMode mediaPlayerCORSMode() const { return Unspecified; }
+    virtual void mediaPlayerEnterFullscreen() { }
     virtual void mediaPlayerExitFullscreen() { }
+    virtual bool mediaPlayerIsFullscreen() const { return false; }
+    virtual bool mediaPlayerIsFullscreenPermitted() const { return false; }
     virtual bool mediaPlayerIsVideo() const { return false; }
     virtual LayoutRect mediaPlayerContentBoxRect() const { return LayoutRect(); }
     virtual void mediaPlayerSetSize(const IntSize&) { }

Modified: trunk/Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.cpp (133605 => 133606)


--- trunk/Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.cpp	2012-11-06 15:20:42 UTC (rev 133605)
+++ trunk/Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.cpp	2012-11-06 15:27:54 UTC (rev 133606)
@@ -39,6 +39,7 @@
 #include "TimeRanges.h"
 #include "WebPageClient.h"
 
+#include <BlackBerryPlatformDeviceInfo.h>
 #include <BlackBerryPlatformSettings.h>
 #include <FrameLoaderClientBlackBerry.h>
 #include <set>
@@ -187,8 +188,11 @@
 
 void MediaPlayerPrivate::play()
 {
-    if (m_platformPlayer)
+    if (m_platformPlayer) {
         m_platformPlayer->play();
+        if (m_platformPlayer->isMetadataReady())
+            conditionallyGoFullscreenAfterPlay();
+    }
 }
 
 void MediaPlayerPrivate::pause()
@@ -663,6 +667,7 @@
 {
     if (m_platformPlayer->isMetadataReady()) {
         m_platformPlayer->playWithMetadataReady();
+        conditionallyGoFullscreenAfterPlay();
         m_waitMetadataPopDialogCounter = 0;
         return;
     }
@@ -679,9 +684,10 @@
     if (!wait)
         onPauseNotified();
     else {
-        if (m_platformPlayer->isMetadataReady())
+        if (m_platformPlayer->isMetadataReady()) {
             m_platformPlayer->playWithMetadataReady();
-        else
+            conditionallyGoFullscreenAfterPlay();
+        } else
             m_waitMetadataTimer.startOneShot(checkMetadataReadyInterval);
     }
 }
@@ -963,6 +969,29 @@
 }
 #endif
 
+void MediaPlayerPrivate::conditionallyGoFullscreenAfterPlay()
+{
+    BlackBerry::Platform::DeviceInfo* info = BlackBerry::Platform::DeviceInfo::instance();
+    if (hasVideo() && m_webCorePlayer->mediaPlayerClient()->mediaPlayerIsFullscreenPermitted() && info->isMobile()) {
+        // This is a mobile device (small screen), not a tablet, so we
+        // enter fullscreen video on user-initiated plays.
+        bool nothingIsFullscreen = !m_webCorePlayer->mediaPlayerClient()->mediaPlayerIsFullscreen();
+#if ENABLE(FULLSCREEN_API)
+        if (m_webCorePlayer->mediaPlayerClient()->mediaPlayerOwningDocument()->webkitIsFullScreen())
+            nothingIsFullscreen = false;
+#endif
+        if (nothingIsFullscreen && currentTime() == 0.0f) {
+            // Only enter fullscreen when playing from the beginning. Doing
+            // so on every play is sure to annoy the user who does not want
+            // to watch the video fullscreen. Note that the following call
+            // will fail if we are not here due to a user gesture, as per the
+            // check in Document::requestFullScreenForElement() to prevent
+            // popups.
+            m_webCorePlayer->mediaPlayerClient()->mediaPlayerEnterFullscreen();
+        }
+    }
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(VIDEO)

Modified: trunk/Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.h (133605 => 133606)


--- trunk/Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.h	2012-11-06 15:20:42 UTC (rev 133605)
+++ trunk/Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.h	2012-11-06 15:27:54 UTC (rev 133606)
@@ -170,6 +170,7 @@
     bool m_mediaIsBuffering;
 #endif
 
+    void conditionallyGoFullscreenAfterPlay();
     void userDrivenSeekTimerFired(Timer<MediaPlayerPrivate>*);
     Timer<MediaPlayerPrivate> m_userDrivenSeekTimer;
     float m_lastSeekTime;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to