<!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>[171286] 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/171286">171286</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2014-07-20 19:30:24 -0700 (Sun, 20 Jul 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Decrease flicker when enter and exit fullscreen.
https://bugs.webkit.org/show_bug.cgi?id=134919

Patch by Jeremy Jones &lt;jeremyj@apple.com&gt; on 2014-07-20
Reviewed by Simon Fraser.

Source/WebCore:
Put AVPlayerLayer in a container layer so moving it between inline and fullscreen
is as easy as adding and removing it from a containter layer; no need to do a layout.

Make sure fullscreen layers are transparent before moving moving the AVPlayerLayer
between inline and fullscreen so you don't briefly see the empty fullscreen layers.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::platformLayer): remove fullscreen special case.
(WebCore::HTMLMediaElement::setVideoFullscreenLayer): no need to recalc style
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h: add inline container layer
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
add WebVideoContainerLayer to contain AVPlayerLayer and keep layout correct.
(-[WebVideoContainerLayer setBounds:]): forward setbounds to set child frame.
(WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayerLayer): create the video container layer
(WebCore::MediaPlayerPrivateAVFoundationObjC::destroyVideoLayer): destroy the video container layer
(WebCore::MediaPlayerPrivateAVFoundationObjC::platformLayer): use container layer instead of video layer
(WebCore::MediaPlayerPrivateAVFoundationObjC::setVideoFullscreenLayer): use transactions to prevent unwanted animation.
(WebCore::MediaPlayerPrivateAVFoundationObjC::setVideoFullscreenFrame): ditto
* platform/graphics/ca/mac/PlatformCALayerMac.mm:
(PlatformCALayerMac::layerTypeForPlatformLayer): WebVideoContainerLayer is a kind of AVPlayerLayer
* platform/ios/WebVideoFullscreenControllerAVKit.mm:
(-[WebVideoFullscreenController didCleanupFullscreen]): remove video fullscreen layer first
* platform/ios/WebVideoFullscreenInterfaceAVKit.mm:
(WebVideoFullscreenInterfaceAVKit::setupFullscreen): make background transparent during transition.
   dispatch_async to allow CATransaction to complete before calling didSetupFullscreen()

Source/WebKit2:
Change the sequence of tear down and use transparency to prevent flicker when entering and exiting fullscreen.

