Title: [151512] trunk/Source
Revision
151512
Author
[email protected]
Date
2013-06-12 10:33:31 -0700 (Wed, 12 Jun 2013)

Log Message

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

Patch by Ruth Fong <[email protected]> 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.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (151511 => 151512)


--- trunk/Source/WebCore/ChangeLog	2013-06-12 17:32:33 UTC (rev 151511)
+++ trunk/Source/WebCore/ChangeLog	2013-06-12 17:33:31 UTC (rev 151512)
@@ -1,3 +1,33 @@
+2013-06-12  Ruth Fong  <[email protected]>
+
+        Allow for toggling fullscreen on <video> elements
+        https://bugs.webkit.org/show_bug.cgi?id=117220
+
+        Reviewed by Dean Jackson.
+
+        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:
+
 2013-06-12  Sergio Villar Senin  <[email protected]>
 
         Skipping {}, () and [] blocks while error recovering in CSS

Modified: trunk/Source/WebCore/English.lproj/Localizable.strings (151511 => 151512)


--- trunk/Source/WebCore/English.lproj/Localizable.strings	2013-06-12 17:32:33 UTC (rev 151511)
+++ trunk/Source/WebCore/English.lproj/Localizable.strings	2013-06-12 17:33:31 UTC (rev 151512)
@@ -175,6 +175,9 @@
 /* Video Enter Fullscreen context menu item */
 "Enter Fullscreen" = "Enter Fullscreen";
 
+/* Video Exit Fullscreen context menu item */
+"Exit Fullscreen" = "Exit Fullscreen";
+
 /* Default application name for Open With context menu */
 "Finder" = "Finder";
 

Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (151511 => 151512)


--- trunk/Source/WebCore/html/HTMLMediaElement.cpp	2013-06-12 17:32:33 UTC (rev 151511)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp	2013-06-12 17:33:31 UTC (rev 151512)
@@ -4362,6 +4362,16 @@
     return false;
 }
 
