Title: [230194] trunk/Source
Revision
230194
Author
[email protected]
Date
2018-04-02 17:50:29 -0700 (Mon, 02 Apr 2018)

Log Message

[Extra zoom mode] Replace video with a placeholder image during fullscreen transition
https://bugs.webkit.org/show_bug.cgi?id=184188
<rdar://problem/38940307>

Reviewed by Youenn Fablet.

Source/WebCore:

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::willExitFullscreen):
* html/HTMLMediaElement.h:
* platform/cocoa/VideoFullscreenChangeObserver.h:
* platform/cocoa/VideoFullscreenModelVideoElement.h:
* platform/cocoa/VideoFullscreenModelVideoElement.mm:
(VideoFullscreenModelVideoElement::willExitFullscreen):
* platform/graphics/MediaPlayer.cpp:
(WebCore::MediaPlayer::updateVideoFullscreenInlineImage):
* platform/graphics/MediaPlayer.h:
* platform/graphics/MediaPlayerPrivate.h:
(WebCore::MediaPlayerPrivateInterface::updateVideoFullscreenInlineImage):
* platform/graphics/VideoFullscreenLayerManager.h:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayerItem):
(WebCore::MediaPlayerPrivateAVFoundationObjC::updateVideoFullscreenInlineImage):
(WebCore::MediaPlayerPrivateAVFoundationObjC::setVideoFullscreenLayer):
(WebCore::MediaPlayerPrivateAVFoundationObjC::updateLastPixelBuffer):
(WebCore::MediaPlayerPrivateAVFoundationObjC::updateLastImage):
(WebCore::MediaPlayerPrivateAVFoundationObjC::paintWithVideoOutput):
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setVideoFullscreenLayer):
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::setVideoFullscreenLayer):
* platform/graphics/avfoundation/objc/VideoFullscreenLayerManagerObjC.h:
* platform/graphics/avfoundation/objc/VideoFullscreenLayerManagerObjC.mm:
(WebCore::VideoFullscreenLayerManagerObjC::setVideoLayer):
(WebCore::VideoFullscreenLayerManagerObjC::updateVideoFullscreenInlineImage):
(WebCore::VideoFullscreenLayerManagerObjC::setVideoFullscreenLayer):
* platform/ios/VideoFullscreenInterfaceAVKit.h:
* platform/ios/VideoFullscreenInterfaceAVKit.mm:
(VideoFullscreenInterfaceAVKit::exitFullscreen):
(VideoFullscreenInterfaceAVKit::preparedToExitFullscreen):
(VideoFullscreenInterfaceAVKit::shouldExitFullscreenWithReason):
* platform/ios/WebVideoFullscreenControllerAVKit.mm:
(VideoFullscreenControllerContext::willExitFullscreen):

Source/WebKit:

* UIProcess/Cocoa/VideoFullscreenManagerProxy.h:
* UIProcess/Cocoa/VideoFullscreenManagerProxy.messages.in:
* UIProcess/Cocoa/VideoFullscreenManagerProxy.mm:
(WebKit::VideoFullscreenModelContext::willExitFullscreen):
(WebKit::VideoFullscreenManagerProxy::preparedToExitFullscreen):
(WebKit::VideoFullscreenManagerProxy::willExitFullscreen):
* WebProcess/cocoa/VideoFullscreenManager.h:
* WebProcess/cocoa/VideoFullscreenManager.messages.in:
* WebProcess/cocoa/VideoFullscreenManager.mm:
(WebKit::VideoFullscreenManager::willExitFullscreen):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (230193 => 230194)


--- trunk/Source/WebCore/ChangeLog	2018-04-03 00:11:16 UTC (rev 230193)
+++ trunk/Source/WebCore/ChangeLog	2018-04-03 00:50:29 UTC (rev 230194)
@@ -1,5 +1,51 @@
 2018-04-02  Eric Carlson  <[email protected]>
 
