Title: [234071] branches/safari-606-branch
Revision
234071
Author
bshaf...@apple.com
Date
2018-07-20 15:55:33 -0700 (Fri, 20 Jul 2018)

Log Message

Revert r233926. rdar://problem/42446531

Modified Paths

Added Paths

Removed Paths

Diff

Modified: branches/safari-606-branch/LayoutTests/ChangeLog (234070 => 234071)


--- branches/safari-606-branch/LayoutTests/ChangeLog	2018-07-20 22:55:25 UTC (rev 234070)
+++ branches/safari-606-branch/LayoutTests/ChangeLog	2018-07-20 22:55:33 UTC (rev 234071)
@@ -1,3 +1,7 @@
+2018-07-20  Babak Shafiei  <bshaf...@apple.com>
+
+        Revert r233926. rdar://problem/42446531
+
 2018-07-20  Ryan Haddad  <ryanhad...@apple.com>
 
         Cherry-pick r234041. rdar://problem/42417113

Modified: branches/safari-606-branch/LayoutTests/TestExpectations (234070 => 234071)


--- branches/safari-606-branch/LayoutTests/TestExpectations	2018-07-20 22:55:25 UTC (rev 234070)
+++ branches/safari-606-branch/LayoutTests/TestExpectations	2018-07-20 22:55:33 UTC (rev 234071)
@@ -1448,8 +1448,10 @@
 media/controls/pip-placeholder-without-video-controls.html [ WontFix ]
 media/element-containing-pip-video-going-into-fullscreen.html [ WontFix ]
 media/fullscreen-api-enabled-media-with-presentation-mode.html [ WontFix ]
+media/fullscreen-video-going-into-pip.html [ WontFix ]
 media/navigate-with-pip-should-not-crash.html [ WontFix ]
 media/pip-video-going-into-fullscreen.html [ WontFix ]
+media/video-contained-in-fullscreen-element-going-into-pip.html [ WontFix ]
 
 webkit.org/b/159370 [ Debug ] fast/history/page-cache-destroy-document.html [ Skip ]
 

Added: branches/safari-606-branch/LayoutTests/media/fullscreen-video-going-into-pip-expected.txt (0 => 234071)


--- branches/safari-606-branch/LayoutTests/media/fullscreen-video-going-into-pip-expected.txt	                        (rev 0)
+++ branches/safari-606-branch/LayoutTests/media/fullscreen-video-going-into-pip-expected.txt	2018-07-20 22:55:33 UTC (rev 234071)
@@ -0,0 +1,9 @@
+Tests fullscreen video going into pip should exit fullscreen
+
+Going into Full Screen
+EXPECTED (document.webkitCurrentFullScreenElement == '[object HTMLVideoElement]') OK
+Going into Picture-in-Picture from Full Screen
+Entered Picture-in-Picture from Full Screen
+EXPECTED (document.webkitCurrentFullScreenElement == 'null') OK
+END OF TEST
+

Added: branches/safari-606-branch/LayoutTests/media/fullscreen-video-going-into-pip.html (0 => 234071)


--- branches/safari-606-branch/LayoutTests/media/fullscreen-video-going-into-pip.html	                        (rev 0)
+++ branches/safari-606-branch/LayoutTests/media/fullscreen-video-going-into-pip.html	2018-07-20 22:55:33 UTC (rev 234071)
@@ -0,0 +1,54 @@
+<html>
+<head>
+    <title>Test fullscreen video going into pip should exit fullscreen</title>
+    <script src=""
+    <script src=""
+    <script>
+        if (window.internals)
+            window.internals.settings.setAllowsPictureInPictureMediaPlayback(true);
+
+        function init()
+        {
+            findMediaElement();
+            video.addEventListener('canplaythrough', oncanplaythrough);
+            video.src = "" 'content/test');
+        }
+
+        function oncanplaythrough()
+        {
+            if (!('webkitSupportsPresentationMode' in video && 'webkitPresentationMode' in video)) {
+                failTest("Presentation mode is not supported in this video element.")
+                return;
+            }
+
+            consoleWrite("Going into Full Screen");
+            video.addEventListener('webkitpresentationmodechanged', onfullscreenchange);
+            runWithKeyDown(function(){ video.webkitRequestFullscreen(); });
+        }
+
+        function onfullscreenchange()
+        {
+            testExpected("document.webkitCurrentFullScreenElement", video);
+            video.removeEventListener('webkitpresentationmodechanged', onfullscreenchange);
+
+            consoleWrite("Going into Picture-in-Picture from Full Screen");
+            video.addEventListener('webkitpresentationmodechanged', onpresentationmodechanged);
+            runWithKeyDown(function() { video.webkitSetPresentationMode("picture-in-picture"); });
+        }
+
+        function onpresentationmodechanged()
+        {
+            consoleWrite("Entered Picture-in-Picture from Full Screen");
+            testExpected("document.webkitCurrentFullScreenElement", null);
+
+            endTest();
+        }
+
+    </script>
+</head>
+<body _onload_="init()">
+    Tests fullscreen video going into pip should exit fullscreen<br>
+    <video controls></video>
+</body>
+</html>
+

Added: branches/safari-606-branch/LayoutTests/media/video-contained-in-fullscreen-element-going-into-pip-expected.txt (0 => 234071)


--- branches/safari-606-branch/LayoutTests/media/video-contained-in-fullscreen-element-going-into-pip-expected.txt	                        (rev 0)
+++ branches/safari-606-branch/LayoutTests/media/video-contained-in-fullscreen-element-going-into-pip-expected.txt	2018-07-20 22:55:33 UTC (rev 234071)
@@ -0,0 +1,11 @@
+Tests video contained in fullscreen element going into pip should exit fullscreen
+
+Container div going into Full Screen
+EXPECTED (document.webkitCurrentFullScreenElement == '[object HTMLDivElement]') OK
+EXPECTED (video.webkitPresentationMode == 'inline') OK
+Video going into Picture-in-Picture
+Entered Picture-in-Picture from Full Screen
+EXPECTED (document.webkitCurrentFullScreenElement == 'null') OK
+EXPECTED (video.webkitPresentationMode == 'picture-in-picture') OK
+END OF TEST
+

Added: branches/safari-606-branch/LayoutTests/media/video-contained-in-fullscreen-element-going-into-pip.html (0 => 234071)


--- branches/safari-606-branch/LayoutTests/media/video-contained-in-fullscreen-element-going-into-pip.html	                        (rev 0)
+++ branches/safari-606-branch/LayoutTests/media/video-contained-in-fullscreen-element-going-into-pip.html	2018-07-20 22:55:33 UTC (rev 234071)
@@ -0,0 +1,59 @@
+<html>
+<head>
+    <title>Test video contained in fullscreen element going into pip should exit fullscreen</title>
+    <script src=""
+    <script src=""
+    <script>
+        if (window.internals)
+            window.internals.settings.setAllowsPictureInPictureMediaPlayback(true);
+
+        function init()
+        {
+            findMediaElement();
+            video.addEventListener('canplaythrough', oncanplaythrough);
+            video.src = "" 'content/test');
+        }
+
+        function oncanplaythrough()
+        {
+            if (!('webkitSupportsPresentationMode' in video && 'webkitPresentationMode' in video)) {
+                failTest("Presentation mode is not supported in this video element.")
+                return;
+            }
+
+            consoleWrite("Container div going into Full Screen");
+            videoContainer.addEventListener('webkitfullscreenchange', onfullscreenchange);
+            runWithKeyDown(function(){ videoContainer.webkitRequestFullscreen(); });
+        }
+
+        function onfullscreenchange()
+        {
+            testExpected("document.webkitCurrentFullScreenElement", videoContainer);
+            testExpected("video.webkitPresentationMode", "inline")
+
+            videoContainer.removeEventListener('webkitfullscreenchange', onfullscreenchange);
+
+            consoleWrite("Video going into Picture-in-Picture");
+            video.addEventListener('webkitpresentationmodechanged', onpresentationmodechanged);
+            runWithKeyDown(function() { video.webkitSetPresentationMode("picture-in-picture"); });
+        }
+
+        function onpresentationmodechanged()
+        {
+            consoleWrite("Entered Picture-in-Picture from Full Screen");
+            testExpected("document.webkitCurrentFullScreenElement", null);
+            testExpected("video.webkitPresentationMode", "picture-in-picture");
+
+            endTest();
+        }
+
+    </script>
+</head>
+<body _onload_="init()">
+    Tests video contained in fullscreen element going into pip should exit fullscreen<br>
+    <div id="videoContainer">
+        <video controls></video>
+    </div>
+</body>
+</html>
+

Modified: branches/safari-606-branch/LayoutTests/platform/mac-wk2/TestExpectations (234070 => 234071)


--- branches/safari-606-branch/LayoutTests/platform/mac-wk2/TestExpectations	2018-07-20 22:55:25 UTC (rev 234070)
+++ branches/safari-606-branch/LayoutTests/platform/mac-wk2/TestExpectations	2018-07-20 22:55:33 UTC (rev 234071)
@@ -549,8 +549,10 @@
 webkit.org/b/170620 [ Sierra+ ] media/controls/pip-placeholder-without-video-controls.html [ Pass Failure ]
 [ Sierra+ ] media/element-containing-pip-video-going-into-fullscreen.html [ Pass Timeout ]
 webkit.org/b/172998 [ Sierra+ ] media/fullscreen-api-enabled-media-with-presentation-mode.html [ Failure ]
