Title: [164617] trunk/Source
Revision
164617
Author
[email protected]
Date
2014-02-24 16:40:06 -0800 (Mon, 24 Feb 2014)

Log Message

WK2 AVKit fullscreen doesn't display video.
https://bugs.webkit.org/show_bug.cgi?id=128564

Patch by Jeremy Jones <[email protected]> on 2014-02-24
Reviewed by Simon Fraser.

Source/WebCore:

* WebCore.exp.in:
Export WebCore::PlatformCALayer::platformCALayer()

* platform/ios/WebVideoFullscreenInterface.h:
* platform/ios/WebVideoFullscreenInterfaceAVKit.h:
Remove SetVideoLayerID().

* platform/ios/WebVideoFullscreenInterfaceAVKit.mm:
(WebVideoFullscreenInterfaceAVKit::setVideoLayer):
Wrap make video layer look like an AVAVPlayerLayer with WebAVPlayerLayer

* platform/ios/WebVideoFullscreenModelMediaElement.mm:
(WebVideoFullscreenModelMediaElement::setMediaElement):
Pass along the videoLayer before borrowing it so the interface will be ready to
catch the transaction that removes it.

Source/WebKit2:

* Shared/mac/RemoteLayerTreeTransaction.h:
Add a property to track video layer pending fullscreen.

(WebKit::RemoteLayerTreeTransaction::isVideoLayerIDPendingFullscreen):
(WebKit::RemoteLayerTreeTransaction::addVideoLayerIDPendingFullscreen):
Add a property to track video layer pending fullscreen.

* Shared/mac/RemoteLayerTreeTransaction.mm:
(WebKit::RemoteLayerTreeTransaction::encode):
(WebKit::RemoteLayerTreeTransaction::decode):
Encode and decode m_videoLayerIDsPendingFullscreen.

* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::didCommitLayerTree):
Let WebVideoFullscreenManagerProxy see the RemoteLayerTreeTransaction.

* UIProcess/ios/WebVideoFullscreenManagerProxy.cpp:
(WebKit::WebVideoFullscreenManagerProxy::didCommitLayerTree):
Look for video layer pending fullscreen on the transaction to initiate
fullscreen.

(WebKit::WebVideoFullscreenManagerProxy::setVideoLayerID):
Start looking for the video layer pending fullscreen in the transaction.

(WebKit::WebVideoFullscreenManagerProxy::enterFullscreen):
Override to prevent fullscreen from happening before the layer
is pending fullscreen.

* UIProcess/ios/WebVideoFullscreenManagerProxy.h:
* UIProcess/ios/WebVideoFullscreenManagerProxy.messages.in:
Pass a more specific videoLayerID in SetVideoLayerID,
i.e. WebCore::GraphicsLayer::PlatformLayerID.

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::willCommitLayerTree):
Move webPage specific transaction building here, including,
giving WebVideoFullscreenManager a chance to modify the transaction.

* WebProcess/WebPage/WebPage.h:
Add willCommitLayerTree();

* WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.mm:
(PlatformCALayerRemoteCustom::PlatformCALayerRemoteCustom):
(PlatformCALayerRemoteCustom::~PlatformCALayerRemoteCustom):
Make and break the connection from CALayer to PlatformCALayerRemoteCustom,
the same way it is done for PlatformCALayerMac.

* WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm:
(WebKit::RemoteLayerTreeDrawingArea::flushLayers):
Move WebPage specific transaction building into WebPage::willCommitLayerTree.

* WebProcess/ios/WebVideoFullscreenManager.cpp:
(WebKit::WebVideoFullscreenManager::willCommitLayerTree):
addVideoLayerIDPendingFullscreen on RemoteLayerTreeTransaction when needed.

(WebKit::WebVideoFullscreenManager::setVideoLayer):
Pass along the video layerID.

* WebProcess/ios/WebVideoFullscreenManager.h:
Add willCommitLayerTree() and remove setVideoLayerID().
Add a member to retain the unparented PlatformCALayer.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (164616 => 164617)


