Add the new "toggle enhanced fullscreen" context menu item to the video context menu...
authoradachan@apple.com <adachan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 31 Mar 2016 18:23:29 +0000 (18:23 +0000)
committeradachan@apple.com <adachan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 31 Mar 2016 18:23:29 +0000 (18:23 +0000)
https://bugs.webkit.org/show_bug.cgi?id=156031

Reviewed by Eric Carlson.

Source/WebCore:

* page/ContextMenuController.cpp:
(WebCore::ContextMenuController::contextMenuItemSelected):
Handle the selection of the context menu item.
(WebCore::ContextMenuController::populate):
Add this menu item on Mac.
(WebCore::ContextMenuController::checkOrEnableIfNeeded):
Set the menu item's title depending on the current enhanced fullscreen state
and enable this menu item if supported.

* platform/ContextMenuItem.h:
Define the new tag for this menu item.

* platform/LocalizedStrings.cpp:
(WebCore::contextMenuItemTagEnterVideoEnhancedFullscreen):
(WebCore::contextMenuItemTagExitVideoEnhancedFullscreen):
* platform/LocalizedStrings.h:

* rendering/HitTestResult.cpp:
(WebCore::HitTestResult::mediaSupportsEnhancedFullscreen):
(WebCore::HitTestResult::mediaIsInEnhancedFullscreen):
(WebCore::HitTestResult::toggleEnhancedFullscreenForVideo):
* rendering/HitTestResult.h:

Source/WebKit/mac:

* WebView/WebHTMLView.mm:
(toAction):
(toTag):
* WebView/WebUIDelegatePrivate.h:

Source/WebKit2:

* Shared/API/c/WKContextMenuItemTypes.h:
* Shared/API/c/WKSharedAPICast.h:
(WebKit::toAPI):
(WebKit::toImpl):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@198900 268f45cc-cd09-0410-ab3c-d52691b4dbfc

13 files changed:
Source/WebCore/ChangeLog
Source/WebCore/page/ContextMenuController.cpp
Source/WebCore/platform/ContextMenuItem.h
Source/WebCore/platform/LocalizedStrings.cpp
Source/WebCore/platform/LocalizedStrings.h
Source/WebCore/rendering/HitTestResult.cpp
Source/WebCore/rendering/HitTestResult.h
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebView/WebHTMLView.mm
Source/WebKit/mac/WebView/WebUIDelegatePrivate.h
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/API/c/WKContextMenuItemTypes.h
Source/WebKit2/Shared/API/c/WKSharedAPICast.h

index 1f263c6..d1d6be3 100644 (file)
@@ -1,3 +1,33 @@
+2016-03-30  Ada Chan  <adachan@apple.com>
+
+        Add the new "toggle enhanced fullscreen" context menu item to the video context menu on supporting platforms.
+        https://bugs.webkit.org/show_bug.cgi?id=156031
+
+        Reviewed by Eric Carlson.
+
+        * page/ContextMenuController.cpp:
+        (WebCore::ContextMenuController::contextMenuItemSelected):
+        Handle the selection of the context menu item.
+        (WebCore::ContextMenuController::populate):
+        Add this menu item on Mac.
+        (WebCore::ContextMenuController::checkOrEnableIfNeeded):
+        Set the menu item's title depending on the current enhanced fullscreen state
+        and enable this menu item if supported.
+
+        * platform/ContextMenuItem.h:
+        Define the new tag for this menu item.
+
+        * platform/LocalizedStrings.cpp:
+        (WebCore::contextMenuItemTagEnterVideoEnhancedFullscreen):
+        (WebCore::contextMenuItemTagExitVideoEnhancedFullscreen):
+        * platform/LocalizedStrings.h:
+
+        * rendering/HitTestResult.cpp:
+        (WebCore::HitTestResult::mediaSupportsEnhancedFullscreen):
+        (WebCore::HitTestResult::mediaIsInEnhancedFullscreen):
+        (WebCore::HitTestResult::toggleEnhancedFullscreenForVideo):
+        * rendering/HitTestResult.h:
+
 2016-03-31  Nan Wang  <n_wang@apple.com>
 
         AX: aria-hidden=false causes video fallback content to be exposed to AX API