+[ Sierra+ ] media/fullscreen-video-going-into-pip.html [ Pass ]
 webkit.org/b/173199 [ Sierra+ ] media/navigate-with-pip-should-not-crash.html [ Pass Failure ]
 [ Sierra+ ] media/pip-video-going-into-fullscreen.html [ Pass ]
+[ Sierra+ ] media/video-contained-in-fullscreen-element-going-into-pip.html [ Pass ]
 
 # RTL Scrollbars are enabled on Sierra WebKit2.
 webkit.org/b/179455 [ Sierra+ ] fast/scrolling/rtl-scrollbars.html [ Pass ImageOnlyFailure ]

Modified: branches/safari-606-branch/Source/WebCore/ChangeLog (234070 => 234071)


--- branches/safari-606-branch/Source/WebCore/ChangeLog	2018-07-20 22:55:25 UTC (rev 234070)
+++ branches/safari-606-branch/Source/WebCore/ChangeLog	2018-07-20 22:55:33 UTC (rev 234071)
@@ -1,5 +1,9 @@
 2018-07-20  Babak Shafiei  <bshaf...@apple.com>
 
+        Revert r233926. rdar://problem/42446531
+
+2018-07-20  Babak Shafiei  <bshaf...@apple.com>
+
         Revert r233930. rdar://problem/42446531
 
 2018-07-20  Babak Shafiei  <bshaf...@apple.com>

Modified: branches/safari-606-branch/Source/WebCore/PAL/ChangeLog (234070 => 234071)


--- branches/safari-606-branch/Source/WebCore/PAL/ChangeLog	2018-07-20 22:55:25 UTC (rev 234070)
+++ branches/safari-606-branch/Source/WebCore/PAL/ChangeLog	2018-07-20 22:55:33 UTC (rev 234071)
@@ -1,3 +1,7 @@
+2018-07-20  Babak Shafiei  <bshaf...@apple.com>
+
+        Revert r233926. rdar://problem/42446531
+
 2018-07-18  Babak Shafiei  <bshaf...@apple.com>
 
         Cherry-pick r233932. rdar://problem/42353789

Modified: branches/safari-606-branch/Source/WebCore/PAL/pal/spi/mac/PIPSPI.h (234070 => 234071)


--- branches/safari-606-branch/Source/WebCore/PAL/pal/spi/mac/PIPSPI.h	2018-07-20 22:55:25 UTC (rev 234070)
+++ branches/safari-606-branch/Source/WebCore/PAL/pal/spi/mac/PIPSPI.h	2018-07-20 22:55:33 UTC (rev 234071)
@@ -49,7 +49,6 @@
 @protocol PIPViewControllerDelegate <NSObject>
 @optional
 - (BOOL)pipShouldClose:(PIPViewController *)pip;
-- (void)pipWillClose:(PIPViewController *)pip;
 - (void)pipDidClose:(PIPViewController *)pip;
 - (void)pipActionPlay:(PIPViewController *)pip;
 - (void)pipActionPause:(PIPViewController *)pip;

Modified: branches/safari-606-branch/Source/WebCore/html/HTMLMediaElement.cpp (234070 => 234071)


--- branches/safari-606-branch/Source/WebCore/html/HTMLMediaElement.cpp	2018-07-20 22:55:25 UTC (rev 234070)
+++ branches/safari-606-branch/Source/WebCore/html/HTMLMediaElement.cpp	2018-07-20 22:55:33 UTC (rev 234071)
@@ -5923,10 +5923,22 @@
     m_temporarilyAllowingInlinePlaybackAfterFullscreen = false;
     m_waitingToEnterFullscreen = true;
 
-#if ENABLE(FULLSCREEN_API) && ENABLE(VIDEO_USES_ELEMENT_FULLSCREEN)
-    if (document().settings().fullScreenEnabled() && mode == VideoFullscreenModeStandard) {
-        document().requestFullScreenForElement(this, Document::ExemptIFrameAllowFullScreenRequirement);
-        return;
+#if ENABLE(FULLSCREEN_API)
+    if (document().settings().fullScreenEnabled()) {
+#if ENABLE(VIDEO_USES_ELEMENT_FULLSCREEN)
+        if (mode == VideoFullscreenModeStandard) {
+            document().requestFullScreenForElement(this, Document::ExemptIFrameAllowFullScreenRequirement);
+            return;
+        }
+#endif
+
+        // If this media element is not going to standard fullscreen mode but there's
+        // an element that's currently in full screen in the document, exit full screen
+        // if it contains this media element.
+        if (RefPtr<Element> fullscreenElement = document().webkitCurrentFullScreenElement()) {
+            if (fullscreenElement->contains(this))
+                document().webkitCancelFullScreen();
+        }
     }
 #endif
 

Modified: branches/safari-606-branch/Source/WebCore/platform/cocoa/VideoFullscreenModel.h (234070 => 234071)


--- branches/safari-606-branch/Source/WebCore/platform/cocoa/VideoFullscreenModel.h	2018-07-20 22:55:25 UTC (rev 234070)
+++ branches/safari-606-branch/Source/WebCore/platform/cocoa/VideoFullscreenModel.h	2018-07-20 22:55:33 UTC (rev 234071)
@@ -57,12 +57,6 @@
     virtual FloatSize videoDimensions() const = 0;
     virtual bool hasVideo() const = 0;
 
-    virtual void willEnterPictureInPicture() = 0;
-    virtual void didEnterPictureInPicture() = 0;
-    virtual void failedToEnterPictureInPicture() = 0;
-    virtual void willExitPictureInPicture() = 0;
-    virtual void didExitPictureInPicture() = 0;
-
 #if PLATFORM(IOS)
     virtual UIViewController *presentingViewController() { return nullptr; }
     virtual UIViewController *createVideoFullscreenViewController(AVPlayerViewController *) { return nullptr; }
@@ -72,13 +66,8 @@
 class VideoFullscreenModelClient {
 public:
     virtual ~VideoFullscreenModelClient() = default;
-    virtual void hasVideoChanged(bool) { };
-    virtual void videoDimensionsChanged(const FloatSize&) { };
-    virtual void willEnterPictureInPicture() { }
-    virtual void didEnterPictureInPicture() { }
-    virtual void failedToEnterPictureInPicture() { }
-    virtual void willExitPictureInPicture() { }
-    virtual void didExitPictureInPicture() { }
+    virtual void hasVideoChanged(bool) = 0;
+    virtual void videoDimensionsChanged(const FloatSize&) = 0;
 };
 
 WEBCORE_EXPORT bool supportsPictureInPicture();

Modified: branches/safari-606-branch/Source/WebCore/platform/cocoa/VideoFullscreenModelVideoElement.h (234070 => 234071)


--- branches/safari-606-branch/Source/WebCore/platform/cocoa/VideoFullscreenModelVideoElement.h	2018-07-20 22:55:25 UTC (rev 234070)
+++ branches/safari-606-branch/Source/WebCore/platform/cocoa/VideoFullscreenModelVideoElement.h	2018-07-20 22:55:33 UTC (rev 234071)
@@ -80,12 +80,6 @@
     void setHasVideo(bool);
     void setVideoDimensions(const FloatSize&);
 
-    void willEnterPictureInPicture() override;
-    void didEnterPictureInPicture() override;
-    void failedToEnterPictureInPicture() override;
-    void willExitPictureInPicture() override;
-    void didExitPictureInPicture() override;
-
     static const Vector<WTF::AtomicString>& observedEventNames();
     const WTF::AtomicString& eventNameAll();
 

Modified: branches/safari-606-branch/Source/WebCore/platform/cocoa/VideoFullscreenModelVideoElement.mm (234070 => 234071)


--- branches/safari-606-branch/Source/WebCore/platform/cocoa/VideoFullscreenModelVideoElement.mm	2018-07-20 22:55:25 UTC (rev 234070)
+++ branches/safari-606-branch/Source/WebCore/platform/cocoa/VideoFullscreenModelVideoElement.mm	2018-07-20 22:55:33 UTC (rev 234071)
@@ -240,34 +240,4 @@
         client->videoDimensionsChanged(m_videoDimensions);
 }
 
-void VideoFullscreenModelVideoElement::willEnterPictureInPicture()
-{
-    for (auto& client : m_clients)
-        client->willEnterPictureInPicture();
-}
-
-void VideoFullscreenModelVideoElement::didEnterPictureInPicture()
-{
-    for (auto& client : m_clients)
-        client->didEnterPictureInPicture();
-}
-
-void VideoFullscreenModelVideoElement::failedToEnterPictureInPicture()
-{
-    for (auto& client : m_clients)
-        client->failedToEnterPictureInPicture();
-}
-
-void VideoFullscreenModelVideoElement::willExitPictureInPicture()
-{
-    for (auto& client : m_clients)
-        client->willExitPictureInPicture();
-}
-
-void VideoFullscreenModelVideoElement::didExitPictureInPicture()
-{
-    for (auto& client : m_clients)
-        client->didExitPictureInPicture();
-}
-
 #endif

Modified: branches/safari-606-branch/Source/WebCore/platform/ios/VideoFullscreenInterfaceAVKit.h (234070 => 234071)


--- branches/safari-606-branch/Source/WebCore/platform/ios/VideoFullscreenInterfaceAVKit.h	2018-07-20 22:55:25 UTC (rev 234070)
+++ branches/safari-606-branch/Source/WebCore/platform/ios/VideoFullscreenInterfaceAVKit.h	2018-07-20 22:55:33 UTC (rev 234071)
@@ -58,17 +58,16 @@
 class VideoFullscreenModel;
 class VideoFullscreenChangeObserver;
     