--- trunk/Source/WebCore/ChangeLog	2014-02-25 00:29:28 UTC (rev 164616)
+++ trunk/Source/WebCore/ChangeLog	2014-02-25 00:40:06 UTC (rev 164617)
@@ -1,3 +1,26 @@
+2014-02-24  Jeremy Jones  <[email protected]>
+
+        WK2 AVKit fullscreen doesn't display video.
+        https://bugs.webkit.org/show_bug.cgi?id=128564
+
+        Reviewed by Simon Fraser.
+
+        * WebCore.exp.in:
+        Export WebCore::PlatformCALayer::platformCALayer()
+
+        * platform/ios/WebVideoFullscreenInterface.h:
+        * platform/ios/WebVideoFullscreenInterfaceAVKit.h:
+        Remove SetVideoLayerID(). 
+
+        * platform/ios/WebVideoFullscreenInterfaceAVKit.mm:
+        (WebVideoFullscreenInterfaceAVKit::setVideoLayer):
+        Wrap make video layer look like an AVAVPlayerLayer with WebAVPlayerLayer
+
+        * platform/ios/WebVideoFullscreenModelMediaElement.mm:
+        (WebVideoFullscreenModelMediaElement::setMediaElement):
+        Pass along the videoLayer before borrowing it so the interface will be ready to
+        catch the transaction that removes it.
+
 2014-02-24  Samuel White  <[email protected]>
 
         AX: AccessibilityObject::findMatchingObjects should never include 'this' in results.

Modified: trunk/Source/WebCore/WebCore.exp.in (164616 => 164617)


--- trunk/Source/WebCore/WebCore.exp.in	2014-02-25 00:29:28 UTC (rev 164616)
+++ trunk/Source/WebCore/WebCore.exp.in	2014-02-25 00:40:06 UTC (rev 164617)
@@ -589,6 +589,7 @@
 __ZN7WebCore15JSDOMWindowBase8commonVMEv
 __ZN7WebCore15PasteboardImageC1Ev
 __ZN7WebCore15PasteboardImageD1Ev
+__ZN7WebCore15PlatformCALayer15platformCALayerEPv
 __ZN7WebCore15PlatformCALayerC2ENS0_9LayerTypeEPNS_21PlatformCALayerClientE
 __ZN7WebCore15PlatformCALayerD2Ev
 __ZN7WebCore15ProtectionSpaceC1ERKN3WTF6StringEiNS_25ProtectionSpaceServerTypeES4_NS_35ProtectionSpaceAuthenticationSchemeE

Modified: trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterface.h (164616 => 164617)


--- trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterface.h	2014-02-25 00:29:28 UTC (rev 164616)
+++ trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterface.h	2014-02-25 00:40:06 UTC (rev 164617)
@@ -41,7 +41,6 @@
     virtual void setRate(bool isPlaying, float playbackRate) = 0;
     virtual void setVideoDimensions(bool hasVideo, float width, float height) = 0;
     virtual void setVideoLayer(PlatformLayer*) = 0;
-    virtual void setVideoLayerID(uint32_t) = 0;
     virtual void enterFullscreen() = 0;
     virtual void exitFullscreen() = 0;
 };

Modified: trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.h (164616 => 164617)


--- trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.h	2014-02-25 00:29:28 UTC (rev 164616)
+++ trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.h	2014-02-25 00:40:06 UTC (rev 164617)
@@ -66,7 +66,6 @@
     void setRate(bool isPlaying, float playbackRate) override;
     void setVideoDimensions(bool hasVideo, float width, float height) override;
     void setVideoLayer(PlatformLayer*) override;
-    void setVideoLayerID(uint32_t) override { };
     void enterFullscreen() override;
     void enterFullscreenWithCompletionHandler(std::function<void()>);
     void exitFullscreen() override;

Modified: trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.mm (164616 => 164617)


--- trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.mm	2014-02-25 00:29:28 UTC (rev 164616)
+++ trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.mm	2014-02-25 00:40:06 UTC (rev 164617)
@@ -68,6 +68,9 @@
 @end
 
 @protocol AVPlayerLayer
+@property (nonatomic, copy) NSString *videoGravity;
+@property (nonatomic, readonly, getter = isReadyForDisplay) BOOL readyForDisplay;
+@property (nonatomic, readonly) CGRect videoRect;
 @end
 
 @interface AVPlayerController : UIResponder
@@ -202,6 +205,20 @@
 
 @end
 