+        [Extra zoom mode] Replace video with a placeholder image during fullscreen transition
+        https://bugs.webkit.org/show_bug.cgi?id=184188
+        <rdar://problem/38940307>
+
+        Reviewed by Youenn Fablet.
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::willExitFullscreen):
+        * html/HTMLMediaElement.h:
+        * platform/cocoa/VideoFullscreenChangeObserver.h:
+        * platform/cocoa/VideoFullscreenModelVideoElement.h:
+        * platform/cocoa/VideoFullscreenModelVideoElement.mm:
+        (VideoFullscreenModelVideoElement::willExitFullscreen):
+        * platform/graphics/MediaPlayer.cpp:
+        (WebCore::MediaPlayer::updateVideoFullscreenInlineImage):
+        * platform/graphics/MediaPlayer.h:
+        * platform/graphics/MediaPlayerPrivate.h:
+        (WebCore::MediaPlayerPrivateInterface::updateVideoFullscreenInlineImage):
+        * platform/graphics/VideoFullscreenLayerManager.h:
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayerItem):
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::updateVideoFullscreenInlineImage):
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::setVideoFullscreenLayer):
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::updateLastPixelBuffer):
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::updateLastImage):
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::paintWithVideoOutput):
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setVideoFullscreenLayer):
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
+        (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::setVideoFullscreenLayer):
+        * platform/graphics/avfoundation/objc/VideoFullscreenLayerManagerObjC.h:
+        * platform/graphics/avfoundation/objc/VideoFullscreenLayerManagerObjC.mm:
+        (WebCore::VideoFullscreenLayerManagerObjC::setVideoLayer):
+        (WebCore::VideoFullscreenLayerManagerObjC::updateVideoFullscreenInlineImage):
+        (WebCore::VideoFullscreenLayerManagerObjC::setVideoFullscreenLayer):
+        * platform/ios/VideoFullscreenInterfaceAVKit.h:
+        * platform/ios/VideoFullscreenInterfaceAVKit.mm:
+        (VideoFullscreenInterfaceAVKit::exitFullscreen):
+        (VideoFullscreenInterfaceAVKit::preparedToExitFullscreen):
+        (VideoFullscreenInterfaceAVKit::shouldExitFullscreenWithReason):
+        * platform/ios/WebVideoFullscreenControllerAVKit.mm:
+        (VideoFullscreenControllerContext::willExitFullscreen):
+
+2018-04-02  Eric Carlson  <[email protected]>
+
         Define AVKit softlink macro
         https://bugs.webkit.org/show_bug.cgi?id=184241
 

Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (230193 => 230194)


--- trunk/Source/WebCore/html/HTMLMediaElement.cpp	2018-04-03 00:11:16 UTC (rev 230193)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp	2018-04-03 00:50:29 UTC (rev 230194)
@@ -6023,6 +6023,12 @@
 
 #if PLATFORM(IOS) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
 
+void HTMLMediaElement::willExitFullscreen()
+{
+    if (m_player)
+        m_player->updateVideoFullscreenInlineImage();
+}
+
 bool HTMLMediaElement::isVideoLayerInline()
 {
     return !m_videoFullscreenLayer;

Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (230193 => 230194)


--- trunk/Source/WebCore/html/HTMLMediaElement.h	2018-04-03 00:11:16 UTC (rev 230193)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h	2018-04-03 00:50:29 UTC (rev 230194)
@@ -554,6 +554,7 @@
     bool isSuspended() const final;
 
     WEBCORE_EXPORT void didBecomeFullscreenElement() override;
+    WEBCORE_EXPORT void willExitFullscreen();
 
 protected:
     HTMLMediaElement(const QualifiedName&, Document&, bool createdByParser);

Modified: trunk/Source/WebCore/platform/cocoa/VideoFullscreenChangeObserver.h (230193 => 230194)


--- trunk/Source/WebCore/platform/cocoa/VideoFullscreenChangeObserver.h	2018-04-03 00:11:16 UTC (rev 230193)
+++ trunk/Source/WebCore/platform/cocoa/VideoFullscreenChangeObserver.h	2018-04-03 00:50:29 UTC (rev 230194)
@@ -38,6 +38,7 @@
     virtual void returnVideoContentLayer() = 0;
     virtual void didSetupFullscreen() = 0;
     virtual void didEnterFullscreen() = 0;
+    virtual void willExitFullscreen() = 0;
     virtual void didExitFullscreen() = 0;
     virtual void didCleanupFullscreen() = 0;
     virtual void fullscreenMayReturnToInline() = 0;

Modified: trunk/Source/WebCore/platform/cocoa/VideoFullscreenModelVideoElement.h (230193 => 230194)


--- trunk/Source/WebCore/platform/cocoa/VideoFullscreenModelVideoElement.h	2018-04-03 00:11:16 UTC (rev 230193)
+++ trunk/Source/WebCore/platform/cocoa/VideoFullscreenModelVideoElement.h	2018-04-03 00:50:29 UTC (rev 230194)
@@ -55,6 +55,7 @@
     WEBCORE_EXPORT void setVideoElement(HTMLVideoElement*);
     HTMLVideoElement* videoElement() const { return m_videoElement.get(); }
     WEBCORE_EXPORT void setVideoFullscreenLayer(PlatformLayer*, WTF::Function<void()>&& completionHandler = [] { });
+    WEBCORE_EXPORT void willExitFullscreen();
     WEBCORE_EXPORT void waitForPreparedForInlineThen(WTF::Function<void()>&& completionHandler = [] { });
     
     WEBCORE_EXPORT void handleEvent(WebCore::ScriptExecutionContext&, WebCore::Event&) override;

Modified: trunk/Source/WebCore/platform/cocoa/VideoFullscreenModelVideoElement.mm (230193 => 230194)


--- trunk/Source/WebCore/platform/cocoa/VideoFullscreenModelVideoElement.mm	2018-04-03 00:11:16 UTC (rev 230193)
+++ trunk/Source/WebCore/platform/cocoa/VideoFullscreenModelVideoElement.mm	2018-04-03 00:50:29 UTC (rev 230194)
@@ -100,6 +100,12 @@
     }
 }
 