-class VideoFullscreenInterfaceAVKit final
+class WEBCORE_EXPORT VideoFullscreenInterfaceAVKit final
     : public VideoFullscreenModelClient
     , public PlaybackSessionModelClient
     , public ThreadSafeRefCounted<VideoFullscreenInterfaceAVKit> {
 
 public:
-    WEBCORE_EXPORT static Ref<VideoFullscreenInterfaceAVKit> create(PlaybackSessionInterfaceAVKit&);
+    static Ref<VideoFullscreenInterfaceAVKit> create(PlaybackSessionInterfaceAVKit&);
     virtual ~VideoFullscreenInterfaceAVKit();
     WEBCORE_EXPORT void setVideoFullscreenModel(VideoFullscreenModel*);
     WEBCORE_EXPORT void setVideoFullscreenChangeObserver(VideoFullscreenChangeObserver*);
-    PlaybackSessionInterfaceAVKit& playbackSessionInterface() const { return m_playbackSessionInterface.get(); }
     PlaybackSessionModel* playbackSessionModel() const { return m_playbackSessionInterface->playbackSessionModel(); }
 
     // VideoFullscreenModelClient
@@ -131,7 +130,7 @@
     Mode m_targetMode;
 #endif
 
-    VideoFullscreenModel* videoFullscreenModel() const { return m_videoFullscreenModel; }
+    VideoFullscreenModel* model() const { return m_videoFullscreenModel; }
     bool shouldExitFullscreenWithReason(ExitFullScreenReason);
     HTMLMediaElementEnums::VideoFullscreenMode mode() const { return m_currentMode.mode(); }
     bool allowsPictureInPicturePlayback() const { return m_allowsPictureInPicturePlayback; }
@@ -138,7 +137,7 @@
     WEBCORE_EXPORT bool mayAutomaticallyShowVideoPictureInPicture() const;
     void fullscreenMayReturnToInline(WTF::Function<void(bool)>&& callback);
     bool wirelessVideoPlaybackDisabled() const;
-    WEBCORE_EXPORT void applicationDidBecomeActive();
+    void applicationDidBecomeActive();
 
     void willStartPictureInPicture();
     void didStartPictureInPicture();
@@ -152,7 +151,7 @@
 #endif
     bool isPlayingVideoInEnhancedFullscreen() const;
 
-    WEBCORE_EXPORT void setMode(HTMLMediaElementEnums::VideoFullscreenMode);
+    void setMode(HTMLMediaElementEnums::VideoFullscreenMode);
     void clearMode(HTMLMediaElementEnums::VideoFullscreenMode);
     bool hasMode(HTMLMediaElementEnums::VideoFullscreenMode mode) const { return m_currentMode.hasMode(mode); }
 
@@ -160,7 +159,6 @@
     UIViewController *presentingViewController();
     UIViewController *fullscreenViewController() const { return m_viewController.get(); }
     WebAVPlayerLayerView* playerLayerView() const { return m_playerLayerView.get(); }
-    WEBCORE_EXPORT bool pictureInPictureWasStartedWhenEnteringBackground() const;
 #endif
 
 protected:

Modified: branches/safari-606-branch/Source/WebCore/platform/ios/VideoFullscreenInterfaceAVKit.mm (234070 => 234071)


--- branches/safari-606-branch/Source/WebCore/platform/ios/VideoFullscreenInterfaceAVKit.mm	2018-07-20 22:55:25 UTC (rev 234070)
+++ branches/safari-606-branch/Source/WebCore/platform/ios/VideoFullscreenInterfaceAVKit.mm	2018-07-20 22:55:33 UTC (rev 234071)
@@ -289,8 +289,8 @@
     } else if ([getAVLayerVideoGravityResizeAspectFill() isEqualToString:self.videoGravity]) {
         sourceVideoFrame = smallestRectWithAspectRatioAroundRect(videoAspectRatio, self.modelVideoLayerFrame);
         self.modelVideoLayerFrame = CGRectMake(0, 0, sourceVideoFrame.width(), sourceVideoFrame.height());
-        ASSERT(_fullscreenInterface->videoFullscreenModel());
-        _fullscreenInterface->videoFullscreenModel()->setVideoLayerFrame(self.modelVideoLayerFrame);
+        ASSERT(_fullscreenInterface->model());
+        _fullscreenInterface->model()->setVideoLayerFrame(self.modelVideoLayerFrame);
         targetVideoFrame = smallestRectWithAspectRatioAroundRect(videoAspectRatio, self.bounds);
     } else
         ASSERT_NOT_REACHED();
@@ -325,8 +325,8 @@
     
     if (!CGRectEqualToRect(self.modelVideoLayerFrame, [self bounds])) {
         self.modelVideoLayerFrame = [self bounds];
-        ASSERT(_fullscreenInterface->videoFullscreenModel());
-        _fullscreenInterface->videoFullscreenModel()->setVideoLayerFrame(self.modelVideoLayerFrame);
+        ASSERT(_fullscreenInterface->model());
+        _fullscreenInterface->model()->setVideoLayerFrame(self.modelVideoLayerFrame);
     }
     [(UIView *)[_videoSublayer delegate] setTransform:CGAffineTransformIdentity];
     
@@ -350,8 +350,8 @@
     else
         ASSERT_NOT_REACHED();
     
-    ASSERT(_fullscreenInterface->videoFullscreenModel());
-    _fullscreenInterface->videoFullscreenModel()->setVideoLayerGravity(gravity);
+    ASSERT(_fullscreenInterface->model());
+    _fullscreenInterface->model()->setVideoLayerGravity(gravity);
 }
 
 - (NSString *)videoGravity
@@ -797,11 +797,6 @@
     [m_playerLayerView setHidden:enabled];
 }
 
-BOOL VideoFullscreenInterfaceAVKit::pictureInPictureWasStartedWhenEnteringBackground() const
-{
-    return [m_playerViewController pictureInPictureWasStartedWhenEnteringBackground];
-}
-
 #if !ENABLE(FULLSCREEN_API)
 
 void VideoFullscreenInterfaceAVKit::applicationDidBecomeActive()
@@ -884,7 +879,7 @@
     [playerController() setPictureInPicturePossible:m_allowsPictureInPicturePlayback];
 
 #if PLATFORM(WATCHOS)
-    m_viewController = videoFullscreenModel()->createVideoFullscreenViewController(m_playerViewController.get().avPlayerViewController);
+    m_viewController = model()->createVideoFullscreenViewController(m_playerViewController.get().avPlayerViewController);
 #endif
 
     if (m_viewController) {
@@ -949,7 +944,7 @@
 
 UIViewController *VideoFullscreenInterfaceAVKit::presentingViewController()
 {
-    auto *controller = videoFullscreenModel()->presentingViewController();
+    auto *controller = model()->presentingViewController();
     if (!controller)
         controller = fallbackViewController(m_parentView.get());
 
@@ -1139,18 +1134,16 @@
 {
     LOG(Fullscreen, "VideoFullscreenInterfaceAVKit::willStartPictureInPicture(%p)", this);
     setMode(HTMLMediaElementEnums::VideoFullscreenModePictureInPicture);
-    if (m_videoFullscreenModel)
-        m_videoFullscreenModel->willEnterPictureInPicture();
 }
 
 void VideoFullscreenInterfaceAVKit::didStartPictureInPicture()
 {
     LOG(Fullscreen, "VideoFullscreenInterfaceAVKit::didStartPictureInPicture(%p)", this);
-    m_shouldReturnToFullscreenAfterEnteringForeground = pictureInPictureWasStartedWhenEnteringBackground();
+    m_shouldReturnToFullscreenAfterEnteringForeground = [m_playerViewController pictureInPictureWasStartedWhenEnteringBackground];
     [m_playerViewController setShowsPlaybackControls:YES];
 
     if (m_currentMode.hasFullscreen()) {
-        if (!pictureInPictureWasStartedWhenEnteringBackground()) {
+        if (![m_playerViewController pictureInPictureWasStartedWhenEnteringBackground]) {
             [[m_playerViewController view] layoutIfNeeded];
             [m_playerViewController exitFullScreenAnimated:YES completionHandler:[protectedThis = makeRefPtr(this), this] (BOOL success, NSError* error) {
                 if (!success)
@@ -1166,8 +1159,6 @@
 
     if (m_fullscreenChangeObserver)
         m_fullscreenChangeObserver->didEnterFullscreen();
-    if (m_videoFullscreenModel)
-        m_videoFullscreenModel->didEnterPictureInPicture();
 }
 
 void VideoFullscreenInterfaceAVKit::failedToStartPictureInPicture()
@@ -1182,8 +1173,6 @@
 
     if (m_fullscreenChangeObserver)
         m_fullscreenChangeObserver->didEnterFullscreen();
-    if (m_videoFullscreenModel)
-        m_videoFullscreenModel->failedToEnterPictureInPicture();
 
     if (m_videoFullscreenModel)
         m_videoFullscreenModel->requestFullscreenMode(HTMLMediaElementEnums::VideoFullscreenModeNone);
@@ -1204,8 +1193,6 @@
 
     if (m_videoFullscreenModel)
         m_videoFullscreenModel->requestFullscreenMode(HTMLMediaElementEnums::VideoFullscreenModeNone);
-    if (m_videoFullscreenModel)
-        m_videoFullscreenModel->willExitPictureInPicture();
 }
 
 void VideoFullscreenInterfaceAVKit::didStopPictureInPicture()
@@ -1228,8 +1215,6 @@
 
     if (m_fullscreenChangeObserver)
         m_fullscreenChangeObserver->didExitFullscreen();
-    if (m_videoFullscreenModel)
-        m_videoFullscreenModel->didExitPictureInPicture();
 }
 
 void VideoFullscreenInterfaceAVKit::prepareForPictureInPictureStopWithCompletionHandler(void (^completionHandler)(BOOL restored))
@@ -1270,7 +1255,7 @@
         return true;
 
     if (reason == ExitFullScreenReason::PictureInPictureStarted) {
-        if (pictureInPictureWasStartedWhenEnteringBackground())
+        if ([m_playerViewController pictureInPictureWasStartedWhenEnteringBackground])
             return false;
 
         m_shouldReturnToFullscreenWhenStoppingPiP = m_currentMode.hasFullscreen();
@@ -1445,8 +1430,6 @@
 
     if (!m_hasVideoContentLayer)
         m_fullscreenChangeObserver->requestVideoContentLayer();
-    if (m_videoFullscreenModel)
-        m_videoFullscreenModel->willEnterPictureInPicture();
 }
 
 void VideoFullscreenInterfaceAVKit::didStartPictureInPicture()
@@ -1466,9 +1449,6 @@
         [[m_playerViewController view] setHidden:YES];
     }
 
-    if (m_videoFullscreenModel)
-        m_videoFullscreenModel->didEnterPictureInPicture();
-
     if (m_enterFullscreenNeedsEnterPictureInPicture)
         doEnterFullscreen();
 }
@@ -1486,9 +1466,6 @@
         m_fullscreenChangeObserver->didEnterFullscreen();
 
     if (m_videoFullscreenModel)
-        m_videoFullscreenModel->failedToEnterPictureInPicture();
-
-    if (m_videoFullscreenModel)
         m_videoFullscreenModel->requestFullscreenMode(HTMLMediaElementEnums::VideoFullscreenModeNone);
 }
 
@@ -1503,9 +1480,6 @@
 
     [m_window setHidden:NO];
     [[m_playerViewController view] setHidden:NO];
-
-    if (m_videoFullscreenModel)
-        m_videoFullscreenModel->willExitPictureInPicture();
 }
 
 void VideoFullscreenInterfaceAVKit::didStopPictureInPicture()
@@ -1530,9 +1504,6 @@
 
     clearMode(HTMLMediaElementEnums::VideoFullscreenModePictureInPicture);
 
-    if (m_videoFullscreenModel)
-        m_videoFullscreenModel->didExitPictureInPicture();
-
     if (m_enterFullscreenNeedsExitPictureInPicture)
         doEnterFullscreen();
 
@@ -1682,7 +1653,7 @@
     [playerController() setPictureInPicturePossible:m_allowsPictureInPicturePlayback];
 
 #if PLATFORM(WATCHOS)
-    m_viewController = videoFullscreenModel()->createVideoFullscreenViewController(m_playerViewController.get().avPlayerViewController);
+    m_viewController = model()->createVideoFullscreenViewController(m_playerViewController.get().avPlayerViewController);
 #endif
 
     if (m_viewController) {

Modified: branches/safari-606-branch/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm (234070 => 234071)


--- branches/safari-606-branch/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm	2018-07-20 22:55:25 UTC (rev 234070)
+++ branches/safari-606-branch/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm	2018-07-20 22:55:33 UTC (rev 234071)
@@ -202,11 +202,6 @@
     bool isMuted() const override;
     double volume() const override;
     bool isPictureInPictureActive() const override;
-    void willEnterPictureInPicture() final;
-    void didEnterPictureInPicture() final;
-    void failedToEnterPictureInPicture() final;
-    void willExitPictureInPicture() final;
-    void didExitPictureInPicture() final;
 
     HashSet<PlaybackSessionModelClient*> m_playbackClients;
     HashSet<VideoFullscreenModelClient*> m_fullscreenClients;
@@ -632,41 +627,6 @@
     return m_playbackModel ? m_playbackModel->isPictureInPictureActive() : false;
 }
 
-void VideoFullscreenControllerContext::willEnterPictureInPicture()
-{
-    ASSERT(isUIThread());
-    for (auto* client : m_fullscreenClients)
-        client->willEnterPictureInPicture();
-}
-
-void VideoFullscreenControllerContext::didEnterPictureInPicture()
-{
-    ASSERT(isUIThread());
-    for (auto* client : m_fullscreenClients)
-        client->didEnterPictureInPicture();
-}
-
-void VideoFullscreenControllerContext::failedToEnterPictureInPicture()
-{
-    ASSERT(isUIThread());
-    for (auto* client : m_fullscreenClients)
-        client->failedToEnterPictureInPicture();
-}
-
-void VideoFullscreenControllerContext::willExitPictureInPicture()
-{
-    ASSERT(isUIThread());
-    for (auto* client : m_fullscreenClients)
-        client->willExitPictureInPicture();
-}
-
-void VideoFullscreenControllerContext::didExitPictureInPicture()
-{
-    ASSERT(isUIThread());
-    for (auto* client : m_fullscreenClients)
-        client->didExitPictureInPicture();
-}
-
 FloatSize VideoFullscreenControllerContext::videoDimensions() const
 {
     ASSERT(isUIThread());

Modified: branches/safari-606-branch/Source/WebCore/platform/mac/VideoFullscreenInterfaceMac.h (234070 => 234071)


--- branches/safari-606-branch/Source/WebCore/platform/mac/VideoFullscreenInterfaceMac.h	2018-07-20 22:55:25 UTC (rev 234070)
+++ branches/safari-606-branch/Source/WebCore/platform/mac/VideoFullscreenInterfaceMac.h	2018-07-20 22:55:33 UTC (rev 234071)
@@ -44,7 +44,7 @@
 class PlaybackSessionInterfaceMac;
 class VideoFullscreenChangeObserver;
 
-class VideoFullscreenInterfaceMac
+class WEBCORE_EXPORT VideoFullscreenInterfaceMac
     : public VideoFullscreenModelClient
     , private PlaybackSessionModelClient
     , public RefCounted<VideoFullscreenInterfaceMac> {
@@ -55,7 +55,6 @@
         return adoptRef(*new VideoFullscreenInterfaceMac(playbackSessionInterface));
     }
     virtual ~VideoFullscreenInterfaceMac();
-    PlaybackSessionInterfaceMac& playbackSessionInterface() const { return m_playbackSessionInterface.get(); }
     VideoFullscreenModel* videoFullscreenModel() const { return m_videoFullscreenModel; }
     PlaybackSessionModel* playbackSessionModel() const { return m_playbackSessionInterface->playbackSessionModel(); }
     WEBCORE_EXPORT void setVideoFullscreenModel(VideoFullscreenModel*);
@@ -77,7 +76,7 @@
     WEBCORE_EXPORT void exitFullscreenWithoutAnimationToMode(HTMLMediaElementEnums::VideoFullscreenMode);
     WEBCORE_EXPORT void cleanupFullscreen();
     WEBCORE_EXPORT void invalidate();
-    WEBCORE_EXPORT void requestHideAndExitFullscreen();
+    void requestHideAndExitFullscreen() { }
     WEBCORE_EXPORT void preparedToReturnToInline(bool visible, const IntRect& inlineRect, NSWindow *parentWindow);
     void preparedToExitFullscreen() { }
 
@@ -84,10 +83,10 @@
     HTMLMediaElementEnums::VideoFullscreenMode mode() const { return m_mode; }
     bool hasMode(HTMLMediaElementEnums::VideoFullscreenMode mode) const { return m_mode & mode; }
     bool isMode(HTMLMediaElementEnums::VideoFullscreenMode mode) const { return m_mode == mode; }
-    WEBCORE_EXPORT void setMode(HTMLMediaElementEnums::VideoFullscreenMode);
+    void setMode(HTMLMediaElementEnums::VideoFullscreenMode);
     void clearMode(HTMLMediaElementEnums::VideoFullscreenMode);
 
-    WEBCORE_EXPORT bool isPlayingVideoInEnhancedFullscreen() const;
+    bool isPlayingVideoInEnhancedFullscreen() const;
 
     bool mayAutomaticallyShowVideoPictureInPicture() const { return false; }
     void applicationDidBecomeActive() { }
@@ -95,7 +94,7 @@
     WEBCORE_EXPORT WebVideoFullscreenInterfaceMacObjC *videoFullscreenInterfaceObjC();
 
 private:
-    WEBCORE_EXPORT VideoFullscreenInterfaceMac(PlaybackSessionInterfaceMac&);
+    VideoFullscreenInterfaceMac(PlaybackSessionInterfaceMac&);
     Ref<PlaybackSessionInterfaceMac> m_playbackSessionInterface;
     VideoFullscreenModel* m_videoFullscreenModel { nullptr };
     VideoFullscreenChangeObserver* m_fullscreenChangeObserver { nullptr };

Modified: branches/safari-606-branch/Source/WebCore/platform/mac/VideoFullscreenInterfaceMac.mm (234070 => 234071)


--- branches/safari-606-branch/Source/WebCore/platform/mac/VideoFullscreenInterfaceMac.mm	2018-07-20 22:55:25 UTC (rev 234070)
+++ branches/safari-606-branch/Source/WebCore/platform/mac/VideoFullscreenInterfaceMac.mm	2018-07-20 22:55:33 UTC (rev 234071)
@@ -107,6 +107,7 @@
     RetainPtr<NSWindow> _returningWindow;
     NSRect _returningRect;
     BOOL _playing;
+    BOOL _didRequestExitingPIP;
     BOOL _exitingToStandardFullscreen;
 }
 
@@ -120,6 +121,7 @@
 - (void)updateIsPlaying:(BOOL)isPlaying newPlaybackRate:(float)playbackRate;
 
 // Handling PIP transitions
+@property (nonatomic, readonly) BOOL didRequestExitingPIP;
 @property (nonatomic, getter=isExitingToStandardFullscreen) BOOL exitingToStandardFullscreen;
 
 - (void)setUpPIPForVideoView:(NSView *)videoView withFrame:(NSRect)frame inWindow:(NSWindow *)window;
@@ -133,6 +135,7 @@
 
 @synthesize playing=_playing;
 @synthesize videoDimensions=_videoDimensions;
+@synthesize didRequestExitingPIP=_didRequestExitingPIP;
 @synthesize exitingToStandardFullscreen=_exitingToStandardFullscreen;
 
 - (instancetype)initWithVideoFullscreenInterfaceMac:(WebCore::VideoFullscreenInterfaceMac*)videoFullscreenInterfaceMac
@@ -155,6 +158,7 @@
     _videoViewContainer = nil;
     _videoViewContainerController = nil;
     _pipState = PIPState::NotInPIP;
+    _didRequestExitingPIP = NO;
     _exitingToStandardFullscreen = NO;
     _returningWindow = nil;
     _returningRect = NSZeroRect;
@@ -221,6 +225,7 @@
     if (_pipState != PIPState::InPIP || !_pipViewController || !_videoViewContainerController)
         return;
 
+    _didRequestExitingPIP = YES;
     [_videoViewContainerController view].layer.backgroundColor = CGColorGetConstantColor(kCGColorClear);
     [_pipViewController dismissViewController:_videoViewContainerController.get()];
     _pipState = PIPState::ExitingPIP;
@@ -230,7 +235,7 @@
 {
     _returningWindow = window;
     _returningRect = rect;
-
+    
     [_pipViewController setReplacementRect:rect];
     [_pipViewController setReplacementWindow:window];
 
@@ -274,7 +279,8 @@
     if (!_videoFullscreenInterfaceMac || !_videoFullscreenInterfaceMac->videoFullscreenChangeObserver())
         return YES;
 
-    _videoFullscreenInterfaceMac->requestHideAndExitFullscreen();
+    _didRequestExitingPIP = YES;
+    _videoFullscreenInterfaceMac->videoFullscreenChangeObserver()->fullscreenMayReturnToInline();
 
     return NO;
 }
@@ -297,11 +303,13 @@
     if (_videoFullscreenInterfaceMac) {
         if (!self.isExitingToStandardFullscreen) {
             if (VideoFullscreenModel* videoFullscreenModel = _videoFullscreenInterfaceMac->videoFullscreenModel()) {
-                videoFullscreenModel->didExitPictureInPicture();
+                videoFullscreenModel->requestFullscreenMode(HTMLMediaElementEnums::VideoFullscreenModeNone);
                 videoFullscreenModel->setVideoLayerGravity(VideoFullscreenModel::VideoGravityResizeAspect);
             }
         }
 
+        _videoFullscreenInterfaceMac->clearMode(HTMLMediaElementEnums::VideoFullscreenModePictureInPicture);
+
         if (VideoFullscreenChangeObserver* fullscreenChangeObserver = _videoFullscreenInterfaceMac->videoFullscreenChangeObserver())
             fullscreenChangeObserver->didExitFullscreen();
     }
@@ -435,7 +443,6 @@
     LOG(Fullscreen, "VideoFullscreenInterfaceMac::enterFullscreen(%p)", this);
 
     if (mode() == HTMLMediaElementEnums::VideoFullscreenModePictureInPicture) {
-        m_videoFullscreenModel->willEnterPictureInPicture();
         [m_webVideoFullscreenInterfaceObjC enterPIP];
 
 #if ENABLE(WEB_PLAYBACK_CONTROLS_MANAGER)
@@ -442,8 +449,6 @@
         [m_playbackSessionInterface->playBackControlsManager() setPictureInPictureActive:YES];
 #endif
 
-        // FIXME(rdar://problem/42250952): Move this call into a completion handler or delegate callback.
-        m_videoFullscreenModel->didEnterPictureInPicture();
         if (m_fullscreenChangeObserver)
             m_fullscreenChangeObserver->didEnterFullscreen();
     }
@@ -457,6 +462,9 @@
     [m_playbackSessionInterface->playBackControlsManager() setPictureInPictureActive:NO];
 #endif
 
+    if ([m_webVideoFullscreenInterfaceObjC didRequestExitingPIP])
+        return;
+
     if (finalRect.isEmpty())
         [m_webVideoFullscreenInterfaceObjC exitPIP];
     else
@@ -471,6 +479,9 @@
     [m_playbackSessionInterface->playBackControlsManager() setPictureInPictureActive:NO];
 #endif
 
+    if ([m_webVideoFullscreenInterfaceObjC didRequestExitingPIP])
+        return;
+
     bool isExitingToStandardFullscreen = mode == HTMLMediaElementEnums::VideoFullscreenModeStandard;
     // On Mac, standard fullscreen is handled by the Fullscreen API and not by VideoFullscreenManager.
     // Just update m_mode directly to HTMLMediaElementEnums::VideoFullscreenModeStandard in that case to keep
@@ -506,15 +517,6 @@
     m_webVideoFullscreenInterfaceObjC = nil;
 }
 
-void VideoFullscreenInterfaceMac::requestHideAndExitFullscreen()
-{
-    if (!m_videoFullscreenModel)
-        return;
-
-    m_videoFullscreenModel->requestFullscreenMode(HTMLMediaElementEnums::VideoFullscreenModeNone);
-    m_videoFullscreenModel->willExitPictureInPicture();
-}
-
 #if !LOG_DISABLED
 static const char* boolString(bool val)
 {

Modified: branches/safari-606-branch/Source/WebKit/ChangeLog (234070 => 234071)


--- branches/safari-606-branch/Source/WebKit/ChangeLog	2018-07-20 22:55:25 UTC (rev 234070)
+++ branches/safari-606-branch/Source/WebKit/ChangeLog	2018-07-20 22:55:33 UTC (rev 234071)
@@ -1,5 +1,9 @@
 2018-07-20  Babak Shafiei  <bshaf...@apple.com>
 
+        Revert r233926. rdar://problem/42446531
+
+2018-07-20  Babak Shafiei  <bshaf...@apple.com>
+
         Cherry-pick r233925. rdar://problem/42354959
 
     Dissociate the VideoFullscreenInterface from its VideoFullscreenModel before removing it from the manager

Modified: branches/safari-606-branch/Source/WebKit/UIProcess/Cocoa/PlaybackSessionManagerProxy.h (234070 => 234071)


--- branches/safari-606-branch/Source/WebKit/UIProcess/Cocoa/PlaybackSessionManagerProxy.h	2018-07-20 22:55:25 UTC (rev 234070)
+++ branches/safari-606-branch/Source/WebKit/UIProcess/Cocoa/PlaybackSessionManagerProxy.h	2018-07-20 22:55:33 UTC (rev 234071)
@@ -190,8 +190,6 @@
     void addClientForContext(uint64_t contextId);
     void removeClientForContext(uint64_t contextId);
 
-    uint64_t controlsManagerContextId() const { return m_controlsManagerContextId; }
-
     // Messages from PlaybackSessionManager
     void setUpPlaybackControlsManagerWithID(uint64_t contextId);
     void clearPlaybackControlsManager();

Modified: branches/safari-606-branch/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.h (234070 => 234071)


--- branches/safari-606-branch/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.h	2018-07-20 22:55:25 UTC (rev 234070)
+++ branches/safari-606-branch/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.h	2018-07-20 22:55:33 UTC (rev 234071)
@@ -89,11 +89,6 @@
     UIViewController *presentingViewController() final;
     UIViewController *createVideoFullscreenViewController(AVPlayerViewController*) final;
 #endif
-    void willEnterPictureInPicture() final;
-    void didEnterPictureInPicture() final;
-    void failedToEnterPictureInPicture() final;
-    void willExitPictureInPicture() final;
-    void didExitPictureInPicture() final;
 
     // VideoFullscreenChangeObserver
     void requestUpdateInlineRect() final;
@@ -132,8 +127,6 @@
     bool isPlayingVideoInEnhancedFullscreen() const;
 #endif
 
-    PlatformVideoFullscreenInterface* controlsManagerInterface();
-
 private:
     friend class VideoFullscreenModelContext;
 

Modified: branches/safari-606-branch/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.mm (234070 => 234071)


--- branches/safari-606-branch/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.mm	2018-07-20 22:55:25 UTC (rev 234070)
+++ branches/safari-606-branch/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.mm	2018-07-20 22:55:33 UTC (rev 234071)
@@ -282,36 +282,6 @@
         m_manager->fullscreenMayReturnToInline(m_contextId);
 }
 
-void VideoFullscreenModelContext::willEnterPictureInPicture()
-{
-    for (auto& client : m_clients)
-        client->willEnterPictureInPicture();
-}
-
-void VideoFullscreenModelContext::didEnterPictureInPicture()
-{
-    for (auto& client : m_clients)
-        client->didEnterPictureInPicture();
-}
-
-void VideoFullscreenModelContext::failedToEnterPictureInPicture()
-{
-    for (auto& client : m_clients)
-        client->failedToEnterPictureInPicture();
-}
-
-void VideoFullscreenModelContext::willExitPictureInPicture()
-{
-    for (auto& client : m_clients)
-        client->willExitPictureInPicture();
-}
-
-void VideoFullscreenModelContext::didExitPictureInPicture()
-{
-    for (auto& client : m_clients)
-        client->didExitPictureInPicture();
-}
-
 #pragma mark - VideoFullscreenManagerProxy
 
 RefPtr<VideoFullscreenManagerProxy> VideoFullscreenManagerProxy::create(WebPageProxy& page, PlaybackSessionManagerProxy& playbackSessionManagerProxy)
@@ -388,13 +358,6 @@
 }
 #endif
 
-PlatformVideoFullscreenInterface* VideoFullscreenManagerProxy::controlsManagerInterface()
-{
-    if (auto contextId = m_playbackSessionManagerProxy->controlsManagerContextId())
-        return &ensureInterface(contextId);
-    return nullptr;
-}
-
 void VideoFullscreenManagerProxy::applicationDidBecomeActive()
 {
     for (auto& tuple : m_contextMap.values())

Modified: branches/safari-606-branch/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm (234070 => 234071)


--- branches/safari-606-branch/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm	2018-07-20 22:55:25 UTC (rev 234070)
+++ branches/safari-606-branch/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm	2018-07-20 22:55:33 UTC (rev 234071)
@@ -3283,11 +3283,6 @@
 #if HAVE(TOUCH_BAR)
     updateTouchBar();
 #endif
-
-#if ENABLE(FULLSCREEN_API)
-    if (hasFullScreenWindowController())
-        [fullScreenWindowController() videoControlsManagerDidChange];
-#endif
 }
 
 void WebViewImpl::setIgnoresNonWheelEvents(bool ignoresNonWheelEvents)

Modified: branches/safari-606-branch/Source/WebKit/UIProcess/ios/fullscreen/WKFullScreenViewController.mm (234070 => 234071)


--- branches/safari-606-branch/Source/WebKit/UIProcess/ios/fullscreen/WKFullScreenViewController.mm	2018-07-20 22:55:25 UTC (rev 234070)
+++ branches/safari-606-branch/Source/WebKit/UIProcess/ios/fullscreen/WKFullScreenViewController.mm	2018-07-20 22:55:33 UTC (rev 234071)
@@ -31,7 +31,6 @@
 #import "FullscreenTouchSecheuristic.h"
 #import "PlaybackSessionManagerProxy.h"
 #import "UIKitSPI.h"
-#import "VideoFullscreenManagerProxy.h"
 #import "WKFullscreenStackView.h"
 #import "WKWebViewInternal.h"
 #import "WebFullScreenManagerProxy.h"
@@ -44,18 +43,11 @@
 using namespace WebKit;
 
 static const NSTimeInterval showHideAnimationDuration = 0.1;
-static const NSTimeInterval pipHideAnimationDuration = 0.2;
 static const NSTimeInterval autoHideDelay = 4.0;
 static const double requiredScore = 0.1;
 
 @class WKFullscreenStackView;
 
-@interface WKFullScreenViewController (VideoFullscreenClientCallbacks)
-- (void)willEnterPictureInPicture;
-- (void)didEnterPictureInPicture;
-- (void)failedToEnterPictureInPicture;
-@end
-
 class WKFullScreenViewControllerPlaybackSessionModelClient : PlaybackSessionModelClient {
 public:
     void setParent(WKFullScreenViewController *parent) { m_parent = parent; }
@@ -87,44 +79,6 @@
     RefPtr<PlaybackSessionInterfaceAVKit> m_interface;
 };
 
-class WKFullScreenViewControllerVideoFullscreenModelClient : VideoFullscreenModelClient {
-public:
-    void setParent(WKFullScreenViewController *parent) { m_parent = parent; }
-
-    void setInterface(VideoFullscreenInterfaceAVKit* interface)
-    {
-        if (m_interface == interface)
-            return;
-
-        if (m_interface && m_interface->videoFullscreenModel())
-            m_interface->videoFullscreenModel()->removeClient(*this);
-        m_interface = interface;
-        if (m_interface && m_interface->videoFullscreenModel())
-            m_interface->videoFullscreenModel()->addClient(*this);
-    }
-
-    VideoFullscreenInterfaceAVKit* interface() const { return m_interface.get(); }
-
-    void willEnterPictureInPicture() final
-    {
-        [m_parent willEnterPictureInPicture];
-    }
-
-    void didEnterPictureInPicture() final
-    {
-        [m_parent didEnterPictureInPicture];
-    }
-
-    void failedToEnterPictureInPicture() final
-    {
-        [m_parent failedToEnterPictureInPicture];
-    }
-
-private:
-    WKFullScreenViewController *m_parent { nullptr };
-    RefPtr<VideoFullscreenInterfaceAVKit> m_interface;
-};
-
 #pragma mark - _WKExtrinsicButton
 
 @interface _WKExtrinsicButton : UIButton
@@ -154,7 +108,6 @@
 
 @implementation WKFullScreenViewController {
     RetainPtr<UILongPressGestureRecognizer> _touchGestureRecognizer;
-    RetainPtr<UIView> _animatingView;
     RetainPtr<WKFullscreenStackView> _stackView;
     RetainPtr<_WKExtrinsicButton> _cancelButton;
     RetainPtr<_WKExtrinsicButton> _pipButton;
@@ -163,7 +116,6 @@
     RetainPtr<NSLayoutConstraint> _topConstraint;
     WebKit::FullscreenTouchSecheuristic _secheuristic;
     WKFullScreenViewControllerPlaybackSessionModelClient _playbackClient;
-    WKFullScreenViewControllerVideoFullscreenModelClient _videoFullscreenClient;
     CGFloat _nonZeroStatusBarHeight;
 }
 
@@ -189,7 +141,6 @@
     self._webView = webView;
 
     _playbackClient.setParent(self);
-    _videoFullscreenClient.setParent(self);
 
     return self;
 }
@@ -200,8 +151,6 @@
     [[NSNotificationCenter defaultCenter] removeObserver:self];
 
     _playbackClient.setInterface(nullptr);
-    _videoFullscreenClient.setParent(nullptr);
-    _videoFullscreenClient.setInterface(nullptr);
 
     [_target release];
     [_location release];
@@ -256,12 +205,9 @@
 - (void)videoControlsManagerDidChange
 {
     WebPageProxy* page = [self._webView _page];
-    auto* videoFullscreenManager = page ? page->videoFullscreenManager() : nullptr;
-    auto* videoFullscreenInterface = videoFullscreenManager ? videoFullscreenManager->controlsManagerInterface() : nullptr;
-    auto* playbackSessionInterface = videoFullscreenInterface ? &videoFullscreenInterface->playbackSessionInterface() : nullptr;
-
+    PlaybackSessionManagerProxy* playbackSessionManager = page ? page->playbackSessionManager() : nullptr;
+    PlatformPlaybackSessionInterface* playbackSessionInterface = playbackSessionManager ? playbackSessionManager->controlsManagerInterface() : nullptr;
     _playbackClient.setInterface(playbackSessionInterface);
-    _videoFullscreenClient.setInterface(videoFullscreenInterface);
 
     PlaybackSessionModel* playbackSessionModel = playbackSessionInterface ? playbackSessionInterface->playbackSessionModel() : nullptr;
     self.playing = playbackSessionModel ? playbackSessionModel->isPlaying() : NO;
@@ -318,33 +264,6 @@
         [self showUI];
 }
 
-- (void)willEnterPictureInPicture
-{
-    auto* interface = _videoFullscreenClient.interface();
-    if (!interface || !interface->pictureInPictureWasStartedWhenEnteringBackground())
-        return;
-
-    [UIView animateWithDuration:pipHideAnimationDuration animations:^{
-        _animatingView.get().alpha = 0;
-    }];
-}
-
-- (void)didEnterPictureInPicture
-{
-    [self _cancelAction:self];
-}
-
-- (void)failedToEnterPictureInPicture
-{
-    auto* interface = _videoFullscreenClient.interface();
-    if (!interface || !interface->pictureInPictureWasStartedWhenEnteringBackground())
-        return;
-
-    [UIView animateWithDuration:pipHideAnimationDuration animations:^{
-        _animatingView.get().alpha = 1;
-    }];
-}
-
 #pragma mark - UIViewController Overrides
 
 - (void)loadView
@@ -351,12 +270,7 @@
 {
     [self setView:adoptNS([[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)]).get()];
     self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
-    self.view.backgroundColor = [UIColor blackColor];
 
-    _animatingView = adoptNS([[UIView alloc] initWithFrame:self.view.bounds]);
-    _animatingView.get().autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
-    [self.view addSubview:_animatingView.get()];
-
     _cancelButton = [_WKExtrinsicButton buttonWithType:UIButtonTypeSystem];
     [_cancelButton setTranslatesAutoresizingMaskIntoConstraints:NO];
     [_cancelButton setAdjustsImageWhenHighlighted:NO];
@@ -384,7 +298,7 @@
     [_stackView setTranslatesAutoresizingMaskIntoConstraints:NO];
     [_stackView addArrangedSubview:_cancelButton.get() applyingMaterialStyle:AVBackgroundViewMaterialStyleSecondary tintEffectStyle:AVBackgroundViewTintEffectStyleSecondary];
     [_stackView addArrangedSubview:_pipButton.get() applyingMaterialStyle:AVBackgroundViewMaterialStylePrimary tintEffectStyle:AVBackgroundViewTintEffectStyleSecondary];
-    [_animatingView addSubview:_stackView.get()];
+    [[self view] addSubview:_stackView.get()];
 
     UILayoutGuide *safeArea = self.view.safeAreaLayoutGuide;
     UILayoutGuide *margins = self.view.layoutMarginsGuide;
@@ -414,7 +328,7 @@
 {
     self._webView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
     self._webView.frame = self.view.bounds;
-    [_animatingView insertSubview:self._webView atIndex:0];
+    [self.view insertSubview:self._webView atIndex:0];
 
     if (auto* manager = self._manager)
         manager->setFullscreenAutoHideDuration(Seconds(showHideAnimationDuration));

Modified: branches/safari-606-branch/Source/WebKit/UIProcess/mac/WKFullScreenWindowController.h (234070 => 234071)


--- branches/safari-606-branch/Source/WebKit/UIProcess/mac/WKFullScreenWindowController.h	2018-07-20 22:55:25 UTC (rev 234070)
+++ branches/safari-606-branch/Source/WebKit/UIProcess/mac/WKFullScreenWindowController.h	2018-07-20 22:55:33 UTC (rev 234071)
@@ -31,7 +31,6 @@
 namespace WebKit { 
 class LayerTreeContext;
 class WebPageProxy;
-class WKFullScreenWindowControllerVideoFullscreenModelClient;
 }
 
 namespace WebCore {
@@ -60,7 +59,6 @@
 
     double _savedScale;
     RefPtr<WebKit::VoidCallback> _repaintCallback;
-    std::unique_ptr<WebKit::WKFullScreenWindowControllerVideoFullscreenModelClient> _videoFullscreenClient;
     float _savedTopContentInset;
 }
 
@@ -81,9 +79,6 @@
 - (void)beganEnterFullScreenWithInitialFrame:(NSRect)initialFrame finalFrame:(NSRect)finalFrame;
 - (void)beganExitFullScreenWithInitialFrame:(NSRect)initialFrame finalFrame:(NSRect)finalFrame;
 
-- (void)videoControlsManagerDidChange;
-- (void)didEnterPictureInPicture;
-
 @end
 
 #endif

Modified: branches/safari-606-branch/Source/WebKit/UIProcess/mac/WKFullScreenWindowController.mm (234070 => 234071)


--- branches/safari-606-branch/Source/WebKit/UIProcess/mac/WKFullScreenWindowController.mm	2018-07-20 22:55:25 UTC (rev 234070)
+++ branches/safari-606-branch/Source/WebKit/UIProcess/mac/WKFullScreenWindowController.mm	2018-07-20 22:55:33 UTC (rev 234071)
@@ -30,7 +30,6 @@
 #import "WKFullScreenWindowController.h"
 
 #import "LayerTreeContext.h"
-#import "VideoFullscreenManagerProxy.h"
 #import "WKAPICast.h"
 #import "WKViewInternal.h"
 #import "WKViewPrivate.h"
@@ -41,51 +40,16 @@
 #import <WebCore/GeometryUtilities.h>
 #import <WebCore/IntRect.h>
 #import <WebCore/LocalizedStrings.h>
-#import <WebCore/VideoFullscreenInterfaceMac.h>
-#import <WebCore/VideoFullscreenModel.h>
 #import <WebCore/WebCoreFullScreenPlaceholderView.h>
 #import <WebCore/WebCoreFullScreenWindow.h>
 #import <pal/system/SleepDisabler.h>
 #import <wtf/BlockObjCExceptions.h>
 
+using namespace WebKit;
 using namespace WebCore;
 
 static const NSTimeInterval DefaultWatchdogTimerInterval = 1;
 
-namespace WebKit {
-
-class WKFullScreenWindowControllerVideoFullscreenModelClient : VideoFullscreenModelClient {
-public:
-    void setParent(WKFullScreenWindowController *parent) { m_parent = parent; }
-
-    void setInterface(VideoFullscreenInterfaceMac* interface)
-    {
-        if (m_interface == interface)
-            return;
-
-        if (m_interface && m_interface->videoFullscreenModel())
-            m_interface->videoFullscreenModel()->removeClient(*this);
-        m_interface = interface;
-        if (m_interface && m_interface->videoFullscreenModel())
-            m_interface->videoFullscreenModel()->addClient(*this);
-    }
-
-    VideoFullscreenInterfaceMac* interface() const { return m_interface.get(); }
-
-    void didEnterPictureInPicture() final
-    {
-        [m_parent didEnterPictureInPicture];
-    }
-
-private:
-    WKFullScreenWindowController *m_parent { nullptr };
-    RefPtr<VideoFullscreenInterfaceMac> m_interface;
-};
-
-}
-
-using namespace WebKit;
-
 enum FullScreenState : NSInteger {
     NotInFullScreen,
     WaitingToEnterFullScreen,
@@ -149,12 +113,7 @@
     [window displayIfNeeded];
     _webView = webView;
     _page = &page;
-
-    _videoFullscreenClient = std::make_unique<WKFullScreenWindowControllerVideoFullscreenModelClient>();
-    _videoFullscreenClient->setParent(self);
-
-    [self videoControlsManagerDidChange];
-
+    
     return self;
 }
 
@@ -173,9 +132,6 @@
         ASSERT(!_repaintCallback);
     }
 
-    _videoFullscreenClient->setParent(nil);
-    _videoFullscreenClient->setInterface(nullptr);
-
     [super dealloc];
 }
 
@@ -550,19 +506,6 @@
     [super close];
 }
 
-- (void)videoControlsManagerDidChange
-{
-    auto* videoFullscreenManager = _page ? _page->videoFullscreenManager() : nullptr;
-    auto* videoFullscreenInterface = videoFullscreenManager ? videoFullscreenManager->controlsManagerInterface() : nullptr;
-
-    _videoFullscreenClient->setInterface(videoFullscreenInterface);
-}
-
-- (void)didEnterPictureInPicture
-{
-    [self requestExitFullScreen];
-}
-
 #pragma mark -
 #pragma mark Custom NSWindow Full Screen Animation
 

Modified: branches/safari-606-branch/Tools/ChangeLog (234070 => 234071)


--- branches/safari-606-branch/Tools/ChangeLog	2018-07-20 22:55:25 UTC (rev 234070)
+++ branches/safari-606-branch/Tools/ChangeLog	2018-07-20 22:55:33 UTC (rev 234071)
@@ -1,3 +1,7 @@
+2018-07-20  Babak Shafiei  <bshaf...@apple.com>
+
+        Revert r233926. rdar://problem/42446531
+
 2018-07-18  Babak Shafiei  <bshaf...@apple.com>
 
         Cherry-pick r233915. rdar://problem/42345407

Modified: branches/safari-606-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (234070 => 234071)


--- branches/safari-606-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2018-07-20 22:55:25 UTC (rev 234070)
+++ branches/safari-606-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2018-07-20 22:55:33 UTC (rev 234071)
@@ -720,8 +720,6 @@
 		CD78E11D1DB7EA660014A2DE /* FullscreenDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD78E11A1DB7EA360014A2DE /* FullscreenDelegate.mm */; };
 		CD78E11E1DB7EE2A0014A2DE /* FullscreenDelegate.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CD78E11B1DB7EA360014A2DE /* FullscreenDelegate.html */; };
 		CD9E292E1C90C33F000BB800 /* audio-only.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CD9E292D1C90C1BA000BB800 /* audio-only.html */; };
-		CDA29B2920FD2A9900F15CED /* ExitFullscreenOnEnterPiP.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDA29B2820FD2A9900F15CED /* ExitFullscreenOnEnterPiP.mm */; };
-		CDA29B2B20FD358400F15CED /* ExitFullscreenOnEnterPiP.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CDA29B2A20FD344E00F15CED /* ExitFullscreenOnEnterPiP.html */; };
 		CDA315981ED53651009F60D3 /* MediaPlaybackSleepAssertion.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDA315961ED53651009F60D3 /* MediaPlaybackSleepAssertion.mm */; };
 		CDA3159A1ED548F1009F60D3 /* MediaPlaybackSleepAssertion.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CDA315991ED540A5009F60D3 /* MediaPlaybackSleepAssertion.html */; };
 		CDA3159D1ED5643F009F60D3 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CDA3159C1ED5643F009F60D3 /* IOKit.framework */; };
@@ -983,7 +981,6 @@
 				F407FE391F1D0DFC0017CF25 /* enormous.svg in Copy Resources */,
 				07492B3C1DF8B86600633DE1 /* enumerateMediaDevices.html in Copy Resources */,
 				C5E1AFFE16B221F1006CC1F2 /* execCopy.html in Copy Resources */,
-				CDA29B2B20FD358400F15CED /* ExitFullscreenOnEnterPiP.html in Copy Resources */,
 				F41AB9A31EF4696B0083FA08 /* file-uploading.html in Copy Resources */,
 				BC2D006412AA04CE00E732A3 /* file-with-anchor.html in Copy Resources */,
 				CD59F53419E9110D00CF1835 /* file-with-mse.html in Copy Resources */,