+@interface WebAVPlayerLayer : CALayer <AVPlayerLayer>
++(WebAVPlayerLayer *)playerLayer;
+@property (nonatomic, copy) NSString *videoGravity;
+@property (nonatomic, getter = isReadyForDisplay) BOOL readyForDisplay;
+@property (nonatomic) CGRect videoRect;
+@end
+
+@implementation WebAVPlayerLayer
++(WebAVPlayerLayer *)playerLayer
+{
+    return [[[WebAVPlayerLayer alloc] init] autorelease];
+}
+@end
+
 WebVideoFullscreenInterfaceAVKit::WebVideoFullscreenInterfaceAVKit()
     : m_videoFullscreenModel(nullptr)
 {
@@ -278,10 +295,19 @@
 {
     [playerController().playerLayer removeFromSuperlayer];
     [videoLayer removeFromSuperlayer];
-    ASSERT(!videoLayer
-        || [videoLayer isKindOfClass:[classAVPlayerLayer class]]
-        || ([videoLayer isKindOfClass:[CALayer class]] && [videoLayer conformsToProtocol:@protocol(AVPlayerLayer)]));
-    playerController().playerLayer = (CALayer<AVPlayerLayer>*)videoLayer;
+    
+    CALayer<AVPlayerLayer> *avPlayerLayer = nil;
+    
+    // WebKit provides a AVPlayerLayer. WebKit2 provies a hosted layer.
+    if ([videoLayer isKindOfClass:[classAVPlayerLayer class]])
+        avPlayerLayer = (CALayer<AVPlayerLayer>*)videoLayer;
+    else if (videoLayer) {
+        ASSERT([videoLayer isKindOfClass:[CALayer class]]);
+        avPlayerLayer = [WebAVPlayerLayer playerLayer];
+        [avPlayerLayer addSublayer:videoLayer];
+    }
+
+    m_playerController.get().playerLayer = avPlayerLayer;
 }
 
 void WebVideoFullscreenInterfaceAVKit::enterFullscreenWithCompletionHandler(std::function<void()> completion)

Modified: trunk/Source/WebCore/platform/ios/WebVideoFullscreenModelMediaElement.mm (164616 => 164617)


--- trunk/Source/WebCore/platform/ios/WebVideoFullscreenModelMediaElement.mm	2014-02-25 00:29:28 UTC (rev 164616)
+++ trunk/Source/WebCore/platform/ios/WebVideoFullscreenModelMediaElement.mm	2014-02-25 00:40:06 UTC (rev 164617)
@@ -94,8 +94,9 @@
     m_videoFullscreenInterface->setDuration(m_mediaElement->duration());
     m_videoFullscreenInterface->setRate(m_mediaElement->isPlaying(), m_mediaElement->playbackRate());
 
+    m_videoFullscreenInterface->setVideoLayer(m_mediaElement->platformLayer());
+
     m_borrowedVideoLayer = m_mediaElement->borrowPlatformLayer();
-    m_videoFullscreenInterface->setVideoLayer(m_borrowedVideoLayer.get());
 
     m_videoFullscreenInterface->setCurrentTime(m_mediaElement->currentTime(), [[NSProcessInfo processInfo] systemUptime]);
 

Modified: trunk/Source/WebKit2/ChangeLog (164616 => 164617)


--- trunk/Source/WebKit2/ChangeLog	2014-02-25 00:29:28 UTC (rev 164616)
+++ trunk/Source/WebKit2/ChangeLog	2014-02-25 00:40:06 UTC (rev 164617)
@@ -1,3 +1,72 @@
+2014-02-24  Jeremy Jones  <[email protected]>
+
+        WK2 AVKit fullscreen doesn't display video.
+        https://bugs.webkit.org/show_bug.cgi?id=128564
+
+        Reviewed by Simon Fraser.
+
+        * Shared/mac/RemoteLayerTreeTransaction.h:
+        Add a property to track video layer pending fullscreen.
+
+        (WebKit::RemoteLayerTreeTransaction::isVideoLayerIDPendingFullscreen):
+        (WebKit::RemoteLayerTreeTransaction::addVideoLayerIDPendingFullscreen):
+        Add a property to track video layer pending fullscreen.
+
+        * Shared/mac/RemoteLayerTreeTransaction.mm:
+        (WebKit::RemoteLayerTreeTransaction::encode):
+        (WebKit::RemoteLayerTreeTransaction::decode):
+        Encode and decode m_videoLayerIDsPendingFullscreen.
+
+        * UIProcess/ios/WebPageProxyIOS.mm:
+        (WebKit::WebPageProxy::didCommitLayerTree):
+        Let WebVideoFullscreenManagerProxy see the RemoteLayerTreeTransaction.
+
+        * UIProcess/ios/WebVideoFullscreenManagerProxy.cpp:
+        (WebKit::WebVideoFullscreenManagerProxy::didCommitLayerTree):
+        Look for video layer pending fullscreen on the transaction to initiate
+        fullscreen.
+
+        (WebKit::WebVideoFullscreenManagerProxy::setVideoLayerID):
+        Start looking for the video layer pending fullscreen in the transaction.
+
+        (WebKit::WebVideoFullscreenManagerProxy::enterFullscreen):
+        Override to prevent fullscreen from happening before the layer
+        is pending fullscreen.
+
+        * UIProcess/ios/WebVideoFullscreenManagerProxy.h:
+        * UIProcess/ios/WebVideoFullscreenManagerProxy.messages.in:
+        Pass a more specific videoLayerID in SetVideoLayerID,
+        i.e. WebCore::GraphicsLayer::PlatformLayerID.
+
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::willCommitLayerTree):
+        Move webPage specific transaction building here, including,
+        giving WebVideoFullscreenManager a chance to modify the transaction.
+
+        * WebProcess/WebPage/WebPage.h:
+        Add willCommitLayerTree();
+
+        * WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.mm:
+        (PlatformCALayerRemoteCustom::PlatformCALayerRemoteCustom):
+        (PlatformCALayerRemoteCustom::~PlatformCALayerRemoteCustom):
+        Make and break the connection from CALayer to PlatformCALayerRemoteCustom,
+        the same way it is done for PlatformCALayerMac.
+
+        * WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm:
+        (WebKit::RemoteLayerTreeDrawingArea::flushLayers):
+        Move WebPage specific transaction building into WebPage::willCommitLayerTree.
+
+        * WebProcess/ios/WebVideoFullscreenManager.cpp:
+        (WebKit::WebVideoFullscreenManager::willCommitLayerTree):
+        addVideoLayerIDPendingFullscreen on RemoteLayerTreeTransaction when needed.
+
+        (WebKit::WebVideoFullscreenManager::setVideoLayer):
+        Pass along the video layerID.
+
+        * WebProcess/ios/WebVideoFullscreenManager.h:
+        Add willCommitLayerTree() and remove setVideoLayerID().
+        Add a member to retain the unparented PlatformCALayer.
+
 2014-02-24  Martin Hock  <[email protected]>
 
         Create SessionID value-style class for session IDs.

