Changeset 151512 in webkit


Ignore:
Timestamp:
Jun 12, 2013 10:33:31 AM (11 years ago)
Author:
commit-queue@webkit.org
Message:

Allow for toggling fullscreen on <video> elements
https://bugs.webkit.org/show_bug.cgi?id=117220

Patch by Ruth Fong <ruth_fong@apple.com> on 2013-06-12
Reviewed by Dean Jackson.

Source/WebCore:

This patch adds the ability for fullscreen
context menu item on <video> elements to switch between "Enter Fullscreen"
and "Exit Fullscreen" and behave appropriately.

No new tests. media/context-menu-action.html,
which has been disabled by bug 116651, is used to test context menus.

  • English.lproj/Localizable.strings: Add "Exit Fullscreen" string.
  • html/HTMLMediaElement.cpp:

(WebCore::HTMLMediaElement::toggleFullscreenState): Added to appropriately enter/exit fullscreen.

  • html/HTMLMediaElement.h:
  • page/ContextMenuController.cpp:
  • platform/ContextMenuItem.h:
  • platform/LocalizedStrings.cpp:
  • platform/LocalizedStrings.h:

Updated to rename variables more appropriately to reflect the toggle-ability of video fullscreen.

  • rendering/HitTestResult.cpp:

(WebCore::HitTestResult::mediaIsInFullscreen): Added to check if an element
was a media element in fullscreen.
(WebCore::HitTestResult::toggleMediaFullscreenState): Added to hook into
HTMLMediaElement::toggleFullscreenState.

  • rendering/HitTestResult.h:

Source/WebKit2:

  • Shared/API/c/WKContextMenuItemTypes.h:
  • Shared/API/c/WKSharedAPICast.h:

Added variables to support the toggle-ability of the fullscreen
video context menu item.

