<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[226217] trunk/Source</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/226217">226217</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2017-12-21 02:08:14 -0800 (Thu, 21 Dec 2017)</dd>
</dl>
<h3>Log Message</h3>
<pre>Enable picture-in-picture from inline element on suspend.
https://bugs.webkit.org/show_bug.cgi?id=180942
rdar://problem/34745234
Patch by Jeremy Jones <jeremyj@apple.com> on 2017-12-21
Reviewed by Jer Noble.
Source/WebCore:
When a element goes into element fullscreen mode, a descendant video element gains the ability to automatically enter picture-in-picture on application suspend.
This adds support for video fullscreen standby mode, which creates a VideoFullscreenInterfaceAVKit so that it can
trigger auto-pip on application suspend while the element is not actually presenting in video fullscreen mode.
VideoFullscreenInterfaceAVKit has a new state transition system that will replace the existing one to enable the increased
number and complexity of state transitions. Until we are ready to completely commit to this new code path, this implementation is
conditionalized to keep the existing code path working.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::enterFullscreen):
(WebCore::HTMLMediaElement::exitFullscreen):
(WebCore::HTMLMediaElement::setVideoFullscreenStandby):
(WebCore::HTMLMediaElement::shouldOverrideBackgroundPlaybackRestriction const):
* html/HTMLMediaElement.h:
* page/ChromeClient.h:
* platform/cocoa/VideoFullscreenChangeObserver.h:
* platform/ios/VideoFullscreenInterfaceAVKit.h:
* platform/ios/VideoFullscreenInterfaceAVKit.mm:
(-[WebAVPlayerViewControllerDelegate playerViewControllerShouldStartPictureInPictureFromInlineWhenEnteringBackground:]):
(-[WebAVPlayerLayer layoutSublayers]):
(allocWebAVPictureInPicturePlayerLayerViewInstance):
(allocWebAVPlayerLayerViewInstance):
(VideoFullscreenInterfaceAVKit::applicationDidBecomeActive):
(VideoFullscreenInterfaceAVKit::setupFullscreen):
(VideoFullscreenInterfaceAVKit::enterFullscreen):
(VideoFullscreenInterfaceAVKit::exitFullscreen):
(VideoFullscreenInterfaceAVKit::cleanupFullscreen):
(VideoFullscreenInterfaceAVKit::requestHideAndExitFullscreen):
(VideoFullscreenInterfaceAVKit::preparedToReturnToInline):
(VideoFullscreenInterfaceAVKit::mayAutomaticallyShowVideoPictureInPicture const):
(VideoFullscreenInterfaceAVKit::willStartPictureInPicture):
(VideoFullscreenInterfaceAVKit::didStartPictureInPicture):
(VideoFullscreenInterfaceAVKit::failedToStartPictureInPicture):
(VideoFullscreenInterfaceAVKit::willStopPictureInPicture):
(VideoFullscreenInterfaceAVKit::didStopPictureInPicture):
(VideoFullscreenInterfaceAVKit::prepareForPictureInPictureStopWithCompletionHandler):
(VideoFullscreenInterfaceAVKit::shouldExitFullscreenWithReason):
(VideoFullscreenInterfaceAVKit::setMode):
(VideoFullscreenInterfaceAVKit::clearMode):
(VideoFullscreenInterfaceAVKit::setHasVideoContentLayer):
(VideoFullscreenInterfaceAVKit::setInlineRect):
(VideoFullscreenInterfaceAVKit::doSetup):
(VideoFullscreenInterfaceAVKit::finalizeSetup):
(VideoFullscreenInterfaceAVKit::doEnterFullscreen):
(VideoFullscreenInterfaceAVKit::doExitFullscreen):
(VideoFullscreenInterfaceAVKit::exitFullscreenHandler):
(VideoFullscreenInterfaceAVKit::enterFullscreenHandler):
(VideoFullscreenInterfaceAVKit::returnToStandby):
* platform/ios/WebVideoFullscreenControllerAVKit.mm:
(VideoFullscreenControllerContext::requestUpdateInlineRect):
(VideoFullscreenControllerContext::requestVideoContentLayer):
(VideoFullscreenControllerContext::returnVideoContentLayer):
(VideoFullscreenControllerContext::didSetupFullscreen):
(VideoFullscreenControllerContext::didExitFullscreen):
(VideoFullscreenControllerContext::setUpFullscreen):
Source/WebKit:
Add support for video fullscreen standby and imporved fullscreen state transition process.
Video fullscreen standby allows a video element to have its fullscreen interface state created and
continuously updated so that it can quickly change presentation state on application state.
In order to accomplish this, this change allows the fullscreen presentation to decide when it needs
an updated inline rect, or the presence of the video layer.
This is conditionalized until mac supports this model.
* UIProcess/Cocoa/VideoFullscreenManagerProxy.h:
* UIProcess/Cocoa/VideoFullscreenManagerProxy.messages.in:
* UIProcess/Cocoa/VideoFullscreenManagerProxy.mm:
(WebKit::VideoFullscreenModelContext::requestUpdateInlineRect):
(WebKit::VideoFullscreenModelContext::requestVideoContentLayer):
(WebKit::VideoFullscreenModelContext::returnVideoContentLayer):
(WebKit::VideoFullscreenManagerProxy::setupFullscreenWithID):
(WebKit::VideoFullscreenManagerProxy::setInlineRect):
(WebKit::VideoFullscreenManagerProxy::setHasVideoContentLayer):
(WebKit::VideoFullscreenManagerProxy::requestUpdateInlineRect):
(WebKit::VideoFullscreenManagerProxy::requestVideoContentLayer):
(WebKit::VideoFullscreenManagerProxy::returnVideoContentLayer):
* WebProcess/FullScreen/WebFullScreenManager.cpp:
(WebKit::WebFullScreenManager::didEnterFullScreen):
(WebKit::WebFullScreenManager::willExitFullScreen):
* WebProcess/FullScreen/WebFullScreenManager.h:
* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::supportsVideoFullscreenStandby):
(WebKit::WebChromeClient::enterVideoFullscreenForVideoElement):
* WebProcess/WebCoreSupport/WebChromeClient.h:
* WebProcess/cocoa/VideoFullscreenManager.h:
(WebKit::VideoFullscreenInterfaceContext::fullscreenStandby const):
(WebKit::VideoFullscreenInterfaceContext::setFullscreenStandby):
* WebProcess/cocoa/VideoFullscreenManager.messages.in:
* WebProcess/cocoa/VideoFullscreenManager.mm:
(WebKit::VideoFullscreenManager::supportsVideoFullscreenStandby const):
(WebKit::VideoFullscreenManager::enterVideoFullscreenForVideoElement):
(WebKit::VideoFullscreenManager::requestUpdateInlineRect):
(WebKit::VideoFullscreenManager::requestVideoContentLayer):
(WebKit::VideoFullscreenManager::returnVideoContentLayer):
(WebKit::VideoFullscreenManager::didSetupFullscreen):
(WebKit::VideoFullscreenManager::didExitFullscreen):
(WebKit::VideoFullscreenManager::didCleanupFullscreen):
Source/WebKitLegacy/mac:
Update signature of enterVideoFullscreenForVideoElement().
* WebCoreSupport/WebChromeClient.h:
* WebCoreSupport/WebChromeClient.mm:
(WebChromeClient::enterVideoFullscreenForVideoElement):
Source/WebKitLegacy/win:
Update signature of enterVideoFullscreenForVideoElement.
* WebCoreSupport/WebChromeClient.cpp:
(WebChromeClient::enterVideoFullscreenForVideoElement):
* WebCoreSupport/WebChromeClient.h:</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLMediaElementcpp">trunk/Source/WebCore/html/HTMLMediaElement.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLMediaElementh">trunk/Source/WebCore/html/HTMLMediaElement.h</a></li>
<li><a href="#trunkSourceWebCorepageChromeClienth">trunk/Source/WebCore/page/ChromeClient.h</a></li>
<li><a href="#trunkSourceWebCoreplatformcocoaVideoFullscreenChangeObserverh">trunk/Source/WebCore/platform/cocoa/VideoFullscreenChangeObserver.h</a></li>
<li><a href="#trunkSourceWebCoreplatformiosVideoFullscreenInterfaceAVKith">trunk/Source/WebCore/platform/ios/VideoFullscreenInterfaceAVKit.h</a></li>
<li><a href="#trunkSourceWebCoreplatformiosVideoFullscreenInterfaceAVKitmm">trunk/Source/WebCore/platform/ios/VideoFullscreenInterfaceAVKit.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformiosWebVideoFullscreenControllerAVKitmm">trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformmacVideoFullscreenInterfaceMacmm">trunk/Source/WebCore/platform/mac/VideoFullscreenInterfaceMac.mm</a></li>
<li><a href="#trunkSourceWebKitChangeLog">trunk/Source/WebKit/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitUIProcessCocoaVideoFullscreenManagerProxyh">trunk/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessCocoaVideoFullscreenManagerProxymessagesin">trunk/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.messages.in</a></li>
<li><a href="#trunkSourceWebKitUIProcessCocoaVideoFullscreenManagerProxymm">trunk/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.mm</a></li>
<li><a href="#trunkSourceWebKitUIProcessiosWKFullScreenWindowControllerIOSmm">trunk/Source/WebKit/UIProcess/ios/WKFullScreenWindowControllerIOS.mm</a></li>
<li><a href="#trunkSourceWebKitWebProcessFullScreenWebFullScreenManagercpp">trunk/Source/WebKit/WebProcess/FullScreen/WebFullScreenManager.cpp</a></li>
<li><a href="#trunkSourceWebKitWebProcessFullScreenWebFullScreenManagerh">trunk/Source/WebKit/WebProcess/FullScreen/WebFullScreenManager.h</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebCoreSupportWebChromeClientcpp">trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebCoreSupportWebChromeClienth">trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h</a></li>
<li><a href="#trunkSourceWebKitWebProcesscocoaVideoFullscreenManagerh">trunk/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.h</a></li>
<li><a href="#trunkSourceWebKitWebProcesscocoaVideoFullscreenManagermessagesin">trunk/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.messages.in</a></li>
<li><a href="#trunkSourceWebKitWebProcesscocoaVideoFullscreenManagermm">trunk/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm</a></li>
<li><a href="#trunkSourceWebKitLegacymacChangeLog">trunk/Source/WebKitLegacy/mac/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitLegacymacWebCoreSupportWebChromeClienth">trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.h</a></li>
<li><a href="#trunkSourceWebKitLegacymacWebCoreSupportWebChromeClientmm">trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.mm</a></li>
<li><a href="#trunkSourceWebKitLegacywinChangeLog">trunk/Source/WebKitLegacy/win/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitLegacywinWebCoreSupportWebChromeClientcpp">trunk/Source/WebKitLegacy/win/WebCoreSupport/WebChromeClient.cpp</a></li>
<li><a href="#trunkSourceWebKitLegacywinWebCoreSupportWebChromeClienth">trunk/Source/WebKitLegacy/win/WebCoreSupport/WebChromeClient.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (226216 => 226217)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog 2017-12-21 06:48:48 UTC (rev 226216)
+++ trunk/Source/WebCore/ChangeLog 2017-12-21 10:08:14 UTC (rev 226217)
</span><span class="lines">@@ -1,3 +1,68 @@
</span><ins>+2017-12-21 Jeremy Jones <jeremyj@apple.com>
+
+ Enable picture-in-picture from inline element on suspend.
+ https://bugs.webkit.org/show_bug.cgi?id=180942
+ rdar://problem/34745234
+
+ Reviewed by Jer Noble.
+
+ When a element goes into element fullscreen mode, a descendant video element gains the ability to automatically enter picture-in-picture on application suspend.
+
+ This adds support for video fullscreen standby mode, which creates a VideoFullscreenInterfaceAVKit so that it can
+ trigger auto-pip on application suspend while the element is not actually presenting in video fullscreen mode.
+
+ VideoFullscreenInterfaceAVKit has a new state transition system that will replace the existing one to enable the increased
+ number and complexity of state transitions. Until we are ready to completely commit to this new code path, this implementation is
+ conditionalized to keep the existing code path working.
+
+ * html/HTMLMediaElement.cpp:
+ (WebCore::HTMLMediaElement::enterFullscreen):
+ (WebCore::HTMLMediaElement::exitFullscreen):
+ (WebCore::HTMLMediaElement::setVideoFullscreenStandby):
+ (WebCore::HTMLMediaElement::shouldOverrideBackgroundPlaybackRestriction const):
+ * html/HTMLMediaElement.h:
+ * page/ChromeClient.h:
+ * platform/cocoa/VideoFullscreenChangeObserver.h:
+ * platform/ios/VideoFullscreenInterfaceAVKit.h:
+ * platform/ios/VideoFullscreenInterfaceAVKit.mm:
+ (-[WebAVPlayerViewControllerDelegate playerViewControllerShouldStartPictureInPictureFromInlineWhenEnteringBackground:]):
+ (-[WebAVPlayerLayer layoutSublayers]):
+ (allocWebAVPictureInPicturePlayerLayerViewInstance):
+ (allocWebAVPlayerLayerViewInstance):
+ (VideoFullscreenInterfaceAVKit::applicationDidBecomeActive):
+ (VideoFullscreenInterfaceAVKit::setupFullscreen):
+ (VideoFullscreenInterfaceAVKit::enterFullscreen):
+ (VideoFullscreenInterfaceAVKit::exitFullscreen):
+ (VideoFullscreenInterfaceAVKit::cleanupFullscreen):
+ (VideoFullscreenInterfaceAVKit::requestHideAndExitFullscreen):
+ (VideoFullscreenInterfaceAVKit::preparedToReturnToInline):
+ (VideoFullscreenInterfaceAVKit::mayAutomaticallyShowVideoPictureInPicture const):
+ (VideoFullscreenInterfaceAVKit::willStartPictureInPicture):
+ (VideoFullscreenInterfaceAVKit::didStartPictureInPicture):
+ (VideoFullscreenInterfaceAVKit::failedToStartPictureInPicture):
+ (VideoFullscreenInterfaceAVKit::willStopPictureInPicture):
+ (VideoFullscreenInterfaceAVKit::didStopPictureInPicture):
+ (VideoFullscreenInterfaceAVKit::prepareForPictureInPictureStopWithCompletionHandler):
+ (VideoFullscreenInterfaceAVKit::shouldExitFullscreenWithReason):
+ (VideoFullscreenInterfaceAVKit::setMode):
+ (VideoFullscreenInterfaceAVKit::clearMode):
+ (VideoFullscreenInterfaceAVKit::setHasVideoContentLayer):
+ (VideoFullscreenInterfaceAVKit::setInlineRect):
+ (VideoFullscreenInterfaceAVKit::doSetup):
+ (VideoFullscreenInterfaceAVKit::finalizeSetup):
+ (VideoFullscreenInterfaceAVKit::doEnterFullscreen):
+ (VideoFullscreenInterfaceAVKit::doExitFullscreen):
+ (VideoFullscreenInterfaceAVKit::exitFullscreenHandler):
+ (VideoFullscreenInterfaceAVKit::enterFullscreenHandler):
+ (VideoFullscreenInterfaceAVKit::returnToStandby):
+ * platform/ios/WebVideoFullscreenControllerAVKit.mm:
+ (VideoFullscreenControllerContext::requestUpdateInlineRect):
+ (VideoFullscreenControllerContext::requestVideoContentLayer):
+ (VideoFullscreenControllerContext::returnVideoContentLayer):
+ (VideoFullscreenControllerContext::didSetupFullscreen):
+ (VideoFullscreenControllerContext::didExitFullscreen):
+ (VideoFullscreenControllerContext::setUpFullscreen):
+
</ins><span class="cx"> 2017-12-20 Ryosuke Niwa <rniwa@webkit.org>
</span><span class="cx">
</span><span class="cx"> DeferredLoadingScope incorrectly disabled images or enables deferred loading
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLMediaElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (226216 => 226217)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLMediaElement.cpp 2017-12-21 06:48:48 UTC (rev 226216)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp 2017-12-21 10:08:14 UTC (rev 226217)
</span><span class="lines">@@ -5840,7 +5840,7 @@
</span><span class="cx"> if (document().page() && is<HTMLVideoElement>(*this)) {
</span><span class="cx"> HTMLVideoElement& asVideo = downcast<HTMLVideoElement>(*this);
</span><span class="cx"> if (document().page()->chrome().client().supportsVideoFullscreen(m_videoFullscreenMode)) {
</span><del>- document().page()->chrome().client().enterVideoFullscreenForVideoElement(asVideo, m_videoFullscreenMode);
</del><ins>+ document().page()->chrome().client().enterVideoFullscreenForVideoElement(asVideo, m_videoFullscreenMode, m_videoFullscreenStandby);
</ins><span class="cx"> scheduleEvent(eventNames().webkitbeginfullscreenEvent);
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="lines">@@ -5892,11 +5892,34 @@
</span><span class="cx"> else
</span><span class="cx"> #endif
</span><span class="cx"> if (document().page()->chrome().client().supportsVideoFullscreen(oldVideoFullscreenMode)) {
</span><del>- document().page()->chrome().client().exitVideoFullscreenForVideoElement(downcast<HTMLVideoElement>(*this));
</del><ins>+ if (m_videoFullscreenStandby)
+ document().page()->chrome().client().enterVideoFullscreenForVideoElement(downcast<HTMLVideoElement>(*this), m_videoFullscreenMode, m_videoFullscreenStandby);
+ else
+ document().page()->chrome().client().exitVideoFullscreenForVideoElement(downcast<HTMLVideoElement>(*this));
</ins><span class="cx"> scheduleEvent(eventNames().webkitendfullscreenEvent);
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+WEBCORE_EXPORT void HTMLMediaElement::setVideoFullscreenStandby(bool value)
+{
+ ASSERT(is<HTMLVideoElement>(*this));
+ if (m_videoFullscreenStandby == value)
+ return;
+
+ if (!document().page())
+ return;
+
+ if (!document().page()->chrome().client().supportsVideoFullscreenStandby())
+ return;
+
+ m_videoFullscreenStandby = value;
+
+ if (m_videoFullscreenStandby || m_videoFullscreenMode != VideoFullscreenModeNone)
+ document().page()->chrome().client().enterVideoFullscreenForVideoElement(downcast<HTMLVideoElement>(*this), m_videoFullscreenMode, m_videoFullscreenStandby);
+ else
+ document().page()->chrome().client().exitVideoFullscreenForVideoElement(downcast<HTMLVideoElement>(*this));
+}
+
</ins><span class="cx"> void HTMLMediaElement::willBecomeFullscreenElement()
</span><span class="cx"> {
</span><span class="cx"> #if PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)
</span><span class="lines">@@ -7446,7 +7469,7 @@
</span><span class="cx"> if (m_videoFullscreenMode & VideoFullscreenModePictureInPicture)
</span><span class="cx"> return true;
</span><span class="cx"> #if PLATFORM(IOS) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
</span><del>- if (m_videoFullscreenMode == VideoFullscreenModeStandard && supportsPictureInPicture() && isPlaying())
</del><ins>+ if (((m_videoFullscreenMode == VideoFullscreenModeStandard) || m_videoFullscreenStandby) && supportsPictureInPicture() && isPlaying())
</ins><span class="cx"> return true;
</span><span class="cx"> #endif
</span><span class="cx"> } else if (type == PlatformMediaSession::SuspendedUnderLock) {
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLMediaElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (226216 => 226217)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLMediaElement.h 2017-12-21 06:48:48 UTC (rev 226216)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h 2017-12-21 10:08:14 UTC (rev 226217)
</span><span class="lines">@@ -422,6 +422,7 @@
</span><span class="cx"> void enterFullscreen(VideoFullscreenMode);
</span><span class="cx"> void enterFullscreen() override;
</span><span class="cx"> WEBCORE_EXPORT void exitFullscreen();
</span><ins>+ WEBCORE_EXPORT void setVideoFullscreenStandby(bool);
</ins><span class="cx">
</span><span class="cx"> bool hasClosedCaptions() const override;
</span><span class="cx"> bool closedCaptionsVisible() const override;
</span><span class="lines">@@ -977,6 +978,7 @@
</span><span class="cx"> RefPtr<HTMLSourceElement> m_nextChildNodeToConsider;
</span><span class="cx">
</span><span class="cx"> VideoFullscreenMode m_videoFullscreenMode { VideoFullscreenModeNone };
</span><ins>+ bool m_videoFullscreenStandby { false };
</ins><span class="cx"> bool m_preparedForInline;
</span><span class="cx"> WTF::Function<void()> m_preparedForInlineCompletionHandler;
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorepageChromeClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/ChromeClient.h (226216 => 226217)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/ChromeClient.h 2017-12-21 06:48:48 UTC (rev 226216)
+++ trunk/Source/WebCore/page/ChromeClient.h 2017-12-21 10:08:14 UTC (rev 226217)
</span><span class="lines">@@ -334,9 +334,10 @@
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> virtual bool supportsVideoFullscreen(HTMLMediaElementEnums::VideoFullscreenMode) { return false; }
</span><ins>+ virtual bool supportsVideoFullscreenStandby() { return false; }
</ins><span class="cx">
</span><span class="cx"> #if ENABLE(VIDEO)
</span><del>- virtual void enterVideoFullscreenForVideoElement(HTMLVideoElement&, HTMLMediaElementEnums::VideoFullscreenMode) { }
</del><ins>+ virtual void enterVideoFullscreenForVideoElement(HTMLVideoElement&, HTMLMediaElementEnums::VideoFullscreenMode, bool standby) { UNUSED_PARAM(standby); }
</ins><span class="cx"> virtual void setUpPlaybackControlsManager(HTMLMediaElement&) { }
</span><span class="cx"> virtual void clearPlaybackControlsManager() { }
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformcocoaVideoFullscreenChangeObserverh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/cocoa/VideoFullscreenChangeObserver.h (226216 => 226217)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/cocoa/VideoFullscreenChangeObserver.h 2017-12-21 06:48:48 UTC (rev 226216)
+++ trunk/Source/WebCore/platform/cocoa/VideoFullscreenChangeObserver.h 2017-12-21 10:08:14 UTC (rev 226217)
</span><span class="lines">@@ -33,6 +33,9 @@
</span><span class="cx"> class VideoFullscreenChangeObserver {
</span><span class="cx"> public:
</span><span class="cx"> virtual ~VideoFullscreenChangeObserver() { };
</span><ins>+ virtual void requestUpdateInlineRect() = 0;
+ virtual void requestVideoContentLayer() = 0;
+ virtual void returnVideoContentLayer() = 0;
</ins><span class="cx"> virtual void didSetupFullscreen() = 0;
</span><span class="cx"> virtual void didEnterFullscreen() = 0;
</span><span class="cx"> virtual void didExitFullscreen() = 0;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformiosVideoFullscreenInterfaceAVKith"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/VideoFullscreenInterfaceAVKit.h (226216 => 226217)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/VideoFullscreenInterfaceAVKit.h 2017-12-21 06:48:48 UTC (rev 226216)
+++ trunk/Source/WebCore/platform/ios/VideoFullscreenInterfaceAVKit.h 2017-12-21 10:08:14 UTC (rev 226217)
</span><span class="lines">@@ -49,6 +49,7 @@
</span><span class="cx"> OBJC_CLASS WebAVPlayerLayerView;
</span><span class="cx"> OBJC_CLASS WebAVPlayerLayer;
</span><span class="cx"> OBJC_CLASS WebAVPlayerViewControllerDelegate;
</span><ins>+OBJC_CLASS NSError;
</ins><span class="cx">
</span><span class="cx"> namespace WTF {
</span><span class="cx"> class String;
</span><span class="lines">@@ -79,13 +80,17 @@
</span><span class="cx"> // PlaybackSessionModelClient
</span><span class="cx"> WEBCORE_EXPORT void externalPlaybackChanged(bool enabled, PlaybackSessionModel::ExternalPlaybackTargetType, const String& localizedDeviceName) final;
</span><span class="cx">
</span><del>- WEBCORE_EXPORT virtual void setupFullscreen(UIView&, const IntRect& initialRect, UIView *, HTMLMediaElementEnums::VideoFullscreenMode, bool allowsPictureInPicturePlayback);
- WEBCORE_EXPORT virtual void enterFullscreen();
- WEBCORE_EXPORT virtual void exitFullscreen(const IntRect& finalRect);
- WEBCORE_EXPORT virtual void cleanupFullscreen();
- WEBCORE_EXPORT virtual void invalidate();
- WEBCORE_EXPORT virtual void requestHideAndExitFullscreen();
- WEBCORE_EXPORT virtual void preparedToReturnToInline(bool visible, const IntRect& inlineRect);
</del><ins>+ WEBCORE_EXPORT void setupFullscreen(UIView&, const IntRect& initialRect, UIView *, HTMLMediaElementEnums::VideoFullscreenMode, bool allowsPictureInPicturePlayback, bool standby);
+ WEBCORE_EXPORT void enterFullscreen();
+ WEBCORE_EXPORT void exitFullscreen(const IntRect& finalRect);
+ WEBCORE_EXPORT void cleanupFullscreen();
+ WEBCORE_EXPORT void invalidate();
+ WEBCORE_EXPORT void requestHideAndExitFullscreen();
+ WEBCORE_EXPORT void preparedToReturnToInline(bool visible, const IntRect& inlineRect);
+#if ENABLE(FULLSCREEN_API)
+ WEBCORE_EXPORT void setHasVideoContentLayer(bool);
+ WEBCORE_EXPORT void setInlineRect(const IntRect&, bool visible);
+#endif
</ins><span class="cx">
</span><span class="cx"> enum class ExitFullScreenReason {
</span><span class="cx"> DoneButtonTapped,
</span><span class="lines">@@ -95,9 +100,41 @@
</span><span class="cx"> PictureInPictureStarted
</span><span class="cx"> };
</span><span class="cx">
</span><ins>+ class Mode {
+ HTMLMediaElementEnums::VideoFullscreenMode m_mode { HTMLMediaElementEnums::VideoFullscreenModeNone };
+
+ public:
+ Mode() = default;
+ Mode(const Mode&) = default;
+ Mode(HTMLMediaElementEnums::VideoFullscreenMode mode) : m_mode(mode) { }
+ void operator=(HTMLMediaElementEnums::VideoFullscreenMode mode) { m_mode = mode; }
+ HTMLMediaElementEnums::VideoFullscreenMode mode() const { return m_mode; }
+
+ void setModeValue(HTMLMediaElementEnums::VideoFullscreenMode mode, bool value) { value ? setMode(mode) : clearMode(mode); }
+ void setMode(HTMLMediaElementEnums::VideoFullscreenMode mode) { m_mode |= mode; }
+ void clearMode(HTMLMediaElementEnums::VideoFullscreenMode mode) { m_mode &= ~mode; }
+ bool hasMode(HTMLMediaElementEnums::VideoFullscreenMode mode) const { return m_mode & mode; }
+
+ bool isPictureInPicture() const { return m_mode == HTMLMediaElementEnums::VideoFullscreenModePictureInPicture; }
+ bool isFullscreen() const { return m_mode == HTMLMediaElementEnums::VideoFullscreenModeStandard; }
+
+ void setPictureInPicture(bool value) { setModeValue(HTMLMediaElementEnums::VideoFullscreenModePictureInPicture, value); }
+ void setFullscreen(bool value) { setModeValue(HTMLMediaElementEnums::VideoFullscreenModeStandard, value); }
+
+ bool hasFullscreen() const { return hasMode(HTMLMediaElementEnums::VideoFullscreenModeStandard); }
+ bool hasPictureInPicture() const { return hasMode(HTMLMediaElementEnums::VideoFullscreenModePictureInPicture); }
+
+ bool hasVideo() const { return m_mode & (HTMLMediaElementEnums::VideoFullscreenModeStandard | HTMLMediaElementEnums::VideoFullscreenModePictureInPicture); }
+ };
+
+ Mode m_currentMode;
+#if ENABLE(FULLSCREEN_API)
+ Mode m_targetMode;
+#endif
+
</ins><span class="cx"> VideoFullscreenModel* model() const { return m_videoFullscreenModel; }
</span><span class="cx"> bool shouldExitFullscreenWithReason(ExitFullScreenReason);
</span><del>- HTMLMediaElementEnums::VideoFullscreenMode mode() const { return m_mode; }
</del><ins>+ HTMLMediaElementEnums::VideoFullscreenMode mode() const { return m_currentMode.mode(); }
</ins><span class="cx"> bool allowsPictureInPicturePlayback() const { return m_allowsPictureInPicturePlayback; }
</span><span class="cx"> WEBCORE_EXPORT bool mayAutomaticallyShowVideoPictureInPicture() const;
</span><span class="cx"> void fullscreenMayReturnToInline(WTF::Function<void(bool)>&& callback);
</span><span class="lines">@@ -110,17 +147,28 @@
</span><span class="cx"> void willStopPictureInPicture();
</span><span class="cx"> void didStopPictureInPicture();
</span><span class="cx"> void prepareForPictureInPictureStopWithCompletionHandler(void (^)(BOOL));
</span><ins>+#if ENABLE(FULLSCREEN_API)
+ void exitFullscreenHandler(BOOL success, NSError *);
+ void enterFullscreenHandler(BOOL success, NSError *);
+#endif
</ins><span class="cx">
</span><span class="cx"> void setMode(HTMLMediaElementEnums::VideoFullscreenMode);
</span><span class="cx"> void clearMode(HTMLMediaElementEnums::VideoFullscreenMode);
</span><del>- bool hasMode(HTMLMediaElementEnums::VideoFullscreenMode mode) const { return m_mode & mode; }
- bool isMode(HTMLMediaElementEnums::VideoFullscreenMode mode) const { return m_mode == mode; }
</del><ins>+ bool hasMode(HTMLMediaElementEnums::VideoFullscreenMode mode) const { return m_currentMode.hasMode(mode); }
</ins><span class="cx">
</span><span class="cx"> protected:
</span><span class="cx"> WEBCORE_EXPORT VideoFullscreenInterfaceAVKit(PlaybackSessionInterfaceAVKit&);
</span><del>- void beginSession();
</del><ins>+
+#if ENABLE(FULLSCREEN_API)
+ void doSetup();
+ void finalizeSetup();
+ void doExitFullscreen();
+ void returnToStandby();
+#else
</ins><span class="cx"> void enterPictureInPicture();
</span><span class="cx"> void enterFullscreenStandard();
</span><ins>+#endif
+ void doEnterFullscreen();
</ins><span class="cx"> void watchdogTimerFired();
</span><span class="cx"> WebAVPlayerController *playerController() const;
</span><span class="cx">
</span><span class="lines">@@ -133,25 +181,52 @@
</span><span class="cx"> // These are only used when fullscreen is presented in a separate window.
</span><span class="cx"> RetainPtr<UIWindow> m_window;
</span><span class="cx"> RetainPtr<UIViewController> m_viewController;
</span><ins>+ RetainPtr<UIView> m_videoView;
</ins><span class="cx"> RetainPtr<UIView> m_parentView;
</span><span class="cx"> RetainPtr<UIWindow> m_parentWindow;
</span><span class="cx"> RetainPtr<WebAVPlayerLayerView> m_playerLayerView;
</span><del>- HTMLMediaElementEnums::VideoFullscreenMode m_mode { HTMLMediaElementEnums::VideoFullscreenModeNone };
</del><span class="cx"> WTF::Function<void(bool)> m_prepareToInlineCallback;
</span><span class="cx"> RunLoop::Timer<VideoFullscreenInterfaceAVKit> m_watchdogTimer;
</span><ins>+ FloatRect m_inlineRect;
</ins><span class="cx"> bool m_allowsPictureInPicturePlayback { false };
</span><ins>+ bool m_wirelessVideoPlaybackDisabled { true };
+ bool m_shouldReturnToFullscreenWhenStoppingPiP { false };
+ bool m_restoringFullscreenForPictureInPictureStop { false };
+
+#if ENABLE(FULLSCREEN_API)
+ bool m_setupNeedsInlineRect { false };
+ bool m_exitFullscreenNeedInlineRect { false };
+
+ bool m_finalizeSetupNeedsVideoContentLayer { false };
+ bool m_cleanupNeedsReturnVideoContentLayer { false };
+
+ bool m_returnToStandbyNeedsReturnVideoContentLayer { false };
+ bool m_finalizeSetupNeedsReturnVideoContentLayer { false };
+
+ bool m_exitFullscreenNeedsExitFullscreen { false };
+ bool m_exitFullscreenNeedsExitPictureInPicture { false };
+ bool m_exitFullscreenNeedsReturnContentLayer { false };
+
+ bool m_enterFullscreenNeedsEnterFullscreen { false };
+ bool m_enterFullscreenNeedsExitFullscreen { false };
+ bool m_enterFullscreenNeedsEnterPictureInPicture { false };
+ bool m_enterFullscreenNeedsExitPictureInPicture { false };
+
+ bool m_hasVideoContentLayer { false };
+
+ bool m_hasUpdatedInlineRect { false };
+ bool m_inlineIsVisible { false };
+ bool m_standby { false };
+ bool m_targetStandby { false };
+#else
</ins><span class="cx"> bool m_exitRequested { false };
</span><span class="cx"> bool m_exitCompleted { false };
</span><span class="cx"> bool m_enterRequested { false };
</span><del>- bool m_wirelessVideoPlaybackDisabled { true };
- bool m_shouldReturnToFullscreenWhenStoppingPiP { false };
</del><span class="cx"> bool m_shouldReturnToFullscreenAfterEnteringForeground { false };
</span><del>- bool m_restoringFullscreenForPictureInPictureStop { false };
-
- void doEnterFullscreen();
</del><ins>+#endif
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> }
</span><span class="cx">
</span><del>-#endif
</del><ins>+#endif // PLATFORM(IOS)
</ins><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformiosVideoFullscreenInterfaceAVKitmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/VideoFullscreenInterfaceAVKit.mm (226216 => 226217)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/VideoFullscreenInterfaceAVKit.mm 2017-12-21 06:48:48 UTC (rev 226216)
+++ trunk/Source/WebCore/platform/ios/VideoFullscreenInterfaceAVKit.mm 2017-12-21 10:08:14 UTC (rev 226217)
</span><span class="lines">@@ -72,6 +72,14 @@
</span><span class="cx"> SOFT_LINK_CLASS(UIKit, UIColor)
</span><span class="cx"> SOFT_LINK_CONSTANT(UIKit, UITextEffectsBeneathStatusBarWindowLevel, UIWindowLevel)
</span><span class="cx">
</span><ins>+@interface UIWindow ()
+- (BOOL)_isHostedInAnotherProcess;
+@end
+
+@interface UIViewController ()
+@property (nonatomic, assign, setter=_setIgnoreAppSupportedOrientations:) BOOL _ignoreAppSupportedOrientations;
+@end
+
</ins><span class="cx"> static UIColor *clearUIColor()
</span><span class="cx"> {
</span><span class="cx"> return (UIColor *)[getUIColorClass() clearColor];
</span><span class="lines">@@ -164,6 +172,15 @@
</span><span class="cx"> UNUSED_PARAM(playerViewController);
</span><span class="cx"> self.fullscreenInterface->prepareForPictureInPictureStopWithCompletionHandler(completionHandler);
</span><span class="cx"> }
</span><ins>+
+#if ENABLE(FULLSCREEN_API)
+- (BOOL)playerViewControllerShouldStartPictureInPictureFromInlineWhenEnteringBackground:(AVPlayerViewController *)playerViewController
+{
+ UNUSED_PARAM(playerViewController);
+ return YES;
+}
+#endif
+
</ins><span class="cx"> @end
</span><span class="cx">
</span><span class="cx"> @interface WebAVPlayerLayer : CALayer
</span><span class="lines">@@ -269,7 +286,7 @@
</span><span class="cx"> [view setTransform:transform];
</span><span class="cx">
</span><span class="cx"> NSTimeInterval animationDuration = [CATransaction animationDuration];
</span><del>- dispatch_async(dispatch_get_main_queue(), ^ {
</del><ins>+ dispatch_async(dispatch_get_main_queue(), ^{
</ins><span class="cx"> [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(resolveBounds) object:nil];
</span><span class="cx">
</span><span class="cx"> [self performSelector:@selector(resolveBounds) withObject:nil afterDelay:animationDuration + 0.1];
</span><span class="lines">@@ -362,7 +379,7 @@
</span><span class="cx"> {
</span><span class="cx"> static Class theClass = nil;
</span><span class="cx"> static dispatch_once_t onceToken;
</span><del>- dispatch_once(&onceToken, ^ {
</del><ins>+ dispatch_once(&onceToken, ^{
</ins><span class="cx"> theClass = objc_allocateClassPair(getUIViewClass(), "WebAVPictureInPicturePlayerLayerView", 0);
</span><span class="cx"> objc_registerClassPair(theClass);
</span><span class="cx"> Class metaClass = objc_getMetaClass("WebAVPictureInPicturePlayerLayerView");
</span><span class="lines">@@ -468,7 +485,7 @@
</span><span class="cx"> {
</span><span class="cx"> static Class theClass = nil;
</span><span class="cx"> static dispatch_once_t onceToken;
</span><del>- dispatch_once(&onceToken, ^ {
</del><ins>+ dispatch_once(&onceToken, ^{
</ins><span class="cx"> theClass = objc_allocateClassPair(get__AVPlayerLayerViewClass(), "WebAVPlayerLayerView", 0);
</span><span class="cx"> class_addMethod(theClass, @selector(dealloc), (IMP)WebAVPlayerLayerView_dealloc, "v@:");
</span><span class="cx"> class_addMethod(theClass, @selector(setPlayerController:), (IMP)WebAVPlayerLayerView_setPlayerController, "v@:@");
</span><span class="lines">@@ -560,6 +577,8 @@
</span><span class="cx"> [m_playerLayerView setHidden:enabled];
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+#if !ENABLE(FULLSCREEN_API)
+
</ins><span class="cx"> void VideoFullscreenInterfaceAVKit::applicationDidBecomeActive()
</span><span class="cx"> {
</span><span class="cx"> LOG(Fullscreen, "VideoFullscreenInterfaceAVKit::applicationDidBecomeActive(%p)", this);
</span><span class="lines">@@ -570,9 +589,8 @@
</span><span class="cx">
</span><span class="cx"> // If we are both in PiP and in Fullscreen (i.e., via auto-PiP), and we did not stop fullscreen upon returning, it must be
</span><span class="cx"> // because the originating view is not visible, so hide the fullscreen window.
</span><del>- if (isMode(HTMLMediaElementEnums::VideoFullscreenModeStandard | HTMLMediaElementEnums::VideoFullscreenModePictureInPicture)) {
- RefPtr<VideoFullscreenInterfaceAVKit> protectedThis(this);
- [m_playerViewController exitFullScreenAnimated:NO completionHandler:[protectedThis, this] (BOOL, NSError*) {
</del><ins>+ if (m_currentMode.hasFullscreen() && m_currentMode.hasPictureInPicture()) {
+ [m_playerViewController exitFullScreenAnimated:NO completionHandler:[protectedThis = makeRefPtr(this), this] (BOOL, NSError *) {
</ins><span class="cx"> [m_window setHidden:YES];
</span><span class="cx"> [[m_playerViewController view] setHidden:YES];
</span><span class="cx"> }];
</span><span class="lines">@@ -579,29 +597,25 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>-@interface UIWindow ()
-- (BOOL)_isHostedInAnotherProcess;
-@end
-
-@interface UIViewController ()
-@property (nonatomic, assign, setter=_setIgnoreAppSupportedOrientations:) BOOL _ignoreAppSupportedOrientations;
-@end
-
-void VideoFullscreenInterfaceAVKit::setupFullscreen(UIView& videoView, const WebCore::IntRect& initialRect, UIView* parentView, HTMLMediaElementEnums::VideoFullscreenMode mode, bool allowsPictureInPicturePlayback)
</del><ins>+void VideoFullscreenInterfaceAVKit::setupFullscreen(UIView& videoView, const IntRect& initialRect, UIView* parentView, HTMLMediaElementEnums::VideoFullscreenMode mode, bool allowsPictureInPicturePlayback, bool standby)
</ins><span class="cx"> {
</span><span class="cx"> ASSERT(mode != HTMLMediaElementEnums::VideoFullscreenModeNone);
</span><span class="cx"> LOG(Fullscreen, "VideoFullscreenInterfaceAVKit::setupFullscreen(%p)", this);
</span><span class="cx">
</span><span class="cx"> m_allowsPictureInPicturePlayback = allowsPictureInPicturePlayback;
</span><ins>+ m_videoView = &videoView;
+ m_parentView = parentView;
+ m_parentWindow = parentView.window;
</ins><span class="cx">
</span><ins>+ ASSERT_UNUSED(standby, !standby);
+ bool isInPictureInPictureMode = m_currentMode.hasPictureInPicture();
+ m_currentMode = mode;
+ m_inlineRect = initialRect;
+
</ins><span class="cx"> [CATransaction begin];
</span><span class="cx"> [CATransaction setDisableActions:YES];
</span><del>- bool isInPictureInPictureMode = hasMode(HTMLMediaElementEnums::VideoFullscreenModePictureInPicture);
- m_mode = mode;
- m_parentView = parentView;
- m_parentWindow = parentView.window;
</del><span class="cx">
</span><del>- if (![[parentView window] _isHostedInAnotherProcess]) {
</del><ins>+ if (![[m_parentView window] _isHostedInAnotherProcess]) {
</ins><span class="cx"> if (!m_window)
</span><span class="cx"> m_window = adoptNS([allocUIWindowInstance() initWithFrame:[[getUIScreenClass() mainScreen] bounds]]);
</span><span class="cx"> [m_window setBackgroundColor:clearUIColor()];
</span><span class="lines">@@ -620,13 +634,13 @@
</span><span class="cx"> [m_playerLayerView setBackgroundColor:clearUIColor()];
</span><span class="cx">
</span><span class="cx"> if (!isInPictureInPictureMode) {
</span><del>- [m_playerLayerView setVideoView:&videoView];
- [m_playerLayerView addSubview:&videoView];
</del><ins>+ [m_playerLayerView setVideoView:m_videoView.get()];
+ [m_playerLayerView addSubview:m_videoView.get()];
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> WebAVPlayerLayer *playerLayer = (WebAVPlayerLayer *)[m_playerLayerView playerLayer];
</span><span class="cx">
</span><del>- [playerLayer setModelVideoLayerFrame:CGRectMake(0, 0, initialRect.width(), initialRect.height())];
</del><ins>+ [playerLayer setModelVideoLayerFrame:CGRectMake(0, 0, m_inlineRect.width(), m_inlineRect.height())];
</ins><span class="cx"> [playerLayer setVideoDimensions:[playerController() contentDimensions]];
</span><span class="cx"> playerLayer.fullscreenInterface = this;
</span><span class="cx">
</span><span class="lines">@@ -644,9 +658,9 @@
</span><span class="cx"> [m_viewController addChildViewController:m_playerViewController.get()];
</span><span class="cx"> [[m_viewController view] addSubview:[m_playerViewController view]];
</span><span class="cx"> } else
</span><del>- [parentView addSubview:[m_playerViewController view]];
</del><ins>+ [m_parentView addSubview:[m_playerViewController view]];
</ins><span class="cx">
</span><del>- [m_playerViewController view].frame = [parentView convertRect:initialRect toView:[m_playerViewController view].superview];
</del><ins>+ [m_playerViewController view].frame = [m_parentView convertRect:m_inlineRect toView:[m_playerViewController view].superview];
</ins><span class="cx">
</span><span class="cx"> [[m_playerViewController view] setBackgroundColor:clearUIColor()];
</span><span class="cx"> [[m_playerViewController view] setAutoresizingMask:(UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleRightMargin)];
</span><span class="lines">@@ -656,8 +670,7 @@
</span><span class="cx">
</span><span class="cx"> [CATransaction commit];
</span><span class="cx">
</span><del>- RefPtr<VideoFullscreenInterfaceAVKit> protectedThis(this);
- dispatch_async(dispatch_get_main_queue(), [protectedThis, this] {
</del><ins>+ dispatch_async(dispatch_get_main_queue(), [protectedThis = makeRefPtr(this), this] {
</ins><span class="cx"> if (m_fullscreenChangeObserver)
</span><span class="cx"> m_fullscreenChangeObserver->didSetupFullscreen();
</span><span class="cx"> });
</span><span class="lines">@@ -665,15 +678,15 @@
</span><span class="cx">
</span><span class="cx"> void VideoFullscreenInterfaceAVKit::enterFullscreen()
</span><span class="cx"> {
</span><del>- LOG(Fullscreen, "VideoFullscreenInterfaceAVKit::enterFullscreen(%p)", this);
</del><ins>+ LOG(Fullscreen, "VideoFullscreenInterfaceAVKit::enterFullscreen(%p) %d", this, mode());
</ins><span class="cx">
</span><span class="cx"> m_exitCompleted = false;
</span><span class="cx"> m_exitRequested = false;
</span><span class="cx"> m_enterRequested = true;
</span><span class="cx">
</span><del>- if (mode() == HTMLMediaElementEnums::VideoFullscreenModePictureInPicture)
</del><ins>+ if (m_currentMode.isPictureInPicture())
</ins><span class="cx"> enterPictureInPicture();
</span><del>- else if (mode() == HTMLMediaElementEnums::VideoFullscreenModeStandard)
</del><ins>+ else if (m_currentMode.isFullscreen())
</ins><span class="cx"> enterFullscreenStandard();
</span><span class="cx"> else
</span><span class="cx"> ASSERT_NOT_REACHED();
</span><span class="lines">@@ -692,7 +705,6 @@
</span><span class="cx"> void VideoFullscreenInterfaceAVKit::enterFullscreenStandard()
</span><span class="cx"> {
</span><span class="cx"> LOG(Fullscreen, "VideoFullscreenInterfaceAVKit::enterFullscreenStandard(%p)", this);
</span><del>- RefPtr<VideoFullscreenInterfaceAVKit> protectedThis(this);
</del><span class="cx">
</span><span class="cx"> if ([m_playerViewController isPictureInPictureActive]) {
</span><span class="cx"> // NOTE: The fullscreen mode will be restored in prepareForPictureInPictureStopWithCompletionHandler().
</span><span class="lines">@@ -701,7 +713,7 @@
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- [m_playerViewController enterFullScreenAnimated:YES completionHandler:[this, protectedThis] (BOOL succeeded, NSError*) {
</del><ins>+ [m_playerViewController enterFullScreenAnimated:YES completionHandler:[this, protectedThis = makeRefPtr(this)] (BOOL succeeded, NSError*) {
</ins><span class="cx"> UNUSED_PARAM(succeeded);
</span><span class="cx"> LOG(Fullscreen, "VideoFullscreenInterfaceAVKit::enterFullscreenStandard - lambda(%p) - succeeded(%s)", this, boolString(succeeded));
</span><span class="cx"> [m_playerViewController setShowsPlaybackControls:YES];
</span><span class="lines">@@ -711,7 +723,7 @@
</span><span class="cx"> }];
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void VideoFullscreenInterfaceAVKit::exitFullscreen(const WebCore::IntRect& finalRect)
</del><ins>+void VideoFullscreenInterfaceAVKit::exitFullscreen(const IntRect& finalRect)
</ins><span class="cx"> {
</span><span class="cx"> m_watchdogTimer.stop();
</span><span class="cx">
</span><span class="lines">@@ -732,20 +744,18 @@
</span><span class="cx"> [playerLayer setVideoGravity:getAVLayerVideoGravityResizeAspect()];
</span><span class="cx"> [[m_playerViewController view] layoutIfNeeded];
</span><span class="cx">
</span><del>- if (isMode(HTMLMediaElementEnums::VideoFullscreenModePictureInPicture)) {
</del><ins>+ if (m_currentMode.isPictureInPicture()) {
</ins><span class="cx"> m_shouldReturnToFullscreenWhenStoppingPiP = false;
</span><span class="cx"> [m_window setHidden:NO];
</span><span class="cx"> [m_playerViewController stopPictureInPicture];
</span><del>- } else if (isMode(HTMLMediaElementEnums::VideoFullscreenModePictureInPicture | HTMLMediaElementEnums::VideoFullscreenModeStandard)) {
- RefPtr<VideoFullscreenInterfaceAVKit> protectedThis(this);
- [m_playerViewController exitFullScreenAnimated:NO completionHandler:[protectedThis, this] (BOOL, NSError*) {
</del><ins>+ } else if (m_currentMode.hasPictureInPicture() && m_currentMode.hasFullscreen()) {
+ [m_playerViewController exitFullScreenAnimated:NO completionHandler:[protectedThis = makeRefPtr(this), this] (BOOL, NSError*) {
</ins><span class="cx"> clearMode(HTMLMediaElementEnums::VideoFullscreenModeStandard);
</span><span class="cx"> [m_window setHidden:NO];
</span><span class="cx"> [m_playerViewController stopPictureInPicture];
</span><span class="cx"> }];
</span><del>- } else if (isMode(HTMLMediaElementEnums::VideoFullscreenModeStandard)) {
- RefPtr<VideoFullscreenInterfaceAVKit> protectedThis(this);
- [m_playerViewController exitFullScreenAnimated:YES completionHandler:[protectedThis, this] (BOOL, NSError*) {
</del><ins>+ } else if (m_currentMode.isFullscreen()) {
+ [m_playerViewController exitFullScreenAnimated:YES completionHandler:[protectedThis = makeRefPtr(this), this] (BOOL, NSError*) () mutable {
</ins><span class="cx"> m_exitCompleted = true;
</span><span class="cx">
</span><span class="cx"> [CATransaction begin];
</span><span class="lines">@@ -754,7 +764,7 @@
</span><span class="cx"> [[m_playerViewController view] setBackgroundColor:clearUIColor()];
</span><span class="cx"> [CATransaction commit];
</span><span class="cx">
</span><del>- dispatch_async(dispatch_get_main_queue(), [protectedThis, this]() {
</del><ins>+ dispatch_async(dispatch_get_main_queue(), [protectedThis = WTFMove(protectedThis), this]() {
</ins><span class="cx"> if (m_fullscreenChangeObserver)
</span><span class="cx"> m_fullscreenChangeObserver->didExitFullscreen();
</span><span class="cx"> });
</span><span class="lines">@@ -765,6 +775,7 @@
</span><span class="cx"> void VideoFullscreenInterfaceAVKit::cleanupFullscreen()
</span><span class="cx"> {
</span><span class="cx"> LOG(Fullscreen, "VideoFullscreenInterfaceAVKit::cleanupFullscreen(%p)", this);
</span><ins>+
</ins><span class="cx"> if (m_window) {
</span><span class="cx"> [m_window setHidden:YES];
</span><span class="cx"> [m_window setRootViewController:nil];
</span><span class="lines">@@ -773,9 +784,9 @@
</span><span class="cx"> [m_playerViewController setDelegate:nil];
</span><span class="cx"> [m_playerViewController setPlayerController:nil];
</span><span class="cx">
</span><del>- if (hasMode(HTMLMediaElementEnums::VideoFullscreenModePictureInPicture))
</del><ins>+ if (m_currentMode.hasPictureInPicture())
</ins><span class="cx"> [m_playerViewController stopPictureInPicture];
</span><del>- if (hasMode(HTMLMediaElementEnums::VideoFullscreenModeStandard))
</del><ins>+ if (m_currentMode.hasFullscreen())
</ins><span class="cx"> [m_playerViewController exitFullScreenAnimated:NO completionHandler:[] (BOOL, NSError *) { }];
</span><span class="cx">
</span><span class="cx"> [[m_playerViewController view] removeFromSuperview];
</span><span class="lines">@@ -788,6 +799,7 @@
</span><span class="cx"> m_playerLayerView = nil;
</span><span class="cx"> m_playerViewController = nil;
</span><span class="cx"> m_window = nil;
</span><ins>+ m_videoView = nil;
</ins><span class="cx"> m_parentView = nil;
</span><span class="cx"> m_parentWindow = nil;
</span><span class="cx">
</span><span class="lines">@@ -810,7 +822,7 @@
</span><span class="cx"> if (!m_enterRequested)
</span><span class="cx"> return;
</span><span class="cx">
</span><del>- if (hasMode(HTMLMediaElementEnums::VideoFullscreenModePictureInPicture))
</del><ins>+ if (m_currentMode.hasPictureInPicture())
</ins><span class="cx"> return;
</span><span class="cx">
</span><span class="cx"> LOG(Fullscreen, "VideoFullscreenInterfaceAVKit::requestHideAndExitFullscreen(%p)", this);
</span><span class="lines">@@ -828,9 +840,7 @@
</span><span class="cx"> {
</span><span class="cx"> LOG(Fullscreen, "VideoFullscreenInterfaceAVKit::preparedToReturnToInline(%p) - visible(%s)", this, boolString(visible));
</span><span class="cx"> if (m_prepareToInlineCallback) {
</span><del>-
</del><span class="cx"> [m_playerViewController view].frame = [m_parentView convertRect:inlineRect toView:[m_playerViewController view].superview];
</span><del>-
</del><span class="cx"> WTF::Function<void(bool)> callback = WTFMove(m_prepareToInlineCallback);
</span><span class="cx"> callback(visible);
</span><span class="cx"> }
</span><span class="lines">@@ -838,7 +848,7 @@
</span><span class="cx">
</span><span class="cx"> bool VideoFullscreenInterfaceAVKit::mayAutomaticallyShowVideoPictureInPicture() const
</span><span class="cx"> {
</span><del>- return [playerController() isPlaying] && m_mode == HTMLMediaElementEnums::VideoFullscreenModeStandard && supportsPictureInPicture();
</del><ins>+ return [playerController() isPlaying] && m_currentMode.isFullscreen() && supportsPictureInPicture();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void VideoFullscreenInterfaceAVKit::fullscreenMayReturnToInline(WTF::Function<void(bool)>&& callback)
</span><span class="lines">@@ -860,10 +870,9 @@
</span><span class="cx"> m_shouldReturnToFullscreenAfterEnteringForeground = [m_playerViewController pictureInPictureWasStartedWhenEnteringBackground];
</span><span class="cx"> [m_playerViewController setShowsPlaybackControls:YES];
</span><span class="cx">
</span><del>- if (m_mode & HTMLMediaElementEnums::VideoFullscreenModeStandard) {
</del><ins>+ if (m_currentMode.hasFullscreen()) {
</ins><span class="cx"> if (![m_playerViewController pictureInPictureWasStartedWhenEnteringBackground]) {
</span><del>- RefPtr<VideoFullscreenInterfaceAVKit> protectedThis(this);
- [m_playerViewController exitFullScreenAnimated:YES completionHandler:[protectedThis, this] (BOOL, NSError*) {
</del><ins>+ [m_playerViewController exitFullScreenAnimated:YES completionHandler:[protectedThis = makeRefPtr(this), this] (BOOL, NSError *) {
</ins><span class="cx"> [m_window setHidden:YES];
</span><span class="cx"> [[m_playerViewController view] setHidden:YES];
</span><span class="cx"> }];
</span><span class="lines">@@ -882,7 +891,7 @@
</span><span class="cx"> LOG(Fullscreen, "VideoFullscreenInterfaceAVKit::failedToStartPictureInPicture(%p)", this);
</span><span class="cx"> [m_playerViewController setShowsPlaybackControls:YES];
</span><span class="cx">
</span><del>- if (hasMode(HTMLMediaElementEnums::VideoFullscreenModeStandard))
</del><ins>+ if (m_currentMode.hasFullscreen())
</ins><span class="cx"> return;
</span><span class="cx">
</span><span class="cx"> m_exitCompleted = true;
</span><span class="lines">@@ -896,11 +905,12 @@
</span><span class="cx">
</span><span class="cx"> void VideoFullscreenInterfaceAVKit::willStopPictureInPicture()
</span><span class="cx"> {
</span><ins>+ LOG(Fullscreen, "VideoFullscreenInterfaceAVKit::willStopPictureInPicture(%p)", this);
+
</ins><span class="cx"> m_shouldReturnToFullscreenWhenStoppingPiP = false;
</span><span class="cx"> m_shouldReturnToFullscreenAfterEnteringForeground = false;
</span><span class="cx">
</span><del>- LOG(Fullscreen, "VideoFullscreenInterfaceAVKit::willStopPictureInPicture(%p)", this);
- if (hasMode(HTMLMediaElementEnums::VideoFullscreenModeStandard) || m_restoringFullscreenForPictureInPictureStop)
</del><ins>+ if (m_currentMode.hasFullscreen() || m_restoringFullscreenForPictureInPictureStop)
</ins><span class="cx"> return;
</span><span class="cx">
</span><span class="cx"> [m_window setHidden:NO];
</span><span class="lines">@@ -913,10 +923,11 @@
</span><span class="cx"> void VideoFullscreenInterfaceAVKit::didStopPictureInPicture()
</span><span class="cx"> {
</span><span class="cx"> LOG(Fullscreen, "VideoFullscreenInterfaceAVKit::didStopPictureInPicture(%p)", this);
</span><del>- if (hasMode(HTMLMediaElementEnums::VideoFullscreenModeStandard) || m_restoringFullscreenForPictureInPictureStop) {
- // ASSUMPTION: we are exiting pip because we are entering fullscreen
</del><ins>+
+ if (m_currentMode.hasFullscreen() || m_restoringFullscreenForPictureInPictureStop) {
</ins><span class="cx"> clearMode(HTMLMediaElementEnums::VideoFullscreenModePictureInPicture);
</span><span class="cx"> [m_playerViewController setShowsPlaybackControls:YES];
</span><ins>+
</ins><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -926,7 +937,7 @@
</span><span class="cx"> [[m_playerViewController view] setBackgroundColor:clearUIColor()];
</span><span class="cx">
</span><span class="cx"> clearMode(HTMLMediaElementEnums::VideoFullscreenModePictureInPicture);
</span><del>-
</del><ins>+
</ins><span class="cx"> if (m_fullscreenChangeObserver)
</span><span class="cx"> m_fullscreenChangeObserver->didExitFullscreen();
</span><span class="cx"> }
</span><span class="lines">@@ -935,14 +946,16 @@
</span><span class="cx"> {
</span><span class="cx"> LOG(Fullscreen, "VideoFullscreenInterfaceAVKit::prepareForPictureInPictureStopWithCompletionHandler(%p)", this);
</span><span class="cx"> if (m_shouldReturnToFullscreenWhenStoppingPiP || m_shouldReturnToFullscreenAfterEnteringForeground) {
</span><ins>+
+ m_shouldReturnToFullscreenAfterEnteringForeground = false;
</ins><span class="cx"> m_shouldReturnToFullscreenWhenStoppingPiP = false;
</span><del>- m_shouldReturnToFullscreenAfterEnteringForeground = false;
</del><span class="cx"> m_restoringFullscreenForPictureInPictureStop = true;
</span><span class="cx">
</span><span class="cx"> [m_window setHidden:NO];
</span><span class="cx"> [[m_playerViewController view] setHidden:NO];
</span><span class="cx">
</span><del>- [m_playerViewController enterFullScreenAnimated:YES completionHandler:^(BOOL success, NSError*) {
</del><ins>+ [m_playerViewController enterFullScreenAnimated:YES completionHandler:^(BOOL success, NSError *error) {
+ UNUSED_PARAM(error);
</ins><span class="cx"> m_restoringFullscreenForPictureInPictureStop = false;
</span><span class="cx"> setMode(HTMLMediaElementEnums::VideoFullscreenModeStandard);
</span><span class="cx"> completionHandler(success);
</span><span class="lines">@@ -952,12 +965,9 @@
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- RefPtr<VideoFullscreenInterfaceAVKit> protectedThis(this);
- RetainPtr<id> strongCompletionHandler = adoptNS([completionHandler copy]);
- fullscreenMayReturnToInline([protectedThis, strongCompletionHandler](bool restored) {
</del><ins>+ fullscreenMayReturnToInline([protectedThis = makeRefPtr(this), strongCompletionHandler = adoptNS([completionHandler copy])](bool restored) {
</ins><span class="cx"> LOG(Fullscreen, "VideoFullscreenInterfaceAVKit::prepareForPictureInPictureStopWithCompletionHandler lambda(%p) - restored(%s)", protectedThis.get(), boolString(restored));
</span><del>- void (^completionHandler)(BOOL restored) = strongCompletionHandler.get();
- completionHandler(restored);
</del><ins>+ ((void (^)(BOOL))strongCompletionHandler.get())(restored);
</ins><span class="cx"> });
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -970,7 +980,7 @@
</span><span class="cx"> if ([m_playerViewController pictureInPictureWasStartedWhenEnteringBackground])
</span><span class="cx"> return false;
</span><span class="cx">
</span><del>- m_shouldReturnToFullscreenWhenStoppingPiP = hasMode(HTMLMediaElementEnums::VideoFullscreenModeStandard);
</del><ins>+ m_shouldReturnToFullscreenWhenStoppingPiP = m_currentMode.hasFullscreen();
</ins><span class="cx"> clearMode(HTMLMediaElementEnums::VideoFullscreenModeStandard);
</span><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="lines">@@ -987,6 +997,565 @@
</span><span class="cx"> return false;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+#else // ENABLE(FULLSCREEN_API)
+
+void VideoFullscreenInterfaceAVKit::applicationDidBecomeActive()
+{
+ LOG(Fullscreen, "VideoFullscreenInterfaceAVKit::applicationDidBecomeActive(%p)", this);
+
+ // If we are both in PiP and in Fullscreen (i.e., via auto-PiP), and we did not stop fullscreen upon returning, it must be
+ // because the originating view is not visible, so hide the fullscreen window.
+ if (m_currentMode.hasFullscreen() && m_currentMode.hasPictureInPicture()) {
+ [m_playerViewController exitFullScreenAnimated:NO completionHandler:[protectedThis = makeRefPtr(this), this] (BOOL success, NSError *error) {
+ exitFullscreenHandler(success, error);
+ }];
+ }
+}
+
+void VideoFullscreenInterfaceAVKit::setupFullscreen(UIView& videoView, const IntRect& initialRect, UIView* parentView, HTMLMediaElementEnums::VideoFullscreenMode mode, bool allowsPictureInPicturePlayback, bool standby)
+{
+ ASSERT(standby || mode != HTMLMediaElementEnums::VideoFullscreenModeNone);
+ LOG(Fullscreen, "VideoFullscreenInterfaceAVKit::setupFullscreen(%p)", this);
+
+ m_allowsPictureInPicturePlayback = allowsPictureInPicturePlayback;
+ m_videoView = &videoView;
+ m_parentView = parentView;
+ m_parentWindow = parentView.window;
+
+ m_targetStandby = standby;
+ m_targetMode = mode;
+ setInlineRect(initialRect, true);
+ doSetup();
+}
+
+void VideoFullscreenInterfaceAVKit::enterFullscreen()
+{
+ LOG(Fullscreen, "VideoFullscreenInterfaceAVKit::enterFullscreen(%p) %d", this, mode());
+
+ doEnterFullscreen();
+}
+
+void VideoFullscreenInterfaceAVKit::exitFullscreen(const IntRect& finalRect)
+{
+ m_watchdogTimer.stop();
+
+ m_targetMode = HTMLMediaElementEnums::VideoFullscreenModeNone;
+
+ setInlineRect(finalRect, true);
+ doExitFullscreen();
+}
+
+void VideoFullscreenInterfaceAVKit::cleanupFullscreen()
+{
+ LOG(Fullscreen, "VideoFullscreenInterfaceAVKit::cleanupFullscreen(%p)", this);
+
+ m_cleanupNeedsReturnVideoContentLayer = true;
+ if (m_hasVideoContentLayer && m_fullscreenChangeObserver) {
+ m_fullscreenChangeObserver->returnVideoContentLayer();
+ return;
+ }
+ m_cleanupNeedsReturnVideoContentLayer = false;
+
+ if (m_window) {
+ [m_window setHidden:YES];
+ [m_window setRootViewController:nil];
+ }
+
+ [m_playerViewController setDelegate:nil];
+ [m_playerViewController setPlayerController:nil];
+
+ if (m_currentMode.hasPictureInPicture())
+ [m_playerViewController stopPictureInPicture];
+ if (m_currentMode.hasFullscreen())
+ [m_playerViewController exitFullScreenAnimated:NO completionHandler:[] (BOOL, NSError *) { }];
+
+ [[m_playerViewController view] removeFromSuperview];
+ if (m_viewController)
+ [m_playerViewController removeFromParentViewController];
+
+ [m_playerLayerView removeFromSuperview];
+ [[m_viewController view] removeFromSuperview];
+
+ m_playerLayerView = nil;
+ m_playerViewController = nil;
+ m_window = nil;
+ m_videoView = nil;
+ m_parentView = nil;
+ m_parentWindow = nil;
+
+ if (m_fullscreenChangeObserver)
+ m_fullscreenChangeObserver->didCleanupFullscreen();
+}
+
+void VideoFullscreenInterfaceAVKit::invalidate()
+{
+ m_videoFullscreenModel = nil;
+ m_fullscreenChangeObserver = nil;
+
+ cleanupFullscreen();
+}
+
+void VideoFullscreenInterfaceAVKit::requestHideAndExitFullscreen()
+{
+ if (m_currentMode.hasPictureInPicture())
+ return;
+
+ LOG(Fullscreen, "VideoFullscreenInterfaceAVKit::requestHideAndExitFullscreen(%p)", this);
+
+ [m_window setHidden:YES];
+ [[m_playerViewController view] setHidden:YES];
+
+ if (playbackSessionModel() && m_videoFullscreenModel) {
+ playbackSessionModel()->pause();
+ m_videoFullscreenModel->requestFullscreenMode(HTMLMediaElementEnums::VideoFullscreenModeNone);
+ }
+}
+
+void VideoFullscreenInterfaceAVKit::preparedToReturnToInline(bool visible, const IntRect& inlineRect)
+{
+ LOG(Fullscreen, "VideoFullscreenInterfaceAVKit::preparedToReturnToInline(%p) - visible(%s)", this, boolString(visible));
+ setInlineRect(inlineRect, visible);
+ if (m_prepareToInlineCallback) {
+ WTF::Function<void(bool)> callback = WTFMove(m_prepareToInlineCallback);
+ callback(visible);
+ }
+}
+
+bool VideoFullscreenInterfaceAVKit::mayAutomaticallyShowVideoPictureInPicture() const
+{
+ return [playerController() isPlaying] && (m_standby || m_currentMode.isFullscreen()) && supportsPictureInPicture();
+}
+
+void VideoFullscreenInterfaceAVKit::fullscreenMayReturnToInline(WTF::Function<void(bool)>&& callback)
+{
+ m_prepareToInlineCallback = WTFMove(callback);
+ if (m_fullscreenChangeObserver)
+ m_fullscreenChangeObserver->fullscreenMayReturnToInline();
+}
+
+void VideoFullscreenInterfaceAVKit::willStartPictureInPicture()
+{
+ LOG(Fullscreen, "VideoFullscreenInterfaceAVKit::willStartPictureInPicture(%p)", this);
+ if (m_standby && !m_currentMode.hasVideo()) {
+ [m_window setHidden:NO];
+ [[m_playerViewController view] setHidden:NO];
+ }
+
+ if (!m_hasVideoContentLayer)
+ m_fullscreenChangeObserver->requestVideoContentLayer();
+}
+
+void VideoFullscreenInterfaceAVKit::didStartPictureInPicture()
+{
+ LOG(Fullscreen, "VideoFullscreenInterfaceAVKit::didStartPictureInPicture(%p)", this);
+ setMode(HTMLMediaElementEnums::VideoFullscreenModePictureInPicture);
+ [m_playerViewController setShowsPlaybackControls:YES];
+
+ if (m_currentMode.hasFullscreen()) {
+ if (![m_playerViewController pictureInPictureWasStartedWhenEnteringBackground]) {
+ [m_playerViewController exitFullScreenAnimated:YES completionHandler:[protectedThis = makeRefPtr(this), this] (BOOL success, NSError *error) {
+ exitFullscreenHandler(success, error);
+ }];
+ }
+ } else {
+ [m_window setHidden:YES];
+ [[m_playerViewController view] setHidden:YES];
+ }
+
+ if (m_enterFullscreenNeedsEnterPictureInPicture)
+ doEnterFullscreen();
+}
+
+void VideoFullscreenInterfaceAVKit::failedToStartPictureInPicture()
+{
+ LOG(Fullscreen, "VideoFullscreenInterfaceAVKit::failedToStartPictureInPicture(%p)", this);
+ [m_playerViewController setShowsPlaybackControls:YES];
+
+ m_targetMode.setPictureInPicture(false);
+ if (m_currentMode.hasFullscreen())
+ return;
+
+ if (m_fullscreenChangeObserver)
+ m_fullscreenChangeObserver->didEnterFullscreen();
+
+ if (m_videoFullscreenModel)
+ m_videoFullscreenModel->requestFullscreenMode(HTMLMediaElementEnums::VideoFullscreenModeNone);
+}
+
+void VideoFullscreenInterfaceAVKit::willStopPictureInPicture()
+{
+ LOG(Fullscreen, "VideoFullscreenInterfaceAVKit::willStopPictureInPicture(%p)", this);
+
+ m_shouldReturnToFullscreenWhenStoppingPiP = false;
+
+ if (m_currentMode.hasFullscreen() || m_restoringFullscreenForPictureInPictureStop)
+ return;
+
+ [m_window setHidden:NO];
+ [[m_playerViewController view] setHidden:NO];
+}
+
+void VideoFullscreenInterfaceAVKit::didStopPictureInPicture()
+{
+ LOG(Fullscreen, "VideoFullscreenInterfaceAVKit::didStopPictureInPicture(%p)", this);
+ m_targetMode.setPictureInPicture(false);
+
+ if (m_currentMode.hasFullscreen() || m_restoringFullscreenForPictureInPictureStop) {
+ clearMode(HTMLMediaElementEnums::VideoFullscreenModePictureInPicture);
+ [m_playerViewController setShowsPlaybackControls:YES];
+
+ if (m_exitFullscreenNeedsExitPictureInPicture)
+ doExitFullscreen();
+ return;
+ }
+
+ [m_playerLayerView setBackgroundColor:clearUIColor()];
+ [[m_playerViewController view] setBackgroundColor:clearUIColor()];
+
+ if (m_videoFullscreenModel)
+ m_videoFullscreenModel->requestFullscreenMode(HTMLMediaElementEnums::VideoFullscreenModeNone);
+
+ clearMode(HTMLMediaElementEnums::VideoFullscreenModePictureInPicture);
+
+ if (m_enterFullscreenNeedsExitPictureInPicture)
+ doEnterFullscreen();
+
+ if (m_exitFullscreenNeedsExitPictureInPicture)
+ doExitFullscreen();
+}
+
+void VideoFullscreenInterfaceAVKit::prepareForPictureInPictureStopWithCompletionHandler(void (^completionHandler)(BOOL restored))
+{
+ LOG(Fullscreen, "VideoFullscreenInterfaceAVKit::prepareForPictureInPictureStopWithCompletionHandler(%p)", this);
+ if (m_shouldReturnToFullscreenWhenStoppingPiP) {
+
+ m_shouldReturnToFullscreenWhenStoppingPiP = false;
+ m_restoringFullscreenForPictureInPictureStop = true;
+
+ [m_window setHidden:NO];
+ [[m_playerViewController view] setHidden:NO];
+
+ [m_playerViewController enterFullScreenAnimated:YES completionHandler:^(BOOL success, NSError *error) {
+ enterFullscreenHandler(success, error);
+ completionHandler(success);
+ }];
+ return;
+ }
+
+ fullscreenMayReturnToInline([protectedThis = makeRefPtr(this), strongCompletionHandler = adoptNS([completionHandler copy])](bool restored) {
+ LOG(Fullscreen, "VideoFullscreenInterfaceAVKit::prepareForPictureInPictureStopWithCompletionHandler lambda(%p) - restored(%s)", protectedThis.get(), boolString(restored));
+ ((void (^)(BOOL))strongCompletionHandler.get())(restored);
+ });
+}
+
+bool VideoFullscreenInterfaceAVKit::shouldExitFullscreenWithReason(VideoFullscreenInterfaceAVKit::ExitFullScreenReason reason)
+{
+ if (!m_videoFullscreenModel)
+ return true;
+
+ if (reason == ExitFullScreenReason::PictureInPictureStarted) {
+ m_shouldReturnToFullscreenWhenStoppingPiP = m_currentMode.hasMode(HTMLMediaElementEnums::VideoFullscreenModeStandard);
+ dispatch_async(dispatch_get_main_queue(), [protectedThis = makeRefPtr(this), this] () mutable {
+ [m_playerViewController exitFullScreenAnimated:NO completionHandler:[protectedThis = WTFMove(protectedThis), this] (BOOL success, NSError *error) {
+ exitFullscreenHandler(success, error);
+ }];
+ });
+ return false;
+ }
+
+ if (playbackSessionModel() && (reason == ExitFullScreenReason::DoneButtonTapped || reason == ExitFullScreenReason::RemoteControlStopEventReceived))
+ playbackSessionModel()->pause();
+
+ BOOL finished = reason == ExitFullScreenReason::DoneButtonTapped || reason == ExitFullScreenReason::PinchGestureHandled;
+ m_videoFullscreenModel->requestFullscreenMode(HTMLMediaElementEnums::VideoFullscreenModeNone, finished);
+
+ if (!m_watchdogTimer.isActive())
+ m_watchdogTimer.startOneShot(defaultWatchdogTimerInterval);
+
+ return false;
+}
+
+void VideoFullscreenInterfaceAVKit::setHasVideoContentLayer(bool value)
+{
+ m_hasVideoContentLayer = value;
+
+ if (m_hasVideoContentLayer && m_finalizeSetupNeedsVideoContentLayer)
+ finalizeSetup();
+ if (!m_hasVideoContentLayer && m_cleanupNeedsReturnVideoContentLayer)
+ cleanupFullscreen();
+ if (!m_hasVideoContentLayer && m_returnToStandbyNeedsReturnVideoContentLayer)
+ returnToStandby();
+ if (!m_hasVideoContentLayer && m_finalizeSetupNeedsReturnVideoContentLayer)
+ finalizeSetup();
+ if (!m_hasVideoContentLayer && m_exitFullscreenNeedsReturnContentLayer)
+ doExitFullscreen();
+}
+
+void VideoFullscreenInterfaceAVKit::setInlineRect(const IntRect& inlineRect, bool visible)
+{
+ m_inlineRect = inlineRect;
+ m_inlineIsVisible = visible;
+ m_hasUpdatedInlineRect = true;
+
+ if (m_playerViewController && m_parentView) {
+ [CATransaction begin];
+ [CATransaction setDisableActions:YES];
+ [m_playerViewController view].frame = [m_parentView convertRect:inlineRect toView:[m_playerViewController view].superview];
+ [CATransaction commit];
+ }
+
+ if (m_setupNeedsInlineRect)
+ doSetup();
+
+ if (m_exitFullscreenNeedInlineRect)
+ doExitFullscreen();
+}
+
+void VideoFullscreenInterfaceAVKit::doSetup()
+{
+ Mode changes { m_currentMode.mode() ^ m_targetMode.mode() };
+
+ if (m_currentMode.hasVideo() && m_targetMode.hasVideo() && (m_standby != m_targetStandby)) {
+ m_standby = m_targetStandby;
+ finalizeSetup();
+ return;
+ }
+
+ if (!m_hasUpdatedInlineRect && m_fullscreenChangeObserver) {
+ m_setupNeedsInlineRect = true;
+ m_fullscreenChangeObserver->requestUpdateInlineRect();
+ return;
+ }
+ m_setupNeedsInlineRect = false;
+
+ [CATransaction begin];
+ [CATransaction setDisableActions:YES];
+ if (![[m_parentView window] _isHostedInAnotherProcess] && !m_window) {
+ if (!m_window)
+ m_window = adoptNS([allocUIWindowInstance() initWithFrame:[[getUIScreenClass() mainScreen] bounds]]);
+ [m_window setBackgroundColor:clearUIColor()];
+ if (!m_viewController)
+ m_viewController = adoptNS([allocUIViewControllerInstance() init]);
+ [[m_viewController view] setFrame:[m_window bounds]];
+ [m_viewController _setIgnoreAppSupportedOrientations:YES];
+ [m_window setRootViewController:m_viewController.get()];
+ [m_window setWindowLevel:getUITextEffectsBeneathStatusBarWindowLevel() + 1];
+ [m_window makeKeyAndVisible];
+ }
+
+ if (!m_playerLayerView)
+ m_playerLayerView = adoptNS([allocWebAVPlayerLayerViewInstance() init]);
+ [m_playerLayerView setHidden:[playerController() isExternalPlaybackActive]];
+ [m_playerLayerView setBackgroundColor:clearUIColor()];
+
+ if (!m_currentMode.hasPictureInPicture()) {
+ [m_playerLayerView setVideoView:m_videoView.get()];
+ [m_playerLayerView addSubview:m_videoView.get()];
+ }
+
+ WebAVPlayerLayer *playerLayer = (WebAVPlayerLayer *)[m_playerLayerView playerLayer];
+
+ [playerLayer setModelVideoLayerFrame:CGRectMake(0, 0, m_inlineRect.width(), m_inlineRect.height())];
+ [playerLayer setVideoDimensions:[playerController() contentDimensions]];
+ playerLayer.fullscreenInterface = this;
+
+ if (!m_playerViewController)
+ m_playerViewController = adoptNS([allocAVPlayerViewControllerInstance() initWithPlayerLayerView:m_playerLayerView.get()]);
+
+ [m_playerViewController setShowsPlaybackControls:NO];
+ [m_playerViewController setPlayerController:(AVPlayerController *)playerController()];
+ [m_playerViewController setDelegate:m_playerViewControllerDelegate.get()];
+ [m_playerViewController setAllowsPictureInPicturePlayback:m_allowsPictureInPicturePlayback];
+
+ [playerController() setPictureInPicturePossible:m_allowsPictureInPicturePlayback];
+
+ if (m_viewController) {
+ [m_viewController addChildViewController:m_playerViewController.get()];
+ [[m_viewController view] addSubview:[m_playerViewController view]];
+ } else
+ [m_parentView addSubview:[m_playerViewController view]];
+
+ [m_playerViewController view].frame = [m_parentView convertRect:m_inlineRect toView:[m_playerViewController view].superview];
+
+ [[m_playerViewController view] setBackgroundColor:clearUIColor()];
+ [[m_playerViewController view] setAutoresizingMask:(UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleRightMargin)];
+
+ [[m_playerViewController view] setNeedsLayout];
+ [[m_playerViewController view] layoutIfNeeded];
+
+ if (m_targetStandby && !m_currentMode.hasVideo()) {
+ [m_window setHidden:YES];
+ [[m_playerViewController view] setHidden:YES];
+ }
+
+ [CATransaction commit];
+
+ finalizeSetup();
+}
+
+void VideoFullscreenInterfaceAVKit::finalizeSetup()
+{
+ dispatch_async(dispatch_get_main_queue(), [protectedThis = makeRefPtr(this), this] {
+ if (m_fullscreenChangeObserver) {
+ if (!m_hasVideoContentLayer && m_targetMode.hasVideo()) {
+ m_finalizeSetupNeedsVideoContentLayer = true;
+ m_fullscreenChangeObserver->requestVideoContentLayer();
+ return;
+ }
+ m_finalizeSetupNeedsVideoContentLayer = false;
+ if (m_hasVideoContentLayer && !m_targetMode.hasVideo()) {
+ m_finalizeSetupNeedsReturnVideoContentLayer = true;
+ m_fullscreenChangeObserver->returnVideoContentLayer();
+ return;
+ }
+ m_finalizeSetupNeedsReturnVideoContentLayer = false;
+ m_fullscreenChangeObserver->didSetupFullscreen();
+ }
+ });
+}
+
+void VideoFullscreenInterfaceAVKit::doEnterFullscreen()
+{
+ m_standby = m_targetStandby;
+
+ if (m_targetMode.hasFullscreen() && !m_currentMode.hasFullscreen()) {
+ m_enterFullscreenNeedsEnterFullscreen = true;
+ [m_playerViewController enterFullScreenAnimated:YES completionHandler:[this, protectedThis = makeRefPtr(this)] (BOOL success, NSError *error) {
+ enterFullscreenHandler(success, error);
+ }];
+ return;
+ }
+ m_enterFullscreenNeedsEnterFullscreen = false;
+
+ if (m_targetMode.hasPictureInPicture() && !m_currentMode.hasPictureInPicture()) {
+ m_enterFullscreenNeedsEnterPictureInPicture = true;
+ if ([m_playerViewController isPictureInPicturePossible])
+ [m_playerViewController startPictureInPicture];
+ else
+ failedToStartPictureInPicture();
+ return;
+ }
+ m_enterFullscreenNeedsEnterPictureInPicture = false;
+
+ if (!m_targetMode.hasFullscreen() && m_currentMode.hasFullscreen()) {
+ m_enterFullscreenNeedsExitFullscreen = true;
+ [m_playerViewController exitFullScreenAnimated:YES completionHandler:[protectedThis = makeRefPtr(this), this] (BOOL success, NSError *error) {
+ exitFullscreenHandler(success, error);
+ }];
+ return;
+ }
+ m_enterFullscreenNeedsExitFullscreen = false;
+
+ if (!m_targetMode.hasPictureInPicture() && m_currentMode.hasPictureInPicture()) {
+ m_enterFullscreenNeedsExitPictureInPicture = true;
+ [m_playerViewController stopPictureInPicture];
+ return;
+ }
+ m_enterFullscreenNeedsExitPictureInPicture = false;
+
+ if (m_fullscreenChangeObserver)
+ m_fullscreenChangeObserver->didEnterFullscreen();
+}
+
+void VideoFullscreenInterfaceAVKit::doExitFullscreen()
+{
+ LOG(Fullscreen, "VideoFullscreenInterfaceAVKit::doExitFullscreen(%p)", this);
+
+ if (m_currentMode.hasVideo() && !m_hasUpdatedInlineRect && m_fullscreenChangeObserver) {
+ m_exitFullscreenNeedInlineRect = true;
+ m_fullscreenChangeObserver->requestUpdateInlineRect();
+ return;
+ }
+ m_exitFullscreenNeedInlineRect = false;
+
+ if (m_currentMode.hasMode(HTMLMediaElementEnums::VideoFullscreenModeStandard)) {
+ m_exitFullscreenNeedsExitFullscreen = true;
+ [m_playerViewController exitFullScreenAnimated:YES completionHandler:[protectedThis = makeRefPtr(this), this] (BOOL success, NSError *error) {
+ exitFullscreenHandler(success, error);
+ }];
+ return;
+ }
+ m_exitFullscreenNeedsExitFullscreen = false;
+
+ if (m_currentMode.hasMode(HTMLMediaElementEnums::VideoFullscreenModePictureInPicture)) {
+ m_exitFullscreenNeedsExitPictureInPicture = true;
+ m_shouldReturnToFullscreenWhenStoppingPiP = false;
+ [m_window setHidden:NO];
+ [m_playerViewController stopPictureInPicture];
+ return;
+ }
+ m_exitFullscreenNeedsExitPictureInPicture = false;
+
+ if (m_hasVideoContentLayer && m_fullscreenChangeObserver) {
+ m_exitFullscreenNeedsReturnContentLayer = true;
+ m_fullscreenChangeObserver->returnVideoContentLayer();
+ return;
+ }
+ m_exitFullscreenNeedsReturnContentLayer = false;
+
+ m_standby = false;
+
+ dispatch_async(dispatch_get_main_queue(), [protectedThis = makeRefPtr(this), this] {
+ if (m_fullscreenChangeObserver)
+ m_fullscreenChangeObserver->didExitFullscreen();
+ });
+}
+
+void VideoFullscreenInterfaceAVKit::exitFullscreenHandler(BOOL success, NSError *)
+{
+ UNUSED_PARAM(success);
+ LOG(Fullscreen, "VideoFullscreenInterfaceAVKit::didExitFullscreen(%p) - %d", this, success);
+
+ clearMode(HTMLMediaElementEnums::VideoFullscreenModeStandard);
+
+ if (hasMode(HTMLMediaElementEnums::VideoFullscreenModePictureInPicture)) {
+ [m_window setHidden:YES];
+ [[m_playerViewController view] setHidden:YES];
+ } else {
+ [CATransaction begin];
+ [CATransaction setDisableActions:YES];
+ [m_playerLayerView setBackgroundColor:clearUIColor()];
+ [[m_playerViewController view] setBackgroundColor:clearUIColor()];
+ [CATransaction commit];
+ }
+
+ if (m_enterFullscreenNeedsExitFullscreen)
+ doEnterFullscreen();
+
+ if (m_exitFullscreenNeedsExitFullscreen)
+ doExitFullscreen();
+}
+
+void VideoFullscreenInterfaceAVKit::enterFullscreenHandler(BOOL success, NSError *)
+{
+ UNUSED_PARAM(success);
+ LOG(Fullscreen, "VideoFullscreenInterfaceAVKit::enterFullscreenStandard - lambda(%p) - success(%s)", this, boolString(success));
+
+ setMode(HTMLMediaElementEnums::VideoFullscreenModeStandard);
+ [m_playerViewController setShowsPlaybackControls:YES];
+
+ m_restoringFullscreenForPictureInPictureStop = false;
+
+ if (m_enterFullscreenNeedsEnterFullscreen)
+ doEnterFullscreen();
+}
+
+void VideoFullscreenInterfaceAVKit::returnToStandby()
+{
+ if (m_hasVideoContentLayer && m_fullscreenChangeObserver) {
+ m_returnToStandbyNeedsReturnVideoContentLayer = true;
+ m_fullscreenChangeObserver->returnVideoContentLayer();
+ return;
+ }
+
+ m_returnToStandbyNeedsReturnVideoContentLayer = false;
+
+ [m_window setHidden:YES];
+ [[m_playerViewController view] setHidden:YES];
+}
+
+#endif // ENABLE(FULLSCREEN_API)
+
</ins><span class="cx"> NO_RETURN_DUE_TO_ASSERT void VideoFullscreenInterfaceAVKit::watchdogTimerFired()
</span><span class="cx"> {
</span><span class="cx"> LOG(Fullscreen, "VideoFullscreenInterfaceAVKit::watchdogTimerFired(%p) - no exit fullscreen response in %gs; forcing fullscreen hidden.", this, defaultWatchdogTimerInterval.value());
</span><span class="lines">@@ -997,24 +1566,22 @@
</span><span class="cx">
</span><span class="cx"> void VideoFullscreenInterfaceAVKit::setMode(HTMLMediaElementEnums::VideoFullscreenMode mode)
</span><span class="cx"> {
</span><del>- HTMLMediaElementEnums::VideoFullscreenMode newMode = m_mode | mode;
- if (m_mode == newMode)
</del><ins>+ if ((m_currentMode.mode() & mode) == mode)
</ins><span class="cx"> return;
</span><span class="cx">
</span><del>- m_mode = newMode;
</del><ins>+ m_currentMode.setMode(mode);
</ins><span class="cx"> if (m_videoFullscreenModel)
</span><del>- m_videoFullscreenModel->fullscreenModeChanged(m_mode);
</del><ins>+ m_videoFullscreenModel->fullscreenModeChanged(m_currentMode.mode());
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void VideoFullscreenInterfaceAVKit::clearMode(HTMLMediaElementEnums::VideoFullscreenMode mode)
</span><span class="cx"> {
</span><del>- HTMLMediaElementEnums::VideoFullscreenMode newMode = m_mode & ~mode;
- if (m_mode == newMode)
</del><ins>+ if ((~m_currentMode.mode() & mode) == mode)
</ins><span class="cx"> return;
</span><span class="cx">
</span><del>- m_mode = newMode;
</del><ins>+ m_currentMode.clearMode(mode);
</ins><span class="cx"> if (m_videoFullscreenModel)
</span><del>- m_videoFullscreenModel->fullscreenModeChanged(m_mode);
</del><ins>+ m_videoFullscreenModel->fullscreenModeChanged(m_currentMode.mode());
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #endif // HAVE(AVKIT)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformiosWebVideoFullscreenControllerAVKitmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm (226216 => 226217)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm 2017-12-21 06:48:48 UTC (rev 226216)
+++ trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm 2017-12-21 10:08:14 UTC (rev 226217)
</span><span class="lines">@@ -122,6 +122,9 @@
</span><span class="cx"> VideoFullscreenControllerContext() { }
</span><span class="cx">
</span><span class="cx"> // VideoFullscreenChangeObserver
</span><ins>+ void requestUpdateInlineRect() override;
+ void requestVideoContentLayer() override;
+ void returnVideoContentLayer() override;
</ins><span class="cx"> void didSetupFullscreen() override;
</span><span class="cx"> void didEnterFullscreen() override { }
</span><span class="cx"> void didExitFullscreen() override;
</span><span class="lines">@@ -207,32 +210,90 @@
</span><span class="cx">
</span><span class="cx"> #pragma mark VideoFullscreenChangeObserver
</span><span class="cx">
</span><ins>+void VideoFullscreenControllerContext::requestUpdateInlineRect()
+{
+#if PLATFORM(IOS) && ENABLE(FULLSCREEN_API)
+ ASSERT(isUIThread());
+ WebThreadRun([protectedThis = makeRefPtr(this), this] () mutable {
+ IntRect clientRect = elementRectInWindow(m_videoElement.get());
+ dispatch_async(dispatch_get_main_queue(), [protectedThis = WTFMove(protectedThis), this, clientRect] {
+ m_interface->setInlineRect(clientRect, clientRect != IntRect(0, 0, 0, 0));
+ });
+ });
+#else
+ ASSERT_NOT_REACHED();
+#endif
+}
+
+void VideoFullscreenControllerContext::requestVideoContentLayer()
+{
+#if PLATFORM(IOS) && ENABLE(FULLSCREEN_API)
+ ASSERT(isUIThread());
+ WebThreadRun([protectedThis = makeRefPtr(this), this, videoFullscreenLayer = retainPtr([m_videoFullscreenView layer])] () mutable {
+ [videoFullscreenLayer setBackgroundColor:cachedCGColor(WebCore::Color::transparent)];
+ m_fullscreenModel->setVideoFullscreenLayer(videoFullscreenLayer.get(), [protectedThis = WTFMove(protectedThis), this] () mutable {
+ dispatch_async(dispatch_get_main_queue(), [protectedThis = WTFMove(protectedThis), this] {
+ m_interface->setHasVideoContentLayer(true);
+ });
+ });
+ });
+#else
+ ASSERT_NOT_REACHED();
+#endif
+}
+
+void VideoFullscreenControllerContext::returnVideoContentLayer()
+{
+#if PLATFORM(IOS) && ENABLE(FULLSCREEN_API)
+ ASSERT(isUIThread());
+ WebThreadRun([protectedThis = makeRefPtr(this), this, videoFullscreenLayer = retainPtr([m_videoFullscreenView layer])] () mutable {
+ [videoFullscreenLayer setBackgroundColor:cachedCGColor(WebCore::Color::transparent)];
+ m_fullscreenModel->setVideoFullscreenLayer(nil, [protectedThis = WTFMove(protectedThis), this] () mutable {
+ dispatch_async(dispatch_get_main_queue(), [protectedThis = WTFMove(protectedThis), this] {
+ m_interface->setHasVideoContentLayer(false);
+ });
+ });
+ });
+#else
+ ASSERT_NOT_REACHED();
+#endif
+}
+
</ins><span class="cx"> void VideoFullscreenControllerContext::didSetupFullscreen()
</span><span class="cx"> {
</span><span class="cx"> ASSERT(isUIThread());
</span><del>- RetainPtr<CALayer> videoFullscreenLayer = [m_videoFullscreenView layer];
- RefPtr<VideoFullscreenControllerContext> protectedThis(this);
- WebThreadRun([protectedThis, this, videoFullscreenLayer] {
</del><ins>+#if PLATFORM(IOS) && ENABLE(FULLSCREEN_API)
+ dispatch_async(dispatch_get_main_queue(), [protectedThis = makeRefPtr(this), this] {
+ m_interface->enterFullscreen();
+ });
+#else
+ WebThreadRun([protectedThis = makeRefPtr(this), this, videoFullscreenLayer = retainPtr([m_videoFullscreenView layer])] () mutable {
</ins><span class="cx"> [videoFullscreenLayer setBackgroundColor:cachedCGColor(WebCore::Color::transparent)];
</span><del>- m_fullscreenModel->setVideoFullscreenLayer(videoFullscreenLayer.get(), [protectedThis, this] {
- dispatch_async(dispatch_get_main_queue(), [protectedThis, this] {
</del><ins>+ m_fullscreenModel->setVideoFullscreenLayer(videoFullscreenLayer.get(), [protectedThis = WTFMove(protectedThis), this] () mutable {
+ dispatch_async(dispatch_get_main_queue(), [protectedThis = WTFMove(protectedThis), this] {
</ins><span class="cx"> m_interface->enterFullscreen();
</span><span class="cx"> });
</span><span class="cx"> });
</span><span class="cx"> });
</span><ins>+#endif
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void VideoFullscreenControllerContext::didExitFullscreen()
</span><span class="cx"> {
</span><span class="cx"> ASSERT(isUIThread());
</span><del>- RefPtr<VideoFullscreenControllerContext> protectedThis(this);
- WebThreadRun([protectedThis, this] {
- m_fullscreenModel->setVideoFullscreenLayer(nil, [protectedThis, this] {
- dispatch_async(dispatch_get_main_queue(), [protectedThis, this] {
</del><ins>+#if PLATFORM(IOS) && ENABLE(FULLSCREEN_API)
+ dispatch_async(dispatch_get_main_queue(), [protectedThis = makeRefPtr(this), this] {
+ m_interface->cleanupFullscreen();
+ });
+#else
+ WebThreadRun([protectedThis = makeRefPtr(this), this] () mutable {
+ m_fullscreenModel->setVideoFullscreenLayer(nil, [protectedThis = WTFMove(protectedThis), this] () mutable {
+ dispatch_async(dispatch_get_main_queue(), [protectedThis = WTFMove(protectedThis), this] {
</ins><span class="cx"> m_interface->cleanupFullscreen();
</span><span class="cx"> });
</span><span class="cx"> });
</span><span class="cx"> });
</span><ins>+#endif
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void VideoFullscreenControllerContext::didCleanupFullscreen()
</span><span class="lines">@@ -243,8 +304,7 @@
</span><span class="cx"> m_interface = nullptr;
</span><span class="cx"> m_videoFullscreenView = nil;
</span><span class="cx">
</span><del>- RefPtr<VideoFullscreenControllerContext> protectedThis(this);
- WebThreadRun([protectedThis, this] {
</del><ins>+ WebThreadRun([protectedThis = makeRefPtr(this), this] {
</ins><span class="cx"> m_fullscreenModel->setVideoFullscreenLayer(nil);
</span><span class="cx"> m_fullscreenModel->setVideoElement(nullptr);
</span><span class="cx"> m_playbackModel->setMediaElement(nullptr);
</span><span class="lines">@@ -259,10 +319,9 @@
</span><span class="cx"> void VideoFullscreenControllerContext::fullscreenMayReturnToInline()
</span><span class="cx"> {
</span><span class="cx"> ASSERT(isUIThread());
</span><del>- RefPtr<VideoFullscreenControllerContext> protectedThis(this);
- WebThreadRun([protectedThis, this] {
</del><ins>+ WebThreadRun([protectedThis = makeRefPtr(this), this] () mutable {
</ins><span class="cx"> IntRect clientRect = elementRectInWindow(m_videoElement.get());
</span><del>- dispatch_async(dispatch_get_main_queue(), [protectedThis, this, clientRect] {
</del><ins>+ dispatch_async(dispatch_get_main_queue(), [protectedThis = WTFMove(protectedThis), this, clientRect] {
</ins><span class="cx"> m_interface->preparedToReturnToInline(true, clientRect);
</span><span class="cx"> });
</span><span class="cx"> });
</span><span class="lines">@@ -273,8 +332,7 @@
</span><span class="cx"> void VideoFullscreenControllerContext::durationChanged(double duration)
</span><span class="cx"> {
</span><span class="cx"> if (WebThreadIsCurrent()) {
</span><del>- RefPtr<VideoFullscreenControllerContext> protectedThis(this);
- dispatch_async(dispatch_get_main_queue(), [protectedThis, duration] {
</del><ins>+ dispatch_async(dispatch_get_main_queue(), [protectedThis = makeRefPtr(this), duration] {
</ins><span class="cx"> protectedThis->durationChanged(duration);
</span><span class="cx"> });
</span><span class="cx"> return;
</span><span class="lines">@@ -287,8 +345,7 @@
</span><span class="cx"> void VideoFullscreenControllerContext::currentTimeChanged(double currentTime, double anchorTime)
</span><span class="cx"> {
</span><span class="cx"> if (WebThreadIsCurrent()) {
</span><del>- RefPtr<VideoFullscreenControllerContext> protectedThis(this);
- dispatch_async(dispatch_get_main_queue(), [protectedThis, currentTime, anchorTime] {
</del><ins>+ dispatch_async(dispatch_get_main_queue(), [protectedThis = makeRefPtr(this), currentTime, anchorTime] {
</ins><span class="cx"> protectedThis->currentTimeChanged(currentTime, anchorTime);
</span><span class="cx"> });
</span><span class="cx"> return;
</span><span class="lines">@@ -301,8 +358,7 @@
</span><span class="cx"> void VideoFullscreenControllerContext::bufferedTimeChanged(double bufferedTime)
</span><span class="cx"> {
</span><span class="cx"> if (WebThreadIsCurrent()) {
</span><del>- RefPtr<VideoFullscreenControllerContext> protectedThis(this);
- dispatch_async(dispatch_get_main_queue(), [protectedThis, bufferedTime] {
</del><ins>+ dispatch_async(dispatch_get_main_queue(), [protectedThis = makeRefPtr(this), bufferedTime] {
</ins><span class="cx"> protectedThis->bufferedTimeChanged(bufferedTime);
</span><span class="cx"> });
</span><span class="cx"> return;
</span><span class="lines">@@ -315,8 +371,7 @@
</span><span class="cx"> void VideoFullscreenControllerContext::rateChanged(bool isPlaying, float playbackRate)
</span><span class="cx"> {
</span><span class="cx"> if (WebThreadIsCurrent()) {
</span><del>- RefPtr<VideoFullscreenControllerContext> protectedThis(this);
- dispatch_async(dispatch_get_main_queue(), [protectedThis, isPlaying, playbackRate] {
</del><ins>+ dispatch_async(dispatch_get_main_queue(), [protectedThis = makeRefPtr(this), isPlaying, playbackRate] {
</ins><span class="cx"> protectedThis->rateChanged(isPlaying, playbackRate);
</span><span class="cx"> });
</span><span class="cx"> return;
</span><span class="lines">@@ -329,8 +384,7 @@
</span><span class="cx"> void VideoFullscreenControllerContext::hasVideoChanged(bool hasVideo)
</span><span class="cx"> {
</span><span class="cx"> if (WebThreadIsCurrent()) {
</span><del>- RefPtr<VideoFullscreenControllerContext> protectedThis(this);
- dispatch_async(dispatch_get_main_queue(), [protectedThis, hasVideo] {
</del><ins>+ dispatch_async(dispatch_get_main_queue(), [protectedThis = makeRefPtr(this), hasVideo] {
</ins><span class="cx"> protectedThis->hasVideoChanged(hasVideo);
</span><span class="cx"> });
</span><span class="cx"> return;
</span><span class="lines">@@ -343,8 +397,7 @@
</span><span class="cx"> void VideoFullscreenControllerContext::videoDimensionsChanged(const FloatSize& videoDimensions)
</span><span class="cx"> {
</span><span class="cx"> if (WebThreadIsCurrent()) {
</span><del>- RefPtr<VideoFullscreenControllerContext> protectedThis(this);
- dispatch_async(dispatch_get_main_queue(), [protectedThis, videoDimensions = videoDimensions] {
</del><ins>+ dispatch_async(dispatch_get_main_queue(), [protectedThis = makeRefPtr(this), videoDimensions = videoDimensions] {
</ins><span class="cx"> protectedThis->videoDimensionsChanged(videoDimensions);
</span><span class="cx"> });
</span><span class="cx"> return;
</span><span class="lines">@@ -357,8 +410,7 @@
</span><span class="cx"> void VideoFullscreenControllerContext::seekableRangesChanged(const TimeRanges& timeRanges, double lastModifiedTime, double liveUpdateInterval)
</span><span class="cx"> {
</span><span class="cx"> if (WebThreadIsCurrent()) {
</span><del>- RefPtr<VideoFullscreenControllerContext> protectedThis(this);
- dispatch_async(dispatch_get_main_queue(), [protectedThis, platformTimeRanges = timeRanges.ranges(), lastModifiedTime, liveUpdateInterval] {
</del><ins>+ dispatch_async(dispatch_get_main_queue(), [protectedThis = makeRefPtr(this), platformTimeRanges = timeRanges.ranges(), lastModifiedTime, liveUpdateInterval] {
</ins><span class="cx"> protectedThis->seekableRangesChanged(TimeRanges::create(platformTimeRanges), lastModifiedTime, liveUpdateInterval);
</span><span class="cx"> });
</span><span class="cx"> return;
</span><span class="lines">@@ -371,8 +423,7 @@
</span><span class="cx"> void VideoFullscreenControllerContext::canPlayFastReverseChanged(bool canPlayFastReverse)
</span><span class="cx"> {
</span><span class="cx"> if (WebThreadIsCurrent()) {
</span><del>- RefPtr<VideoFullscreenControllerContext> protectedThis(this);
- dispatch_async(dispatch_get_main_queue(), [protectedThis, canPlayFastReverse] {
</del><ins>+ dispatch_async(dispatch_get_main_queue(), [protectedThis = makeRefPtr(this), canPlayFastReverse] {
</ins><span class="cx"> protectedThis->canPlayFastReverseChanged(canPlayFastReverse);
</span><span class="cx"> });
</span><span class="cx"> return;
</span><span class="lines">@@ -394,8 +445,7 @@
</span><span class="cx"> void VideoFullscreenControllerContext::audioMediaSelectionOptionsChanged(const Vector<MediaSelectionOption>& options, uint64_t selectedIndex)
</span><span class="cx"> {
</span><span class="cx"> if (WebThreadIsCurrent()) {
</span><del>- RefPtr<VideoFullscreenControllerContext> protectedThis(this);
- dispatch_async(dispatch_get_main_queue(), [protectedThis, options = isolatedCopy(options), selectedIndex] {
</del><ins>+ dispatch_async(dispatch_get_main_queue(), [protectedThis = makeRefPtr(this), options = isolatedCopy(options), selectedIndex] {
</ins><span class="cx"> protectedThis->audioMediaSelectionOptionsChanged(options, selectedIndex);
</span><span class="cx"> });
</span><span class="cx"> return;
</span><span class="lines">@@ -408,8 +458,7 @@
</span><span class="cx"> void VideoFullscreenControllerContext::legibleMediaSelectionOptionsChanged(const Vector<MediaSelectionOption>& options, uint64_t selectedIndex)
</span><span class="cx"> {
</span><span class="cx"> if (WebThreadIsCurrent()) {
</span><del>- RefPtr<VideoFullscreenControllerContext> protectedThis(this);
- dispatch_async(dispatch_get_main_queue(), [protectedThis, options = isolatedCopy(options), selectedIndex] {
</del><ins>+ dispatch_async(dispatch_get_main_queue(), [protectedThis = makeRefPtr(this), options = isolatedCopy(options), selectedIndex] {
</ins><span class="cx"> protectedThis->legibleMediaSelectionOptionsChanged(options, selectedIndex);
</span><span class="cx"> });
</span><span class="cx"> return;
</span><span class="lines">@@ -436,8 +485,7 @@
</span><span class="cx"> void VideoFullscreenControllerContext::wirelessVideoPlaybackDisabledChanged(bool disabled)
</span><span class="cx"> {
</span><span class="cx"> if (WebThreadIsCurrent()) {
</span><del>- RefPtr<VideoFullscreenControllerContext> protectedThis(this);
- dispatch_async(dispatch_get_main_queue(), [protectedThis, disabled] {
</del><ins>+ dispatch_async(dispatch_get_main_queue(), [protectedThis = makeRefPtr(this), disabled] {
</ins><span class="cx"> protectedThis->wirelessVideoPlaybackDisabledChanged(disabled);
</span><span class="cx"> });
</span><span class="cx"> return;
</span><span class="lines">@@ -450,8 +498,7 @@
</span><span class="cx"> void VideoFullscreenControllerContext::mutedChanged(bool muted)
</span><span class="cx"> {
</span><span class="cx"> if (WebThreadIsCurrent()) {
</span><del>- RefPtr<VideoFullscreenControllerContext> protectedThis(this);
- dispatch_async(dispatch_get_main_queue(), [protectedThis, muted] {
</del><ins>+ dispatch_async(dispatch_get_main_queue(), [protectedThis = makeRefPtr(this), muted] {
</ins><span class="cx"> protectedThis->mutedChanged(muted);
</span><span class="cx"> });
</span><span class="cx"> return;
</span><span class="lines">@@ -478,8 +525,7 @@
</span><span class="cx"> void VideoFullscreenControllerContext::requestFullscreenMode(HTMLMediaElementEnums::VideoFullscreenMode mode, bool finishedWithMedia)
</span><span class="cx"> {
</span><span class="cx"> ASSERT(isUIThread());
</span><del>- RefPtr<VideoFullscreenControllerContext> protectedThis(this);
- WebThreadRun([protectedThis, this, mode, finishedWithMedia] {
</del><ins>+ WebThreadRun([protectedThis = makeRefPtr(this), this, mode, finishedWithMedia] {
</ins><span class="cx"> if (m_fullscreenModel)
</span><span class="cx"> m_fullscreenModel->requestFullscreenMode(mode, finishedWithMedia);
</span><span class="cx"> });
</span><span class="lines">@@ -488,13 +534,11 @@
</span><span class="cx"> void VideoFullscreenControllerContext::setVideoLayerFrame(FloatRect frame)
</span><span class="cx"> {
</span><span class="cx"> ASSERT(isUIThread());
</span><del>- RefPtr<VideoFullscreenControllerContext> protectedThis(this);
</del><span class="cx"> RetainPtr<CALayer> videoFullscreenLayer = [m_videoFullscreenView layer];
</span><del>-
</del><span class="cx"> [videoFullscreenLayer setSublayerTransform:[videoFullscreenLayer transform]];
</span><span class="cx">
</span><del>- dispatch_async(dispatch_get_main_queue(), ^ {
- WebThreadRun([protectedThis, this, frame, videoFullscreenLayer] {
</del><ins>+ dispatch_async(dispatch_get_main_queue(), [protectedThis = makeRefPtr(this), this, frame, videoFullscreenLayer = WTFMove(videoFullscreenLayer)] () mutable {
+ WebThreadRun([protectedThis = WTFMove(protectedThis), this, frame, videoFullscreenLayer = WTFMove(videoFullscreenLayer)] {
</ins><span class="cx"> [CATransaction begin];
</span><span class="cx"> [CATransaction setDisableActions:YES];
</span><span class="cx"> [CATransaction setAnimationDuration:0];
</span><span class="lines">@@ -511,8 +555,7 @@
</span><span class="cx"> void VideoFullscreenControllerContext::setVideoLayerGravity(VideoFullscreenModel::VideoGravity videoGravity)
</span><span class="cx"> {
</span><span class="cx"> ASSERT(isUIThread());
</span><del>- RefPtr<VideoFullscreenControllerContext> protectedThis(this);
- WebThreadRun([protectedThis, this, videoGravity] {
</del><ins>+ WebThreadRun([protectedThis = makeRefPtr(this), this, videoGravity] {
</ins><span class="cx"> if (m_fullscreenModel)
</span><span class="cx"> m_fullscreenModel->setVideoLayerGravity(videoGravity);
</span><span class="cx"> });
</span><span class="lines">@@ -521,8 +564,7 @@
</span><span class="cx"> void VideoFullscreenControllerContext::fullscreenModeChanged(HTMLMediaElementEnums::VideoFullscreenMode mode)
</span><span class="cx"> {
</span><span class="cx"> ASSERT(isUIThread());
</span><del>- RefPtr<VideoFullscreenControllerContext> protectedThis(this);
- WebThreadRun([protectedThis, this, mode] {
</del><ins>+ WebThreadRun([protectedThis = makeRefPtr(this), this, mode] {
</ins><span class="cx"> if (m_fullscreenModel)
</span><span class="cx"> m_fullscreenModel->fullscreenModeChanged(mode);
</span><span class="cx"> });
</span><span class="lines">@@ -569,8 +611,7 @@
</span><span class="cx"> void VideoFullscreenControllerContext::play()
</span><span class="cx"> {
</span><span class="cx"> ASSERT(isUIThread());
</span><del>- RefPtr<VideoFullscreenControllerContext> protectedThis(this);
- WebThreadRun([protectedThis, this] {
</del><ins>+ WebThreadRun([protectedThis = makeRefPtr(this), this] {
</ins><span class="cx"> if (m_playbackModel)
</span><span class="cx"> m_playbackModel->play();
</span><span class="cx"> });
</span><span class="lines">@@ -579,8 +620,7 @@
</span><span class="cx"> void VideoFullscreenControllerContext::pause()
</span><span class="cx"> {
</span><span class="cx"> ASSERT(isUIThread());
</span><del>- RefPtr<VideoFullscreenControllerContext> protectedThis(this);
- WebThreadRun([protectedThis, this] {
</del><ins>+ WebThreadRun([protectedThis = makeRefPtr(this), this] {
</ins><span class="cx"> if (m_playbackModel)
</span><span class="cx"> m_playbackModel->pause();
</span><span class="cx"> });
</span><span class="lines">@@ -589,8 +629,7 @@
</span><span class="cx"> void VideoFullscreenControllerContext::togglePlayState()
</span><span class="cx"> {
</span><span class="cx"> ASSERT(isUIThread());
</span><del>- RefPtr<VideoFullscreenControllerContext> protectedThis(this);
- WebThreadRun([protectedThis, this] {
</del><ins>+ WebThreadRun([protectedThis = makeRefPtr(this), this] {
</ins><span class="cx"> if (m_playbackModel)
</span><span class="cx"> m_playbackModel->togglePlayState();
</span><span class="cx"> });
</span><span class="lines">@@ -599,8 +638,7 @@
</span><span class="cx"> void VideoFullscreenControllerContext::toggleMuted()
</span><span class="cx"> {
</span><span class="cx"> ASSERT(isUIThread());
</span><del>- RefPtr<VideoFullscreenControllerContext> protectedThis(this);
- WebThreadRun([protectedThis, this] {
</del><ins>+ WebThreadRun([protectedThis = makeRefPtr(this), this] {
</ins><span class="cx"> if (m_playbackModel)
</span><span class="cx"> m_playbackModel->toggleMuted();
</span><span class="cx"> });
</span><span class="lines">@@ -618,8 +656,7 @@
</span><span class="cx"> void VideoFullscreenControllerContext::beginScrubbing()
</span><span class="cx"> {
</span><span class="cx"> ASSERT(isUIThread());
</span><del>- RefPtr<VideoFullscreenControllerContext> protectedThis(this);
- WebThreadRun([protectedThis, this] {
</del><ins>+ WebThreadRun([protectedThis = makeRefPtr(this), this] {
</ins><span class="cx"> if (m_playbackModel)
</span><span class="cx"> m_playbackModel->beginScrubbing();
</span><span class="cx"> });
</span><span class="lines">@@ -628,8 +665,7 @@
</span><span class="cx"> void VideoFullscreenControllerContext::endScrubbing()
</span><span class="cx"> {
</span><span class="cx"> ASSERT(isUIThread());
</span><del>- RefPtr<VideoFullscreenControllerContext> protectedThis(this);
- WebThreadRun([protectedThis, this] {
</del><ins>+ WebThreadRun([protectedThis = makeRefPtr(this), this] {
</ins><span class="cx"> if (m_playbackModel)
</span><span class="cx"> m_playbackModel->endScrubbing();
</span><span class="cx"> });
</span><span class="lines">@@ -638,8 +674,7 @@
</span><span class="cx"> void VideoFullscreenControllerContext::seekToTime(double time, double toleranceBefore, double toleranceAfter)
</span><span class="cx"> {
</span><span class="cx"> ASSERT(isUIThread());
</span><del>- RefPtr<VideoFullscreenControllerContext> protectedThis(this);
- WebThreadRun([protectedThis, this, time, toleranceBefore, toleranceAfter] {
</del><ins>+ WebThreadRun([protectedThis = makeRefPtr(this), this, time, toleranceBefore, toleranceAfter] {
</ins><span class="cx"> if (m_playbackModel)
</span><span class="cx"> m_playbackModel->seekToTime(time, toleranceBefore, toleranceAfter);
</span><span class="cx"> });
</span><span class="lines">@@ -648,8 +683,7 @@
</span><span class="cx"> void VideoFullscreenControllerContext::fastSeek(double time)
</span><span class="cx"> {
</span><span class="cx"> ASSERT(isUIThread());
</span><del>- RefPtr<VideoFullscreenControllerContext> protectedThis(this);
- WebThreadRun([protectedThis, this, time] {
</del><ins>+ WebThreadRun([protectedThis = makeRefPtr(this), this, time] {
</ins><span class="cx"> if (m_playbackModel)
</span><span class="cx"> m_playbackModel->fastSeek(time);
</span><span class="cx"> });
</span><span class="lines">@@ -658,8 +692,7 @@
</span><span class="cx"> void VideoFullscreenControllerContext::beginScanningForward()
</span><span class="cx"> {
</span><span class="cx"> ASSERT(isUIThread());
</span><del>- RefPtr<VideoFullscreenControllerContext> protectedThis(this);
- WebThreadRun([protectedThis, this] {
</del><ins>+ WebThreadRun([protectedThis = makeRefPtr(this), this] {
</ins><span class="cx"> if (m_playbackModel)
</span><span class="cx"> m_playbackModel->beginScanningForward();
</span><span class="cx"> });
</span><span class="lines">@@ -668,8 +701,7 @@
</span><span class="cx"> void VideoFullscreenControllerContext::beginScanningBackward()
</span><span class="cx"> {
</span><span class="cx"> ASSERT(isUIThread());
</span><del>- RefPtr<VideoFullscreenControllerContext> protectedThis(this);
- WebThreadRun([protectedThis, this] {
</del><ins>+ WebThreadRun([protectedThis = makeRefPtr(this), this] {
</ins><span class="cx"> if (m_playbackModel)
</span><span class="cx"> m_playbackModel->beginScanningBackward();
</span><span class="cx"> });
</span><span class="lines">@@ -678,8 +710,7 @@
</span><span class="cx"> void VideoFullscreenControllerContext::endScanning()
</span><span class="cx"> {
</span><span class="cx"> ASSERT(isUIThread());
</span><del>- RefPtr<VideoFullscreenControllerContext> protectedThis(this);
- WebThreadRun([protectedThis, this] {
</del><ins>+ WebThreadRun([protectedThis = makeRefPtr(this), this] {
</ins><span class="cx"> if (m_playbackModel)
</span><span class="cx"> m_playbackModel->endScanning();
</span><span class="cx"> });
</span><span class="lines">@@ -688,8 +719,7 @@
</span><span class="cx"> void VideoFullscreenControllerContext::selectAudioMediaOption(uint64_t index)
</span><span class="cx"> {
</span><span class="cx"> ASSERT(isUIThread());
</span><del>- RefPtr<VideoFullscreenControllerContext> protectedThis(this);
- WebThreadRun([protectedThis, this, index] {
</del><ins>+ WebThreadRun([protectedThis = makeRefPtr(this), this, index] {
</ins><span class="cx"> if (m_playbackModel)
</span><span class="cx"> m_playbackModel->selectAudioMediaOption(index);
</span><span class="cx"> });
</span><span class="lines">@@ -698,8 +728,7 @@
</span><span class="cx"> void VideoFullscreenControllerContext::selectLegibleMediaOption(uint64_t index)
</span><span class="cx"> {
</span><span class="cx"> ASSERT(isUIThread());
</span><del>- RefPtr<VideoFullscreenControllerContext> protectedThis(this);
- WebThreadRun([protectedThis, this, index] {
</del><ins>+ WebThreadRun([protectedThis = makeRefPtr(this), this, index] {
</ins><span class="cx"> if (m_playbackModel)
</span><span class="cx"> m_playbackModel->selectLegibleMediaOption(index);
</span><span class="cx"> });
</span><span class="lines">@@ -832,8 +861,7 @@
</span><span class="cx"> FloatRect videoLayerFrame = FloatRect(FloatPoint(), videoElementClientRect.size());
</span><span class="cx"> m_fullscreenModel->setVideoLayerFrame(videoLayerFrame);
</span><span class="cx">
</span><del>- RefPtr<VideoFullscreenControllerContext> protectedThis(this);
- dispatch_async(dispatch_get_main_queue(), [protectedThis, this, videoElementClientRect, viewRef, mode, allowsPictureInPicture] {
</del><ins>+ dispatch_async(dispatch_get_main_queue(), [protectedThis = makeRefPtr(this), this, videoElementClientRect, viewRef, mode, allowsPictureInPicture] {
</ins><span class="cx"> ASSERT(isUIThread());
</span><span class="cx">
</span><span class="cx"> Ref<PlaybackSessionInterfaceAVKit> sessionInterface = PlaybackSessionInterfaceAVKit::create(*this);
</span><span class="lines">@@ -844,7 +872,7 @@
</span><span class="cx">
</span><span class="cx"> m_videoFullscreenView = adoptNS([allocUIViewInstance() init]);
</span><span class="cx">
</span><del>- m_interface->setupFullscreen(*m_videoFullscreenView.get(), videoElementClientRect, viewRef.get(), mode, allowsPictureInPicture);
</del><ins>+ m_interface->setupFullscreen(*m_videoFullscreenView.get(), videoElementClientRect, viewRef.get(), mode, allowsPictureInPicture, false);
</ins><span class="cx"> });
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -852,8 +880,7 @@
</span><span class="cx"> {
</span><span class="cx"> ASSERT(WebThreadIsCurrent() || isMainThread());
</span><span class="cx"> IntRect clientRect = elementRectInWindow(m_videoElement.get());
</span><del>- RefPtr<VideoFullscreenControllerContext> protectedThis(this);
- dispatch_async(dispatch_get_main_queue(), [protectedThis, this, clientRect] {
</del><ins>+ dispatch_async(dispatch_get_main_queue(), [protectedThis = makeRefPtr(this), this, clientRect] {
</ins><span class="cx"> ASSERT(isUIThread());
</span><span class="cx"> m_interface->exitFullscreen(clientRect);
</span><span class="cx"> });
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmacVideoFullscreenInterfaceMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mac/VideoFullscreenInterfaceMac.mm (226216 => 226217)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mac/VideoFullscreenInterfaceMac.mm 2017-12-21 06:48:48 UTC (rev 226216)
+++ trunk/Source/WebCore/platform/mac/VideoFullscreenInterfaceMac.mm 2017-12-21 10:08:14 UTC (rev 226217)
</span><span class="lines">@@ -432,8 +432,7 @@
</span><span class="cx">
</span><span class="cx"> [videoFullscreenInterfaceObjC() setUpPIPForVideoView:&layerHostedView withFrame:(NSRect)initialRect inWindow:parentWindow];
</span><span class="cx">
</span><del>- RefPtr<VideoFullscreenInterfaceMac> protectedThis(this);
- dispatch_async(dispatch_get_main_queue(), [protectedThis, this] {
</del><ins>+ dispatch_async(dispatch_get_main_queue(), [protectedThis = makeRefPtr(this), this] {
</ins><span class="cx"> if (m_fullscreenChangeObserver)
</span><span class="cx"> m_fullscreenChangeObserver->didSetupFullscreen();
</span><span class="cx"> });
</span></span></pre></div>
<a id="trunkSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ChangeLog (226216 => 226217)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ChangeLog 2017-12-21 06:48:48 UTC (rev 226216)
+++ trunk/Source/WebKit/ChangeLog 2017-12-21 10:08:14 UTC (rev 226217)
</span><span class="lines">@@ -1,3 +1,55 @@
</span><ins>+2017-12-21 Jeremy Jones <jeremyj@apple.com>
+
+ Enable picture-in-picture from inline element on suspend.
+ https://bugs.webkit.org/show_bug.cgi?id=180942
+ rdar://problem/34745234
+
+ Reviewed by Jer Noble.
+
+ Add support for video fullscreen standby and imporved fullscreen state transition process.
+
+ Video fullscreen standby allows a video element to have its fullscreen interface state created and
+ continuously updated so that it can quickly change presentation state on application state.
+
+ In order to accomplish this, this change allows the fullscreen presentation to decide when it needs
+ an updated inline rect, or the presence of the video layer.
+
+ This is conditionalized until mac supports this model.
+
+ * UIProcess/Cocoa/VideoFullscreenManagerProxy.h:
+ * UIProcess/Cocoa/VideoFullscreenManagerProxy.messages.in:
+ * UIProcess/Cocoa/VideoFullscreenManagerProxy.mm:
+ (WebKit::VideoFullscreenModelContext::requestUpdateInlineRect):
+ (WebKit::VideoFullscreenModelContext::requestVideoContentLayer):
+ (WebKit::VideoFullscreenModelContext::returnVideoContentLayer):
+ (WebKit::VideoFullscreenManagerProxy::setupFullscreenWithID):
+ (WebKit::VideoFullscreenManagerProxy::setInlineRect):
+ (WebKit::VideoFullscreenManagerProxy::setHasVideoContentLayer):
+ (WebKit::VideoFullscreenManagerProxy::requestUpdateInlineRect):
+ (WebKit::VideoFullscreenManagerProxy::requestVideoContentLayer):
+ (WebKit::VideoFullscreenManagerProxy::returnVideoContentLayer):
+ * WebProcess/FullScreen/WebFullScreenManager.cpp:
+ (WebKit::WebFullScreenManager::didEnterFullScreen):
+ (WebKit::WebFullScreenManager::willExitFullScreen):
+ * WebProcess/FullScreen/WebFullScreenManager.h:
+ * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+ (WebKit::WebChromeClient::supportsVideoFullscreenStandby):
+ (WebKit::WebChromeClient::enterVideoFullscreenForVideoElement):
+ * WebProcess/WebCoreSupport/WebChromeClient.h:
+ * WebProcess/cocoa/VideoFullscreenManager.h:
+ (WebKit::VideoFullscreenInterfaceContext::fullscreenStandby const):
+ (WebKit::VideoFullscreenInterfaceContext::setFullscreenStandby):
+ * WebProcess/cocoa/VideoFullscreenManager.messages.in:
+ * WebProcess/cocoa/VideoFullscreenManager.mm:
+ (WebKit::VideoFullscreenManager::supportsVideoFullscreenStandby const):
+ (WebKit::VideoFullscreenManager::enterVideoFullscreenForVideoElement):
+ (WebKit::VideoFullscreenManager::requestUpdateInlineRect):
+ (WebKit::VideoFullscreenManager::requestVideoContentLayer):
+ (WebKit::VideoFullscreenManager::returnVideoContentLayer):
+ (WebKit::VideoFullscreenManager::didSetupFullscreen):
+ (WebKit::VideoFullscreenManager::didExitFullscreen):
+ (WebKit::VideoFullscreenManager::didCleanupFullscreen):
+
</ins><span class="cx"> 2017-12-20 Eric Carlson <eric.carlson@apple.com>
</span><span class="cx">
</span><span class="cx"> [MediaStream] Add screen capture IDL and stub functions
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessCocoaVideoFullscreenManagerProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.h (226216 => 226217)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.h 2017-12-21 06:48:48 UTC (rev 226216)
+++ trunk/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.h 2017-12-21 10:08:14 UTC (rev 226217)
</span><span class="lines">@@ -87,6 +87,9 @@
</span><span class="cx"> WebCore::FloatSize videoDimensions() const override { return m_videoDimensions; }
</span><span class="cx">
</span><span class="cx"> // VideoFullscreenChangeObserver
</span><ins>+ void requestUpdateInlineRect() override;
+ void requestVideoContentLayer() override;
+ void returnVideoContentLayer() override;
</ins><span class="cx"> void didSetupFullscreen() override;
</span><span class="cx"> void didEnterFullscreen() override;
</span><span class="cx"> void didExitFullscreen() override;
</span><span class="lines">@@ -134,7 +137,9 @@
</span><span class="cx"> void removeClientForContext(uint64_t contextId);
</span><span class="cx">
</span><span class="cx"> // Messages from VideoFullscreenManager
</span><del>- void setupFullscreenWithID(uint64_t contextId, uint32_t videoLayerID, const WebCore::IntRect& initialRect, float hostingScaleFactor, WebCore::HTMLMediaElementEnums::VideoFullscreenMode, bool allowsPictureInPicture);
</del><ins>+ void setupFullscreenWithID(uint64_t contextId, uint32_t videoLayerID, const WebCore::IntRect& initialRect, float hostingScaleFactor, WebCore::HTMLMediaElementEnums::VideoFullscreenMode, bool allowsPictureInPicture, bool standby);
+ void setInlineRect(uint64_t contextId, const WebCore::IntRect& inlineRect, bool visible);
+ void setHasVideoContentLayer(uint64_t contextId, bool value);
</ins><span class="cx"> void setHasVideo(uint64_t contextId, bool);
</span><span class="cx"> void setVideoDimensions(uint64_t contextId, const WebCore::FloatSize&);
</span><span class="cx"> void enterFullscreen(uint64_t contextId);
</span><span class="lines">@@ -147,6 +152,9 @@
</span><span class="cx">
</span><span class="cx"> // Messages to VideoFullscreenManager
</span><span class="cx"> void requestFullscreenMode(uint64_t contextId, WebCore::HTMLMediaElementEnums::VideoFullscreenMode, bool finishedWithMedia = false);
</span><ins>+ void requestUpdateInlineRect(uint64_t contextId);
+ void requestVideoContentLayer(uint64_t contextId);
+ void returnVideoContentLayer(uint64_t contextId);
</ins><span class="cx"> void didSetupFullscreen(uint64_t contextId);
</span><span class="cx"> void didExitFullscreen(uint64_t contextId);
</span><span class="cx"> void didEnterFullscreen(uint64_t contextId);
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessCocoaVideoFullscreenManagerProxymessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.messages.in (226216 => 226217)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.messages.in 2017-12-21 06:48:48 UTC (rev 226216)
+++ trunk/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.messages.in 2017-12-21 10:08:14 UTC (rev 226217)
</span><span class="lines">@@ -24,9 +24,11 @@
</span><span class="cx"> messages -> VideoFullscreenManagerProxy {
</span><span class="cx"> SetHasVideo(uint64_t contextId, bool hasVideo)
</span><span class="cx"> SetVideoDimensions(uint64_t contextId, WebCore::FloatSize videoDimensions)
</span><del>- SetupFullscreenWithID(uint64_t contextId, uint32_t videoLayerID, WebCore::IntRect initialRect, float hostingScaleFactor, WebCore::HTMLMediaElementEnums::VideoFullscreenMode videoFullscreenMode, bool allowsPictureInPicture)
</del><ins>+ SetupFullscreenWithID(uint64_t contextId, uint32_t videoLayerID, WebCore::IntRect initialRect, float hostingScaleFactor, WebCore::HTMLMediaElementEnums::VideoFullscreenMode videoFullscreenMode, bool allowsPictureInPicture, bool standby)
</ins><span class="cx"> EnterFullscreen(uint64_t contextId)
</span><span class="cx"> ExitFullscreen(uint64_t contextId, WebCore::IntRect finalRect)
</span><ins>+ SetInlineRect(uint64_t contextId, WebCore::IntRect inlineRect, bool visible)
+ SetHasVideoContentLayer(uint64_t contextId, bool value)
</ins><span class="cx"> CleanupFullscreen(uint64_t contextId)
</span><span class="cx"> PreparedToReturnToInline(uint64_t contextId, bool visible, WebCore::IntRect inlineRect)
</span><span class="cx"> #if PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessCocoaVideoFullscreenManagerProxymm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.mm (226216 => 226217)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.mm 2017-12-21 06:48:48 UTC (rev 226216)
+++ trunk/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.mm 2017-12-21 10:08:14 UTC (rev 226217)
</span><span class="lines">@@ -167,6 +167,24 @@
</span><span class="cx"> return m_manager ? m_manager->isVisible() : false;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void VideoFullscreenModelContext::requestUpdateInlineRect()
+{
+ if (m_manager)
+ m_manager->requestUpdateInlineRect(m_contextId);
+}
+
+void VideoFullscreenModelContext::requestVideoContentLayer()
+{
+ if (m_manager)
+ m_manager->requestVideoContentLayer(m_contextId);
+}
+
+void VideoFullscreenModelContext::returnVideoContentLayer()
+{
+ if (m_manager)
+ m_manager->returnVideoContentLayer(m_contextId);
+}
+
</ins><span class="cx"> void VideoFullscreenModelContext::didSetupFullscreen()
</span><span class="cx"> {
</span><span class="cx"> if (m_manager)
</span><span class="lines">@@ -338,7 +356,7 @@
</span><span class="cx">
</span><span class="cx"> #pragma mark Messages from VideoFullscreenManager
</span><span class="cx">
</span><del>-void VideoFullscreenManagerProxy::setupFullscreenWithID(uint64_t contextId, uint32_t videoLayerID, const WebCore::IntRect& initialRect, float hostingDeviceScaleFactor, HTMLMediaElementEnums::VideoFullscreenMode videoFullscreenMode, bool allowsPictureInPicture)
</del><ins>+void VideoFullscreenManagerProxy::setupFullscreenWithID(uint64_t contextId, uint32_t videoLayerID, const WebCore::IntRect& initialRect, float hostingDeviceScaleFactor, HTMLMediaElementEnums::VideoFullscreenMode videoFullscreenMode, bool allowsPictureInPicture, bool standby)
</ins><span class="cx"> {
</span><span class="cx"> ASSERT(videoLayerID);
</span><span class="cx"> RefPtr<VideoFullscreenModelContext> model;
</span><span class="lines">@@ -364,7 +382,7 @@
</span><span class="cx">
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx"> UIView *parentView = downcast<RemoteLayerTreeDrawingAreaProxy>(*m_page->drawingArea()).remoteLayerTreeHost().rootLayer();
</span><del>- interface->setupFullscreen(*model->layerHostView(), initialRect, parentView, videoFullscreenMode, allowsPictureInPicture);
</del><ins>+ interface->setupFullscreen(*model->layerHostView(), initialRect, parentView, videoFullscreenMode, allowsPictureInPicture, standby);
</ins><span class="cx"> #else
</span><span class="cx"> IntRect initialWindowRect;
</span><span class="cx"> m_page->rootViewToWindow(initialRect, initialWindowRect);
</span><span class="lines">@@ -418,6 +436,24 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx">
</span><ins>+void VideoFullscreenManagerProxy::setInlineRect(uint64_t contextId, const WebCore::IntRect& inlineRect, bool visible)
+{
+#if PLATFORM(IOS) && ENABLE(FULLSCREEN_API)
+ ensureInterface(contextId).setInlineRect(inlineRect, visible);
+#else
+ ASSERT_NOT_REACHED();
+#endif
+}
+
+void VideoFullscreenManagerProxy::setHasVideoContentLayer(uint64_t contextId, bool value)
+{
+#if PLATFORM(IOS) && ENABLE(FULLSCREEN_API)
+ ensureInterface(contextId).setHasVideoContentLayer(value);
+#else
+ ASSERT_NOT_REACHED();
+#endif
+}
+
</ins><span class="cx"> void VideoFullscreenManagerProxy::cleanupFullscreen(uint64_t contextId)
</span><span class="cx"> {
</span><span class="cx"> ensureInterface(contextId).cleanupFullscreen();
</span><span class="lines">@@ -443,6 +479,21 @@
</span><span class="cx"> m_page->send(Messages::VideoFullscreenManager::RequestFullscreenMode(contextId, mode, finishedWithMedia), m_page->pageID());
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void VideoFullscreenManagerProxy::requestUpdateInlineRect(uint64_t contextId)
+{
+ m_page->send(Messages::VideoFullscreenManager::RequestUpdateInlineRect(contextId), m_page->pageID());
+}
+
+void VideoFullscreenManagerProxy::requestVideoContentLayer(uint64_t contextId)
+{
+ m_page->send(Messages::VideoFullscreenManager::RequestVideoContentLayer(contextId), m_page->pageID());
+}
+
+void VideoFullscreenManagerProxy::returnVideoContentLayer(uint64_t contextId)
+{
+ m_page->send(Messages::VideoFullscreenManager::ReturnVideoContentLayer(contextId), m_page->pageID());
+}
+
</ins><span class="cx"> void VideoFullscreenManagerProxy::didSetupFullscreen(uint64_t contextId)
</span><span class="cx"> {
</span><span class="cx"> m_page->send(Messages::VideoFullscreenManager::DidSetupFullscreen(contextId), m_page->pageID());
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessiosWKFullScreenWindowControllerIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/ios/WKFullScreenWindowControllerIOS.mm (226216 => 226217)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/ios/WKFullScreenWindowControllerIOS.mm 2017-12-21 06:48:48 UTC (rev 226216)
+++ trunk/Source/WebKit/UIProcess/ios/WKFullScreenWindowControllerIOS.mm 2017-12-21 10:08:14 UTC (rev 226217)
</span><span class="lines">@@ -129,6 +129,7 @@
</span><span class="cx"> - (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
</span><span class="cx"> {
</span><span class="cx"> [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
</span><ins>+ [self contentView].frame = self.view.bounds;
</ins><span class="cx"> [(WKWebView *)[self contentView] _overrideLayoutParametersWithMinimumLayoutSize:size maximumUnobscuredSizeOverride:size];
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessFullScreenWebFullScreenManagercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/FullScreen/WebFullScreenManager.cpp (226216 => 226217)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/FullScreen/WebFullScreenManager.cpp 2017-12-21 06:48:48 UTC (rev 226216)
+++ trunk/Source/WebKit/WebProcess/FullScreen/WebFullScreenManager.cpp 2017-12-21 10:08:14 UTC (rev 226217)
</span><span class="lines">@@ -35,6 +35,7 @@
</span><span class="cx"> #include <WebCore/Color.h>
</span><span class="cx"> #include <WebCore/Element.h>
</span><span class="cx"> #include <WebCore/FrameView.h>
</span><ins>+#include <WebCore/HTMLVideoElement.h>
</ins><span class="cx"> #include <WebCore/MainFrame.h>
</span><span class="cx"> #include <WebCore/Page.h>
</span><span class="cx"> #include <WebCore/RenderLayer.h>
</span><span class="lines">@@ -42,6 +43,7 @@
</span><span class="cx"> #include <WebCore/RenderObject.h>
</span><span class="cx"> #include <WebCore/RenderView.h>
</span><span class="cx"> #include <WebCore/Settings.h>
</span><ins>+#include <WebCore/TypedElementDescendantIterator.h>
</ins><span class="cx">
</span><span class="cx"> using namespace WebCore;
</span><span class="cx">
</span><span class="lines">@@ -122,11 +124,20 @@
</span><span class="cx"> {
</span><span class="cx"> ASSERT(m_element);
</span><span class="cx"> m_element->document().webkitDidEnterFullScreenForElement(m_element.get());
</span><ins>+
+ m_pipStandbyElement = descendantsOfType<HTMLVideoElement>(*m_element).first();
+ if (m_pipStandbyElement)
+ m_pipStandbyElement->setVideoFullscreenStandby(true);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void WebFullScreenManager::willExitFullScreen()
</span><span class="cx"> {
</span><span class="cx"> ASSERT(m_element);
</span><ins>+
+ if (m_pipStandbyElement)
+ m_pipStandbyElement->setVideoFullscreenStandby(false);
+ m_pipStandbyElement = nullptr;
+
</ins><span class="cx"> m_finalFrame = screenRectOfContents(m_element.get());
</span><span class="cx"> m_element->document().webkitWillExitFullScreenForElement(m_element.get());
</span><span class="cx"> #if !PLATFORM(IOS)
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessFullScreenWebFullScreenManagerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/FullScreen/WebFullScreenManager.h (226216 => 226217)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/FullScreen/WebFullScreenManager.h 2017-12-21 06:48:48 UTC (rev 226216)
+++ trunk/Source/WebKit/WebProcess/FullScreen/WebFullScreenManager.h 2017-12-21 10:08:14 UTC (rev 226217)
</span><span class="lines">@@ -40,6 +40,7 @@
</span><span class="cx"> class IntRect;
</span><span class="cx"> class Element;
</span><span class="cx"> class GraphicsLayer;
</span><ins>+class HTMLVideoElement;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> namespace WebKit {
</span><span class="lines">@@ -82,6 +83,7 @@
</span><span class="cx"> float m_topContentInset;
</span><span class="cx"> RefPtr<WebPage> m_page;
</span><span class="cx"> RefPtr<WebCore::Element> m_element;
</span><ins>+ RefPtr<WebCore::HTMLVideoElement> m_pipStandbyElement;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebCoreSupportWebChromeClientcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp (226216 => 226217)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp 2017-12-21 06:48:48 UTC (rev 226216)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp 2017-12-21 10:08:14 UTC (rev 226217)
</span><span class="lines">@@ -941,6 +941,11 @@
</span><span class="cx"> return m_page.videoFullscreenManager().supportsVideoFullscreen(mode);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+bool WebChromeClient::supportsVideoFullscreenStandby()
+{
+ return m_page.videoFullscreenManager().supportsVideoFullscreenStandby();
+}
+
</ins><span class="cx"> void WebChromeClient::setUpPlaybackControlsManager(HTMLMediaElement& mediaElement)
</span><span class="cx"> {
</span><span class="cx"> m_page.playbackSessionManager().setUpPlaybackControlsManager(mediaElement);
</span><span class="lines">@@ -951,10 +956,14 @@
</span><span class="cx"> m_page.playbackSessionManager().clearPlaybackControlsManager();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void WebChromeClient::enterVideoFullscreenForVideoElement(HTMLVideoElement& videoElement, HTMLMediaElementEnums::VideoFullscreenMode mode)
</del><ins>+void WebChromeClient::enterVideoFullscreenForVideoElement(HTMLVideoElement& videoElement, HTMLMediaElementEnums::VideoFullscreenMode mode, bool standby)
</ins><span class="cx"> {
</span><ins>+#if ENABLE(FULLSCREEN_API) && PLATFORM(IOS)
+ ASSERT(standby || mode != HTMLMediaElementEnums::VideoFullscreenModeNone);
+#else
</ins><span class="cx"> ASSERT(mode != HTMLMediaElementEnums::VideoFullscreenModeNone);
</span><del>- m_page.videoFullscreenManager().enterVideoFullscreenForVideoElement(videoElement, mode);
</del><ins>+#endif
+ m_page.videoFullscreenManager().enterVideoFullscreenForVideoElement(videoElement, mode, standby);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void WebChromeClient::exitVideoFullscreenForVideoElement(HTMLVideoElement& videoElement)
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebCoreSupportWebChromeClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h (226216 => 226217)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h 2017-12-21 06:48:48 UTC (rev 226216)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h 2017-12-21 10:08:14 UTC (rev 226217)
</span><span class="lines">@@ -247,9 +247,10 @@
</span><span class="cx">
</span><span class="cx"> #if (PLATFORM(IOS) && HAVE(AVKIT)) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
</span><span class="cx"> bool supportsVideoFullscreen(WebCore::HTMLMediaElementEnums::VideoFullscreenMode) final;
</span><ins>+ bool supportsVideoFullscreenStandby() final;
</ins><span class="cx"> void setUpPlaybackControlsManager(WebCore::HTMLMediaElement&) final;
</span><span class="cx"> void clearPlaybackControlsManager() final;
</span><del>- void enterVideoFullscreenForVideoElement(WebCore::HTMLVideoElement&, WebCore::HTMLMediaElementEnums::VideoFullscreenMode) final;
</del><ins>+ void enterVideoFullscreenForVideoElement(WebCore::HTMLVideoElement&, WebCore::HTMLMediaElementEnums::VideoFullscreenMode, bool standby) final;
</ins><span class="cx"> void exitVideoFullscreenForVideoElement(WebCore::HTMLVideoElement&) final;
</span><span class="cx"> #endif
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcesscocoaVideoFullscreenManagerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.h (226216 => 226217)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.h 2017-12-21 06:48:48 UTC (rev 226216)
+++ trunk/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.h 2017-12-21 10:08:14 UTC (rev 226217)
</span><span class="lines">@@ -80,6 +80,9 @@
</span><span class="cx"> WebCore::HTMLMediaElementEnums::VideoFullscreenMode fullscreenMode() const { return m_fullscreenMode; }
</span><span class="cx"> void setFullscreenMode(WebCore::HTMLMediaElementEnums::VideoFullscreenMode mode) { m_fullscreenMode = mode; }
</span><span class="cx">
</span><ins>+ bool fullscreenStandby() const { return m_fullscreenStandby; }
+ void setFullscreenStandby(bool value) { m_fullscreenStandby = value; }
+
</ins><span class="cx"> bool isFullscreen() const { return m_isFullscreen; }
</span><span class="cx"> void setIsFullscreen(bool flag) { m_isFullscreen = flag; }
</span><span class="cx">
</span><span class="lines">@@ -96,6 +99,7 @@
</span><span class="cx"> bool m_isAnimating { false };
</span><span class="cx"> bool m_targetIsFullscreen { false };
</span><span class="cx"> WebCore::HTMLMediaElementEnums::VideoFullscreenMode m_fullscreenMode { WebCore::HTMLMediaElementEnums::VideoFullscreenModeNone };
</span><ins>+ bool m_fullscreenStandby { false };
</ins><span class="cx"> bool m_isFullscreen { false };
</span><span class="cx"> };
</span><span class="cx">
</span><span class="lines">@@ -110,7 +114,8 @@
</span><span class="cx">
</span><span class="cx"> // Interface to ChromeClient
</span><span class="cx"> bool supportsVideoFullscreen(WebCore::HTMLMediaElementEnums::VideoFullscreenMode) const;
</span><del>- void enterVideoFullscreenForVideoElement(WebCore::HTMLVideoElement&, WebCore::HTMLMediaElementEnums::VideoFullscreenMode);
</del><ins>+ bool supportsVideoFullscreenStandby() const;
+ void enterVideoFullscreenForVideoElement(WebCore::HTMLVideoElement&, WebCore::HTMLMediaElementEnums::VideoFullscreenMode, bool standby);
</ins><span class="cx"> void exitVideoFullscreenForVideoElement(WebCore::HTMLVideoElement&);
</span><span class="cx"> void exitVideoFullscreenToModeWithoutAnimation(WebCore::HTMLVideoElement&, WebCore::HTMLMediaElementEnums::VideoFullscreenMode);
</span><span class="cx">
</span><span class="lines">@@ -134,6 +139,9 @@
</span><span class="cx">
</span><span class="cx"> // Messages from VideoFullscreenManagerProxy
</span><span class="cx"> void requestFullscreenMode(uint64_t contextId, WebCore::HTMLMediaElementEnums::VideoFullscreenMode, bool finishedWithMedia);
</span><ins>+ void requestUpdateInlineRect(uint64_t contextId);
+ void requestVideoContentLayer(uint64_t contextId);
+ void returnVideoContentLayer(uint64_t contextId);
</ins><span class="cx"> void didSetupFullscreen(uint64_t contextId);
</span><span class="cx"> void didExitFullscreen(uint64_t contextId);
</span><span class="cx"> void didEnterFullscreen(uint64_t contextId);
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcesscocoaVideoFullscreenManagermessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.messages.in (226216 => 226217)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.messages.in 2017-12-21 06:48:48 UTC (rev 226216)
+++ trunk/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.messages.in 2017-12-21 10:08:14 UTC (rev 226217)
</span><span class="lines">@@ -23,6 +23,9 @@
</span><span class="cx"> #if (PLATFORM(IOS) && HAVE(AVKIT)) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
</span><span class="cx"> messages -> VideoFullscreenManager {
</span><span class="cx"> RequestFullscreenMode(uint64_t contextId, WebCore::HTMLMediaElementEnums::VideoFullscreenMode videoFullscreenMode, bool finishedWithMedia)
</span><ins>+ RequestUpdateInlineRect(uint64_t contextId)
+ RequestVideoContentLayer(uint64_t contextId)
+ ReturnVideoContentLayer(uint64_t contextId)
</ins><span class="cx"> DidSetupFullscreen(uint64_t contextId)
</span><span class="cx"> DidExitFullscreen(uint64_t contextId)
</span><span class="cx"> DidEnterFullscreen(uint64_t contextId)
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcesscocoaVideoFullscreenManagermm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm (226216 => 226217)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm 2017-12-21 06:48:48 UTC (rev 226216)
+++ trunk/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm 2017-12-21 10:08:14 UTC (rev 226217)
</span><span class="lines">@@ -49,6 +49,7 @@
</span><span class="cx"> #import <WebCore/RenderView.h>
</span><span class="cx"> #import <WebCore/Settings.h>
</span><span class="cx"> #import <WebCore/TimeRanges.h>
</span><ins>+#import <WebCore/WebActionDisablingCALayerDelegate.h>
</ins><span class="cx"> #import <mach/mach_port.h>
</span><span class="cx">
</span><span class="cx"> using namespace WebCore;
</span><span class="lines">@@ -226,10 +227,19 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void VideoFullscreenManager::enterVideoFullscreenForVideoElement(HTMLVideoElement& videoElement, HTMLMediaElementEnums::VideoFullscreenMode mode)
</del><ins>+bool VideoFullscreenManager::supportsVideoFullscreenStandby() const
</ins><span class="cx"> {
</span><ins>+#if PLATFORM(IOS) && ENABLE(FULLSCREEN_API)
+ return true;
+#else
+ return false;
+#endif
+}
+
+void VideoFullscreenManager::enterVideoFullscreenForVideoElement(HTMLVideoElement& videoElement, HTMLMediaElementEnums::VideoFullscreenMode mode, bool standby)
+{
</ins><span class="cx"> ASSERT(m_page);
</span><del>- ASSERT(mode != HTMLMediaElementEnums::VideoFullscreenModeNone);
</del><ins>+ ASSERT(standby || mode != HTMLMediaElementEnums::VideoFullscreenModeNone);
</ins><span class="cx"> LOG(Fullscreen, "VideoFullscreenManager::enterVideoFullscreenForVideoElement(%p)", this);
</span><span class="cx">
</span><span class="cx"> uint64_t contextId = m_playbackSessionManager->contextIdForMediaElement(videoElement);
</span><span class="lines">@@ -250,8 +260,9 @@
</span><span class="cx"> HTMLMediaElementEnums::VideoFullscreenMode oldMode = interface->fullscreenMode();
</span><span class="cx"> interface->setTargetIsFullscreen(true);
</span><span class="cx"> interface->setFullscreenMode(mode);
</span><ins>+ interface->setFullscreenStandby(standby);
</ins><span class="cx"> model->setVideoElement(&videoElement);
</span><del>- if (oldMode == HTMLMediaElementEnums::VideoFullscreenModeNone)
</del><ins>+ if (oldMode == HTMLMediaElementEnums::VideoFullscreenModeNone && mode != HTMLMediaElementEnums::VideoFullscreenModeNone)
</ins><span class="cx"> model->setVideoLayerFrame(videoLayerFrame);
</span><span class="cx">
</span><span class="cx"> if (interface->isAnimating())
</span><span class="lines">@@ -259,8 +270,24 @@
</span><span class="cx"> interface->setIsAnimating(true);
</span><span class="cx">
</span><span class="cx"> bool allowsPictureInPicture = videoElement.webkitSupportsPresentationMode(HTMLVideoElement::VideoPresentationMode::PictureInPicture);
</span><del>-
- m_page->send(Messages::VideoFullscreenManagerProxy::SetupFullscreenWithID(contextId, interface->layerHostingContext()->contextID(), videoRect, m_page->deviceScaleFactor(), interface->fullscreenMode(), allowsPictureInPicture), m_page->pageID());
</del><ins>+
+ if (!interface->layerHostingContext()->rootLayer()) {
+ PlatformLayer* videoLayer = [CALayer layer];
+ [videoLayer setDelegate:[WebActionDisablingCALayerDelegate shared]];
+
+ [videoLayer setName:@"Web video fullscreen manager layer"];
+ [videoLayer setPosition:CGPointMake(0, 0)];
+ [videoLayer setBackgroundColor:cachedCGColor(WebCore::Color::transparent)];
+
+ // Set a scale factor here to make convertRect:toLayer:nil take scale factor into account. <rdar://problem/18316542>.
+ // This scale factor is inverted in the hosting process.
+ float hostingScaleFactor = m_page->deviceScaleFactor();
+ [videoLayer setTransform:CATransform3DMakeScale(hostingScaleFactor, hostingScaleFactor, 1)];
+
+ interface->layerHostingContext()->setRootLayer(videoLayer);
+ }
+
+ m_page->send(Messages::VideoFullscreenManagerProxy::SetupFullscreenWithID(contextId, interface->layerHostingContext()->contextID(), videoRect, m_page->deviceScaleFactor(), interface->fullscreenMode(), allowsPictureInPicture, standby), m_page->pageID());
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void VideoFullscreenManager::exitVideoFullscreenForVideoElement(WebCore::HTMLVideoElement& videoElement)
</span><span class="lines">@@ -327,43 +354,74 @@
</span><span class="cx"> ensureModel(contextId).fullscreenModeChanged(videoFullscreenMode);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void VideoFullscreenManager::didSetupFullscreen(uint64_t contextId)
</del><ins>+void VideoFullscreenManager::requestUpdateInlineRect(uint64_t contextId)
</ins><span class="cx"> {
</span><del>- LOG(Fullscreen, "VideoFullscreenManager::didSetupFullscreen(%p, %x)", this, contextId);
</del><ins>+ if (!m_page)
+ return;
</ins><span class="cx">
</span><del>- ASSERT(m_page);
- PlatformLayer* videoLayer = [CALayer layer];
-#ifndef NDEBUG
- [videoLayer setName:@"Web video fullscreen manager layer"];
-#endif
</del><ins>+ auto& model = ensureModel(contextId);
+ IntRect inlineRect = inlineVideoFrame(*model.videoElement());
+ m_page->send(Messages::VideoFullscreenManagerProxy::SetInlineRect(contextId, inlineRect, inlineRect != IntRect(0, 0, 0, 0)), m_page->pageID());
+}
</ins><span class="cx">
</span><del>- [CATransaction begin];
- [CATransaction setDisableActions:YES];
</del><ins>+void VideoFullscreenManager::requestVideoContentLayer(uint64_t contextId)
+{
+ RefPtr<VideoFullscreenModelVideoElement> model;
+ RefPtr<VideoFullscreenInterfaceContext> interface;
+ std::tie(model, interface) = ensureModelAndInterface(contextId);
</ins><span class="cx">
</span><del>- [videoLayer setPosition:CGPointMake(0, 0)];
- [videoLayer setBackgroundColor:cachedCGColor(WebCore::Color::transparent)];
</del><ins>+ CALayer* videoLayer = interface->layerHostingContext()->rootLayer();
</ins><span class="cx">
</span><del>- // Set a scale factor here to make convertRect:toLayer:nil take scale factor into account. <rdar://problem/18316542>.
- // This scale factor is inverted in the hosting process.
- float hostingScaleFactor = m_page->deviceScaleFactor();
- [videoLayer setTransform:CATransform3DMakeScale(hostingScaleFactor, hostingScaleFactor, 1)];
</del><ins>+ model->setVideoFullscreenLayer(videoLayer, [protectedThis = makeRefPtr(this), this, contextId] () mutable {
+ dispatch_async(dispatch_get_main_queue(), [protectedThis = WTFMove(protectedThis), this, contextId] {
+ if (protectedThis->m_page)
+ m_page->send(Messages::VideoFullscreenManagerProxy::SetHasVideoContentLayer(contextId, true), protectedThis->m_page->pageID());
+ });
+ });
+}
</ins><span class="cx">
</span><ins>+void VideoFullscreenManager::returnVideoContentLayer(uint64_t contextId)
+{
</ins><span class="cx"> RefPtr<VideoFullscreenModelVideoElement> model;
</span><span class="cx"> RefPtr<VideoFullscreenInterfaceContext> interface;
</span><span class="cx"> std::tie(model, interface) = ensureModelAndInterface(contextId);
</span><span class="cx">
</span><del>- interface->layerHostingContext()->setRootLayer(videoLayer);
</del><ins>+ model->waitForPreparedForInlineThen([protectedThis = makeRefPtr(this), this, contextId, model] () mutable { // need this for return video layer
+ dispatch_async(dispatch_get_main_queue(), [protectedThis = WTFMove(protectedThis), this, contextId, model] () mutable {
+ model->setVideoFullscreenLayer(nil, [protectedThis = WTFMove(protectedThis), this, contextId] () mutable {
+ dispatch_async(dispatch_get_main_queue(), [protectedThis = WTFMove(protectedThis), this, contextId] {
+ if (protectedThis->m_page)
+ m_page->send(Messages::VideoFullscreenManagerProxy::SetHasVideoContentLayer(contextId, false), protectedThis->m_page->pageID());
+ });
+ });
+ });
+ });
+}
</ins><span class="cx">
</span><del>- RefPtr<VideoFullscreenManager> protectedThis(this);
-
- model->setVideoFullscreenLayer(videoLayer, [protectedThis, this, contextId] {
- dispatch_async(dispatch_get_main_queue(), [protectedThis, this, contextId] {
</del><ins>+void VideoFullscreenManager::didSetupFullscreen(uint64_t contextId)
+{
+ LOG(Fullscreen, "VideoFullscreenManager::didSetupFullscreen(%p, %x)", this, contextId);
+
+ ASSERT(m_page);
+ RefPtr<VideoFullscreenModelVideoElement> model;
+ RefPtr<VideoFullscreenInterfaceContext> interface;
+ std::tie(model, interface) = ensureModelAndInterface(contextId);
+
+#if PLATFORM(IOS) && ENABLE(FULLSCREEN_API)
+ dispatch_async(dispatch_get_main_queue(), [protectedThis = makeRefPtr(this), this, contextId] {
+ if (protectedThis->m_page)
+ m_page->send(Messages::VideoFullscreenManagerProxy::EnterFullscreen(contextId), protectedThis->m_page->pageID());
+ });
+#else
+ CALayer* videoLayer = interface->layerHostingContext()->rootLayer();
+
+ model->setVideoFullscreenLayer(videoLayer, [protectedThis = makeRefPtr(this), this, contextId] () mutable {
+ dispatch_async(dispatch_get_main_queue(), [protectedThis = WTFMove(protectedThis), this, contextId] {
</ins><span class="cx"> if (protectedThis->m_page)
</span><span class="cx"> m_page->send(Messages::VideoFullscreenManagerProxy::EnterFullscreen(contextId), protectedThis->m_page->pageID());
</span><span class="cx"> });
</span><span class="cx"> });
</span><del>-
- [CATransaction commit];
</del><ins>+#endif
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void VideoFullscreenManager::didEnterFullscreen(uint64_t contextId)
</span><span class="lines">@@ -385,8 +443,7 @@
</span><span class="cx"> return;
</span><span class="cx">
</span><span class="cx"> // exit fullscreen now if it was previously requested during an animation.
</span><del>- RefPtr<VideoFullscreenManager> protectedThis(this);
- dispatch_async(dispatch_get_main_queue(), [protectedThis, videoElement] {
</del><ins>+ dispatch_async(dispatch_get_main_queue(), [protectedThis = makeRefPtr(this), videoElement] {
</ins><span class="cx"> if (protectedThis->m_page)
</span><span class="cx"> protectedThis->exitVideoFullscreenForVideoElement(*videoElement);
</span><span class="cx"> });
</span><span class="lines">@@ -399,12 +456,17 @@
</span><span class="cx"> RefPtr<VideoFullscreenModelVideoElement> model;
</span><span class="cx"> RefPtr<VideoFullscreenInterfaceContext> interface;
</span><span class="cx"> std::tie(model, interface) = ensureModelAndInterface(contextId);
</span><del>- RefPtr<VideoFullscreenManager> protectedThis(this);
-
- model->waitForPreparedForInlineThen([protectedThis, contextId, interface, model] {
- dispatch_async(dispatch_get_main_queue(), [protectedThis, contextId, interface, model] {
- model->setVideoFullscreenLayer(nil, [protectedThis, contextId, interface] {
- dispatch_async(dispatch_get_main_queue(), [protectedThis, contextId, interface] {
</del><ins>+
+#if PLATFORM(IOS) && ENABLE(FULLSCREEN_API)
+ dispatch_async(dispatch_get_main_queue(), [protectedThis = makeRefPtr(this), contextId, interface] {
+ if (protectedThis->m_page)
+ protectedThis->m_page->send(Messages::VideoFullscreenManagerProxy::CleanupFullscreen(contextId), protectedThis->m_page->pageID());
+ });
+#else
+ model->waitForPreparedForInlineThen([protectedThis = makeRefPtr(this), contextId, interface, model] () mutable {
+ dispatch_async(dispatch_get_main_queue(), [protectedThis = WTFMove(protectedThis), contextId, interface, model] () mutable {
+ model->setVideoFullscreenLayer(nil, [protectedThis = WTFMove(protectedThis), contextId, interface] () mutable {
+ dispatch_async(dispatch_get_main_queue(), [protectedThis = WTFMove(protectedThis), contextId, interface] {
</ins><span class="cx"> if (interface->layerHostingContext()) {
</span><span class="cx"> interface->layerHostingContext()->setRootLayer(nullptr);
</span><span class="cx"> interface->setLayerHostingContext(nullptr);
</span><span class="lines">@@ -415,6 +477,7 @@
</span><span class="cx"> });
</span><span class="cx"> });
</span><span class="cx"> });
</span><ins>+#endif
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void VideoFullscreenManager::didCleanupFullscreen(uint64_t contextId)
</span><span class="lines">@@ -425,9 +488,15 @@
</span><span class="cx"> RefPtr<VideoFullscreenInterfaceContext> interface;
</span><span class="cx"> std::tie(model, interface) = ensureModelAndInterface(contextId);
</span><span class="cx">
</span><ins>+ if (interface->layerHostingContext()) {
+ interface->layerHostingContext()->setRootLayer(nullptr);
+ interface->setLayerHostingContext(nullptr);
+ }
+
</ins><span class="cx"> interface->setIsAnimating(false);
</span><span class="cx"> interface->setIsFullscreen(false);
</span><span class="cx"> HTMLMediaElementEnums::VideoFullscreenMode mode = interface->fullscreenMode();
</span><ins>+ bool standby = interface->fullscreenStandby();
</ins><span class="cx"> bool targetIsFullscreen = interface->targetIsFullscreen();
</span><span class="cx">
</span><span class="cx"> model->setVideoFullscreenLayer(nil);
</span><span class="lines">@@ -434,15 +503,15 @@
</span><span class="cx"> RefPtr<HTMLVideoElement> videoElement = model->videoElement();
</span><span class="cx">
</span><span class="cx"> interface->setFullscreenMode(HTMLMediaElementEnums::VideoFullscreenModeNone);
</span><ins>+ interface->setFullscreenStandby(false);
</ins><span class="cx"> removeClientForContext(contextId);
</span><span class="cx">
</span><span class="cx"> if (!videoElement || !targetIsFullscreen)
</span><span class="cx"> return;
</span><span class="cx">
</span><del>- RefPtr<VideoFullscreenManager> protectedThis(this);
- dispatch_async(dispatch_get_main_queue(), [protectedThis, videoElement, mode] {
</del><ins>+ dispatch_async(dispatch_get_main_queue(), [protectedThis = makeRefPtr(this), videoElement, mode, standby] {
</ins><span class="cx"> if (protectedThis->m_page)
</span><del>- protectedThis->enterVideoFullscreenForVideoElement(*videoElement, mode);
</del><ins>+ protectedThis->enterVideoFullscreenForVideoElement(*videoElement, mode, standby);
</ins><span class="cx"> });
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -476,13 +545,10 @@
</span><span class="cx"> bounds = FloatRect(0, 0, videoRect.width(), videoRect.height());
</span><span class="cx"> }
</span><span class="cx">
</span><del>- [CATransaction begin];
- [CATransaction setAnimationDuration:0];
</del><span class="cx"> if (interface->layerHostingContext())
</span><span class="cx"> interface->layerHostingContext()->setFencePort(fencePort.port());
</span><span class="cx"> model->setVideoLayerFrame(bounds);
</span><span class="cx"> mach_port_deallocate(mach_task_self(), fencePort.port());
</span><del>- [CATransaction commit];
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKitLegacymacChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (226216 => 226217)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKitLegacy/mac/ChangeLog 2017-12-21 06:48:48 UTC (rev 226216)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog 2017-12-21 10:08:14 UTC (rev 226217)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2017-12-21 Jeremy Jones <jeremyj@apple.com>
+
+ Enable picture-in-picture from inline element on suspend.
+ https://bugs.webkit.org/show_bug.cgi?id=180942
+ rdar://problem/34745234
+
+ Reviewed by Jer Noble.
+
+ Update signature of enterVideoFullscreenForVideoElement().
+
+ * WebCoreSupport/WebChromeClient.h:
+ * WebCoreSupport/WebChromeClient.mm:
+ (WebChromeClient::enterVideoFullscreenForVideoElement):
+
</ins><span class="cx"> 2017-12-20 Daniel Bates <dabates@apple.com>
</span><span class="cx">
</span><span class="cx"> Remove Alternative Presentation Button
</span></span></pre></div>
<a id="trunkSourceWebKitLegacymacWebCoreSupportWebChromeClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.h (226216 => 226217)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.h 2017-12-21 06:48:48 UTC (rev 226216)
+++ trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.h 2017-12-21 10:08:14 UTC (rev 226217)
</span><span class="lines">@@ -184,7 +184,7 @@
</span><span class="cx">
</span><span class="cx"> #if ENABLE(VIDEO)
</span><span class="cx"> bool supportsVideoFullscreen(WebCore::HTMLMediaElementEnums::VideoFullscreenMode) final;
</span><del>- void enterVideoFullscreenForVideoElement(WebCore::HTMLVideoElement&, WebCore::HTMLMediaElementEnums::VideoFullscreenMode) final;
</del><ins>+ void enterVideoFullscreenForVideoElement(WebCore::HTMLVideoElement&, WebCore::HTMLMediaElementEnums::VideoFullscreenMode, bool standby) final;
</ins><span class="cx"> void exitVideoFullscreenForVideoElement(WebCore::HTMLVideoElement&) final;
</span><span class="cx"> void exitVideoFullscreenToModeWithoutAnimation(WebCore::HTMLVideoElement&, WebCore::HTMLMediaElementEnums::VideoFullscreenMode) final;
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKitLegacymacWebCoreSupportWebChromeClientmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.mm (226216 => 226217)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.mm 2017-12-21 06:48:48 UTC (rev 226216)
+++ trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.mm 2017-12-21 10:08:14 UTC (rev 226217)
</span><span class="lines">@@ -964,8 +964,9 @@
</span><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void WebChromeClient::enterVideoFullscreenForVideoElement(HTMLVideoElement& videoElement, HTMLMediaElementEnums::VideoFullscreenMode mode)
</del><ins>+void WebChromeClient::enterVideoFullscreenForVideoElement(HTMLVideoElement& videoElement, HTMLMediaElementEnums::VideoFullscreenMode mode, bool standby)
</ins><span class="cx"> {
</span><ins>+ ASSERT_UNUSED(standby, !standby);
</ins><span class="cx"> ASSERT(mode != HTMLMediaElementEnums::VideoFullscreenModeNone);
</span><span class="cx"> BEGIN_BLOCK_OBJC_EXCEPTIONS;
</span><span class="cx"> [m_webView _enterVideoFullscreenForVideoElement:&videoElement mode:mode];
</span></span></pre></div>
<a id="trunkSourceWebKitLegacywinChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKitLegacy/win/ChangeLog (226216 => 226217)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKitLegacy/win/ChangeLog 2017-12-21 06:48:48 UTC (rev 226216)
+++ trunk/Source/WebKitLegacy/win/ChangeLog 2017-12-21 10:08:14 UTC (rev 226217)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2017-12-21 Jeremy Jones <jeremyj@apple.com>
+
+ Enable picture-in-picture from inline element on suspend.
+ https://bugs.webkit.org/show_bug.cgi?id=180942
+ rdar://problem/34745234
+
+ Reviewed by Jer Noble.
+
+ Update signature of enterVideoFullscreenForVideoElement.
+
+ * WebCoreSupport/WebChromeClient.cpp:
+ (WebChromeClient::enterVideoFullscreenForVideoElement):
+ * WebCoreSupport/WebChromeClient.h:
+
</ins><span class="cx"> 2017-12-18 Fujii Hironori <Hironori.Fujii@sony.com>
</span><span class="cx">
</span><span class="cx"> [Win] SHOULD NEVER BE REACHED in WebFrameLoaderClient::pageID
</span></span></pre></div>
<a id="trunkSourceWebKitLegacywinWebCoreSupportWebChromeClientcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKitLegacy/win/WebCoreSupport/WebChromeClient.cpp (226216 => 226217)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKitLegacy/win/WebCoreSupport/WebChromeClient.cpp 2017-12-21 06:48:48 UTC (rev 226216)
+++ trunk/Source/WebKitLegacy/win/WebCoreSupport/WebChromeClient.cpp 2017-12-21 10:08:14 UTC (rev 226217)
</span><span class="lines">@@ -758,7 +758,7 @@
</span><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void WebChromeClient::enterVideoFullscreenForVideoElement(HTMLVideoElement& videoElement, HTMLMediaElementEnums::VideoFullscreenMode)
</del><ins>+void WebChromeClient::enterVideoFullscreenForVideoElement(HTMLVideoElement& videoElement, HTMLMediaElementEnums::VideoFullscreenMode, bool)
</ins><span class="cx"> {
</span><span class="cx"> m_webView->enterVideoFullscreenForVideoElement(videoElement);
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKitLegacywinWebCoreSupportWebChromeClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKitLegacy/win/WebCoreSupport/WebChromeClient.h (226216 => 226217)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKitLegacy/win/WebCoreSupport/WebChromeClient.h 2017-12-21 06:48:48 UTC (rev 226216)
+++ trunk/Source/WebKitLegacy/win/WebCoreSupport/WebChromeClient.h 2017-12-21 10:08:14 UTC (rev 226217)
</span><span class="lines">@@ -139,7 +139,7 @@
</span><span class="cx">
</span><span class="cx"> #if ENABLE(VIDEO)
</span><span class="cx"> bool supportsVideoFullscreen(WebCore::HTMLMediaElementEnums::VideoFullscreenMode) final;
</span><del>- void enterVideoFullscreenForVideoElement(WebCore::HTMLVideoElement&, WebCore::HTMLMediaElementEnums::VideoFullscreenMode) final;
</del><ins>+ void enterVideoFullscreenForVideoElement(WebCore::HTMLVideoElement&, WebCore::HTMLMediaElementEnums::VideoFullscreenMode, bool) final;
</ins><span class="cx"> void exitVideoFullscreenForVideoElement(WebCore::HTMLVideoElement&) final;
</span><span class="cx"> #endif
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>