Modified: trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.h (164616 => 164617)


--- trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.h	2014-02-25 00:29:28 UTC (rev 164616)
+++ trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.h	2014-02-25 00:40:06 UTC (rev 164617)
@@ -176,6 +176,9 @@
 
     bool allowsUserScaling() const { return m_allowsUserScaling; }
     void setAllowsUserScaling(bool allowsUserScaling) { m_allowsUserScaling = allowsUserScaling; }
+    
+    bool isVideoLayerIDPendingFullscreen(WebCore::GraphicsLayer::PlatformLayerID layerID) const { return m_videoLayerIDsPendingFullscreen.contains(layerID); }
+    void addVideoLayerIDPendingFullscreen(WebCore::GraphicsLayer::PlatformLayerID layerID) { m_videoLayerIDsPendingFullscreen.append(layerID); }
 
 private:
     WebCore::GraphicsLayer::PlatformLayerID m_rootLayerID;
@@ -188,6 +191,7 @@
     double m_minimumScaleFactor;
     double m_maximumScaleFactor;
     bool m_allowsUserScaling;
+    Vector<WebCore::GraphicsLayer::PlatformLayerID> m_videoLayerIDsPendingFullscreen;
 };
 
 } // namespace WebKit

Modified: trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.mm (164616 => 164617)


--- trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.mm	2014-02-25 00:29:28 UTC (rev 164616)
+++ trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.mm	2014-02-25 00:40:06 UTC (rev 164617)
@@ -414,6 +414,7 @@
     encoder << m_maximumScaleFactor;
     encoder << m_allowsUserScaling;
     encoder << m_renderTreeSize;
+    encoder << m_videoLayerIDsPendingFullscreen;
 }
 
 bool RemoteLayerTreeTransaction::decode(IPC::ArgumentDecoder& decoder, RemoteLayerTreeTransaction& result)
@@ -467,6 +468,9 @@
     
     if (!decoder.decode(result.m_renderTreeSize))
         return false;
+    
+    if (!decoder.decode(result.m_videoLayerIDsPendingFullscreen))
+        return false;
 
     return true;
 }

Modified: trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm (164616 => 164617)


--- trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm	2014-02-25 00:29:28 UTC (rev 164616)
+++ trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm	2014-02-25 00:40:06 UTC (rev 164617)
@@ -32,9 +32,10 @@
 #import "WebKitSystemInterfaceIOS.h"
 #import "WebPageMessages.h"
 #import "WebProcessProxy.h"