Location:
trunk/Source
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r151510 r151512  
     12013-06-12  Ruth Fong  <ruth_fong@apple.com>
     2
     3        Allow for toggling fullscreen on <video> elements
     4        https://bugs.webkit.org/show_bug.cgi?id=117220
     5
     6        Reviewed by Dean Jackson.
     7
     8        This patch adds the ability for fullscreen
     9        context menu item on <video> elements to switch between "Enter Fullscreen"
     10        and "Exit Fullscreen" and behave appropriately.
     11
     12        No new tests. media/context-menu-action.html,
     13        which has been disabled by bug 116651, is used to test context menus.
     14
     15        * English.lproj/Localizable.strings: Add "Exit Fullscreen" string.
     16        * html/HTMLMediaElement.cpp:
     17        (WebCore::HTMLMediaElement::toggleFullscreenState): Added to appropriately enter/exit fullscreen.
     18        * html/HTMLMediaElement.h:
     19        * page/ContextMenuController.cpp:
     20        * platform/ContextMenuItem.h:
     21        * platform/LocalizedStrings.cpp:
     22        * platform/LocalizedStrings.h:
     23        Updated to rename variables more appropriately to reflect the toggle-ability of video fullscreen.
     24        * rendering/HitTestResult.cpp:
     25        (WebCore::HitTestResult::mediaIsInFullscreen): Added to check if an element
     26        was a media element in fullscreen.
     27        (WebCore::HitTestResult::toggleMediaFullscreenState): Added to hook into
     28        HTMLMediaElement::toggleFullscreenState.
     29        * rendering/HitTestResult.h:
     30
    1312013-06-12  Sergio Villar Senin  <svillar@igalia.com>
    232
  • trunk/Source/WebCore/English.lproj/Localizable.strings

    r151469 r151512  
    176176"Enter Fullscreen" = "Enter Fullscreen";
    177177
     178/* Video Exit Fullscreen context menu item */
     179"Exit Fullscreen" = "Exit Fullscreen";
     180
    178181/* Default application name for Open With context menu */
    179182"Finder" = "Finder";
  • trunk/Source/WebCore/html/HTMLMediaElement.cpp

    r151282 r151512  
    43634363}
    43644364
     4365void HTMLMediaElement::toggleFullscreenState()
     4366{
     4367    LOG(Media, "HTMLMediaElement::toggleFullscreenState - isFullscreen() is %s", boolString(isFullscreen()));
     4368   
     4369    if (isFullscreen())
     4370        exitFullscreen();
     4371    else
     4372        enterFullscreen();
     4373}
     4374
    43654375void HTMLMediaElement::enterFullscreen()
    43664376{
  • trunk/Source/WebCore/html/HTMLMediaElement.h

    r151282 r151512  
    338338   
    339339    bool isFullscreen() const;
     340    void toggleFullscreenState();
    340341    void enterFullscreen();
    341342    void exitFullscreen();
  • trunk/Source/WebCore/page/ContextMenuController.cpp

    r150575 r151512  
    264264        m_hitTestResult.toggleMediaLoopPlayback();
    265265        break;
     266    case ContextMenuItemTagToggleVideoFullscreen:
     267        m_hitTestResult.toggleMediaFullscreenState();
     268        break;
    266269    case ContextMenuItemTagEnterVideoFullscreen:
    267270        m_hitTestResult.enterFullscreenForVideo();
     
    731734#define INCLUDE_SPOTLIGHT_CONTEXT_MENU_ITEM 0
    732735#endif
     736#endif
     737
     738#if PLATFORM(MAC)
     739#define SUPPORTS_TOGGLE_VIDEO_FULLSCREEN 1
     740#else
     741#define SUPPORTS_TOGGLE_VIDEO_FULLSCREEN 0
    733742#endif
    734743
     
    763772    ContextMenuItem ToggleMediaLoop(CheckableActionType, ContextMenuItemTagToggleMediaLoop,
    764773        contextMenuItemTagToggleMediaLoop());
    765     ContextMenuItem EnterVideoFullscreen(ActionType, ContextMenuItemTagEnterVideoFullscreen,
     774    ContextMenuItem EnterVideoFullscreen(ActionType, ContextMenuItemTagEnterVideoFullscreen,
     775        contextMenuItemTagEnterVideoFullscreen());
     776    ContextMenuItem ToggleVideoFullscreen(ActionType, ContextMenuItemTagToggleVideoFullscreen,
    766777        contextMenuItemTagEnterVideoFullscreen());
    767778#if PLATFORM(MAC)
     
    846857            appendItem(ToggleMediaControls, m_contextMenu.get());
    847858            appendItem(ToggleMediaLoop, m_contextMenu.get());
     859#if SUPPORTS_TOGGLE_VIDEO_FULLSCREEN
     860            appendItem(ToggleVideoFullscreen, m_contextMenu.get());
     861#else
    848862            appendItem(EnterVideoFullscreen, m_contextMenu.get());
    849 
     863#endif
    850864            appendItem(*separatorItem(), m_contextMenu.get());
    851865            appendItem(CopyMediaLinkItem, m_contextMenu.get());
     
    13431357            shouldCheck = m_hitTestResult.mediaLoopEnabled();
    13441358            break;
     1359        case ContextMenuItemTagToggleVideoFullscreen:
     1360#if SUPPORTS_TOGGLE_VIDEO_FULLSCREEN
     1361            item.setTitle(m_hitTestResult.mediaIsInFullscreen() ? contextMenuItemTagExitVideoFullscreen() : contextMenuItemTagEnterVideoFullscreen());
     1362            break;
     1363#endif
    13451364        case ContextMenuItemTagEnterVideoFullscreen:
    13461365            shouldEnable = m_hitTestResult.mediaSupportsFullscreen();
  • trunk/Source/WebCore/platform/ContextMenuItem.h

    r149186 r151512  
    162162        ContextMenuItemTagDictationAlternative,
    163163        ContextMenuItemTagOpenLinkInThisWindow,
     164        ContextMenuItemTagToggleVideoFullscreen,
    164165        ContextMenuItemBaseCustomTag = 5000,
    165166        ContextMenuItemCustomTagNoAction = 5998,
  • trunk/Source/WebCore/platform/LocalizedStrings.cpp

    r151469 r151512  
    493493{
    494494    return WEB_UI_STRING("Enter Fullscreen", "Video Enter Fullscreen context menu item");
     495}
     496
     497String contextMenuItemTagExitVideoFullscreen()
     498{
     499    return WEB_UI_STRING("Exit Fullscreen", "Video Exit Fullscreen context menu item");
    495500}
    496501
  • trunk/Source/WebCore/platform/LocalizedStrings.h

    r151469 r151512  
    138138    String contextMenuItemTagToggleMediaLoop();
    139139    String contextMenuItemTagEnterVideoFullscreen();
     140    String contextMenuItemTagExitVideoFullscreen();
    140141    String contextMenuItemTagMediaPlay();
    141142    String contextMenuItemTagMediaPause();
  • trunk/Source/WebCore/rendering/HitTestResult.cpp

    r151003 r151512  
    400400}
    401401
     402bool HitTestResult::mediaIsInFullscreen() const
     403{
     404#if ENABLE(VIDEO)
     405    if (HTMLMediaElement* mediaElement = this->mediaElement())
     406        return mediaElement->isVideo() && mediaElement->isFullscreen();
     407#endif
     408    return false;
     409}
     410
     411void HitTestResult::toggleMediaFullscreenState() const
     412{
     413#if ENABLE(VIDEO)
     414    if (HTMLMediaElement* mediaElement = this->mediaElement()) {
     415        if (mediaElement->isVideo() && mediaElement->supportsFullscreen()) {
     416            UserGestureIndicator indicator(DefinitelyProcessingNewUserGesture);
     417            mediaElement->toggleFullscreenState();
     418        }
     419    }
     420#endif
     421}
     422
    402423void HitTestResult::enterFullscreenForVideo() const
    403424{
  • trunk/Source/WebCore/rendering/HitTestResult.h

    r147739 r151512  
    113113    void toggleMediaControlsDisplay() const;
    114114    void toggleMediaLoopPlayback() const;
     115    bool mediaIsInFullscreen() const;
     116    void toggleMediaFullscreenState() const;
    115117    void enterFullscreenForVideo() const;
    116118    bool mediaControlsEnabled() const;
  • trunk/Source/WebKit2/ChangeLog

    r151508 r151512  
     12013-06-12  Ruth Fong  <ruth_fong@apple.com>
     2
     3        Allow for toggling fullscreen on <video> elements
     4        https://bugs.webkit.org/show_bug.cgi?id=117220
     5
     6        Reviewed by Dean Jackson.
     7
     8        * Shared/API/c/WKContextMenuItemTypes.h:
     9        * Shared/API/c/WKSharedAPICast.h:
     10        Added variables to support the toggle-ability of the fullscreen
     11        video context menu item.
     12
    1132013-06-12  Carlos Garcia Campos  <cgarcia@igalia.com>
    214
  • trunk/Source/WebKit2/Shared/API/c/WKContextMenuItemTypes.h

    r143700 r151512  
    118118    kWKContextMenuItemTagSelectAll,
    119119    kWKContextMenuItemTagOpenLinkInThisWindow,
     120    kWKContextMenuItemTagToggleVideoFullscreen,
    120121    kWKContextMenuItemBaseApplicationTag = 10000
    121122};
  • trunk/Source/WebKit2/Shared/API/c/WKSharedAPICast.h

    r150695 r151512  
    469469    case WebCore::ContextMenuItemTagToggleMediaLoop:
    470470        return kWKContextMenuItemTagToggleMediaLoop;
     471    case WebCore::ContextMenuItemTagToggleVideoFullscreen:
     472        return kWKContextMenuItemTagToggleVideoFullscreen;
    471473    case WebCore::ContextMenuItemTagEnterVideoFullscreen:
    472474        return kWKContextMenuItemTagEnterVideoFullscreen;
     
    659661    case kWKContextMenuItemTagToggleMediaLoop:
    660662        return WebCore::ContextMenuItemTagToggleMediaLoop;
     663    case kWKContextMenuItemTagToggleVideoFullscreen:
     664        return WebCore::ContextMenuItemTagToggleVideoFullscreen;
    661665    case kWKContextMenuItemTagEnterVideoFullscreen:
    662666        return WebCore::ContextMenuItemTagEnterVideoFullscreen;
Note: See TracChangeset for help on using the changeset viewer.