+void VideoFullscreenModelVideoElement::willExitFullscreen()
+{
+    if (m_videoElement)
+        m_videoElement->willExitFullscreen();
+}
+
 void VideoFullscreenModelVideoElement::setVideoFullscreenLayer(PlatformLayer* videoLayer, WTF::Function<void()>&& completionHandler)
 {
     if (m_videoFullscreenLayer == videoLayer) {

Modified: trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp (230193 => 230194)


--- trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp	2018-04-03 00:11:16 UTC (rev 230193)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp	2018-04-03 00:50:29 UTC (rev 230194)
@@ -705,6 +705,11 @@
     m_private->setVideoFullscreenLayer(layer, WTFMove(completionHandler));
 }
 
+void MediaPlayer::updateVideoFullscreenInlineImage()
+{
+    m_private->updateVideoFullscreenInlineImage();
+}
+
 void MediaPlayer::setVideoFullscreenFrame(FloatRect frame)
 {
     m_private->setVideoFullscreenFrame(frame);

Modified: trunk/Source/WebCore/platform/graphics/MediaPlayer.h (230193 => 230194)


--- trunk/Source/WebCore/platform/graphics/MediaPlayer.h	2018-04-03 00:11:16 UTC (rev 230193)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayer.h	2018-04-03 00:50:29 UTC (rev 230194)
@@ -335,6 +335,7 @@
 #if PLATFORM(IOS) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
     void setVideoFullscreenLayer(PlatformLayer*, WTF::Function<void()>&& completionHandler = [] { });
     void setVideoFullscreenFrame(FloatRect);
+    void updateVideoFullscreenInlineImage();
     using MediaPlayerEnums::VideoGravity;
     void setVideoFullscreenGravity(VideoGravity);
     void setVideoFullscreenMode(VideoFullscreenMode);

Modified: trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h (230193 => 230194)


--- trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h	2018-04-03 00:11:16 UTC (rev 230193)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h	2018-04-03 00:50:29 UTC (rev 230194)
@@ -61,6 +61,7 @@
 
 #if PLATFORM(IOS) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
     virtual void setVideoFullscreenLayer(PlatformLayer*, WTF::Function<void()>&& completionHandler) { completionHandler(); }
+    virtual void updateVideoFullscreenInlineImage() { }
     virtual void setVideoFullscreenFrame(FloatRect) { }
     virtual void setVideoFullscreenGravity(MediaPlayer::VideoGravity) { }
     virtual void setVideoFullscreenMode(MediaPlayer::VideoFullscreenMode) { }

Modified: trunk/Source/WebCore/platform/graphics/VideoFullscreenLayerManager.h (230193 => 230194)


--- trunk/Source/WebCore/platform/graphics/VideoFullscreenLayerManager.h	2018-04-03 00:11:16 UTC (rev 230193)
+++ trunk/Source/WebCore/platform/graphics/VideoFullscreenLayerManager.h	2018-04-03 00:50:29 UTC (rev 230194)
@@ -25,6 +25,7 @@
 
 #pragma once
 
+#include "NativeImage.h"
 #include "PlatformLayer.h"
 #include <wtf/Function.h>
 #include <wtf/Noncopyable.h>
@@ -45,7 +46,8 @@
     virtual PlatformLayer *videoFullscreenLayer() const = 0;
     virtual FloatRect videoFullscreenFrame() const = 0;
     virtual void setVideoLayer(PlatformLayer*, IntSize) = 0;
-    virtual void setVideoFullscreenLayer(PlatformLayer*, WTF::Function<void()>&& completionHandler) = 0;
+    virtual void setVideoFullscreenLayer(PlatformLayer*, WTF::Function<void()>&& completionHandler, NativeImagePtr) = 0;
+    virtual void updateVideoFullscreenInlineImage(NativeImagePtr) = 0;
     virtual void setVideoFullscreenFrame(FloatRect) = 0;
     virtual void didDestroyVideoLayer() = 0;
 

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h (230193 => 230194)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h	2018-04-03 00:11:16 UTC (rev 230193)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h	2018-04-03 00:50:29 UTC (rev 230194)
@@ -185,7 +185,8 @@
     void paint(GraphicsContext&, const FloatRect&) override;
     void paintCurrentFrameInContext(GraphicsContext&, const FloatRect&) override;
     PlatformLayer* platformLayer() const override;
-    void setVideoFullscreenLayer(PlatformLayer*, WTF::Function<void()>&& completionHandler) override;
+    void setVideoFullscreenLayer(PlatformLayer*, Function<void()>&& completionHandler) override;
+    void updateVideoFullscreenInlineImage() final;
     void setVideoFullscreenFrame(FloatRect) override;
     void setVideoFullscreenGravity(MediaPlayer::VideoGravity) override;
     void setVideoFullscreenMode(MediaPlayer::VideoFullscreenMode) override;
@@ -261,10 +262,12 @@
     void paintWithImageGenerator(GraphicsContext&, const FloatRect&);
 
 #if HAVE(AVFOUNDATION_VIDEO_OUTPUT)
+    enum class UpdateType { UpdateSynchronously, UpdateAsynchronously };
+    void updateLastImage(UpdateType type = UpdateType::UpdateAsynchronously);
+
     void createVideoOutput();
     void destroyVideoOutput();
     bool updateLastPixelBuffer();
-    void updateLastImage();
     bool videoOutputHasAvailableFrame();
     void paintWithVideoOutput(GraphicsContext&, const FloatRect&);
     NativeImagePtr nativeImageForCurrentTime() override;

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (230193 => 230194)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm	2018-04-03 00:11:16 UTC (rev 230193)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm	2018-04-03 00:50:29 UTC (rev 230194)
@@ -1079,6 +1079,10 @@
     }
 #endif
 
+#if ENABLE(EXTRA_ZOOM_MODE)
+    createVideoOutput();
+#endif
+
     setDelayCallbacks(false);
 }
 