@@ -1911,8 +1908,6 @@
 		CD89D0381C4EDB2A00040A04 /* WebCoreNSURLSession.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreNSURLSession.mm; sourceTree = "<group>"; };
 		CD9E292B1C90A71F000BB800 /* RequiresUserActionForPlayback.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RequiresUserActionForPlayback.mm; sourceTree = "<group>"; };
 		CD9E292D1C90C1BA000BB800 /* audio-only.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "audio-only.html"; sourceTree = "<group>"; };
-		CDA29B2820FD2A9900F15CED /* ExitFullscreenOnEnterPiP.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ExitFullscreenOnEnterPiP.mm; sourceTree = "<group>"; };
-		CDA29B2A20FD344E00F15CED /* ExitFullscreenOnEnterPiP.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = ExitFullscreenOnEnterPiP.html; sourceTree = "<group>"; };
 		CDA315961ED53651009F60D3 /* MediaPlaybackSleepAssertion.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MediaPlaybackSleepAssertion.mm; sourceTree = "<group>"; };
 		CDA315991ED540A5009F60D3 /* MediaPlaybackSleepAssertion.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = MediaPlaybackSleepAssertion.html; sourceTree = "<group>"; };
 		CDA3159C1ED5643F009F60D3 /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = System/Library/Frameworks/IOKit.framework; sourceTree = SDKROOT; };
@@ -2258,7 +2253,6 @@
 				A1A4FE5D18DD3DB700B5EA8A /* Download.mm */,
 				A15502281E05020B00A24C57 /* DuplicateCompletionHandlerCalls.mm */,
 				F44D06461F395C4D001A0E29 /* EditorStateTests.mm */,
-				CDA29B2820FD2A9900F15CED /* ExitFullscreenOnEnterPiP.mm */,
 				2D8104CB1BEC13E70020DA46 /* FindInPage.mm */,
 				2D1FE0AF1AD465C1006CD9E6 /* FixedLayoutSize.mm */,
 				5CB5B3BD1FFC517E00C27BB0 /* FrameHandleSerialization.mm */,
@@ -2574,7 +2568,6 @@
 				9984FACD1CFFB038008D198C /* editable-body.html */,
 				F44D06441F395C0D001A0E29 /* editor-state-test-harness.html */,
 				51C8E1A81F27F47300BF731B /* EmptyGrandfatheredResourceLoadStatistics.plist */,
-				CDA29B2A20FD344E00F15CED /* ExitFullscreenOnEnterPiP.html */,
 				F4C2AB211DD6D94100E06D5B /* enormous-video-with-sound.html */,
 				F407FE381F1D0DE60017CF25 /* enormous.svg */,
 				F41AB99B1EF4692C0083FA08 /* file-uploading.html */,
@@ -3814,7 +3807,6 @@
 				518C1153205B0504001FF4AE /* ProcessSwapOnNavigation.mm in Sources */,
 				7C83E0C11D0A652F00FEBCF3 /* ProvisionalURLNotChange.mm in Sources */,
 				7CCE7EC81A411A7E00447C4C /* PublicSuffix.mm in Sources */,
-				CDA29B2920FD2A9900F15CED /* ExitFullscreenOnEnterPiP.mm in Sources */,
 				7C83E0C21D0A653500FEBCF3 /* QuickLook.mm in Sources */,
 				7CCE7F0D1A411AE600447C4C /* ReloadPageAfterCrash.cpp in Sources */,
 				7C83E0C31D0A653A00FEBCF3 /* RemoteObjectRegistry.mm in Sources */,

Deleted: branches/safari-606-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/ExitFullscreenOnEnterPiP.html (234070 => 234071)


--- branches/safari-606-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/ExitFullscreenOnEnterPiP.html	2018-07-20 22:55:25 UTC (rev 234070)
+++ branches/safari-606-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/ExitFullscreenOnEnterPiP.html	2018-07-20 22:55:33 UTC (rev 234071)
@@ -1,14 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-</head>
-<button id="enter-video-fullscreen" _onclick_="document.querySelector('video').webkitEnterFullscreen()">enter video fullscreen</button>
-<button id="enter-element-fullscreen" _onclick_="document.querySelector('#target').webkitRequestFullscreen()">enter element fullscreen</button>
-<button id="enter-pip" _onclick_="document.querySelector('video').webkitSetPresentationMode('picture-in-picture')">enter pip</button>
-<button id="exit-pip" _onclick_="document.querySelector('video').webkitSetPresentationMode('inline')">exit pip</button>
-<body _onload_="load(); window._onloadcompleted_ = true; ">
-    <div id="target">
-        <video id="video" playsinline src="" />
-    </div>
-</body>
-</html>

Deleted: branches/safari-606-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/ExitFullscreenOnEnterPiP.mm (234070 => 234071)


--- branches/safari-606-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/ExitFullscreenOnEnterPiP.mm	2018-07-20 22:55:25 UTC (rev 234070)
+++ branches/safari-606-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/ExitFullscreenOnEnterPiP.mm	2018-07-20 22:55:33 UTC (rev 234071)
@@ -1,131 +0,0 @@
-/*
- * Copyright (C) 2018 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#if (WK_API_ENABLED && PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300) || (PLATFORM(IOS) && !PLATFORM(IOS_SIMULATOR))
-
-#import "PlatformUtilities.h"
-#import "Test.h"
-#import "TestWKWebView.h"
-#import <WebKit/WKPreferencesPrivate.h>
-#import <WebKit/WKUIDelegatePrivate.h>
-#import <WebKit/_WKFullscreenDelegate.h>
-#import <wtf/RetainPtr.h>
-#import <wtf/Seconds.h>
-
-static bool didEnterPiP;
-static bool didExitPiP;
-static bool didEnterFullscreen;
-static bool didExitFullscreen;
-
-@interface ExitFullscreenOnEnterPiPUIDelegate : NSObject <WKUIDelegate, _WKFullscreenDelegate>
-@end
-
-@implementation ExitFullscreenOnEnterPiPUIDelegate
-
-- (void)_webView:(WKWebView *)webView hasVideoInPictureInPictureDidChange:(BOOL)value
-{
-    if (value)
-        didEnterPiP = true;
-    else
-        didExitPiP = true;
-}
-
-- (void)_webViewDidEnterFullscreen:(WKWebView *)webView
-{
-    didEnterFullscreen = true;
-}
-
-- (void)_webViewDidExitFullscreen:(WKWebView *)webView
-{
-    didExitFullscreen = true;
-}
-@end
-
-namespace TestWebKitAPI {
-
-TEST(ExitFullscreenOnEnterPiP, VideoFullscreen)
-{
-    RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
-    [configuration preferences]._fullScreenEnabled = YES;
-    [configuration preferences]._allowsPictureInPictureMediaPlayback = YES;
-    RetainPtr<TestWKWebView> webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 300, 300) configuration:configuration.get() addToWindow:YES]);
-    RetainPtr<ExitFullscreenOnEnterPiPUIDelegate> handler = adoptNS([[ExitFullscreenOnEnterPiPUIDelegate alloc] init]);
-    [webView setUIDelegate:handler.get()];
-    [webView _setFullscreenDelegate:handler.get()];
-
-    [webView synchronouslyLoadTestPageNamed:@"ExitFullscreenOnEnterPiP"];
-
-    didEnterFullscreen = false;
-    [webView evaluateJavaScript:@"document.getElementById('enter-video-fullscreen').click()" completionHandler: nil];
-    TestWebKitAPI::Util::run(&didEnterFullscreen);
-    ASSERT_TRUE(didEnterFullscreen);
-
-    didEnterPiP = false;
-    didExitFullscreen = false;
-    [webView evaluateJavaScript:@"document.getElementById('enter-pip').click()" completionHandler: nil];
-    TestWebKitAPI::Util::run(&didEnterPiP);
-    TestWebKitAPI::Util::run(&didExitFullscreen);
-
-    sleep(1_s); // Wait for PIPAgent to launch, or it won't call -pipDidClose: callback.
-
-    [webView evaluateJavaScript:@"document.getElementById('exit-pip').click()" completionHandler: nil];
-    TestWebKitAPI::Util::run(&didExitPiP);
-}
-
-
-TEST(ExitFullscreenOnEnterPiP, ElementFullscreen)
-{
-    RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
-    [configuration preferences]._fullScreenEnabled = YES;
-    [configuration preferences]._allowsPictureInPictureMediaPlayback = YES;
-    RetainPtr<TestWKWebView> webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 300, 300) configuration:configuration.get() addToWindow:YES]);
-    RetainPtr<ExitFullscreenOnEnterPiPUIDelegate> handler = adoptNS([[ExitFullscreenOnEnterPiPUIDelegate alloc] init]);
-    [webView setUIDelegate:handler.get()];
-    [webView _setFullscreenDelegate:handler.get()];
-
-    [webView synchronouslyLoadTestPageNamed:@"ExitFullscreenOnEnterPiP"];
-
-    didEnterFullscreen = false;
-    [webView evaluateJavaScript:@"document.getElementById('enter-element-fullscreen').click()" completionHandler: nil];
-    TestWebKitAPI::Util::run(&didEnterFullscreen);
-    ASSERT_TRUE(didEnterFullscreen);
-
-    didEnterPiP = false;
-    didExitFullscreen = false;
-    [webView evaluateJavaScript:@"document.getElementById('enter-pip').click()" completionHandler: nil];
-    TestWebKitAPI::Util::run(&didEnterPiP);
-    TestWebKitAPI::Util::run(&didExitFullscreen);
-
-    sleep(1_s); // Wait for PIPAgent to launch, or it won't call -pipDidClose: callback.
-
-    [webView evaluateJavaScript:@"document.getElementById('exit-pip').click()" completionHandler: nil];
-    TestWebKitAPI::Util::run(&didExitPiP);
-}
-
-} // namespace TestWebKitAPI
-
-#endif
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to