index 890da88..1442252 100644 (file)
@@ -279,6 +279,9 @@ void ContextMenuController::contextMenuItemSelected(ContextMenuAction action, co
     case ContextMenuItemTagMediaMute:
         m_context.hitTestResult().toggleMediaMuteState();
         break;
+    case ContextMenuItemTagToggleVideoEnhancedFullscreen:
+        m_context.hitTestResult().toggleEnhancedFullscreenForVideo();
+        break;
     case ContextMenuItemTagOpenFrameInNewWindow: {
         DocumentLoader* loader = frame->loader().documentLoader();
         if (!loader->unreachableURL().isEmpty())
@@ -766,6 +769,9 @@ void ContextMenuController::populate()
         contextMenuItemTagEnterVideoFullscreen());
     ContextMenuItem ToggleVideoFullscreen(ActionType, ContextMenuItemTagToggleVideoFullscreen,
         contextMenuItemTagEnterVideoFullscreen());
+#if PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)
+    ContextMenuItem ToggleVideoEnhancedFullscreen(ActionType, ContextMenuItemTagToggleVideoEnhancedFullscreen, contextMenuItemTagEnterVideoEnhancedFullscreen());
+#endif
 #if PLATFORM(COCOA)
     ContextMenuItem SearchSpotlightItem(ActionType, ContextMenuItemTagSearchInSpotlight, 
         contextMenuItemTagSearchInSpotlight());
@@ -863,6 +869,9 @@ void ContextMenuController::populate()
 #else
             appendItem(EnterVideoFullscreen, m_contextMenu.get());
 #endif
+#if PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)
+            appendItem(ToggleVideoEnhancedFullscreen, m_contextMenu.get());
+#endif
             appendItem(*separatorItem(), m_contextMenu.get());
             appendItem(CopyMediaLinkItem, m_contextMenu.get());
             appendItem(OpenMediaInNewWindowItem, m_contextMenu.get());
@@ -1362,6 +1371,12 @@ void ContextMenuController::checkOrEnableIfNeeded(ContextMenuItem& item) const
         case ContextMenuItemTagEnterVideoFullscreen:
             shouldEnable = m_context.hitTestResult().mediaSupportsFullscreen();
             break;
+        case ContextMenuItemTagToggleVideoEnhancedFullscreen:
+#if PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)
+            item.setTitle(m_context.hitTestResult().mediaIsInEnhancedFullscreen() ? contextMenuItemTagExitVideoEnhancedFullscreen() : contextMenuItemTagEnterVideoEnhancedFullscreen());
+#endif
+            shouldEnable = m_context.hitTestResult().mediaSupportsEnhancedFullscreen();
+            break;
         case ContextMenuItemTagOpenFrameInNewWindow:
         case ContextMenuItemTagSpellingGuess:
         case ContextMenuItemTagOther:
index fa53c22..c65cc81 100644 (file)
@@ -146,7 +146,8 @@ enum ContextMenuAction {
     ContextMenuItemTagMediaMute,
     ContextMenuItemTagDictationAlternative,
     ContextMenuItemTagToggleVideoFullscreen,
-    ContextMenuItemTagShareMenu, 
+    ContextMenuItemTagShareMenu,
+    ContextMenuItemTagToggleVideoEnhancedFullscreen,
     ContextMenuItemBaseCustomTag = 5000,
     ContextMenuItemLastCustomTag = 5999,
     ContextMenuItemBaseApplicationTag = 10000
index 4ca3d92..16d22d6 100644 (file)
@@ -507,6 +507,24 @@ String contextMenuItemTagExitVideoFullscreen()
     return WEB_UI_STRING("Exit Full Screen", "Video Exit Fullscreen context menu item");
 }
 
+#if PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)
+
+#if USE(APPLE_INTERNAL_SDK)
+#include <WebKitAdditions/ContextMenuLocalizedStringsAdditions.cpp>
+#else
+String contextMenuItemTagEnterVideoEnhancedFullscreen()
+{
+    return { };
+}
+
+String contextMenuItemTagExitVideoEnhancedFullscreen()
+{
+    return { };
+}
+#endif
+
+#endif
+
 String contextMenuItemTagMediaPlay()
 {
     return WEB_UI_STRING("Play", "Media Play context menu item");
index f0eac4f..9f5915c 100644 (file)
@@ -139,6 +139,10 @@ namespace WebCore {
     String contextMenuItemTagToggleMediaLoop();
     String contextMenuItemTagEnterVideoFullscreen();
     String contextMenuItemTagExitVideoFullscreen();
+#if PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)
+    String contextMenuItemTagEnterVideoEnhancedFullscreen();
+    String contextMenuItemTagExitVideoEnhancedFullscreen();
+#endif
     String contextMenuItemTagMediaPlay();
     String contextMenuItemTagMediaPause();
     String contextMenuItemTagMediaMute();
index 1a3f6ae..97498e8 100644 (file)
@@ -773,4 +773,22 @@ Element* HitTestResult::innerNonSharedElement() const
     return node->parentElement();
 }
 
+#if USE(APPLE_INTERNAL_SDK)
+#include <WebKitAdditions/HitTestResultAdditions.cpp>
+#else
+bool HitTestResult::mediaSupportsEnhancedFullscreen() const
+{
+    return false;
+}
+
+bool HitTestResult::mediaIsInEnhancedFullscreen() const
+{
+    return false;
+}
+
+void HitTestResult::toggleEnhancedFullscreenForVideo() const
+{
+}
+#endif
+
 } // namespace WebCore
index e855074..fb08388 100644 (file)
@@ -127,6 +127,10 @@ public:
     WEBCORE_EXPORT bool mediaIsVideo() const;
     bool mediaMuted() const;
     void toggleMediaMuteState() const;
+    bool mediaSupportsEnhancedFullscreen() const;
+    bool mediaIsInEnhancedFullscreen() const;
+    void toggleEnhancedFullscreenForVideo() const;
+
     WEBCORE_EXPORT bool isDownloadableMedia() const;
     WEBCORE_EXPORT bool isOverTextInsideFormControlElement() const;
     WEBCORE_EXPORT bool allowsCopy() const;
index ae3839e..23b8be9 100644 (file)
@@ -1,3 +1,15 @@
+2016-03-30  Ada Chan  <adachan@apple.com>
+
+        Add the new "toggle enhanced fullscreen" context menu item to the video context menu on supporting platforms.
+        https://bugs.webkit.org/show_bug.cgi?id=156031
+
+        Reviewed by Eric Carlson.
+
+        * WebView/WebHTMLView.mm:
+        (toAction):
+        (toTag):
+        * WebView/WebUIDelegatePrivate.h:
+
 2016-03-24  Said Abou-Hallawa  <sabouhallawa@apple,com>
 
         Change NativeImagePtr for CG to be RetainPtr<CGImageRef>
index 3da100a..18c1b6f 100644 (file)
@@ -347,6 +347,8 @@ static Optional<ContextMenuAction> toAction(NSInteger tag)
         return ContextMenuItemTagToggleMediaLoop;
     case WebMenuItemTagEnterVideoFullscreen:
         return ContextMenuItemTagEnterVideoFullscreen;
+    case WebMenuItemTagToggleVideoEnhancedFullscreen:
+        return ContextMenuItemTagToggleVideoEnhancedFullscreen;
     case WebMenuItemTagMediaPlayPause:
         return ContextMenuItemTagMediaPlayPause;
     case WebMenuItemTagMediaMute:
@@ -533,6 +535,8 @@ static Optional<NSInteger> toTag(ContextMenuAction action)
         return WebMenuItemTagToggleVideoFullscreen;
     case ContextMenuItemTagShareMenu:
         return WebMenuItemTagShareMenu;
+    case ContextMenuItemTagToggleVideoEnhancedFullscreen:
+        return WebMenuItemTagToggleVideoEnhancedFullscreen;
 
     case ContextMenuItemBaseCustomTag ... ContextMenuItemLastCustomTag:
         // We just pass these through.
index 84155e8..eea9b4e 100644 (file)
@@ -102,6 +102,7 @@ enum {
     WebMenuItemTagDictationAlternative,
     WebMenuItemTagToggleVideoFullscreen,
     WebMenuItemTagShareMenu,
+    WebMenuItemTagToggleVideoEnhancedFullscreen,
 };
 
 // Deprecated; remove when there are no more clients.
index ff9a2b1..5c4ead6 100644 (file)
@@ -1,3 +1,15 @@
+2016-03-30  Ada Chan  <adachan@apple.com>
+
+        Add the new "toggle enhanced fullscreen" context menu item to the video context menu on supporting platforms.
+        https://bugs.webkit.org/show_bug.cgi?id=156031
+
+        Reviewed by Eric Carlson.
+
+        * Shared/API/c/WKContextMenuItemTypes.h:
+        * Shared/API/c/WKSharedAPICast.h:
+        (WebKit::toAPI):
+        (WebKit::toImpl):
+
 2016-03-31  Brent Fulgham  <bfulgham@apple.com>
 
         Unreviewed build fix after r198893.
index 33ef0ff..2a67631 100644 (file)
@@ -122,6 +122,7 @@ enum {
     kWKContextMenuItemTagOpenLinkInThisWindow,
     kWKContextMenuItemTagToggleVideoFullscreen,
     kWKContextMenuItemTagShareMenu,
+    kWKContextMenuItemTagToggleVideoEnhancedFullscreen,
     kWKContextMenuItemBaseApplicationTag = 10000
 };
 typedef uint32_t WKContextMenuItemTag;
index e24b179..f0ea5ac 100644 (file)
@@ -472,6 +472,8 @@ inline WKContextMenuItemTag toAPI(WebCore::ContextMenuAction action)
         return kWKContextMenuItemTagToggleVideoFullscreen;
     case WebCore::ContextMenuItemTagEnterVideoFullscreen:
         return kWKContextMenuItemTagEnterVideoFullscreen;
+    case WebCore::ContextMenuItemTagToggleVideoEnhancedFullscreen:
+        return kWKContextMenuItemTagToggleVideoEnhancedFullscreen;
     case WebCore::ContextMenuItemTagMediaPlayPause:
         return kWKContextMenuItemTagMediaPlayPause;
     case WebCore::ContextMenuItemTagMediaMute:
@@ -664,6 +666,8 @@ inline WebCore::ContextMenuAction toImpl(WKContextMenuItemTag tag)
         return WebCore::ContextMenuItemTagToggleVideoFullscreen;
     case kWKContextMenuItemTagEnterVideoFullscreen:
         return WebCore::ContextMenuItemTagEnterVideoFullscreen;
+    case kWKContextMenuItemTagToggleVideoEnhancedFullscreen:
+        return WebCore::ContextMenuItemTagToggleVideoEnhancedFullscreen;
     case kWKContextMenuItemTagMediaPlayPause:
         return WebCore::ContextMenuItemTagMediaPlayPause;
     case kWKContextMenuItemTagMediaMute: