Implement basic functionality in WebVideoFullscreenInterfaceMac.
authoradachan@apple.com <adachan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 23 Feb 2016 00:40:16 +0000 (00:40 +0000)
committeradachan@apple.com <adachan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 23 Feb 2016 00:40:16 +0000 (00:40 +0000)
https://bugs.webkit.org/show_bug.cgi?id=153241

Reviewed by Beth Dakin.

Source/WebCore:

* platform/cocoa/WebVideoFullscreenInterface.h:
* platform/mac/WebVideoFullscreenInterfaceMac.h:
* platform/mac/WebVideoFullscreenInterfaceMac.mm:
(WebCore::WebVideoFullscreenInterfaceMac::setupFullscreen):
(WebCore::WebVideoFullscreenInterfaceMac::enterFullscreen):
(WebCore::WebVideoFullscreenInterfaceMac::exitFullscreen):
(WebCore::WebVideoFullscreenInterfaceMac::cleanupFullscreen):
(WebCore::WebVideoFullscreenInterfaceMac::invalidate):
(WebCore::WebVideoFullscreenInterfaceMac::preparedToReturnToInline):

Source/WebKit2:

* UIProcess/Cocoa/WebVideoFullscreenManagerProxy.mm:
(WebKit::WebVideoFullscreenManagerProxy::setupFullscreenWithID):
(WebKit::WebVideoFullscreenManagerProxy::exitFullscreen):
(WebKit::WebVideoFullscreenManagerProxy::preparedToReturnToInline):
* UIProcess/PageClient.h:
* UIProcess/WebPageProxy.h:
* UIProcess/mac/PageClientImpl.h:
* UIProcess/mac/PageClientImpl.mm:
(WebKit::PageClientImpl::rootViewToWindow):
* UIProcess/mac/WebPageProxyMac.mm:
(WebKit::WebPageProxy::rootViewToWindow):
* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::supportsVideoFullscreen):
* WebProcess/cocoa/WebVideoFullscreenManager.h:
* WebProcess/cocoa/WebVideoFullscreenManager.mm:
(WebKit::WebVideoFullscreenManager::supportsVideoFullscreen):

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

14 files changed:
Source/WebCore/ChangeLog
Source/WebCore/platform/cocoa/WebVideoFullscreenInterface.h
Source/WebCore/platform/mac/WebVideoFullscreenInterfaceMac.h
Source/WebCore/platform/mac/WebVideoFullscreenInterfaceMac.mm
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/Cocoa/WebVideoFullscreenManagerProxy.mm
Source/WebKit2/UIProcess/PageClient.h
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/UIProcess/mac/PageClientImpl.h
Source/WebKit2/UIProcess/mac/PageClientImpl.mm
Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm
Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp
Source/WebKit2/WebProcess/cocoa/WebVideoFullscreenManager.h
Source/WebKit2/WebProcess/cocoa/WebVideoFullscreenManager.mm

index b416d58..144011c 100644 (file)
@@ -1,3 +1,20 @@
+2016-02-16  Ada Chan  <adachan@apple.com>
+
+        Implement basic functionality in WebVideoFullscreenInterfaceMac.
+        https://bugs.webkit.org/show_bug.cgi?id=153241
+
+        Reviewed by Beth Dakin.
+
+        * platform/cocoa/WebVideoFullscreenInterface.h:
+        * platform/mac/WebVideoFullscreenInterfaceMac.h:
+        * platform/mac/WebVideoFullscreenInterfaceMac.mm:
+        (WebCore::WebVideoFullscreenInterfaceMac::setupFullscreen):
+        (WebCore::WebVideoFullscreenInterfaceMac::enterFullscreen):
+        (WebCore::WebVideoFullscreenInterfaceMac::exitFullscreen):
+        (WebCore::WebVideoFullscreenInterfaceMac::cleanupFullscreen):
+        (WebCore::WebVideoFullscreenInterfaceMac::invalidate):
+        (WebCore::WebVideoFullscreenInterfaceMac::preparedToReturnToInline):
+
 2016-02-22  Chris Dumez  <cdumez@apple.com>
 
         REGRESSION (r196563): Images not loading on https://klim.co.nz/blog/paypal-sans-design-information/
index d9112df..c6d9bff 100644 (file)
@@ -36,7 +36,7 @@ class String;
 
 namespace WebCore {
 
-bool supportsPictureInPicture();
+WEBCORE_EXPORT bool supportsPictureInPicture();
 
 class TimeRanges;
 
index 285807d..685a67b 100644 (file)
 #include <wtf/RetainPtr.h>
 #include <wtf/text/WTFString.h>
 
+OBJC_CLASS NSWindow;
+
+#if USE(APPLE_INTERNAL_SDK)
+OBJC_CLASS WebVideoFullscreenInterfaceMacObjC;
+#endif
+
 namespace WebCore {
 class IntRect;
 class WebVideoFullscreenChangeObserver;
@@ -49,7 +55,9 @@ public:
         return adoptRef(*new WebVideoFullscreenInterfaceMac());
     }
     virtual ~WebVideoFullscreenInterfaceMac();
+    WebVideoFullscreenModel* webVideoFullscreenModel() const { return m_videoFullscreenModel; }
     WEBCORE_EXPORT void setWebVideoFullscreenModel(WebVideoFullscreenModel*);
+    WebVideoFullscreenChangeObserver* webVideoFullscreenChangeObserver() const { return m_fullscreenChangeObserver; }
     WEBCORE_EXPORT void setWebVideoFullscreenChangeObserver(WebVideoFullscreenChangeObserver*);
 
     WEBCORE_EXPORT void resetMediaState() override { }
@@ -65,13 +73,13 @@ public:
     WEBCORE_EXPORT void setExternalPlayback(bool /*enabled*/, ExternalPlaybackTargetType, WTF::String /*localizedDeviceName*/) override { }
     WEBCORE_EXPORT void setWirelessVideoPlaybackDisabled(bool) override { }
 
-    WEBCORE_EXPORT void setupFullscreen(NSView& /*layerHostedView*/, const IntRect& /*initialRect*/, HTMLMediaElementEnums::VideoFullscreenMode, bool /*allowsPictureInPicturePlayback*/) { }
-    WEBCORE_EXPORT void enterFullscreen() { }
-    WEBCORE_EXPORT void exitFullscreen(const IntRect& /*finalRect*/) { }
-    WEBCORE_EXPORT void cleanupFullscreen() { }
-    WEBCORE_EXPORT void invalidate() { }
+    WEBCORE_EXPORT void setupFullscreen(NSView& layerHostedView, const IntRect& initialRect, NSWindow *parentWindow, HTMLMediaElementEnums::VideoFullscreenMode, bool allowsPictureInPicturePlayback);
+    WEBCORE_EXPORT void enterFullscreen();
+    WEBCORE_EXPORT void exitFullscreen(const IntRect& finalRect, NSWindow *parentWindow);
+    WEBCORE_EXPORT void cleanupFullscreen();
+    WEBCORE_EXPORT void invalidate();
     WEBCORE_EXPORT void requestHideAndExitFullscreen() { }
-    WEBCORE_EXPORT void preparedToReturnToInline(bool /*visible*/, const IntRect& /*inlineRect*/) { }
+    WEBCORE_EXPORT void preparedToReturnToInline(bool visible, const IntRect& inlineRect, NSWindow *parentWindow);
 
     HTMLMediaElementEnums::VideoFullscreenMode mode() const { return m_mode; }
     bool hasMode(HTMLMediaElementEnums::VideoFullscreenMode mode) const { return m_mode & mode; }
@@ -82,10 +90,14 @@ public:
     WEBCORE_EXPORT bool mayAutomaticallyShowVideoPictureInPicture() const { return false; }
     void applicationDidBecomeActive() { }
 
-protected:
+private:
     WebVideoFullscreenModel* m_videoFullscreenModel { nullptr };
     WebVideoFullscreenChangeObserver* m_fullscreenChangeObserver { nullptr };
     HTMLMediaElementEnums::VideoFullscreenMode m_mode { HTMLMediaElementEnums::VideoFullscreenModeNone };
+
+#if USE(APPLE_INTERNAL_SDK)
+    RetainPtr<WebVideoFullscreenInterfaceMacObjC> m_webVideoFullscreenInterfaceObjC;
+#endif
 };
 
 }
index d838f25..1faec25 100644 (file)
 #import "WebVideoFullscreenChangeObserver.h"
 #import "WebVideoFullscreenModel.h"
 
+#if USE(APPLE_INTERNAL_SDK)
+#include <WebKitAdditions/WebVideoFullscreenInterfaceMacAdditions.mm>
+#endif
+
 namespace WebCore {
 
 WebVideoFullscreenInterfaceMac::~WebVideoFullscreenInterfaceMac()
@@ -70,10 +74,36 @@ void WebVideoFullscreenInterfaceMac::clearMode(HTMLMediaElementEnums::VideoFulls
         m_videoFullscreenModel->fullscreenModeChanged(m_mode);
 }
 
+#if !USE(APPLE_INTERNAL_SDK)
+void WebVideoFullscreenInterfaceMac::setupFullscreen(NSView&, const IntRect&, NSWindow *, HTMLMediaElementEnums::VideoFullscreenMode, bool)
+{
+}
+
+void WebVideoFullscreenInterfaceMac::enterFullscreen()
+{
+}
+
+void WebVideoFullscreenInterfaceMac::exitFullscreen(const IntRect&, NSWindow *)
+{
+}
+
+void WebVideoFullscreenInterfaceMac::cleanupFullscreen()
+{
+}
+
+void WebVideoFullscreenInterfaceMac::invalidate()
+{
+}
+
+void WebVideoFullscreenInterfaceMac::preparedToReturnToInline(bool, const IntRect&, NSWindow *)
+{
+}
+
 bool supportsPictureInPicture()
 {
     return false;
 }
+#endif
 
 }
 
index d0616c5..2d4214b 100644 (file)
@@ -1,3 +1,27 @@
+2016-02-16  Ada Chan  <adachan@apple.com>
+
+        Implement basic functionality in WebVideoFullscreenInterfaceMac.
+        https://bugs.webkit.org/show_bug.cgi?id=153241
+
+        Reviewed by Beth Dakin.
+
+        * UIProcess/Cocoa/WebVideoFullscreenManagerProxy.mm:
+        (WebKit::WebVideoFullscreenManagerProxy::setupFullscreenWithID):
+        (WebKit::WebVideoFullscreenManagerProxy::exitFullscreen):
+        (WebKit::WebVideoFullscreenManagerProxy::preparedToReturnToInline):
+        * UIProcess/PageClient.h:
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/mac/PageClientImpl.h:
+        * UIProcess/mac/PageClientImpl.mm:
+        (WebKit::PageClientImpl::rootViewToWindow):
+        * UIProcess/mac/WebPageProxyMac.mm:
+        (WebKit::WebPageProxy::rootViewToWindow):
+        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+        (WebKit::WebChromeClient::supportsVideoFullscreen):
+        * WebProcess/cocoa/WebVideoFullscreenManager.h:
+        * WebProcess/cocoa/WebVideoFullscreenManager.mm:
+        (WebKit::WebVideoFullscreenManager::supportsVideoFullscreen):
+
 2016-02-22  Commit Queue  <commit-queue@webkit.org>
 
         Unreviewed, rolling out r196935.
index 7b2c5b3..95ea011 100644 (file)
@@ -368,7 +368,9 @@ void WebVideoFullscreenManagerProxy::setupFullscreenWithID(uint64_t contextId, u
     UIView *parentView = downcast<RemoteLayerTreeDrawingAreaProxy>(*m_page->drawingArea()).remoteLayerTreeHost().rootLayer();
     interface->setupFullscreen(*model->layerHostView(), initialRect, parentView, videoFullscreenMode, allowsPictureInPicture);
 #else
-    interface->setupFullscreen(*model->layerHostView(), initialRect, videoFullscreenMode, allowsPictureInPicture);
+    IntRect initialWindowRect;
+    m_page->rootViewToWindow(initialRect, initialWindowRect);
+    interface->setupFullscreen(*model->layerHostView(), initialWindowRect, m_page->platformWindow(), videoFullscreenMode, allowsPictureInPicture);
 #endif
 }
 
@@ -462,7 +464,13 @@ void WebVideoFullscreenManagerProxy::enterFullscreen(uint64_t contextId)
 
 void WebVideoFullscreenManagerProxy::exitFullscreen(uint64_t contextId, WebCore::IntRect finalRect)
 {
+#if PLATFORM(IOS)
     ensureInterface(contextId).exitFullscreen(finalRect);
+#else
+    IntRect finalWindowRect;
+    m_page->rootViewToWindow(finalRect, finalWindowRect);
+    ensureInterface(contextId).exitFullscreen(finalWindowRect, m_page->platformWindow());
+#endif
 }
 
 void WebVideoFullscreenManagerProxy::cleanupFullscreen(uint64_t contextId)
@@ -474,7 +482,13 @@ void WebVideoFullscreenManagerProxy::preparedToReturnToInline(uint64_t contextId
 {
     m_page->fullscreenMayReturnToInline();
 
+#if PLATFORM(IOS)
     ensureInterface(contextId).preparedToReturnToInline(visible, inlineRect);
+#else
+    IntRect inlineWindowRect;
+    m_page->rootViewToWindow(inlineRect, inlineWindowRect);
+    ensureInterface(contextId).preparedToReturnToInline(visible, inlineWindowRect, m_page->platformWindow());
+#endif
 }
 
 #pragma mark Messages to WebVideoFullscreenManager
index b5760b7..0812857 100644 (file)
@@ -209,6 +209,9 @@ public:
     virtual WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&) = 0;
     virtual WebCore::IntPoint screenToRootView(const WebCore::IntPoint&) = 0;
     virtual WebCore::IntRect rootViewToScreen(const WebCore::IntRect&) = 0;
+#if PLATFORM(MAC)
+    virtual WebCore::IntRect rootViewToWindow(const WebCore::IntRect&) = 0;
+#endif
 #if PLATFORM(IOS)
     virtual WebCore::IntPoint accessibilityScreenToRootView(const WebCore::IntPoint&) = 0;
     virtual WebCore::IntRect rootViewToAccessibilityScreen(const WebCore::IntRect&) = 0;
index 681bd9a..f23194e 100644 (file)
@@ -581,6 +581,7 @@ public:
 
     void startWindowDrag();
     NSWindow *platformWindow();
+    void rootViewToWindow(const WebCore::IntRect& viewRect, WebCore::IntRect& windowRect);
 
 #if WK_API_ENABLED
     NSView *inspectorAttachmentView();
index 1dc8cf6..f218c8f 100644 (file)
@@ -113,6 +113,9 @@ private:
     virtual WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&) override;
     virtual WebCore::IntPoint screenToRootView(const WebCore::IntPoint&) override;
     virtual WebCore::IntRect rootViewToScreen(const WebCore::IntRect&) override;
+#if PLATFORM(MAC)
+    virtual WebCore::IntRect rootViewToWindow(const WebCore::IntRect&) override;
+#endif
 #if PLATFORM(IOS)
     virtual WebCore::IntPoint accessibilityScreenToRootView(const WebCore::IntPoint&) = 0;
     virtual WebCore::IntRect rootViewToAccessibilityScreen(const WebCore::IntRect&) = 0;
index 121047f..ab231c7 100644 (file)
@@ -421,6 +421,15 @@ IntRect PageClientImpl::rootViewToScreen(const IntRect& rect)
     return enclosingIntRect(tempRect);
 }
 
+#if PLATFORM(MAC)
+IntRect PageClientImpl::rootViewToWindow(const WebCore::IntRect& rect)
+{
+    NSRect tempRect = rect;
+    tempRect = [m_view convertRect:tempRect toView:nil];
+    return enclosingIntRect(tempRect);
+}
+#endif
+
 void PageClientImpl::doneWithKeyEvent(const NativeWebKeyboardEvent& event, bool eventWasHandled)
 {
     m_impl->doneWithKeyEvent(event.nativeEvent(), eventWasHandled);
index 522f815..67858f2 100644 (file)
@@ -584,6 +584,11 @@ NSWindow *WebPageProxy::platformWindow()
     return m_pageClient.platformWindow();
 }
 
+void WebPageProxy::rootViewToWindow(const WebCore::IntRect& viewRect, WebCore::IntRect& windowRect)
+{
+    windowRect = m_pageClient.rootViewToWindow(viewRect);
+}
+
 #if WK_API_ENABLED
 NSView *WebPageProxy::inspectorAttachmentView()
 {
index 09e3262..bf57cbf 100644 (file)
@@ -850,9 +850,9 @@ PassRefPtr<ScrollingCoordinator> WebChromeClient::createScrollingCoordinator(Pag
 #endif
 
 #if PLATFORM(IOS) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
-bool WebChromeClient::supportsVideoFullscreen(WebCore::HTMLMediaElementEnums::VideoFullscreenMode)
+bool WebChromeClient::supportsVideoFullscreen(WebCore::HTMLMediaElementEnums::VideoFullscreenMode mode)
 {
-    return m_page->videoFullscreenManager()->supportsVideoFullscreen();
+    return m_page->videoFullscreenManager()->supportsVideoFullscreen(mode);
 }
 
 void WebChromeClient::enterVideoFullscreenForVideoElement(WebCore::HTMLVideoElement& videoElement, WebCore::HTMLMediaElementEnums::VideoFullscreenMode mode)
index 0961407..d3dac4e 100644 (file)
@@ -113,7 +113,7 @@ public:
     void didReceiveMessage(IPC::Connection&, IPC::MessageDecoder&) override;
 
     // Interface to ChromeClient
-    bool supportsVideoFullscreen() const;
+    bool supportsVideoFullscreen(WebCore::HTMLMediaElementEnums::VideoFullscreenMode) const;
     void enterVideoFullscreenForVideoElement(WebCore::HTMLVideoElement&, WebCore::HTMLMediaElementEnums::VideoFullscreenMode);
     void exitVideoFullscreenForVideoElement(WebCore::HTMLVideoElement&);
     
index b9b6f35..2824481 100644 (file)
@@ -217,12 +217,14 @@ WebVideoFullscreenInterfaceContext& WebVideoFullscreenManager::ensureInterface(u
 
 #pragma mark Interface to ChromeClient:
 
-bool WebVideoFullscreenManager::supportsVideoFullscreen() const
+bool WebVideoFullscreenManager::supportsVideoFullscreen(WebCore::HTMLMediaElementEnums::VideoFullscreenMode mode) const
 {
 #if PLATFORM(IOS)
+    UNUSED_PARAM(mode);
     return Settings::avKitEnabled();
+#elif USE(APPLE_INTERNAL_SDK)
+#import <WebKitAdditions/WebVideoFullscreenManagerSupportsVideoFullscreenMac.mm>
 #else
-    // FIXME 153241: Return false until more of WebVideoFullscreenInterfaceMac has been implemented.
     return false;
 #endif
 }