@@ -1162,9 +1166,16 @@
     return m_videoFullscreenLayerManager->videoInlineLayer();
 }
 
-void MediaPlayerPrivateAVFoundationObjC::setVideoFullscreenLayer(PlatformLayer* videoFullscreenLayer, WTF::Function<void()>&& completionHandler)
+void MediaPlayerPrivateAVFoundationObjC::updateVideoFullscreenInlineImage()
 {
-    m_videoFullscreenLayerManager->setVideoFullscreenLayer(videoFullscreenLayer, WTFMove(completionHandler));
+    updateLastImage(UpdateType::UpdateSynchronously);
+    m_videoFullscreenLayerManager->updateVideoFullscreenInlineImage(m_lastImage);
+}
+
+void MediaPlayerPrivateAVFoundationObjC::setVideoFullscreenLayer(PlatformLayer* videoFullscreenLayer, Function<void()>&& completionHandler)
+{
+    updateLastImage(UpdateType::UpdateSynchronously);
+    m_videoFullscreenLayerManager->setVideoFullscreenLayer(videoFullscreenLayer, WTFMove(completionHandler), m_lastImage);
     updateDisableExternalPlayback();
 }
 
@@ -2231,6 +2242,9 @@
 
 bool MediaPlayerPrivateAVFoundationObjC::updateLastPixelBuffer()
 {
+    if (!m_avPlayerItem)
+        return false;
+
     if (!m_videoOutput)
         createVideoOutput();
     ASSERT(m_videoOutput);
@@ -2259,9 +2273,15 @@
     return [m_videoOutput hasNewPixelBufferForItemTime:[m_avPlayerItem currentTime]];
 }
 
-void MediaPlayerPrivateAVFoundationObjC::updateLastImage()
+void MediaPlayerPrivateAVFoundationObjC::updateLastImage(UpdateType type)
 {
 #if HAVE(CORE_VIDEO)
+    if (!m_avPlayerItem)
+        return;
+
+    if (type == UpdateType::UpdateSynchronously && !m_lastImage && !videoOutputHasAvailableFrame())
+        waitForVideoOutputMediaDataWillChange();
+
     // Calls to copyPixelBufferForItemTime:itemTimeForDisplay: may return nil if the pixel buffer
     // for the requested time has already been retrieved. In this case, the last valid image (if any)
     // should be displayed.
@@ -2291,11 +2311,7 @@
 
 void MediaPlayerPrivateAVFoundationObjC::paintWithVideoOutput(GraphicsContext& context, const FloatRect& outputRect)
 {
-    if (m_videoOutput && !m_lastImage && !videoOutputHasAvailableFrame())
-        waitForVideoOutputMediaDataWillChange();
-
-    updateLastImage();
-
+    updateLastImage(UpdateType::UpdateSynchronously);
     if (!m_lastImage)
         return;
 

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm (230193 => 230194)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm	2018-04-03 00:11:16 UTC (rev 230193)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm	2018-04-03 00:50:29 UTC (rev 230194)
@@ -1068,7 +1068,8 @@
 
 void MediaPlayerPrivateMediaSourceAVFObjC::setVideoFullscreenLayer(PlatformLayer *videoFullscreenLayer, WTF::Function<void()>&& completionHandler)
 {
-    m_videoFullscreenLayerManager->setVideoFullscreenLayer(videoFullscreenLayer, WTFMove(completionHandler));
+    updateLastImage();
+    m_videoFullscreenLayerManager->setVideoFullscreenLayer(videoFullscreenLayer, WTFMove(completionHandler), m_lastImage);
 }
 
 void MediaPlayerPrivateMediaSourceAVFObjC::setVideoFullscreenFrame(FloatRect frame)

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm (230193 => 230194)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm	2018-04-03 00:11:16 UTC (rev 230193)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm	2018-04-03 00:50:29 UTC (rev 230194)
@@ -899,7 +899,8 @@
 
 void MediaPlayerPrivateMediaStreamAVFObjC::setVideoFullscreenLayer(PlatformLayer* videoFullscreenLayer, WTF::Function<void()>&& completionHandler)
 {
-    m_videoFullscreenLayerManager->setVideoFullscreenLayer(videoFullscreenLayer, WTFMove(completionHandler));
+    updateCurrentFrameImage();
+    m_videoFullscreenLayerManager->setVideoFullscreenLayer(videoFullscreenLayer, WTFMove(completionHandler), m_imagePainter.cgImage);
 }
 
 void MediaPlayerPrivateMediaStreamAVFObjC::setVideoFullscreenFrame(FloatRect frame)

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/VideoFullscreenLayerManagerObjC.h (230193 => 230194)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/VideoFullscreenLayerManagerObjC.h	2018-04-03 00:11:16 UTC (rev 230193)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/VideoFullscreenLayerManagerObjC.h	2018-04-03 00:50:29 UTC (rev 230194)
@@ -43,7 +43,8 @@
     PlatformLayer *videoFullscreenLayer() const final { return m_videoFullscreenLayer.get(); }
     FloatRect videoFullscreenFrame() const final { return m_videoFullscreenFrame; }
     void setVideoLayer(PlatformLayer *, IntSize contentSize) final;
-    void setVideoFullscreenLayer(PlatformLayer *, WTF::Function<void()>&& completionHandler) final;
+    void setVideoFullscreenLayer(PlatformLayer *, WTF::Function<void()>&& completionHandler, NativeImagePtr) final;
+    void updateVideoFullscreenInlineImage(NativeImagePtr) final;
     void setVideoFullscreenFrame(FloatRect) final;
     void didDestroyVideoLayer() final;
 

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/VideoFullscreenLayerManagerObjC.mm (230193 => 230194)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/VideoFullscreenLayerManagerObjC.mm	2018-04-03 00:11:16 UTC (rev 230193)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/VideoFullscreenLayerManagerObjC.mm	2018-04-03 00:50:29 UTC (rev 230194)
@@ -74,6 +74,8 @@
     [m_videoInlineLayer setName:@"WebVideoContainerLayer"];
 #endif
     [m_videoInlineLayer setFrame:m_videoInlineFrame];
+    [m_videoInlineLayer setContentsGravity:kCAGravityResizeAspect];
+
     if (m_videoFullscreenLayer) {
         [m_videoLayer setFrame:CGRectMake(0, 0, m_videoFullscreenFrame.width(), m_videoFullscreenFrame.height())];
         [m_videoFullscreenLayer insertSublayer:m_videoLayer.get() atIndex:0];
@@ -83,8 +85,14 @@
     }
 }
 
-void VideoFullscreenLayerManagerObjC::setVideoFullscreenLayer(PlatformLayer *videoFullscreenLayer, WTF::Function<void()>&& completionHandler)
+void VideoFullscreenLayerManagerObjC::updateVideoFullscreenInlineImage(NativeImagePtr image)
 {
+    if (m_videoInlineLayer)
+        [m_videoInlineLayer setContents:(id)image.get()];
+}
+
+void VideoFullscreenLayerManagerObjC::setVideoFullscreenLayer(PlatformLayer *videoFullscreenLayer, WTF::Function<void()>&& completionHandler, NativeImagePtr currentImage)
+{
     if (m_videoFullscreenLayer == videoFullscreenLayer) {
         completionHandler();
         return;
@@ -98,6 +106,9 @@
     if (m_videoLayer) {
         CAContext *oldContext = [m_videoLayer context];
 
+        if (m_videoInlineLayer)
+            [m_videoInlineLayer setContents:(id)currentImage.get()];
+
         if (m_videoFullscreenLayer) {
             [m_videoFullscreenLayer insertSublayer:m_videoLayer.get() atIndex:0];
             [m_videoLayer setFrame:CGRectMake(0, 0, m_videoFullscreenFrame.width(), m_videoFullscreenFrame.height())];

Modified: trunk/Source/WebCore/platform/ios/VideoFullscreenInterfaceAVKit.h (230193 => 230194)


--- trunk/Source/WebCore/platform/ios/VideoFullscreenInterfaceAVKit.h	2018-04-03 00:11:16 UTC (rev 230193)
+++ trunk/Source/WebCore/platform/ios/VideoFullscreenInterfaceAVKit.h	2018-04-03 00:50:29 UTC (rev 230194)
@@ -84,6 +84,7 @@
     WEBCORE_EXPORT void invalidate();
     WEBCORE_EXPORT void requestHideAndExitFullscreen();
     WEBCORE_EXPORT void preparedToReturnToInline(bool visible, const IntRect& inlineRect);
+    WEBCORE_EXPORT void preparedToExitFullscreen();
 #if ENABLE(FULLSCREEN_API)
     WEBCORE_EXPORT void setHasVideoContentLayer(bool);
     WEBCORE_EXPORT void setInlineRect(const IntRect&, bool visible);
@@ -227,6 +228,7 @@
     bool m_exitCompleted { false };
     bool m_enterRequested { false };
     bool m_shouldReturnToFullscreenAfterEnteringForeground { false };
+    bool m_waitingForPreparedToExit { false };
 #endif
 };
 

Modified: trunk/Source/WebCore/platform/ios/VideoFullscreenInterfaceAVKit.mm (230193 => 230194)


--- trunk/Source/WebCore/platform/ios/VideoFullscreenInterfaceAVKit.mm	2018-04-03 00:11:16 UTC (rev 230193)
+++ trunk/Source/WebCore/platform/ios/VideoFullscreenInterfaceAVKit.mm	2018-04-03 00:50:29 UTC (rev 230194)
@@ -979,7 +979,7 @@
             m_fullscreenChangeObserver->didExitFullscreen();
         return;
     }
-    
+
     LOG(Fullscreen, "VideoFullscreenInterfaceAVKit::exitFullscreen(%p)", this);
     [m_playerViewController setShowsPlaybackControls:NO];
     
@@ -1103,6 +1103,15 @@
     }
 }
 
+void VideoFullscreenInterfaceAVKit::preparedToExitFullscreen()
+{
+    if (!m_waitingForPreparedToExit)
+        return;
+
+    m_waitingForPreparedToExit = false;
+    m_videoFullscreenModel->requestFullscreenMode(HTMLMediaElementEnums::VideoFullscreenModeNone, true);
+}
+
 bool VideoFullscreenInterfaceAVKit::mayAutomaticallyShowVideoPictureInPicture() const
 {
     return [playerController() isPlaying] && m_currentMode.isFullscreen() && supportsPictureInPicture();
@@ -1251,12 +1260,20 @@
     if (playbackSessionModel() && (reason == ExitFullScreenReason::DoneButtonTapped || reason == ExitFullScreenReason::RemoteControlStopEventReceived))
         playbackSessionModel()->pause();
 
+    if (!m_watchdogTimer.isActive() && !ignoreWatchdogForDebugging)
+        m_watchdogTimer.startOneShot(defaultWatchdogTimerInterval);
+
+#if ENABLE(EXTRA_ZOOM_MODE)
+    if (m_fullscreenChangeObserver) {
+        m_waitingForPreparedToExit = true;
+        m_fullscreenChangeObserver->willExitFullscreen();
+        return false;
+    }
+#endif
+
     BOOL finished = reason == ExitFullScreenReason::DoneButtonTapped || reason == ExitFullScreenReason::PinchGestureHandled;
     m_videoFullscreenModel->requestFullscreenMode(HTMLMediaElementEnums::VideoFullscreenModeNone, finished);
 
-    if (!m_watchdogTimer.isActive() && !ignoreWatchdogForDebugging)
-        m_watchdogTimer.startOneShot(defaultWatchdogTimerInterval);
-
     return false;
 }
 
@@ -1390,6 +1407,10 @@
     }
 }
 