+#import "WebVideoFullscreenManagerProxy.h"
 #import <WebCore/NotImplemented.h>
+#import <WebCore/SharedBuffer.h>
 #import <WebCore/UserAgent.h>
-#import <WebCore/SharedBuffer.h>
 
 using namespace WebCore;
 
@@ -247,6 +248,8 @@
 void WebPageProxy::didCommitLayerTree(const WebKit::RemoteLayerTreeTransaction& layerTreeTransaction)
 {
     m_pageClient.didCommitLayerTree(layerTreeTransaction);
+    if (m_videoFullscreenManager)
+        m_videoFullscreenManager->didCommitLayerTree(layerTreeTransaction);
 }
 
 void WebPageProxy::selectWithGesture(const WebCore::IntPoint point, WebCore::TextGranularity granularity, uint32_t gestureType, uint32_t gestureState, PassRefPtr<GestureCallback> callback)

Modified: trunk/Source/WebKit2/UIProcess/ios/WebVideoFullscreenManagerProxy.cpp (164616 => 164617)


--- trunk/Source/WebKit2/UIProcess/ios/WebVideoFullscreenManagerProxy.cpp	2014-02-25 00:29:28 UTC (rev 164616)
+++ trunk/Source/WebKit2/UIProcess/ios/WebVideoFullscreenManagerProxy.cpp	2014-02-25 00:40:06 UTC (rev 164617)
@@ -28,6 +28,9 @@
 
 #if PLATFORM(IOS)
 
+#include "DrawingAreaProxy.h"
+#include "RemoteLayerTreeDrawingAreaProxy.h"
+#include "RemoteLayerTreeTransaction.h"
 #include "WebPageProxy.h"
 #include "WebProcessProxy.h"
 #include "WebVideoFullscreenManagerMessages.h"
@@ -44,6 +47,8 @@
 
 WebVideoFullscreenManagerProxy::WebVideoFullscreenManagerProxy(WebPageProxy& page)
     : m_page(&page)
+    , m_enterFullscreenAfterVideoLayerUnparentedTransaction(false)
+    , m_videoLayerID(0)
 {
     m_page->process().addMessageReceiver(Messages::WebVideoFullscreenManagerProxy::messageReceiverName(), m_page->pageID(), *this);
     setWebVideoFullscreenModel(this);
@@ -54,12 +59,26 @@
     m_page->process().removeMessageReceiver(Messages::WebVideoFullscreenManagerProxy::messageReceiverName(), m_page->pageID());
 }
 
-void WebVideoFullscreenManagerProxy::setVideoLayerID(uint32_t videoLayerID)
+void WebVideoFullscreenManagerProxy::didCommitLayerTree(const RemoteLayerTreeTransaction& layerTreeTransaction)
 {
-    // TODO: find a real video layer or make one that meets the necessary requirements.
-    setVideoLayer(nullptr);
+    if (m_enterFullscreenAfterVideoLayerUnparentedTransaction && layerTreeTransaction.isVideoLayerIDPendingFullscreen(m_videoLayerID)) {
+        m_enterFullscreenAfterVideoLayerUnparentedTransaction = false;
+        WebCore::WebVideoFullscreenInterfaceAVKit::enterFullscreen();
+    }
 }
 
