Changeset 133606 in webkit


Ignore:
Timestamp:
Nov 6, 2012, 7:27:54 AM (13 years ago)
Author:
commit-queue@webkit.org
Message:

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

Patch by Max Feil <mfeil@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.
Location:
trunk
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r133598 r133606  
     12012-11-06  Max Feil  <mfeil@rim.com>
     2
     3        [BlackBerry] Automatically go fullscreen on video play
     4        https://bugs.webkit.org/show_bug.cgi?id=101100
     5
     6        Reviewed by Eric Carlson.
     7
     8        Test that fullscreen is entered automatically when play is
     9        pressed (PR131774). This test applies to handheld (small screen)
     10        devices only, not tablets. The html code for this test was based
     11        on video-controls-fullscreen-volume.html and modified.
     12
     13        * platform/blackberry/media/video-automatic-fullscreen-expected.txt: Added.
     14        * platform/blackberry/media/video-automatic-fullscreen.html: Added.
     15
    1162012-11-06  Vsevolod Vlasov  <vsevik@chromium.org>
    217
  • trunk/Source/WebCore/ChangeLog

    r133602 r133606  
     12012-11-06  Max Feil  <mfeil@rim.com>
     2
     3        [BlackBerry] Automatically go fullscreen on video play
     4        https://bugs.webkit.org/show_bug.cgi?id=101100
     5
     6        Reviewed by Eric Carlson.
     7
     8        There is a requirement to have HTML5 video automatically enter
     9        fullscreen when a video starts playing (PR131774). This change
     10        implements this feature, with restrictions. The main restriction
     11        is adherence to WebKit's philosophy of only entering fullscreen
     12        due to a user gesture. This is important in order to avoid
     13        pop-up advertisements and other unwanted fullscreen content.
     14        One consequence of this is that video elements with the autoplay
     15        attribute will not automatically enter fullscreen.
     16
     17        Other caveats:
     18        - This feature applies only to "small screen" devices where
     19        automatically going fullscreen makes more sense.
     20        - Fullscreen will only be entered automatically when the
     21        video is played from the beginning (current time is zero).
     22        It is assumed that if the user is resuming play from a paused
     23        state and is not in fullscreen mode, then they exited fullscreen
     24        mode intentionally.
     25
     26        Test: platform/blackberry/media/video-automatic-fullscreen.html
     27
     28        * html/HTMLMediaElement.cpp:
     29        (WebCore::HTMLMediaElement::mediaPlayerEnterFullscreen):
     30        (WebCore):
     31        (WebCore::HTMLMediaElement::mediaPlayerIsFullscreen):
     32        (WebCore::HTMLMediaElement::mediaPlayerIsFullscreenPermitted):
     33        * html/HTMLMediaElement.h:
     34        (HTMLMediaElement):
     35        * platform/graphics/MediaPlayer.h:
     36        (WebCore::MediaPlayerClient::mediaPlayerEnterFullscreen):
     37        (WebCore::MediaPlayerClient::mediaPlayerIsFullscreen):
     38        (WebCore::MediaPlayerClient::mediaPlayerIsFullscreenPermitted):
     39        * platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.cpp:
     40        (WebCore::MediaPlayerPrivate::play):
     41        (WebCore::MediaPlayerPrivate::waitMetadataTimerFired):
     42        (WebCore::MediaPlayerPrivate::conditionallyGoFullscreenAfterPlay):
     43        (WebCore):
     44        * platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.h:
     45        (MediaPlayerPrivate):
     46
    1472012-11-06  Grzegorz Czajkowski  <g.czajkowski@samsung.com>
    248
  • trunk/Source/WebCore/html/HTMLMediaElement.cpp

    r133262 r133606  
    45244524}
    45254525
     4526void HTMLMediaElement::mediaPlayerEnterFullscreen()
     4527{
     4528    enterFullscreen();
     4529}
     4530
    45264531void HTMLMediaElement::mediaPlayerExitFullscreen()
    45274532{
    45284533    exitFullscreen();
     4534}
     4535
     4536bool HTMLMediaElement::mediaPlayerIsFullscreen() const
     4537{
     4538    return isFullscreen();
     4539}
     4540
     4541bool HTMLMediaElement::mediaPlayerIsFullscreenPermitted() const
     4542{
     4543    return !userGestureRequiredForFullscreen() || ScriptController::processingUserGesture();
    45294544}
    45304545
  • trunk/Source/WebCore/html/HTMLMediaElement.h

    r133262 r133606  
    429429    virtual String mediaPlayerDocumentHost() const OVERRIDE;
    430430
     431    virtual void mediaPlayerEnterFullscreen() OVERRIDE;
    431432    virtual void mediaPlayerExitFullscreen() OVERRIDE;
     433    virtual bool mediaPlayerIsFullscreen() const OVERRIDE;
     434    virtual bool mediaPlayerIsFullscreenPermitted() const OVERRIDE;
    432435    virtual bool mediaPlayerIsVideo() const OVERRIDE;
    433436    virtual LayoutRect mediaPlayerContentBoxRect() const OVERRIDE;
  • trunk/Source/WebCore/platform/graphics/MediaPlayer.h

    r131502 r133606  
    194194    virtual String mediaPlayerUserAgent() const { return String(); }
    195195    virtual CORSMode mediaPlayerCORSMode() const { return Unspecified; }
     196    virtual void mediaPlayerEnterFullscreen() { }
    196197    virtual void mediaPlayerExitFullscreen() { }
     198    virtual bool mediaPlayerIsFullscreen() const { return false; }
     199    virtual bool mediaPlayerIsFullscreenPermitted() const { return false; }
    197200    virtual bool mediaPlayerIsVideo() const { return false; }
    198201    virtual LayoutRect mediaPlayerContentBoxRect() const { return LayoutRect(); }
  • trunk/Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.cpp

    r131316 r133606  
    4040#include "WebPageClient.h"
    4141
     42#include <BlackBerryPlatformDeviceInfo.h>
    4243#include <BlackBerryPlatformSettings.h>
    4344#include <FrameLoaderClientBlackBerry.h>
     
    188189void MediaPlayerPrivate::play()
    189190{
    190     if (m_platformPlayer)
     191    if (m_platformPlayer) {
    191192        m_platformPlayer->play();
     193        if (m_platformPlayer->isMetadataReady())
     194            conditionallyGoFullscreenAfterPlay();
     195    }
    192196}
    193197
     
    664668    if (m_platformPlayer->isMetadataReady()) {
    665669        m_platformPlayer->playWithMetadataReady();
     670        conditionallyGoFullscreenAfterPlay();
    666671        m_waitMetadataPopDialogCounter = 0;
    667672        return;
     
    680685        onPauseNotified();
    681686    else {
    682         if (m_platformPlayer->isMetadataReady())
     687        if (m_platformPlayer->isMetadataReady()) {
    683688            m_platformPlayer->playWithMetadataReady();
    684         else
     689            conditionallyGoFullscreenAfterPlay();
     690        } else
    685691            m_waitMetadataTimer.startOneShot(checkMetadataReadyInterval);
    686692    }
     
    964970#endif
    965971
     972void MediaPlayerPrivate::conditionallyGoFullscreenAfterPlay()
     973{
     974    BlackBerry::Platform::DeviceInfo* info = BlackBerry::Platform::DeviceInfo::instance();
     975    if (hasVideo() && m_webCorePlayer->mediaPlayerClient()->mediaPlayerIsFullscreenPermitted() && info->isMobile()) {
     976        // This is a mobile device (small screen), not a tablet, so we
     977        // enter fullscreen video on user-initiated plays.
     978        bool nothingIsFullscreen = !m_webCorePlayer->mediaPlayerClient()->mediaPlayerIsFullscreen();
     979#if ENABLE(FULLSCREEN_API)
     980        if (m_webCorePlayer->mediaPlayerClient()->mediaPlayerOwningDocument()->webkitIsFullScreen())
     981            nothingIsFullscreen = false;
     982#endif
     983        if (nothingIsFullscreen && currentTime() == 0.0f) {
     984            // Only enter fullscreen when playing from the beginning. Doing
     985            // so on every play is sure to annoy the user who does not want
     986            // to watch the video fullscreen. Note that the following call
     987            // will fail if we are not here due to a user gesture, as per the
     988            // check in Document::requestFullScreenForElement() to prevent
     989            // popups.
     990            m_webCorePlayer->mediaPlayerClient()->mediaPlayerEnterFullscreen();
     991        }
     992    }
     993}
     994
    966995} // namespace WebCore
    967996
  • trunk/Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.h

    r131316 r133606  
    171171#endif
    172172
     173    void conditionallyGoFullscreenAfterPlay();
    173174    void userDrivenSeekTimerFired(Timer<MediaPlayerPrivate>*);
    174175    Timer<MediaPlayerPrivate> m_userDrivenSeekTimer;
Note: See TracChangeset for help on using the changeset viewer.