+void VideoFullscreenInterfaceAVKit::preparedToExitFullscreen()
+{
+}
+
 bool VideoFullscreenInterfaceAVKit::mayAutomaticallyShowVideoPictureInPicture() const
 {
     return [playerController() isPlaying] && (m_standby || m_currentMode.isFullscreen()) && supportsPictureInPicture();

Modified: trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm (230193 => 230194)


--- trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm	2018-04-03 00:11:16 UTC (rev 230193)
+++ trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm	2018-04-03 00:50:29 UTC (rev 230194)
@@ -122,14 +122,15 @@
     VideoFullscreenControllerContext() { }
 
     // VideoFullscreenChangeObserver
-    void requestUpdateInlineRect() override;
-    void requestVideoContentLayer() override;
-    void returnVideoContentLayer() override;
-    void didSetupFullscreen() override;
-    void didEnterFullscreen() override { }
-    void didExitFullscreen() override;
-    void didCleanupFullscreen() override;
-    void fullscreenMayReturnToInline() override;
+    void requestUpdateInlineRect() final;
+    void requestVideoContentLayer() final;
+    void returnVideoContentLayer() final;
+    void didSetupFullscreen() final;
+    void didEnterFullscreen() final { }
+    void willExitFullscreen() final;
+    void didExitFullscreen() final;
+    void didCleanupFullscreen() final;
+    void fullscreenMayReturnToInline() final;
 
     // VideoFullscreenModelClient
     void hasVideoChanged(bool) override;
@@ -279,6 +280,16 @@
 #endif
 }
 