* UIProcess/ios/WebVideoFullscreenManagerProxy.mm: wait to remove layerHost until didCleanupFullscreen
(WebKit::WebVideoFullscreenManagerProxy::didExitFullscreen): removed from here
(WebKit::WebVideoFullscreenManagerProxy::didCleanupFullscreen): added here
* WebProcess/ios/WebVideoFullscreenManager.mm:
(WebKit::WebVideoFullscreenManager::didSetupFullscreen): use transparent background during transition</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="#trunkSourceWebCoreplatformgraphicsavfoundationobjcMediaPlayerPrivateAVFoundationObjCh">trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsavfoundationobjcMediaPlayerPrivateAVFoundationObjCmm">trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscamacPlatformCALayerMacmm">trunk/Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformiosWebVideoFullscreenControllerAVKitmm">trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformiosWebVideoFullscreenInterfaceAVKitmm">trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.mm</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosWebVideoFullscreenManagerProxymm">trunk/Source/WebKit2/UIProcess/ios/WebVideoFullscreenManagerProxy.mm</a></li>
<li><a href="#trunkSourceWebKit2WebProcessiosWebVideoFullscreenManagermm">trunk/Source/WebKit2/WebProcess/ios/WebVideoFullscreenManager.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (171285 => 171286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-07-21 02:19:48 UTC (rev 171285)
+++ trunk/Source/WebCore/ChangeLog        2014-07-21 02:30:24 UTC (rev 171286)
</span><span class="lines">@@ -1,3 +1,36 @@
</span><ins>+2014-07-20  Jeremy Jones  &lt;jeremyj@apple.com&gt;
+
+        Decrease flicker when enter and exit fullscreen.
+        https://bugs.webkit.org/show_bug.cgi?id=134919
+
+        Reviewed by Simon Fraser.
+
+        Put AVPlayerLayer in a container layer so moving it between inline and fullscreen
+        is as easy as adding and removing it from a containter layer; no need to do a layout.
+
+        Make sure fullscreen layers are transparent before moving moving the AVPlayerLayer
+        between inline and fullscreen so you don't briefly see the empty fullscreen layers.
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::platformLayer): remove fullscreen special case.
+        (WebCore::HTMLMediaElement::setVideoFullscreenLayer): no need to recalc style
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h: add inline container layer
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: 
+        add WebVideoContainerLayer to contain AVPlayerLayer and keep layout correct.
+        (-[WebVideoContainerLayer setBounds:]): forward setbounds to set child frame.
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayerLayer): create the video container layer
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::destroyVideoLayer): destroy the video container layer
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::platformLayer): use container layer instead of video layer
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::setVideoFullscreenLayer): use transactions to prevent unwanted animation.
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::setVideoFullscreenFrame): ditto
+        * platform/graphics/ca/mac/PlatformCALayerMac.mm:
+        (PlatformCALayerMac::layerTypeForPlatformLayer): WebVideoContainerLayer is a kind of AVPlayerLayer
+        * platform/ios/WebVideoFullscreenControllerAVKit.mm:
+        (-[WebVideoFullscreenController didCleanupFullscreen]): remove video fullscreen layer first
+        * platform/ios/WebVideoFullscreenInterfaceAVKit.mm:
+        (WebVideoFullscreenInterfaceAVKit::setupFullscreen): make background transparent during transition.
+           dispatch_async to allow CATransaction to complete before calling didSetupFullscreen()
+
</ins><span class="cx"> 2014-07-20  Ryuan Choi  &lt;ryuan.choi@samsung.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Move ExceptionCodeDescription.h into the files that actually need it
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLMediaElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (171285 => 171286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLMediaElement.cpp        2014-07-21 02:19:48 UTC (rev 171285)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp        2014-07-21 02:30:24 UTC (rev 171286)
</span><span class="lines">@@ -4946,10 +4946,6 @@
</span><span class="cx"> 
</span><span class="cx"> PlatformLayer* HTMLMediaElement::platformLayer() const
</span><span class="cx"> {
</span><del>-#if PLATFORM(IOS)
-    if (m_videoFullscreenLayer)
-        return nullptr;
-#endif
</del><span class="cx">     return m_player ? m_player-&gt;platformLayer() : nullptr;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsavfoundationobjcMediaPlayerPrivateAVFoundationObjCh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h (171285 => 171286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h        2014-07-21 02:19:48 UTC (rev 171285)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h        2014-07-21 02:30:24 UTC (rev 171286)
</span><span class="lines">@@ -271,6 +271,7 @@
</span><span class="cx">     RetainPtr&lt;AVPlayer&gt; m_avPlayer;
</span><span class="cx">     RetainPtr&lt;AVPlayerItem&gt; m_avPlayerItem;
</span><span class="cx">     RetainPtr&lt;AVPlayerLayer&gt; m_videoLayer;
</span><ins>+    RetainPtr&lt;PlatformLayer&gt; m_videoInlineLayer;
</ins><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">     RetainPtr&lt;PlatformLayer&gt; m_videoFullscreenLayer;
</span><span class="cx">     FloatRect m_videoFullscreenFrame;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsavfoundationobjcMediaPlayerPrivateAVFoundationObjCmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (171285 => 171286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm        2014-07-21 02:19:48 UTC (rev 171285)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm        2014-07-21 02:30:24 UTC (rev 171286)
</span><span class="lines">@@ -86,6 +86,19 @@
</span><span class="cx"> #import &lt;VideoToolbox/VideoToolbox.h&gt;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+@interface WebVideoContainerLayer : CALayer
+@end
+
+@implementation WebVideoContainerLayer
+
+- (void)setBounds:(CGRect)bounds
+{
+    [super setBounds:bounds];
+    for (CALayer* layer in self.sublayers)
+        layer.frame = bounds;
+}
+@end
+
</ins><span class="cx"> #if ENABLE(AVF_CAPTIONS)
</span><span class="cx"> // Note: This must be defined before our SOFT_LINK macros:
</span><span class="cx"> @class AVMediaSelectionOption;
</span><span class="lines">@@ -573,21 +586,26 @@
</span><span class="cx">     m_videoLayer = adoptNS([[AVPlayerLayer alloc] init]);
</span><span class="cx">     [m_videoLayer setPlayer:m_avPlayer.get()];
</span><span class="cx">     [m_videoLayer setBackgroundColor:cachedCGColor(Color::black, ColorSpaceDeviceRGB)];
</span><ins>+    m_videoInlineLayer = adoptNS([[WebVideoContainerLayer alloc] init]);
</ins><span class="cx"> #ifndef NDEBUG
</span><span class="cx">     [m_videoLayer setName:@&quot;MediaPlayerPrivate AVPlayerLayer&quot;];
</span><span class="cx"> #endif
</span><span class="cx">     [m_videoLayer addObserver:m_objcObserver.get() forKeyPath:@&quot;readyForDisplay&quot; options:NSKeyValueObservingOptionNew context:(void *)MediaPlayerAVFoundationObservationContextAVPlayerLayer];
</span><span class="cx">     updateVideoLayerGravity();
</span><span class="cx">     IntSize defaultSize = player()-&gt;mediaPlayerClient() ? player()-&gt;mediaPlayerClient()-&gt;mediaPlayerContentBoxRect().pixelSnappedSize() : IntSize();
</span><del>-    [m_videoLayer setFrame:CGRectMake(0, 0, defaultSize.width(), defaultSize.height())];
</del><ins>+    [m_videoInlineLayer setFrame:CGRectMake(0, 0, defaultSize.width(), defaultSize.height())];
</ins><span class="cx">     LOG(Media, &quot;MediaPlayerPrivateAVFoundationObjC::createVideoLayer(%p) - returning %p&quot;, this, m_videoLayer.get());
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">     if (m_videoFullscreenLayer) {
</span><del>-        [m_videoLayer setFrame:CGRectMake(0, 0, m_videoFullscreenFrame.width(), m_videoFullscreenFrame.height())];
</del><ins>+        [m_videoLayer setFrame:[m_videoFullscreenLayer bounds]];
</ins><span class="cx">         [m_videoFullscreenLayer insertSublayer:m_videoLayer.get() atIndex:0];
</span><ins>+    } else
+#endif
+    {
+        [m_videoInlineLayer insertSublayer:m_videoLayer.get() atIndex:0];
+        [m_videoLayer setFrame:m_videoInlineLayer.get().bounds];
</ins><span class="cx">     }
</span><del>-#endif
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void MediaPlayerPrivateAVFoundationObjC::destroyVideoLayer()
</span><span class="lines">@@ -605,7 +623,8 @@
</span><span class="cx">         [m_videoLayer removeFromSuperlayer];
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    m_videoLayer = 0;
</del><ins>+    m_videoLayer = nil;
+    m_videoInlineLayer = nil;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool MediaPlayerPrivateAVFoundationObjC::hasAvailableVideoFrame() const
</span><span class="lines">@@ -936,7 +955,7 @@
</span><span class="cx"> 
</span><span class="cx"> PlatformLayer* MediaPlayerPrivateAVFoundationObjC::platformLayer() const
</span><span class="cx"> {
</span><del>-    return m_haveBeenAskedToCreateLayer ? m_videoLayer.get() : nullptr;
</del><ins>+    return m_haveBeenAskedToCreateLayer ? m_videoInlineLayer.get() : nullptr;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="lines">@@ -945,17 +964,24 @@
</span><span class="cx">     if (m_videoFullscreenLayer == videoFullscreenLayer)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    if (m_videoFullscreenLayer)
-       [m_videoLayer removeFromSuperlayer];
-
</del><span class="cx">     m_videoFullscreenLayer = videoFullscreenLayer;
</span><span class="cx"> 
</span><ins>+    [CATransaction begin];
+    [CATransaction setDisableActions:YES];
+
</ins><span class="cx">     if (m_videoFullscreenLayer &amp;&amp; m_videoLayer) {
</span><del>-        CGRect frame = CGRectMake(0, 0, m_videoFullscreenFrame.width(), m_videoFullscreenFrame.height());
-        [m_videoLayer setFrame:frame];
</del><ins>+        [m_videoLayer setFrame:[m_videoFullscreenLayer bounds]];
+        [m_videoLayer removeFromSuperlayer];
</ins><span class="cx">         [m_videoFullscreenLayer insertSublayer:m_videoLayer.get() atIndex:0];
</span><del>-    }
</del><ins>+    } else if (m_videoInlineLayer &amp;&amp; m_videoLayer) {
+        [m_videoLayer setFrame:[m_videoInlineLayer bounds]];
+        [m_videoLayer removeFromSuperlayer];
+        [m_videoInlineLayer insertSublayer:m_videoLayer.get() atIndex:0];
+    } else if (m_videoLayer)
+        [m_videoLayer removeFromSuperlayer];
</ins><span class="cx"> 
</span><ins>+    [CATransaction commit];
+
</ins><span class="cx">     if (m_videoFullscreenLayer &amp;&amp; m_textTrackRepresentationLayer) {
</span><span class="cx">         syncTextTrackBounds();
</span><span class="cx">         [m_videoFullscreenLayer addSublayer:m_textTrackRepresentationLayer.get()];
</span><span class="lines">@@ -971,9 +997,12 @@
</span><span class="cx">     if (!m_videoFullscreenLayer)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    if (m_videoLayer)
</del><ins>+    if (m_videoLayer) {
+        [CATransaction begin];
+        [CATransaction setDisableActions:YES];
</ins><span class="cx">         [m_videoLayer setFrame:CGRectMake(0, 0, frame.width(), frame.height())];
</span><del>-
</del><ins>+        [CATransaction commit];
+    }
</ins><span class="cx">     syncTextTrackBounds();
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscamacPlatformCALayerMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.mm (171285 => 171286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.mm        2014-07-21 02:19:48 UTC (rev 171285)
+++ trunk/Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.mm        2014-07-21 02:30:24 UTC (rev 171286)
</span><span class="lines">@@ -178,7 +178,7 @@
</span><span class="cx"> 
</span><span class="cx"> PlatformCALayer::LayerType PlatformCALayerMac::layerTypeForPlatformLayer(PlatformLayer* layer)
</span><span class="cx"> {
</span><del>-    if ([layer isKindOfClass:getAVPlayerLayerClass()])
</del><ins>+    if ([layer isKindOfClass:getAVPlayerLayerClass()] || [layer isKindOfClass:objc_getClass(&quot;WebVideoContainerLayer&quot;)])
</ins><span class="cx">         return LayerTypeAVPlayerLayer;
</span><span class="cx"> 
</span><span class="cx">     if ([layer isKindOfClass:[WebGLLayer class]])
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformiosWebVideoFullscreenControllerAVKitmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm (171285 => 171286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm        2014-07-21 02:19:48 UTC (rev 171285)
+++ trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm        2014-07-21 02:30:24 UTC (rev 171286)
</span><span class="lines">@@ -161,9 +161,9 @@
</span><span class="cx"> - (void)didCleanupFullscreen
</span><span class="cx"> {
</span><span class="cx">     WebThreadRun(^{
</span><ins>+        _model-&gt;setVideoFullscreenLayer(nil);
</ins><span class="cx">         _interface-&gt;setWebVideoFullscreenModel(nullptr);
</span><span class="cx">         _model-&gt;setWebVideoFullscreenInterface(nullptr);
</span><del>-        _model-&gt;setVideoFullscreenLayer(nil);
</del><span class="cx">         _model-&gt;setMediaElement(nullptr);
</span><span class="cx">         _interface-&gt;setWebVideoFullscreenChangeObserver(nullptr);
</span><span class="cx">         _model = nullptr;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformiosWebVideoFullscreenInterfaceAVKitmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.mm (171285 => 171286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.mm        2014-07-21 02:19:48 UTC (rev 171285)
+++ trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.mm        2014-07-21 02:30:24 UTC (rev 171286)
</span><span class="lines">@@ -774,15 +774,18 @@
</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">         [m_playerViewController view].frame = initialRect;
</span><ins>+        [[m_playerViewController view] setBackgroundColor:[getUIColorClass() clearColor]];
</ins><span class="cx">         [m_playerViewController didMoveToParentViewController:m_viewController.get()];
</span><span class="cx">         [[m_playerViewController view] layoutIfNeeded];
</span><span class="cx"> 
</span><span class="cx">         [CATransaction commit];
</span><del>-        
-        if (m_fullscreenChangeObserver)
-            m_fullscreenChangeObserver-&gt;didSetupFullscreen();
-        
-        protect.clear();
</del><ins>+
+        dispatch_async(dispatch_get_main_queue(), ^{
+            if (m_fullscreenChangeObserver)
+                m_fullscreenChangeObserver-&gt;didSetupFullscreen();
+            
+            protect.clear();
+        });
</ins><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (171285 => 171286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-07-21 02:19:48 UTC (rev 171285)
+++ trunk/Source/WebKit2/ChangeLog        2014-07-21 02:30:24 UTC (rev 171286)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2014-07-20  Jeremy Jones  &lt;jeremyj@apple.com&gt;
+
+        Decrease flicker when enter and exit fullscreen.
+        https://bugs.webkit.org/show_bug.cgi?id=134919
+
+        Reviewed by Simon Fraser.
+
+        Change the sequence of tear down and use transparency to prevent flicker when entering and exiting fullscreen.
+
+        * UIProcess/ios/WebVideoFullscreenManagerProxy.mm: wait to remove layerHost until didCleanupFullscreen
+        (WebKit::WebVideoFullscreenManagerProxy::didExitFullscreen): removed from here
+        (WebKit::WebVideoFullscreenManagerProxy::didCleanupFullscreen): added here
+        * WebProcess/ios/WebVideoFullscreenManager.mm:
+        (WebKit::WebVideoFullscreenManager::didSetupFullscreen): use transparent background during transition
+
</ins><span class="cx"> 2014-07-20  Dan Bernstein  &lt;mitz@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         &lt;rdar://problem/17739526&gt; REGRESSION (r171057): Crash in WebPage::getPositionInformation()
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosWebVideoFullscreenManagerProxymm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/WebVideoFullscreenManagerProxy.mm (171285 => 171286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/WebVideoFullscreenManagerProxy.mm        2014-07-21 02:19:48 UTC (rev 171285)
+++ trunk/Source/WebKit2/UIProcess/ios/WebVideoFullscreenManagerProxy.mm        2014-07-21 02:30:24 UTC (rev 171286)
</span><span class="lines">@@ -109,12 +109,12 @@
</span><span class="cx"> void WebVideoFullscreenManagerProxy::didExitFullscreen()
</span><span class="cx"> {
</span><span class="cx">     m_page-&gt;send(Messages::WebVideoFullscreenManager::DidExitFullscreen(), m_page-&gt;pageID());
</span><del>-    [m_layerHost removeFromSuperlayer];
-    m_layerHost.clear();
</del><span class="cx"> }
</span><span class="cx">     
</span><span class="cx"> void WebVideoFullscreenManagerProxy::didCleanupFullscreen()
</span><span class="cx"> {
</span><ins>+    [m_layerHost removeFromSuperlayer];
+    m_layerHost.clear();
</ins><span class="cx">     m_page-&gt;send(Messages::WebVideoFullscreenManager::DidCleanupFullscreen(), m_page-&gt;pageID());
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessiosWebVideoFullscreenManagermm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/ios/WebVideoFullscreenManager.mm (171285 => 171286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/ios/WebVideoFullscreenManager.mm        2014-07-21 02:19:48 UTC (rev 171285)
+++ trunk/Source/WebKit2/WebProcess/ios/WebVideoFullscreenManager.mm        2014-07-21 02:30:24 UTC (rev 171286)
</span><span class="lines">@@ -33,6 +33,7 @@
</span><span class="cx"> #import &quot;WebVideoFullscreenManagerMessages.h&quot;
</span><span class="cx"> #import &quot;WebVideoFullscreenManagerProxyMessages.h&quot;
</span><span class="cx"> #import &lt;QuartzCore/CoreAnimation.h&gt;
</span><ins>+#import &lt;WebCore/Color.h&gt;
</ins><span class="cx"> #import &lt;WebCore/Event.h&gt;
</span><span class="cx"> #import &lt;WebCore/EventNames.h&gt;
</span><span class="cx"> #import &lt;WebCore/FrameView.h&gt;
</span><span class="lines">@@ -166,9 +167,13 @@
</span><span class="cx"> #ifndef NDEBUG
</span><span class="cx">     [videoLayer setName:@&quot;Web video fullscreen manager layer&quot;];
</span><span class="cx"> #endif
</span><del>-    
</del><ins>+
+    [CATransaction begin];
+    [CATransaction setDisableActions:YES];
+    [videoLayer setBackgroundColor:cachedCGColor(WebCore::Color::transparent, WebCore::ColorSpaceDeviceRGB)];
</ins><span class="cx">     m_layerHostingContext-&gt;setRootLayer(videoLayer);
</span><span class="cx">     setVideoFullscreenLayer(videoLayer);
</span><ins>+    [CATransaction commit];
</ins><span class="cx">     m_page-&gt;send(Messages::WebVideoFullscreenManagerProxy::EnterFullscreen(), m_page-&gt;pageID());
</span><span class="cx"> }
</span><span class="cx">     
</span></span></pre>
</div>
</div>

</body>
</html>