+void HTMLMediaElement::toggleFullscreenState()
+{
+    LOG(Media, "HTMLMediaElement::toggleFullscreenState - isFullscreen() is %s", boolString(isFullscreen()));
+    
+    if (isFullscreen())
+        exitFullscreen();
+    else
+        enterFullscreen();
+}
+
 void HTMLMediaElement::enterFullscreen()
 {
     LOG(Media, "HTMLMediaElement::enterFullscreen");

Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (151511 => 151512)


--- trunk/Source/WebCore/html/HTMLMediaElement.h	2013-06-12 17:32:33 UTC (rev 151511)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h	2013-06-12 17:33:31 UTC (rev 151512)
@@ -337,6 +337,7 @@
     bool hasSingleSecurityOrigin() const { return !m_player || m_player->hasSingleSecurityOrigin(); }
     
     bool isFullscreen() const;
+    void toggleFullscreenState();
     void enterFullscreen();
     void exitFullscreen();
 

Modified: trunk/Source/WebCore/page/ContextMenuController.cpp (151511 => 151512)


--- trunk/Source/WebCore/page/ContextMenuController.cpp	2013-06-12 17:32:33 UTC (rev 151511)
+++ trunk/Source/WebCore/page/ContextMenuController.cpp	2013-06-12 17:33:31 UTC (rev 151512)
@@ -263,6 +263,9 @@
     case ContextMenuItemTagToggleMediaLoop:
         m_hitTestResult.toggleMediaLoopPlayback();
         break;
+    case ContextMenuItemTagToggleVideoFullscreen:
+        m_hitTestResult.toggleMediaFullscreenState();
+        break;
     case ContextMenuItemTagEnterVideoFullscreen:
         m_hitTestResult.enterFullscreenForVideo();
         break;
@@ -732,6 +735,12 @@
 #endif
 #endif
 
+#if PLATFORM(MAC)
+#define SUPPORTS_TOGGLE_VIDEO_FULLSCREEN 1
+#else
+#define SUPPORTS_TOGGLE_VIDEO_FULLSCREEN 0
+#endif
+
 void ContextMenuController::populate()
 {
     ContextMenuItem OpenLinkItem(ActionType, ContextMenuItemTagOpenLink, contextMenuItemTagOpenLink());
@@ -762,8 +771,10 @@
         contextMenuItemTagToggleMediaControls());
     ContextMenuItem ToggleMediaLoop(CheckableActionType, ContextMenuItemTagToggleMediaLoop, 
         contextMenuItemTagToggleMediaLoop());
-    ContextMenuItem EnterVideoFullscreen(ActionType, ContextMenuItemTagEnterVideoFullscreen, 
+    ContextMenuItem EnterVideoFullscreen(ActionType, ContextMenuItemTagEnterVideoFullscreen,
         contextMenuItemTagEnterVideoFullscreen());
+    ContextMenuItem ToggleVideoFullscreen(ActionType, ContextMenuItemTagToggleVideoFullscreen,
+        contextMenuItemTagEnterVideoFullscreen());
 #if PLATFORM(MAC)
     ContextMenuItem SearchSpotlightItem(ActionType, ContextMenuItemTagSearchInSpotlight, 
         contextMenuItemTagSearchInSpotlight());
@@ -845,8 +856,11 @@
             appendItem(MediaMute, m_contextMenu.get());
             appendItem(ToggleMediaControls, m_contextMenu.get());
             appendItem(ToggleMediaLoop, m_contextMenu.get());
+#if SUPPORTS_TOGGLE_VIDEO_FULLSCREEN
+            appendItem(ToggleVideoFullscreen, m_contextMenu.get());
+#else
             appendItem(EnterVideoFullscreen, m_contextMenu.get());
-
+#endif
             appendItem(*separatorItem(), m_contextMenu.get());
             appendItem(CopyMediaLinkItem, m_contextMenu.get());
             appendItem(OpenMediaInNewWindowItem, m_contextMenu.get());
@@ -1342,6 +1356,11 @@
         case ContextMenuItemTagToggleMediaLoop:
             shouldCheck = m_hitTestResult.mediaLoopEnabled();
             break;
+        case ContextMenuItemTagToggleVideoFullscreen:
+#if SUPPORTS_TOGGLE_VIDEO_FULLSCREEN
+            item.setTitle(m_hitTestResult.mediaIsInFullscreen() ? contextMenuItemTagExitVideoFullscreen() : contextMenuItemTagEnterVideoFullscreen());
+            break;
+#endif
         case ContextMenuItemTagEnterVideoFullscreen:
             shouldEnable = m_hitTestResult.mediaSupportsFullscreen();
             break;

Modified: trunk/Source/WebCore/platform/ContextMenuItem.h (151511 => 151512)


--- trunk/Source/WebCore/platform/ContextMenuItem.h	2013-06-12 17:32:33 UTC (rev 151511)
+++ trunk/Source/WebCore/platform/ContextMenuItem.h	2013-06-12 17:33:31 UTC (rev 151512)
@@ -161,6 +161,7 @@
         ContextMenuItemTagMediaMute,
         ContextMenuItemTagDictationAlternative,
         ContextMenuItemTagOpenLinkInThisWindow,
+        ContextMenuItemTagToggleVideoFullscreen,
         ContextMenuItemBaseCustomTag = 5000,
         ContextMenuItemCustomTagNoAction = 5998,
         ContextMenuItemLastCustomTag = 5999,

Modified: trunk/Source/WebCore/platform/LocalizedStrings.cpp (151511 => 151512)


--- trunk/Source/WebCore/platform/LocalizedStrings.cpp	2013-06-12 17:32:33 UTC (rev 151511)
+++ trunk/Source/WebCore/platform/LocalizedStrings.cpp	2013-06-12 17:33:31 UTC (rev 151512)
@@ -494,6 +494,11 @@
     return WEB_UI_STRING("Enter Fullscreen", "Video Enter Fullscreen context menu item");
 }
 
+String contextMenuItemTagExitVideoFullscreen()
+{
+    return WEB_UI_STRING("Exit Fullscreen", "Video Exit Fullscreen context menu item");
+}
+
 String contextMenuItemTagMediaPlay()
 {
     return WEB_UI_STRING("Play", "Media Play context menu item");

Modified: trunk/Source/WebCore/platform/LocalizedStrings.h (151511 => 151512)


--- trunk/Source/WebCore/platform/LocalizedStrings.h	2013-06-12 17:32:33 UTC (rev 151511)
+++ trunk/Source/WebCore/platform/LocalizedStrings.h	2013-06-12 17:33:31 UTC (rev 151512)
@@ -137,6 +137,7 @@
     String contextMenuItemTagToggleMediaControls();
     String contextMenuItemTagToggleMediaLoop();
     String contextMenuItemTagEnterVideoFullscreen();
+    String contextMenuItemTagExitVideoFullscreen();
     String contextMenuItemTagMediaPlay();
     String contextMenuItemTagMediaPause();
     String contextMenuItemTagMediaMute();

Modified: trunk/Source/WebCore/rendering/HitTestResult.cpp (151511 => 151512)


--- trunk/Source/WebCore/rendering/HitTestResult.cpp	2013-06-12 17:32:33 UTC (rev 151511)
+++ trunk/Source/WebCore/rendering/HitTestResult.cpp	2013-06-12 17:33:31 UTC (rev 151512)
@@ -399,6 +399,27 @@
 #endif
 }
 
+bool HitTestResult::mediaIsInFullscreen() const
+{
+#if ENABLE(VIDEO)
+    if (HTMLMediaElement* mediaElement = this->mediaElement())
+        return mediaElement->isVideo() && mediaElement->isFullscreen();
+#endif
+    return false;
+}
+
+void HitTestResult::toggleMediaFullscreenState() const
+{
+#if ENABLE(VIDEO)
+    if (HTMLMediaElement* mediaElement = this->mediaElement()) {
+        if (mediaElement->isVideo() && mediaElement->supportsFullscreen()) {
+            UserGestureIndicator indicator(DefinitelyProcessingNewUserGesture);
+            mediaElement->toggleFullscreenState();
+        }
+    }
+#endif
+}
+
 void HitTestResult::enterFullscreenForVideo() const
 {
 #if ENABLE(VIDEO)

Modified: trunk/Source/WebCore/rendering/HitTestResult.h (151511 => 151512)


--- trunk/Source/WebCore/rendering/HitTestResult.h	2013-06-12 17:32:33 UTC (rev 151511)
+++ trunk/Source/WebCore/rendering/HitTestResult.h	2013-06-12 17:33:31 UTC (rev 151512)
@@ -112,6 +112,8 @@
     bool isContentEditable() const;
     void toggleMediaControlsDisplay() const;
     void toggleMediaLoopPlayback() const;
+    bool mediaIsInFullscreen() const;
+    void toggleMediaFullscreenState() const;
     void enterFullscreenForVideo() const;
     bool mediaControlsEnabled() const;
     bool mediaLoopEnabled() const;

Modified: trunk/Source/WebKit2/ChangeLog (151511 => 151512)


--- trunk/Source/WebKit2/ChangeLog	2013-06-12 17:32:33 UTC (rev 151511)
+++ trunk/Source/WebKit2/ChangeLog	2013-06-12 17:33:31 UTC (rev 151512)
@@ -1,3 +1,15 @@
+2013-06-12  Ruth Fong  <[email protected]>
+
+        Allow for toggling fullscreen on <video> elements
+        https://bugs.webkit.org/show_bug.cgi?id=117220
+
+        Reviewed by Dean Jackson.
+
+        * Shared/API/c/WKContextMenuItemTypes.h:
+        * Shared/API/c/WKSharedAPICast.h:
+        Added variables to support the toggle-ability of the fullscreen
+        video context menu item.
+
 2013-06-12  Carlos Garcia Campos  <[email protected]>
 
         [GTK] Invalidate the ProcessLauncher when the process is terminated before it has finished launching

Modified: trunk/Source/WebKit2/Shared/API/c/WKContextMenuItemTypes.h (151511 => 151512)


--- trunk/Source/WebKit2/Shared/API/c/WKContextMenuItemTypes.h	2013-06-12 17:32:33 UTC (rev 151511)
+++ trunk/Source/WebKit2/Shared/API/c/WKContextMenuItemTypes.h	2013-06-12 17:33:31 UTC (rev 151512)
@@ -117,6 +117,7 @@
     kWKContextMenuItemTagCopyImageUrlToClipboard,
     kWKContextMenuItemTagSelectAll,
     kWKContextMenuItemTagOpenLinkInThisWindow,
+    kWKContextMenuItemTagToggleVideoFullscreen,
     kWKContextMenuItemBaseApplicationTag = 10000
 };
 typedef uint32_t WKContextMenuItemTag;

Modified: trunk/Source/WebKit2/Shared/API/c/WKSharedAPICast.h (151511 => 151512)


--- trunk/Source/WebKit2/Shared/API/c/WKSharedAPICast.h	2013-06-12 17:32:33 UTC (rev 151511)
+++ trunk/Source/WebKit2/Shared/API/c/WKSharedAPICast.h	2013-06-12 17:33:31 UTC (rev 151512)
@@ -468,6 +468,8 @@
         return kWKContextMenuItemTagToggleMediaControls;
     case WebCore::ContextMenuItemTagToggleMediaLoop:
         return kWKContextMenuItemTagToggleMediaLoop;
+    case WebCore::ContextMenuItemTagToggleVideoFullscreen:
+        return kWKContextMenuItemTagToggleVideoFullscreen;
     case WebCore::ContextMenuItemTagEnterVideoFullscreen:
         return kWKContextMenuItemTagEnterVideoFullscreen;
     case WebCore::ContextMenuItemTagMediaPlayPause:
@@ -658,6 +660,8 @@
         return WebCore::ContextMenuItemTagToggleMediaControls;
     case kWKContextMenuItemTagToggleMediaLoop:
         return WebCore::ContextMenuItemTagToggleMediaLoop;
+    case kWKContextMenuItemTagToggleVideoFullscreen:
+        return WebCore::ContextMenuItemTagToggleVideoFullscreen;
     case kWKContextMenuItemTagEnterVideoFullscreen:
         return WebCore::ContextMenuItemTagEnterVideoFullscreen;
     case kWKContextMenuItemTagMediaPlayPause:
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to