+void WebVideoFullscreenManagerProxy::setVideoLayerID(GraphicsLayer::PlatformLayerID videoLayerID)
+{
+    RemoteLayerTreeDrawingAreaProxy* remoteDrawingAreaProxy = toRemoteLayerTreeDrawingAreaProxy(m_page->drawingArea());
+    setVideoLayer(remoteDrawingAreaProxy->remoteLayerTreeHost().getLayer(videoLayerID));
+    m_videoLayerID = videoLayerID;
+    m_enterFullscreenAfterVideoLayerUnparentedTransaction = true;
+}
+
+void WebVideoFullscreenManagerProxy::enterFullscreen()
+{
+}
+    
 void WebVideoFullscreenManagerProxy::requestExitFullScreen()
 {
     m_page->send(Messages::WebVideoFullscreenManager::RequestExitFullScreen(), m_page->pageID());

Modified: trunk/Source/WebKit2/UIProcess/ios/WebVideoFullscreenManagerProxy.h (164616 => 164617)


--- trunk/Source/WebKit2/UIProcess/ios/WebVideoFullscreenManagerProxy.h	2014-02-25 00:29:28 UTC (rev 164616)
+++ trunk/Source/WebKit2/UIProcess/ios/WebVideoFullscreenManagerProxy.h	2014-02-25 00:40:06 UTC (rev 164617)
@@ -29,6 +29,7 @@
 #if PLATFORM(IOS)
 
 #include "MessageReceiver.h"
+#include <WebCore/GraphicsLayer.h>
 #include <WebCore/WebVideoFullscreenInterfaceAVKit.h>
 #include <WebCore/WebVideoFullscreenModel.h>
 #include <wtf/PassRefPtr.h>
@@ -38,17 +39,21 @@
 namespace WebKit {
 
 class WebPageProxy;
+class RemoteLayerTreeTransaction;
 
 class WebVideoFullscreenManagerProxy : public WebCore::WebVideoFullscreenInterfaceAVKit, public WebCore::WebVideoFullscreenModel, private IPC::MessageReceiver {
 public:
     static PassRefPtr<WebVideoFullscreenManagerProxy> create(WebPageProxy&);
     virtual ~WebVideoFullscreenManagerProxy();
 
+    void didCommitLayerTree(const RemoteLayerTreeTransaction&);
+    
 private:
     explicit WebVideoFullscreenManagerProxy(WebPageProxy&);
     virtual void didReceiveMessage(IPC::Connection*, IPC::MessageDecoder&) override;
 
-    virtual void setVideoLayerID(uint32_t) override;
+    virtual void setVideoLayerID(WebCore::GraphicsLayer::PlatformLayerID);
+    virtual void enterFullscreen() override;
     
     virtual void requestExitFullScreen() override;
     virtual void play() override;
@@ -58,6 +63,8 @@
     virtual void didExitFullscreen() override;
 
     WebPageProxy* m_page;
+    bool m_enterFullscreenAfterVideoLayerUnparentedTransaction;
+    WebCore::GraphicsLayer::PlatformLayerID m_videoLayerID;
 };
     
 } // namespace WebKit

Modified: trunk/Source/WebKit2/UIProcess/ios/WebVideoFullscreenManagerProxy.messages.in (164616 => 164617)


--- trunk/Source/WebKit2/UIProcess/ios/WebVideoFullscreenManagerProxy.messages.in	2014-02-25 00:29:28 UTC (rev 164616)
+++ trunk/Source/WebKit2/UIProcess/ios/WebVideoFullscreenManagerProxy.messages.in	2014-02-25 00:40:06 UTC (rev 164617)
@@ -24,7 +24,7 @@
 #if PLATFORM(IOS)
 messages -> WebVideoFullscreenManagerProxy {
     SetCurrentTime(double currentTime, double hostTime)
-    SetVideoLayerID(uint32_t videoLayerID)
+    SetVideoLayerID(WebCore::GraphicsLayer::PlatformLayerID videoLayerID)
     SetVideoDimensions(bool hasVideo, unsigned width, unsigned height)
     SetDuration(double duration)
     SetRate(bool isPlaying, double rate)

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (164616 => 164617)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2014-02-25 00:29:28 UTC (rev 164616)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2014-02-25 00:40:06 UTC (rev 164617)
@@ -171,6 +171,7 @@
 
 #if PLATFORM(COCOA)
 #include "PDFPlugin.h"
+#include "RemoteLayerTreeTransaction.h"
 #include <WebCore/LegacyWebArchive.h>
 #endif
 
@@ -2623,6 +2624,23 @@
         m_drawingArea->updatePreferences(store);
 }
 
+#if PLATFORM(COCOA)
+void WebPage::willCommitLayerTree(RemoteLayerTreeTransaction& layerTransaction)
+{
+    layerTransaction.setContentsSize(corePage()->mainFrame().view()->contentsSize());
+    layerTransaction.setPageScaleFactor(corePage()->pageScaleFactor());
+    layerTransaction.setRenderTreeSize(corePage()->renderTreeSize());
+#if PLATFORM(IOS)
+    layerTransaction.setMinimumScaleFactor(minimumPageScaleFactor());
+    layerTransaction.setMaximumScaleFactor(maximumPageScaleFactor());
+    layerTransaction.setAllowsUserScaling(allowsUserScaling());
+    if (m_videoFullscreenManager)
+        m_videoFullscreenManager->willCommitLayerTree(layerTransaction);
+#endif
+}
+#endif
+
+    
 #if ENABLE(INSPECTOR)
 WebInspector* WebPage::inspector()
 {

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (164616 => 164617)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2014-02-25 00:29:28 UTC (rev 164616)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2014-02-25 00:40:06 UTC (rev 164617)
@@ -167,6 +167,10 @@
 struct WebPageCreationParameters;
 struct WebPreferencesStore;
 
+#if PLATFORM(COCOA)
+class RemoteLayerTreeTransaction;
+#endif
+
 #if ENABLE(TOUCH_EVENTS)
 class WebTouchEvent;
 #endif
@@ -207,6 +211,10 @@
     bool scrollBy(uint32_t scrollDirection, uint32_t scrollGranularity);
 
     void centerSelectionInVisibleArea();
+    
+#if PLATFORM(COCOA)
+    void willCommitLayerTree(RemoteLayerTreeTransaction&);
+#endif
 
 #if ENABLE(INSPECTOR)
     WebInspector* inspector();

Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.mm (164616 => 164617)


--- trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.mm	2014-02-25 00:29:28 UTC (rev 164616)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.mm	2014-02-25 00:40:06 UTC (rev 164617)
@@ -39,6 +39,7 @@
 using namespace WebCore;
 using namespace WebKit;
 
+static NSString * const platformCALayerPointer = @"WKPlatformCALayer";
 PlatformCALayerRemoteCustom::PlatformCALayerRemoteCustom(PlatformLayer* customLayer, PlatformCALayerClient* owner, RemoteLayerTreeContext* context)
     : PlatformCALayerRemote(LayerTypeCustom, owner, context)
 {
@@ -54,6 +55,7 @@
     }
 
     m_layerHostingContext->setRootLayer(customLayer);
+    [customLayer setValue:[NSValue valueWithPointer:this] forKey:platformCALayerPointer];
 
     m_platformLayer = customLayer;
     [customLayer web_disableAllActions];
@@ -63,6 +65,7 @@
 
 PlatformCALayerRemoteCustom::~PlatformCALayerRemoteCustom()
 {
+    [m_platformLayer setValue:nil forKey:platformCALayerPointer];
 }
 
 uint32_t PlatformCALayerRemoteCustom::hostingContextID()

Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm (164616 => 164617)


--- trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm	2014-02-25 00:29:28 UTC (rev 164616)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm	2014-02-25 00:40:06 UTC (rev 164617)
@@ -321,14 +321,7 @@
     // FIXME: minize these transactions if nothing changed.
     RemoteLayerTreeTransaction layerTransaction;
     m_remoteLayerTreeContext->buildTransaction(layerTransaction, *m_rootLayer);
-    layerTransaction.setContentsSize(m_webPage->corePage()->mainFrame().view()->contentsSize());
-    layerTransaction.setPageScaleFactor(m_webPage->corePage()->pageScaleFactor());
-    layerTransaction.setRenderTreeSize(m_webPage->corePage()->renderTreeSize());
-#if PLATFORM(IOS)
-    layerTransaction.setMinimumScaleFactor(m_webPage->minimumPageScaleFactor());
-    layerTransaction.setMaximumScaleFactor(m_webPage->maximumPageScaleFactor());
-    layerTransaction.setAllowsUserScaling(m_webPage->allowsUserScaling());
-#endif
+    m_webPage->willCommitLayerTree(layerTransaction);
 
     RemoteScrollingCoordinatorTransaction scrollingTransaction;
 #if ENABLE(ASYNC_SCROLLING)

Modified: trunk/Source/WebKit2/WebProcess/ios/WebVideoFullscreenManager.cpp (164616 => 164617)


--- trunk/Source/WebKit2/WebProcess/ios/WebVideoFullscreenManager.cpp	2014-02-25 00:29:28 UTC (rev 164616)
+++ trunk/Source/WebKit2/WebProcess/ios/WebVideoFullscreenManager.cpp	2014-02-25 00:40:06 UTC (rev 164617)
@@ -27,6 +27,7 @@
 
 #if PLATFORM(IOS)
 
+#include "RemoteLayerTreeTransaction.h"
 #include "WebPage.h"
 #include "WebProcess.h"
 #include "WebVideoFullscreenManagerMessages.h"
@@ -35,6 +36,7 @@
 #include <WebCore/EventNames.h>
 #include <WebCore/HTMLVideoElement.h>
 #include <WebCore/Settings.h>
+#include <Webcore/PlatformCALayer.h>
 
 using namespace WebCore;
 
@@ -47,6 +49,7 @@
 
 WebVideoFullscreenManager::WebVideoFullscreenManager(PassRefPtr<WebPage> page)
     : m_page(page.get())
+    , m_sendUnparentVideoLayerTransaction(false)
 {
     setWebVideoFullscreenInterface(this);
     WebProcess::shared().addMessageReceiver(Messages::WebVideoFullscreenManager::messageReceiverName(), page->pageID(), *this);
@@ -57,6 +60,14 @@
     WebProcess::shared().removeMessageReceiver(Messages::WebVideoFullscreenManager::messageReceiverName(), m_page->pageID());
 }
 
+void WebVideoFullscreenManager::willCommitLayerTree(RemoteLayerTreeTransaction& transaction)
+{
+    if (m_sendUnparentVideoLayerTransaction) {
+        transaction.addVideoLayerIDPendingFullscreen(m_platformCALayer->layerID());
+        m_sendUnparentVideoLayerTransaction = false;
+    }
+}
+    
 bool WebVideoFullscreenManager::supportsFullscreen(const Node* node) const
 {
     if (!Settings::avKitEnabled())
@@ -98,15 +109,12 @@
     m_page->send(Messages::WebVideoFullscreenManagerProxy::SetVideoDimensions(hasVideo, width, height), m_page->pageID());
 }
     
-void WebVideoFullscreenManager::setVideoLayer(PlatformLayer*)
+void WebVideoFullscreenManager::setVideoLayer(PlatformLayer* videoLayer)
 {
-    // TODO: implement with correct layer ID.
-    m_page->send(Messages::WebVideoFullscreenManagerProxy::SetVideoLayerID(0), m_page->pageID());
-}
+    m_platformCALayer = PlatformCALayer::platformCALayer(videoLayer);
+    m_sendUnparentVideoLayerTransaction = !!m_platformCALayer;
     
-void WebVideoFullscreenManager::setVideoLayerID(uint32_t videoLayerID)
-{
-    m_page->send(Messages::WebVideoFullscreenManagerProxy::SetVideoLayerID(videoLayerID), m_page->pageID());
+    m_page->send(Messages::WebVideoFullscreenManagerProxy::SetVideoLayerID(m_platformCALayer ? m_platformCALayer->layerID() : 0), m_page->pageID());
 }
 
 void WebVideoFullscreenManager::enterFullscreen()

Modified: trunk/Source/WebKit2/WebProcess/ios/WebVideoFullscreenManager.h (164616 => 164617)


--- trunk/Source/WebKit2/WebProcess/ios/WebVideoFullscreenManager.h	2014-02-25 00:29:28 UTC (rev 164616)
+++ trunk/Source/WebKit2/WebProcess/ios/WebVideoFullscreenManager.h	2014-02-25 00:40:06 UTC (rev 164617)
@@ -29,6 +29,7 @@
 
 #include "MessageReceiver.h"
 #include <WebCore/EventListener.h>
+#include <WebCore/PlatformCALayer.h>
 #include <WebCore/WebVideoFullscreenInterface.h>
 #include <WebCore/WebVideoFullscreenModelMediaElement.h>
 #include <wtf/RefCounted.h>
@@ -47,6 +48,7 @@
 namespace WebKit {
 
 class WebPage;
+class RemoteLayerTreeTransaction;
 
 class WebVideoFullscreenManager : public WebCore::WebVideoFullscreenModelMediaElement, public WebCore::WebVideoFullscreenInterface, private IPC::MessageReceiver {
 public:
@@ -55,6 +57,8 @@
     
     void didReceiveMessage(IPC::Connection*, IPC::MessageDecoder&);
     
+    void willCommitLayerTree(RemoteLayerTreeTransaction&);
+
     bool supportsFullscreen(const WebCore::Node*) const;
     void enterFullscreenForNode(WebCore::Node*);
     void exitFullscreenForNode(WebCore::Node*);
@@ -68,12 +72,13 @@
     virtual void setRate(bool isPlaying, float playbackRate) override;
     virtual void setVideoDimensions(bool hasVideo, float width, float height) override;
     virtual void setVideoLayer(PlatformLayer*) override;
-    virtual void setVideoLayerID(uint32_t) override;
     virtual void enterFullscreen() override;
     virtual void exitFullscreen() override;
     
     WebPage* m_page;
     RefPtr<WebCore::Node> m_node;
+    RefPtr<WebCore::PlatformCALayer> m_platformCALayer;
+    bool m_sendUnparentVideoLayerTransaction;
 };
     
 } // namespace WebKit
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to