+void VideoFullscreenControllerContext::willExitFullscreen()
+{
+#if ENABLE(EXTRA_ZOOM_MODE)
+    ASSERT(isUIThread());
+    WebThreadRun([protectedThis = makeRefPtr(this), this] () mutable {
+        m_fullscreenModel->willExitFullscreen();
+    });
+#endif
+}
+
 void VideoFullscreenControllerContext::didExitFullscreen()
 {
     ASSERT(isUIThread());

Modified: trunk/Source/WebCore/platform/mac/VideoFullscreenInterfaceMac.h (230193 => 230194)


--- trunk/Source/WebCore/platform/mac/VideoFullscreenInterfaceMac.h	2018-04-03 00:11:16 UTC (rev 230193)
+++ trunk/Source/WebCore/platform/mac/VideoFullscreenInterfaceMac.h	2018-04-03 00:50:29 UTC (rev 230194)
@@ -78,6 +78,7 @@
     WEBCORE_EXPORT void invalidate();
     void requestHideAndExitFullscreen() { }
     WEBCORE_EXPORT void preparedToReturnToInline(bool visible, const IntRect& inlineRect, NSWindow *parentWindow);
+    void preparedToExitFullscreen() { }
 
     HTMLMediaElementEnums::VideoFullscreenMode mode() const { return m_mode; }
     bool hasMode(HTMLMediaElementEnums::VideoFullscreenMode mode) const { return m_mode & mode; }

Modified: trunk/Source/WebKit/ChangeLog (230193 => 230194)


--- trunk/Source/WebKit/ChangeLog	2018-04-03 00:11:16 UTC (rev 230193)
+++ trunk/Source/WebKit/ChangeLog	2018-04-03 00:50:29 UTC (rev 230194)
@@ -1,3 +1,22 @@
+2018-04-02  Eric Carlson  <[email protected]>
+
+        [Extra zoom mode] Replace video with a placeholder image during fullscreen transition
+        https://bugs.webkit.org/show_bug.cgi?id=184188
+        <rdar://problem/38940307>
+
+        Reviewed by Youenn Fablet.
+
+        * UIProcess/Cocoa/VideoFullscreenManagerProxy.h:
+        * UIProcess/Cocoa/VideoFullscreenManagerProxy.messages.in:
+        * UIProcess/Cocoa/VideoFullscreenManagerProxy.mm:
+        (WebKit::VideoFullscreenModelContext::willExitFullscreen):
+        (WebKit::VideoFullscreenManagerProxy::preparedToExitFullscreen):
+        (WebKit::VideoFullscreenManagerProxy::willExitFullscreen):
+        * WebProcess/cocoa/VideoFullscreenManager.h:
+        * WebProcess/cocoa/VideoFullscreenManager.messages.in:
+        * WebProcess/cocoa/VideoFullscreenManager.mm:
+        (WebKit::VideoFullscreenManager::willExitFullscreen):
+
 2018-04-02  Brian Burg  <[email protected]>
 
         [Cocoa] Fix some internal builds that consume WebDriver atoms

Modified: trunk/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.h (230193 => 230194)


--- trunk/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.h	2018-04-03 00:11:16 UTC (rev 230193)
+++ trunk/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.h	2018-04-03 00:50:29 UTC (rev 230194)
@@ -91,14 +91,15 @@
 #endif
 
     // VideoFullscreenChangeObserver
-    void requestUpdateInlineRect() override;
-    void requestVideoContentLayer() override;
-    void returnVideoContentLayer() override;
-    void didSetupFullscreen() override;
-    void didEnterFullscreen() override;
-    void didExitFullscreen() override;
-    void didCleanupFullscreen() override;
-    void fullscreenMayReturnToInline() override;
+    void requestUpdateInlineRect() final;
+    void requestVideoContentLayer() final;
+    void returnVideoContentLayer() final;
+    void didSetupFullscreen() final;
+    void didEnterFullscreen() final;
+    void willExitFullscreen() final;
+    void didExitFullscreen() final;
+    void didCleanupFullscreen() final;
+    void fullscreenMayReturnToInline() final;
 
     VideoFullscreenManagerProxy* m_manager;
     Ref<PlaybackSessionModelContext> m_playbackSessionModel;
@@ -150,6 +151,7 @@
     void exitFullscreen(uint64_t contextId, WebCore::IntRect finalRect);
     void cleanupFullscreen(uint64_t contextId);
     void preparedToReturnToInline(uint64_t contextId, bool visible, WebCore::IntRect inlineRect);
+    void preparedToExitFullscreen(uint64_t contextId);
 #if PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)
     void exitFullscreenWithoutAnimationToMode(uint64_t contextId, WebCore::HTMLMediaElementEnums::VideoFullscreenMode);
 #endif
@@ -160,6 +162,7 @@
     void requestVideoContentLayer(uint64_t contextId);
     void returnVideoContentLayer(uint64_t contextId);
     void didSetupFullscreen(uint64_t contextId);
+    void willExitFullscreen(uint64_t contextId);
     void didExitFullscreen(uint64_t contextId);
     void didEnterFullscreen(uint64_t contextId);
     void didCleanupFullscreen(uint64_t contextId);

Modified: trunk/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.messages.in (230193 => 230194)


--- trunk/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.messages.in	2018-04-03 00:11:16 UTC (rev 230193)
+++ trunk/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.messages.in	2018-04-03 00:50:29 UTC (rev 230194)
@@ -31,6 +31,7 @@
     SetHasVideoContentLayer(uint64_t contextId, bool value)
     CleanupFullscreen(uint64_t contextId)
     PreparedToReturnToInline(uint64_t contextId, bool visible, WebCore::IntRect inlineRect)
+    PreparedToExitFullscreen(uint64_t contextId)
 #if PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)
     ExitFullscreenWithoutAnimationToMode(uint64_t contextId, WebCore::HTMLMediaElementEnums::VideoFullscreenMode videoFullscreenMode)
 #endif

Modified: trunk/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.mm (230193 => 230194)


--- trunk/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.mm	2018-04-03 00:11:16 UTC (rev 230193)
+++ trunk/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.mm	2018-04-03 00:50:29 UTC (rev 230194)
@@ -258,6 +258,12 @@
         m_manager->didEnterFullscreen(m_contextId);
 }
 
+void VideoFullscreenModelContext::willExitFullscreen()
+{
+    if (m_manager)
+        m_manager->willExitFullscreen(m_contextId);
+}
+
 void VideoFullscreenModelContext::didExitFullscreen()
 {
     if (m_manager)
@@ -541,6 +547,11 @@
 #endif
 }
 
+void VideoFullscreenManagerProxy::preparedToExitFullscreen(uint64_t contextId)
+{
+    ensureInterface(contextId).preparedToExitFullscreen();
+}
+
 #pragma mark Messages to VideoFullscreenManager
 
 void VideoFullscreenManagerProxy::requestFullscreenMode(uint64_t contextId, WebCore::HTMLMediaElementEnums::VideoFullscreenMode mode, bool finishedWithMedia)
@@ -568,6 +579,11 @@
     m_page->send(Messages::VideoFullscreenManager::DidSetupFullscreen(contextId), m_page->pageID());
 }
 
+void VideoFullscreenManagerProxy::willExitFullscreen(uint64_t contextId)
+{
+    m_page->send(Messages::VideoFullscreenManager::WillExitFullscreen(contextId), m_page->pageID());
+}
+
 void VideoFullscreenManagerProxy::didExitFullscreen(uint64_t contextId)
 {
     m_page->send(Messages::VideoFullscreenManager::DidExitFullscreen(contextId), m_page->pageID());

Modified: trunk/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.h (230193 => 230194)


--- trunk/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.h	2018-04-03 00:11:16 UTC (rev 230193)
+++ trunk/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.h	2018-04-03 00:50:29 UTC (rev 230194)
@@ -143,6 +143,7 @@
     void requestVideoContentLayer(uint64_t contextId);
     void returnVideoContentLayer(uint64_t contextId);
     void didSetupFullscreen(uint64_t contextId);
+    void willExitFullscreen(uint64_t contextId);
     void didExitFullscreen(uint64_t contextId);
     void didEnterFullscreen(uint64_t contextId);
     void didCleanupFullscreen(uint64_t contextId);

Modified: trunk/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.messages.in (230193 => 230194)


--- trunk/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.messages.in	2018-04-03 00:11:16 UTC (rev 230193)
+++ trunk/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.messages.in	2018-04-03 00:50:29 UTC (rev 230194)
@@ -27,6 +27,7 @@
     RequestVideoContentLayer(uint64_t contextId)
     ReturnVideoContentLayer(uint64_t contextId)
     DidSetupFullscreen(uint64_t contextId)
+    WillExitFullscreen(uint64_t contextId)
     DidExitFullscreen(uint64_t contextId)
     DidEnterFullscreen(uint64_t contextId)
     DidCleanupFullscreen(uint64_t contextId)

Modified: trunk/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm (230193 => 230194)


--- trunk/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm	2018-04-03 00:11:16 UTC (rev 230193)
+++ trunk/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm	2018-04-03 00:50:29 UTC (rev 230194)
@@ -427,7 +427,26 @@
     });
 #endif
 }
-    
+
+void VideoFullscreenManager::willExitFullscreen(uint64_t contextId)
+{
+    LOG(Fullscreen, "VideoFullscreenManager::willExitFullscreen(%p, %x)", this, contextId);
+
+    RefPtr<VideoFullscreenModelVideoElement> model;
+    RefPtr<VideoFullscreenInterfaceContext> interface;
+    std::tie(model, interface) = ensureModelAndInterface(contextId);
+
+    RefPtr<HTMLVideoElement> videoElement = model->videoElement();
+    if (!videoElement)
+        return;
+
+    dispatch_async(dispatch_get_main_queue(), [protectedThis = makeRefPtr(this), videoElement = WTFMove(videoElement), contextId] {
+        videoElement->willExitFullscreen();
+        if (protectedThis->m_page)
+            protectedThis->m_page->send(Messages::VideoFullscreenManagerProxy::PreparedToExitFullscreen(contextId), protectedThis->m_page->pageID());
+    });
+}
+
 void VideoFullscreenManager::didEnterFullscreen(uint64_t contextId)
 {
     LOG(Fullscreen, "VideoFullscreenManager::didEnterFullscreen(%p, %x)", this, contextId);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to