<!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>[182766] trunk/Source/WebCore</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/182766">182766</a></dd>
<dt>Author</dt> <dd>jer.noble@apple.com</dd>
<dt>Date</dt> <dd>2015-04-13 16:41:17 -0700 (Mon, 13 Apr 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>[iOS] When entering optimized fullscreen, standard fullscreen view should exit.
https://bugs.webkit.org/show_bug.cgi?id=143615
Reviewed by Simon Fraser.
When entering optimized fullscreen from standard fullscreen, the original fullscreen
view should animate out.
The original method for entering optimized fullscreen is deprecated, so replace it with
the new method (which doesn't take completion blocks) and use delegate methods to detect
when the animation transition completes.
* platform/Logging.h:
* platform/ios/WebVideoFullscreenInterfaceAVKit.h:
* platform/ios/WebVideoFullscreenInterfaceAVKit.mm:
(boolString): Added; use for logging boolean parameters.
(-[WebAVPlayerController playerViewControllerWillStartOptimizedFullscreen:]): Pass to WebVideoFullscreenInterfaceAVKit.
(-[WebAVPlayerController playerViewControllerDidStartOptimizedFullscreen:]): Ditto.
(-[WebAVPlayerController playerViewControllerWillStopOptimizedFullscreen:]): Ditto.
(-[WebAVPlayerController playerViewControllerDidStopOptimizedFullscreen:]): Ditto.
(-[WebAVPlayerController playerViewControllerWillCancelOptimizedFullscreen:]): Ditto.
(-[WebAVPlayerController playerViewControllerDidCancelOptimizedFullscreen:]): Ditto.
(-[WebAVPlayerController playerViewController:restoreUserInterfaceForOptimizedFullscreenStopWithCompletionHandler:]): Ditto.
(-[WebAVVideoLayer setPlayerViewController:]): Remove the KVO registration; now handled by above delegate methods.
(WebVideoFullscreenInterfaceAVKit::setupFullscreenInternal): Add logging.
(WebVideoFullscreenInterfaceAVKit::enterFullscreen): Ditto.
(WebVideoFullscreenInterfaceAVKit::enterFullscreenOptimized): Use new -startOptimizedFullscreen method.
(WebVideoFullscreenInterfaceAVKit::enterFullscreenStandard): Add logging.
(WebVideoFullscreenInterfaceAVKit::exitFullscreenInternal): Ditto.
(WebVideoFullscreenInterfaceAVKit::cleanupFullscreenInternal): Use hasMode() & isMode() rather than checking m_mode directly.
(WebVideoFullscreenInterfaceAVKit::requestHideAndExitFullscreen): Ditto.
(WebVideoFullscreenInterfaceAVKit::preparedToReturnToInline): Callback now stored on this object rather than the WebAVPlayerController.
(WebVideoFullscreenInterfaceAVKit::mayAutomaticallyShowVideoOptimized): Moved.
(WebVideoFullscreenInterfaceAVKit::fullscreenMayReturnToInline): Added; store the passed callback.
(WebVideoFullscreenInterfaceAVKit::willStartOptimizedFullscreen): Exit out of standard fullscreen mode if necessary.
(WebVideoFullscreenInterfaceAVKit::didStartOptimizedFullscreen): Moved from the start lambda in enterFullscreenOptimized().
(WebVideoFullscreenInterfaceAVKit::willStopOptimizedFullscreen): Call the model's requestExitFullscreen() method.
(WebVideoFullscreenInterfaceAVKit::didStopOptimizedFullscreen): Moved from the stop lambda in enterFullscreenOptimized().
(WebVideoFullscreenInterfaceAVKit::willCancelOptimizedFullscreen): Call the model's requestExitFullscreen() method.
(WebVideoFullscreenInterfaceAVKit::didCancelOptimizedFullscreen): Moved from the stop lambda in enterFullscreenOptimized().
(WebVideoFullscreenInterfaceAVKit::prepareForOptimizedFullscreenStopWithCompletionHandler): Moved from -playerViewController:shouldExitFullScreenWithReason:.
(WebVideoFullscreenInterfaceAVKit::setMode): Added; Call fullscreenModeChanged() if necessary.
(WebVideoFullscreenInterfaceAVKit::clearMode): Ditto.
(-[WebAVVideoLayer observeValueForKeyPath:ofObject:change:context:]): Deleted.
(WebVideoFullscreenInterfaceAVKit::setIsOptimized): Deleted.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformLoggingh">trunk/Source/WebCore/platform/Logging.h</a></li>
<li><a href="#trunkSourceWebCoreplatformiosWebVideoFullscreenInterfaceAVKith">trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.h</a></li>
<li><a href="#trunkSourceWebCoreplatformiosWebVideoFullscreenInterfaceAVKitmm">trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.mm</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (182765 => 182766)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-04-13 23:23:28 UTC (rev 182765)
+++ trunk/Source/WebCore/ChangeLog        2015-04-13 23:41:17 UTC (rev 182766)
</span><span class="lines">@@ -1,3 +1,51 @@
</span><ins>+2015-04-13 Jer Noble <jer.noble@apple.com>
+
+ [iOS] When entering optimized fullscreen, standard fullscreen view should exit.
+ https://bugs.webkit.org/show_bug.cgi?id=143615
+
+ Reviewed by Simon Fraser.
+
+ When entering optimized fullscreen from standard fullscreen, the original fullscreen
+ view should animate out.
+
+ The original method for entering optimized fullscreen is deprecated, so replace it with
+ the new method (which doesn't take completion blocks) and use delegate methods to detect
+ when the animation transition completes.
+
+ * platform/Logging.h:
+ * platform/ios/WebVideoFullscreenInterfaceAVKit.h:
+ * platform/ios/WebVideoFullscreenInterfaceAVKit.mm:
+ (boolString): Added; use for logging boolean parameters.
+ (-[WebAVPlayerController playerViewControllerWillStartOptimizedFullscreen:]): Pass to WebVideoFullscreenInterfaceAVKit.
+ (-[WebAVPlayerController playerViewControllerDidStartOptimizedFullscreen:]): Ditto.
+ (-[WebAVPlayerController playerViewControllerWillStopOptimizedFullscreen:]): Ditto.
+ (-[WebAVPlayerController playerViewControllerDidStopOptimizedFullscreen:]): Ditto.
+ (-[WebAVPlayerController playerViewControllerWillCancelOptimizedFullscreen:]): Ditto.
+ (-[WebAVPlayerController playerViewControllerDidCancelOptimizedFullscreen:]): Ditto.
+ (-[WebAVPlayerController playerViewController:restoreUserInterfaceForOptimizedFullscreenStopWithCompletionHandler:]): Ditto.
+ (-[WebAVVideoLayer setPlayerViewController:]): Remove the KVO registration; now handled by above delegate methods.
+ (WebVideoFullscreenInterfaceAVKit::setupFullscreenInternal): Add logging.
+ (WebVideoFullscreenInterfaceAVKit::enterFullscreen): Ditto.
+ (WebVideoFullscreenInterfaceAVKit::enterFullscreenOptimized): Use new -startOptimizedFullscreen method.
+ (WebVideoFullscreenInterfaceAVKit::enterFullscreenStandard): Add logging.
+ (WebVideoFullscreenInterfaceAVKit::exitFullscreenInternal): Ditto.
+ (WebVideoFullscreenInterfaceAVKit::cleanupFullscreenInternal): Use hasMode() & isMode() rather than checking m_mode directly.
+ (WebVideoFullscreenInterfaceAVKit::requestHideAndExitFullscreen): Ditto.
+ (WebVideoFullscreenInterfaceAVKit::preparedToReturnToInline): Callback now stored on this object rather than the WebAVPlayerController.
+ (WebVideoFullscreenInterfaceAVKit::mayAutomaticallyShowVideoOptimized): Moved.
+ (WebVideoFullscreenInterfaceAVKit::fullscreenMayReturnToInline): Added; store the passed callback.
+ (WebVideoFullscreenInterfaceAVKit::willStartOptimizedFullscreen): Exit out of standard fullscreen mode if necessary.
+ (WebVideoFullscreenInterfaceAVKit::didStartOptimizedFullscreen): Moved from the start lambda in enterFullscreenOptimized().
+ (WebVideoFullscreenInterfaceAVKit::willStopOptimizedFullscreen): Call the model's requestExitFullscreen() method.
+ (WebVideoFullscreenInterfaceAVKit::didStopOptimizedFullscreen): Moved from the stop lambda in enterFullscreenOptimized().
+ (WebVideoFullscreenInterfaceAVKit::willCancelOptimizedFullscreen): Call the model's requestExitFullscreen() method.
+ (WebVideoFullscreenInterfaceAVKit::didCancelOptimizedFullscreen): Moved from the stop lambda in enterFullscreenOptimized().
+ (WebVideoFullscreenInterfaceAVKit::prepareForOptimizedFullscreenStopWithCompletionHandler): Moved from -playerViewController:shouldExitFullScreenWithReason:.
+ (WebVideoFullscreenInterfaceAVKit::setMode): Added; Call fullscreenModeChanged() if necessary.
+ (WebVideoFullscreenInterfaceAVKit::clearMode): Ditto.
+ (-[WebAVVideoLayer observeValueForKeyPath:ofObject:change:context:]): Deleted.
+ (WebVideoFullscreenInterfaceAVKit::setIsOptimized): Deleted.
+
</ins><span class="cx"> 2015-04-13 Brent Fulgham <bfulgham@apple.com>
</span><span class="cx">
</span><span class="cx"> [Win] Unreviewed fix after r182757.
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformLoggingh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/Logging.h (182765 => 182766)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/Logging.h        2015-04-13 23:23:28 UTC (rev 182765)
+++ trunk/Source/WebCore/platform/Logging.h        2015-04-13 23:41:17 UTC (rev 182766)
</span><span class="lines">@@ -49,6 +49,7 @@
</span><span class="cx"> M(FTP) \
</span><span class="cx"> M(FileAPI) \
</span><span class="cx"> M(Frames) \
</span><ins>+ M(Fullscreen) \
</ins><span class="cx"> M(Gamepad) \
</span><span class="cx"> M(History) \
</span><span class="cx"> M(IconDatabase) \
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformiosWebVideoFullscreenInterfaceAVKith"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.h (182765 => 182766)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.h        2015-04-13 23:23:28 UTC (rev 182765)
+++ trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.h        2015-04-13 23:41:17 UTC (rev 182766)
</span><span class="lines">@@ -96,8 +96,16 @@
</span><span class="cx"> HTMLMediaElement::VideoFullscreenMode mode() const { return m_mode; }
</span><span class="cx"> void setIsOptimized(bool);
</span><span class="cx"> WEBCORE_EXPORT bool mayAutomaticallyShowVideoOptimized();
</span><del>- void fullscreenMayReturnToInline();
</del><ins>+ void fullscreenMayReturnToInline(std::function<void(bool)> callback);
</ins><span class="cx">
</span><ins>+ void willStartOptimizedFullscreen();
+ void didStartOptimizedFullscreen();
+ void willStopOptimizedFullscreen();
+ void didStopOptimizedFullscreen();
+ void willCancelOptimizedFullscreen();
+ void didCancelOptimizedFullscreen();
+ void prepareForOptimizedFullscreenStopWithCompletionHandler(void (^)(BOOL));
+
</ins><span class="cx"> protected:
</span><span class="cx"> void beginSession();
</span><span class="cx"> void setupFullscreenInternal(PlatformLayer&, const IntRect& initialRect, UIView *, HTMLMediaElement::VideoFullscreenMode, bool allowOptimizedFullscreen);
</span><span class="lines">@@ -106,6 +114,11 @@
</span><span class="cx"> void exitFullscreenInternal(const IntRect& finalRect);
</span><span class="cx"> void cleanupFullscreenInternal();
</span><span class="cx">
</span><ins>+ void setMode(HTMLMediaElement::VideoFullscreenMode);
+ void clearMode(HTMLMediaElement::VideoFullscreenMode);
+ bool hasMode(HTMLMediaElement::VideoFullscreenMode mode) const { return m_mode & mode; }
+ bool isMode(HTMLMediaElement::VideoFullscreenMode mode) const { return m_mode == mode; }
+
</ins><span class="cx"> RetainPtr<WebAVPlayerController> m_playerController;
</span><span class="cx"> RetainPtr<AVPlayerViewController> m_playerViewController;
</span><span class="cx"> RetainPtr<CALayer> m_videoLayer;
</span><span class="lines">@@ -119,6 +132,7 @@
</span><span class="cx"> RetainPtr<UIView> m_parentView;
</span><span class="cx"> RetainPtr<UIWindow> m_parentWindow;
</span><span class="cx"> HTMLMediaElement::VideoFullscreenMode m_mode;
</span><ins>+ std::function<void(bool)> m_prepareToInlineCallback;
</ins><span class="cx"> bool m_exitRequested;
</span><span class="cx"> bool m_exitCompleted;
</span><span class="cx"> bool m_enterRequested;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformiosWebVideoFullscreenInterfaceAVKitmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.mm (182765 => 182766)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.mm        2015-04-13 23:23:28 UTC (rev 182765)
+++ trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.mm        2015-04-13 23:41:17 UTC (rev 182766)
</span><span class="lines">@@ -31,15 +31,15 @@
</span><span class="cx"> #import "WebVideoFullscreenInterfaceAVKit.h"
</span><span class="cx">
</span><span class="cx"> #import "AVKitSPI.h"
</span><ins>+#import "GeometryUtilities.h"
</ins><span class="cx"> #import "Logging.h"
</span><del>-#import "GeometryUtilities.h"
</del><ins>+#import "RuntimeApplicationChecksIOS.h"
+#import "TimeRanges.h"
</ins><span class="cx"> #import "WebCoreSystemInterface.h"
</span><ins>+#import "WebCoreThreadRun.h"
</ins><span class="cx"> #import "WebVideoFullscreenModel.h"
</span><span class="cx"> #import <AVFoundation/AVTime.h>
</span><span class="cx"> #import <UIKit/UIKit.h>
</span><del>-#import <WebCore/RuntimeApplicationChecksIOS.h>
-#import <WebCore/TimeRanges.h>
-#import <WebCore/WebCoreThreadRun.h>
</del><span class="cx"> #import <wtf/RetainPtr.h>
</span><span class="cx"> #import <wtf/text/CString.h>
</span><span class="cx"> #import <wtf/text/WTFString.h>
</span><span class="lines">@@ -65,6 +65,14 @@
</span><span class="cx"> SOFT_LINK_CLASS(UIKit, UIViewController)
</span><span class="cx"> SOFT_LINK_CLASS(UIKit, UIColor)
</span><span class="cx">
</span><ins>+#if !LOG_DISABLED
+static const char* boolString(bool val)
+{
+ return val ? "true" : "false";
+}
+#endif
+
+
</ins><span class="cx"> @class WebAVMediaSelectionOption;
</span><span class="cx">
</span><span class="cx"> @interface WebAVPlayerController : NSObject <AVPlayerViewControllerDelegate>
</span><span class="lines">@@ -115,8 +123,6 @@
</span><span class="cx"> @property AVPlayerControllerExternalPlaybackType externalPlaybackType;
</span><span class="cx"> @property (retain) NSString *externalPlaybackAirPlayDeviceLocalizedName;
</span><span class="cx">
</span><del>-@property (copy) void (^exitOptimizedCallback)(BOOL restored);
-
</del><span class="cx"> - (BOOL)playerViewController:(AVPlayerViewController *)playerViewController shouldExitFullScreenWithReason:(AVPlayerViewControllerExitFullScreenReason)reason;
</span><span class="cx"> @end
</span><span class="cx">
</span><span class="lines">@@ -186,6 +192,42 @@
</span><span class="cx"> return self.playerControllerProxy;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+- (void)playerViewControllerWillStartOptimizedFullscreen:(AVPlayerViewController *)playerViewController
+{
+ UNUSED_PARAM(playerViewController);
+ self.fullscreenInterface->willStartOptimizedFullscreen();
+}
+
+- (void)playerViewControllerDidStartOptimizedFullscreen:(AVPlayerViewController *)playerViewController
+{
+ UNUSED_PARAM(playerViewController);
+ self.fullscreenInterface->didStartOptimizedFullscreen();
+}
+
+- (void)playerViewControllerWillStopOptimizedFullscreen:(AVPlayerViewController *)playerViewController
+{
+ UNUSED_PARAM(playerViewController);
+ self.fullscreenInterface->willStopOptimizedFullscreen();
+}
+
+- (void)playerViewControllerDidStopOptimizedFullscreen:(AVPlayerViewController *)playerViewController
+{
+ UNUSED_PARAM(playerViewController);
+ self.fullscreenInterface->didStopOptimizedFullscreen();
+}
+
+- (void)playerViewControllerWillCancelOptimizedFullscreen:(AVPlayerViewController *)playerViewController
+{
+ UNUSED_PARAM(playerViewController);
+ self.fullscreenInterface->willCancelOptimizedFullscreen();
+}
+
+- (void)playerViewControllerDidCancelOptimizedFullscreen:(AVPlayerViewController *)playerViewController
+{
+ UNUSED_PARAM(playerViewController);
+ self.fullscreenInterface->didCancelOptimizedFullscreen();
+}
+
</ins><span class="cx"> - (BOOL)playerViewController:(AVPlayerViewController *)playerViewController shouldExitFullScreenWithReason:(AVPlayerViewControllerExitFullScreenReason)reason
</span><span class="cx"> {
</span><span class="cx"> UNUSED_PARAM(playerViewController);
</span><span class="lines">@@ -203,18 +245,9 @@
</span><span class="cx"> - (void)playerViewController:(AVPlayerViewController *)playerViewController restoreUserInterfaceForOptimizedFullscreenStopWithCompletionHandler:(void (^)(BOOL restored))completionHandler
</span><span class="cx"> {
</span><span class="cx"> UNUSED_PARAM(playerViewController);
</span><del>- self.exitOptimizedCallback = completionHandler;
- self.fullscreenInterface->fullscreenMayReturnToInline();
</del><ins>+ self.fullscreenInterface->prepareForOptimizedFullscreenStopWithCompletionHandler(completionHandler);
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-- (void)playerViewControllerWillCancelOptimizedFullscreen:(AVPlayerViewController *)playerViewController
-{
- UNUSED_PARAM(playerViewController);
- if (!self.delegate)
- return
- self.delegate->requestExitFullscreen();
-}
-
</del><span class="cx"> - (void)play:(id)sender
</span><span class="cx"> {
</span><span class="cx"> UNUSED_PARAM(sender);
</span><span class="lines">@@ -575,29 +608,9 @@
</span><span class="cx">
</span><span class="cx"> - (void)setPlayerViewController:(AVPlayerViewController *)playerViewController
</span><span class="cx"> {
</span><del>- NSString* propertyName = NSStringFromSelector(@selector(optimizedFullscreenActive));
-
- [_avPlayerViewController removeObserver:self forKeyPath:propertyName];
</del><span class="cx"> _avPlayerViewController = playerViewController;
</span><del>- [_avPlayerViewController addObserver:self forKeyPath:propertyName options:(NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld) context:nil];
</del><span class="cx"> }
</span><span class="cx">
</span><del>-- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
-{
- UNUSED_PARAM(context);
- UNUSED_PARAM(object);
-
- NSString* propertyName = NSStringFromSelector(@selector(optimizedFullscreenActive));
-
- if ([keyPath isEqualToString:propertyName] && change[NSKeyValueChangeNewKey]) {
- BOOL oldActive = [change[NSKeyValueChangeOldKey] boolValue];
- BOOL active = [change[NSKeyValueChangeNewKey] boolValue];
- if (oldActive != active && [_avPlayerController fullscreenInterface])
- [_avPlayerController fullscreenInterface]->setIsOptimized(active);
- }
-}
-
-
</del><span class="cx"> - (void)setVideoSublayer:(CALayer *)videoSublayer
</span><span class="cx"> {
</span><span class="cx"> _videoSublayer = videoSublayer;
</span><span class="lines">@@ -887,6 +900,7 @@
</span><span class="cx">
</span><span class="cx"> void WebVideoFullscreenInterfaceAVKit::setupFullscreenInternal(PlatformLayer& videoLayer, const WebCore::IntRect& initialRect, UIView* parentView, HTMLMediaElement::VideoFullscreenMode mode, bool allowOptimizedFullscreen)
</span><span class="cx"> {
</span><ins>+ LOG(Fullscreen, "WebVideoFullscreenInterfaceAVKit::setupFullscreenInternal(%p)", this);
</ins><span class="cx"> UNUSED_PARAM(videoLayer);
</span><span class="cx"> UNUSED_PARAM(mode);
</span><span class="cx">
</span><span class="lines">@@ -948,6 +962,8 @@
</span><span class="cx">
</span><span class="cx"> void WebVideoFullscreenInterfaceAVKit::enterFullscreen()
</span><span class="cx"> {
</span><ins>+ LOG(Fullscreen, "WebVideoFullscreenInterfaceAVKit::enterFullscreen(%p)", this);
+
</ins><span class="cx"> m_exitCompleted = false;
</span><span class="cx"> m_exitRequested = false;
</span><span class="cx"> m_enterRequested = true;
</span><span class="lines">@@ -968,50 +984,17 @@
</span><span class="cx"> {
</span><span class="cx"> RefPtr<WebVideoFullscreenInterfaceAVKit> strongThis(this);
</span><span class="cx">
</span><del>- auto startCompletionHandler = [this, strongThis] (BOOL success, NSError *) {
- [m_playerViewController setShowsPlaybackControls:YES];
-
- WebThreadRun([this, strongThis, success] {
- [m_window setHidden:YES];
- if (m_fullscreenChangeObserver)
- m_fullscreenChangeObserver->didEnterFullscreen();
-
- if (!success) {
- if (m_videoFullscreenModel)
- m_videoFullscreenModel->requestExitFullscreen();
- }
- });
- };
-
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- // FIXME: <rdar://problem/20018692> Fix AVKit deprecation warnings
- auto stopCompletionHandler = [this, strongThis] (AVPlayerViewControllerOptimizedFullscreenStopReason reason) {
- m_exitCompleted = true;
-
- if (m_fullscreenChangeObserver && reason == AVPlayerViewControllerOptimizedFullscreenStopReasonStopped)
- m_fullscreenChangeObserver->fullscreenMayReturnToInline();
- if (m_exitRequested) {
- [m_videoLayerContainer setBackgroundColor:[[getUIColorClass() clearColor] CGColor]];
- [[m_playerViewController view] setBackgroundColor:[getUIColorClass() clearColor]];
- WebThreadRun([this, strongThis] {
- if (m_fullscreenChangeObserver)
- m_fullscreenChangeObserver->didExitFullscreen();
- });
- } else {
- if (m_videoFullscreenModel)
- m_videoFullscreenModel->requestExitFullscreen();
- }
- };
-
- [m_playerViewController startOptimizedFullscreenWithStartCompletionHandler:startCompletionHandler stopCompletionHandler:stopCompletionHandler];
-#pragma clang diagnostic pop
</del><ins>+ LOG(Fullscreen, "WebVideoFullscreenInterfaceAVKit::enterFullscreenOptimized(%p)", this);
+ [m_playerViewController startOptimizedFullscreen];
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void WebVideoFullscreenInterfaceAVKit::enterFullscreenStandard()
</span><span class="cx"> {
</span><ins>+ LOG(Fullscreen, "WebVideoFullscreenInterfaceAVKit::enterFullscreenStandard(%p)", this);
</ins><span class="cx"> RefPtr<WebVideoFullscreenInterfaceAVKit> strongThis(this);
</span><del>- [m_playerViewController enterFullScreenWithCompletionHandler:[this, strongThis] (BOOL, NSError*) {
</del><ins>+ [m_playerViewController enterFullScreenWithCompletionHandler:[this, strongThis] (BOOL succeeded, NSError*) {
+ UNUSED_PARAM(succeeded);
+ LOG(Fullscreen, "WebVideoFullscreenInterfaceAVKit::enterFullscreenStandard - lambda(%p) - succeeded(%s)", this, boolString(succeeded));
</ins><span class="cx"> [m_playerViewController setShowsPlaybackControls:YES];
</span><span class="cx">
</span><span class="cx"> WebThreadRun([this, strongThis] {
</span><span class="lines">@@ -1041,6 +1024,7 @@
</span><span class="cx">
</span><span class="cx"> void WebVideoFullscreenInterfaceAVKit::exitFullscreenInternal(const WebCore::IntRect& finalRect)
</span><span class="cx"> {
</span><ins>+ LOG(Fullscreen, "WebVideoFullscreenInterfaceAVKit::exitFullscreenInternal(%p)", this);
</ins><span class="cx"> [m_playerViewController setShowsPlaybackControls:NO];
</span><span class="cx"> if (m_viewController)
</span><span class="cx"> [m_playerViewController view].frame = [m_parentView convertRect:finalRect toView:nil];
</span><span class="lines">@@ -1052,16 +1036,16 @@
</span><span class="cx"> [[m_playerViewController view] layoutIfNeeded];
</span><span class="cx">
</span><span class="cx">
</span><del>- if (m_mode == HTMLMediaElement::VideoFullscreenModeOptimized) {
</del><ins>+ if (isMode(HTMLMediaElement::VideoFullscreenModeOptimized)) {
</ins><span class="cx"> [m_window setHidden:NO];
</span><span class="cx"> [m_playerViewController stopOptimizedFullscreen];
</span><del>- } else if (m_mode == (HTMLMediaElement::VideoFullscreenModeOptimized | HTMLMediaElement::VideoFullscreenModeStandard)) {
</del><ins>+ } else if (isMode(HTMLMediaElement::VideoFullscreenModeOptimized | HTMLMediaElement::VideoFullscreenModeStandard)) {
</ins><span class="cx"> RefPtr<WebVideoFullscreenInterfaceAVKit> strongThis(this);
</span><span class="cx"> [m_playerViewController exitFullScreenAnimated:NO completionHandler:[strongThis] (BOOL, NSError*) {
</span><span class="cx"> [strongThis->m_window setHidden:NO];
</span><span class="cx"> [strongThis->m_playerViewController stopOptimizedFullscreen];
</span><span class="cx"> }];
</span><del>- } else if (m_mode == HTMLMediaElement::VideoFullscreenModeStandard) {
</del><ins>+ } else if (isMode(HTMLMediaElement::VideoFullscreenModeStandard)) {
</ins><span class="cx"> RefPtr<WebVideoFullscreenInterfaceAVKit> strongThis(this);
</span><span class="cx"> [m_playerViewController exitFullScreenWithCompletionHandler:[strongThis] (BOOL, NSError*) {
</span><span class="cx"> strongThis->m_exitCompleted = true;
</span><span class="lines">@@ -1099,6 +1083,7 @@
</span><span class="cx">
</span><span class="cx"> void WebVideoFullscreenInterfaceAVKit::cleanupFullscreenInternal()
</span><span class="cx"> {
</span><ins>+ LOG(Fullscreen, "WebVideoFullscreenInterfaceAVKit::cleanupFullscreenInternal(%p)", this);
</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">@@ -1112,9 +1097,9 @@
</span><span class="cx"> [m_playerViewController setDelegate:nil];
</span><span class="cx"> [m_playerViewController setPlayerController:nil];
</span><span class="cx">
</span><del>- if (m_mode & HTMLMediaElement::VideoFullscreenModeOptimized)
</del><ins>+ if (hasMode(HTMLMediaElement::VideoFullscreenModeOptimized))
</ins><span class="cx"> [m_playerViewController cancelOptimizedFullscreen];
</span><del>- if (m_mode & HTMLMediaElement::VideoFullscreenModeStandard)
</del><ins>+ if (hasMode(HTMLMediaElement::VideoFullscreenModeStandard))
</ins><span class="cx"> [m_playerViewController exitFullScreenAnimated:NO completionHandler:nil];
</span><span class="cx">
</span><span class="cx"> [[m_playerViewController view] removeFromSuperview];
</span><span class="lines">@@ -1156,9 +1141,11 @@
</span><span class="cx"> if (!m_enterRequested)
</span><span class="cx"> return;
</span><span class="cx">
</span><del>- if (m_mode & HTMLMediaElement::VideoFullscreenModeOptimized)
</del><ins>+ if (hasMode(HTMLMediaElement::VideoFullscreenModeOptimized))
</ins><span class="cx"> return;
</span><span class="cx">
</span><ins>+ LOG(Fullscreen, "WebVideoFullscreenInterfaceAVKit::requestHideAndExitFullscreen(%p)", this);
+
</ins><span class="cx"> RefPtr<WebVideoFullscreenInterfaceAVKit> strongThis(this);
</span><span class="cx"> dispatch_async(dispatch_get_main_queue(), [strongThis] {
</span><span class="cx"> [strongThis->m_window setHidden:YES];
</span><span class="lines">@@ -1172,62 +1159,169 @@
</span><span class="cx">
</span><span class="cx"> void WebVideoFullscreenInterfaceAVKit::preparedToReturnToInline(bool visible, const IntRect& inlineRect)
</span><span class="cx"> {
</span><ins>+ LOG(Fullscreen, "WebVideoFullscreenInterfaceAVKit::preparedToReturnToInline(%p) - visible(%s)", this, boolString(visible));
</ins><span class="cx"> RefPtr<WebVideoFullscreenInterfaceAVKit> strongThis(this);
</span><span class="cx"> dispatch_async(dispatch_get_main_queue(), [strongThis, visible, inlineRect] {
</span><del>- if (strongThis->m_playerController.get().exitOptimizedCallback) {
</del><ins>+ if (strongThis->m_prepareToInlineCallback) {
</ins><span class="cx">
</span><span class="cx"> if (strongThis->m_viewController)
</span><span class="cx"> [strongThis->m_playerViewController view].frame = [strongThis->m_parentView convertRect:inlineRect toView:nil];
</span><span class="cx"> else
</span><span class="cx"> [strongThis->m_playerViewController view].frame = inlineRect;
</span><del>-
- strongThis->m_playerController.get().exitOptimizedCallback(visible);
</del><ins>+
+ std::function<void(bool)> callback = WTF::move(strongThis->m_prepareToInlineCallback);
+ callback(visible);
</ins><span class="cx"> }
</span><span class="cx"> });
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void WebVideoFullscreenInterfaceAVKit::setIsOptimized(bool active)
</del><ins>+bool WebVideoFullscreenInterfaceAVKit::mayAutomaticallyShowVideoOptimized()
</ins><span class="cx"> {
</span><del>- if (m_mode & HTMLMediaElement::VideoFullscreenModeStandard) {
- if (!active)
- m_mode &= ~HTMLMediaElement::VideoFullscreenModeOptimized;
- else
- m_mode |= HTMLMediaElement::VideoFullscreenModeOptimized;
- }
</del><ins>+ return [m_playerController isPlaying] && m_mode == HTMLMediaElement::VideoFullscreenModeStandard && wkIsOptimizedFullscreenSupported();
+}
</ins><span class="cx">
</span><del>- if (m_videoFullscreenModel)
- m_videoFullscreenModel->fullscreenModeChanged(m_exitRequested ? HTMLMediaElement::VideoFullscreenModeNone : m_mode);
</del><ins>+void WebVideoFullscreenInterfaceAVKit::fullscreenMayReturnToInline(std::function<void(bool)> callback)
+{
+ m_prepareToInlineCallback = callback;
+ if (m_fullscreenChangeObserver)
+ m_fullscreenChangeObserver->fullscreenMayReturnToInline();
+}
</ins><span class="cx">
</span><ins>+void WebVideoFullscreenInterfaceAVKit::willStartOptimizedFullscreen()
+{
+ LOG(Fullscreen, "WebVideoFullscreenInterfaceAVKit::willStartOptimizedFullscreen(%p)", this);
+ setMode(HTMLMediaElement::VideoFullscreenModeOptimized);
</ins><span class="cx">
</span><del>- if (m_mode == HTMLMediaElement::VideoFullscreenModeOptimized)
</del><ins>+ if (!hasMode(HTMLMediaElement::VideoFullscreenModeStandard))
</ins><span class="cx"> return;
</span><span class="cx">
</span><del>- [m_window setHidden:m_mode & HTMLMediaElement::VideoFullscreenModeOptimized];
-
- if (m_fullscreenChangeObserver && ~m_mode & HTMLMediaElement::VideoFullscreenModeOptimized)
- m_fullscreenChangeObserver->fullscreenMayReturnToInline();
</del><ins>+ RefPtr<WebVideoFullscreenInterfaceAVKit> strongThis(this);
+ fullscreenMayReturnToInline([strongThis](bool visible) {
+ LOG(Fullscreen, "WebVideoFullscreenInterfaceAVKit::willStartOptimizedFullscreen - lambda(%p) - visible(%s)", strongThis.get(), boolString(visible));
</ins><span class="cx">
</span><del>- if (!m_exitRequested || active)
</del><ins>+ if (!visible) {
+ [strongThis->m_window setHidden:YES];
+ return;
+ }
+
+ [[strongThis->m_playerViewController view] layoutIfNeeded];
+
+ [strongThis->m_playerViewController exitFullScreenAnimated:YES completionHandler:[strongThis] (BOOL completed, NSError*) {
+ if (!completed)
+ return;
+ strongThis->clearMode(HTMLMediaElement::VideoFullscreenModeStandard);
+ [strongThis->m_window setHidden:YES];
+ }];
+ });
+}
+
+void WebVideoFullscreenInterfaceAVKit::didStartOptimizedFullscreen()
+{
+ LOG(Fullscreen, "WebVideoFullscreenInterfaceAVKit::didStartOptimizedFullscreen(%p)", this);
+ [m_playerViewController setShowsPlaybackControls:YES];
+
+ RefPtr<WebVideoFullscreenInterfaceAVKit> strongThis(this);
+ WebThreadRun([strongThis] {
+ [strongThis->m_window setHidden:YES];
+ if (strongThis->m_fullscreenChangeObserver)
+ strongThis->m_fullscreenChangeObserver->didEnterFullscreen();
+ });
+}
+
+void WebVideoFullscreenInterfaceAVKit::willStopOptimizedFullscreen()
+{
+ LOG(Fullscreen, "WebVideoFullscreenInterfaceAVKit::willStopOptimizedFullscreen(%p)", this);
+ [m_window setHidden:NO];
+
+ RefPtr<WebVideoFullscreenInterfaceAVKit> strongThis(this);
+ WebThreadRun([strongThis] {
+ if (strongThis->m_videoFullscreenModel)
+ strongThis->m_videoFullscreenModel->requestExitFullscreen();
+ });
+}
+
+void WebVideoFullscreenInterfaceAVKit::didStopOptimizedFullscreen()
+{
+ LOG(Fullscreen, "WebVideoFullscreenInterfaceAVKit::didStopOptimizedFullscreen(%p)", this);
+ if (hasMode(HTMLMediaElement::VideoFullscreenModeStandard))
</ins><span class="cx"> return;
</span><span class="cx">
</span><span class="cx"> m_exitCompleted = true;
</span><ins>+
</ins><span class="cx"> [m_videoLayerContainer setBackgroundColor:[[getUIColorClass() clearColor] CGColor]];
</span><span class="cx"> [[m_playerViewController view] setBackgroundColor:[getUIColorClass() clearColor]];
</span><del>- WebThreadRun(^{
- if (m_fullscreenChangeObserver)
- m_fullscreenChangeObserver->didExitFullscreen();
</del><ins>+
+ RefPtr<WebVideoFullscreenInterfaceAVKit> strongThis(this);
+ WebThreadRun([strongThis] {
+ strongThis->clearMode(HTMLMediaElement::VideoFullscreenModeOptimized);
+ [strongThis->m_window setHidden:YES];
+ if (strongThis->m_fullscreenChangeObserver)
+ strongThis->m_fullscreenChangeObserver->didExitFullscreen();
</ins><span class="cx"> });
</span><span class="cx"> }
</span><span class="cx">
</span><del>-bool WebVideoFullscreenInterfaceAVKit::mayAutomaticallyShowVideoOptimized()
</del><ins>+void WebVideoFullscreenInterfaceAVKit::willCancelOptimizedFullscreen()
</ins><span class="cx"> {
</span><del>- return [m_playerController isPlaying] && m_mode == HTMLMediaElement::VideoFullscreenModeStandard && wkIsOptimizedFullscreenSupported();
</del><ins>+ LOG(Fullscreen, "WebVideoFullscreenInterfaceAVKit::willCancelOptimizedFullscreen(%p)", this);
+ [m_window setHidden:NO];
+ [m_videoLayerContainer setBackgroundColor:[[getUIColorClass() clearColor] CGColor]];
+ [[m_playerViewController view] setBackgroundColor:[getUIColorClass() clearColor]];
+
+ RefPtr<WebVideoFullscreenInterfaceAVKit> strongThis(this);
+ WebThreadRun([strongThis] {
+ if (strongThis->m_videoFullscreenModel)
+ strongThis->m_videoFullscreenModel->requestExitFullscreen();
+ });
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-void WebVideoFullscreenInterfaceAVKit::fullscreenMayReturnToInline()
</del><ins>+void WebVideoFullscreenInterfaceAVKit::didCancelOptimizedFullscreen()
</ins><span class="cx"> {
</span><del>- if (m_fullscreenChangeObserver)
- m_fullscreenChangeObserver->fullscreenMayReturnToInline();
</del><ins>+ LOG(Fullscreen, "WebVideoFullscreenInterfaceAVKit::didCancelOptimizedFullscreen(%p)", this);
+ if (hasMode(HTMLMediaElement::VideoFullscreenModeStandard))
+ return;
+
+ RefPtr<WebVideoFullscreenInterfaceAVKit> strongThis(this);
+ WebThreadRun([strongThis] {
+ strongThis->clearMode(HTMLMediaElement::VideoFullscreenModeOptimized);
+ [strongThis->m_window setHidden:YES];
+ if (strongThis->m_fullscreenChangeObserver)
+ strongThis->m_fullscreenChangeObserver->didExitFullscreen();
+ });
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+void WebVideoFullscreenInterfaceAVKit::prepareForOptimizedFullscreenStopWithCompletionHandler(void (^completionHandler)(BOOL restored))
+{
+ LOG(Fullscreen, "WebVideoFullscreenInterfaceAVKit::prepareForOptimizedFullscreenStopWithCompletionHandler(%p)", this);
+ RefPtr<WebVideoFullscreenInterfaceAVKit> strongThis(this);
+ RetainPtr<id> strongCompletionHandler = adoptNS([completionHandler copy]);
+ fullscreenMayReturnToInline([strongThis, strongCompletionHandler](bool restored) {
+ LOG(Fullscreen, "WebVideoFullscreenInterfaceAVKit::prepareForOptimizedFullscreenStopWithCompletionHandler lambda(%p) - restored(%s)", strongThis.get(), boolString(restored));
+ void (^completionHandler)(BOOL restored) = strongCompletionHandler.get();
+ completionHandler(restored);
+ });
+}
+
+void WebVideoFullscreenInterfaceAVKit::setMode(HTMLMediaElement::VideoFullscreenMode mode)
+{
+ HTMLMediaElement::VideoFullscreenMode newMode = m_mode | mode;
+ if (m_mode == newMode)
+ return;
+
+ m_mode = newMode;
+ if (m_videoFullscreenModel)
+ m_videoFullscreenModel->fullscreenModeChanged(m_mode);
+}
+
+void WebVideoFullscreenInterfaceAVKit::clearMode(HTMLMediaElement::VideoFullscreenMode mode)
+{
+ HTMLMediaElement::VideoFullscreenMode newMode = m_mode & ~mode;
+ if (m_mode == newMode)
+ return;
+
+ m_mode = newMode;
+ if (m_videoFullscreenModel)
+ m_videoFullscreenModel->fullscreenModeChanged(m_mode);
+}
+
+
</ins><span class="cx"> #endif
</span></span></pre>
</div>
</div>
</body>
</html>