<!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>[195595] 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/195595">195595</a></dd>
<dt>Author</dt> <dd>adachan@apple.com</dd>
<dt>Date</dt> <dd>2016-01-26 10:35:36 -0800 (Tue, 26 Jan 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Enable API related to the video fullscreen layer in MediaPlayerPrivateAVFoundationObjC
also on Mac with video presentation mode support.
https://bugs.webkit.org/show_bug.cgi?id=153222

Reviewed by Eric Carlson.

No new tests. Covered by existing tests.

Introduce VideoFullscreenLayerManager to deal with the video layer when switching
between inline and fullscreen mode. We'll reuse it in other MediaPlayerPrivateInterface
implementations.

Now that MediaPlayerPrivateAVFoundationObjC's platform layer can be a WebVideoContainerLayer,
this exposes a bug in PlatformCALayerCocoa::clone() where we assumed the platform layer
is always an AVPlayerLayer if the PlatformCALayer's layer type is LayerTypeAVPlayerLayer.
Add a helper method to get an AVPlayerLayer from a PlatformCALayerCocoa (which also handles
WebVideoContainerLayer case) and use it in PlatformCALayerCocoa::clone().

* WebCore.xcodeproj/project.pbxproj:
Add VideoFullscreenLayerManager to the project.

* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::MediaPlayerPrivateAVFoundationObjC):
Create m_videoFullscreenLayerManager. The video inline layer, video fullscreen layer,
and the video fullscreen frame are now managed by that class.
(WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayerLayer):
Just call VideoFullscreenLayerManager::setVideoLayer() to handle adding the video
layer in either the inline or fullscreen layer.
(WebCore::MediaPlayerPrivateAVFoundationObjC::destroyVideoLayer):
Call VideoFullscreenLayerManager::didDestroyVideoLayer().
(WebCore::MediaPlayerPrivateAVFoundationObjC::platformLayer):
Get the video inline layer from VideoFullscreenLayerManager.
(WebCore::MediaPlayerPrivateAVFoundationObjC::setVideoFullscreenLayer):
Call VideoFullscreenLayerManager::setVideoFullscreenLayer().
(WebCore::MediaPlayerPrivateAVFoundationObjC::setVideoFullscreenFrame):
Call VideoFullscreenLayerManager::setVideoFullscreenFrame().
(WebCore::MediaPlayerPrivateAVFoundationObjC::setVideoFullscreenMode):
Guard the iOS specific code properly.
(WebCore::MediaPlayerPrivateAVFoundationObjC::updateVideoLayerGravity):
Get the video fullscreen layer from VideoFullscreenLayerManager.
(WebCore::MediaPlayerPrivateAVFoundationObjC::requiresTextTrackRepresentation):
Ditto.
(WebCore::MediaPlayerPrivateAVFoundationObjC::syncTextTrackBounds):
Get the video fullscreen layer and video fullscreen frame from VideoFullscreenLayerManager.
(WebCore::MediaPlayerPrivateAVFoundationObjC::setTextTrackRepresentation):
Get the video fullscreen layer from VideoFullscreenLayerManager.

* platform/graphics/avfoundation/objc/VideoFullscreenLayerManager.h: Added.
(WebCore::VideoFullscreenLayerManager::videoInlineLayer):
(WebCore::VideoFullscreenLayerManager::videoFullscreenLayer):
(WebCore::VideoFullscreenLayerManager::videoFullscreenFrame):
* platform/graphics/avfoundation/objc/VideoFullscreenLayerManager.mm: Added.
(-[WebVideoContainerLayer setBounds:]):
(-[WebVideoContainerLayer setPosition:]):
WebVideoContainerLayer was moved from MediaPlayerPrivateAVFoundationObjC.mm.
(WebCore::VideoFullscreenLayerManager::create):
(WebCore::VideoFullscreenLayerManager::VideoFullscreenLayerManager):
(WebCore::VideoFullscreenLayerManager::setVideoLayer):
Code moved from MediaPlayerPrivateAVFoundationObjC::createAVPlayerLayer().
(WebCore::VideoFullscreenLayerManager::setVideoFullscreenLayer):
Code moved from MediaPlayerPrivateAVFoundationObjC::setVideoFullscreenLayer().
(WebCore::VideoFullscreenLayerManager::setVideoFullscreenFrame):
Code moved from MediaPlayerPrivateAVFoundationObjC::setVideoFullscreenFrame().
(WebCore::VideoFullscreenLayerManager::didDestroyVideoLayer):
Code moved from MediaPlayerPrivateAVFoundationObjC::destroyVideoLayer().

* platform/graphics/ca/cocoa/PlatformCALayerCocoa.h:
* platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm:
(PlatformCALayerCocoa::clone):
Use the new PlatformCALayerCocoa::avPlayerLayer() method to get the AVPlayerLayer from both the
destination and source PlatformCALayers.
(PlatformCALayerCocoa::avPlayerLayer):
Return nil if the layer type is not LayerTypeAVPlayerLayer. Otherwise, return the
platform layer if it is indeed an AVPlayerLayer. If not, it should be a WebVideoContainerLayer
and we should return its sublayer which should be an AVPlayerLayer.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</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="#trunkSourceWebCoreplatformgraphicscacocoaPlatformCALayerCocoah">trunk/Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscacocoaPlatformCALayerCocoamm">trunk/Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreplatformgraphicsavfoundationobjcVideoFullscreenLayerManagerh">trunk/Source/WebCore/platform/graphics/avfoundation/objc/VideoFullscreenLayerManager.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsavfoundationobjcVideoFullscreenLayerManagermm">trunk/Source/WebCore/platform/graphics/avfoundation/objc/VideoFullscreenLayerManager.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (195594 => 195595)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-01-26 18:04:26 UTC (rev 195594)
+++ trunk/Source/WebCore/ChangeLog        2016-01-26 18:35:36 UTC (rev 195595)
</span><span class="lines">@@ -1,3 +1,82 @@
</span><ins>+2016-01-22  Ada Chan  &lt;adachan@apple.com&gt;
+
+        Enable API related to the video fullscreen layer in MediaPlayerPrivateAVFoundationObjC
+        also on Mac with video presentation mode support.
+        https://bugs.webkit.org/show_bug.cgi?id=153222
+
+        Reviewed by Eric Carlson.
+
+        No new tests. Covered by existing tests.
+
+        Introduce VideoFullscreenLayerManager to deal with the video layer when switching
+        between inline and fullscreen mode. We'll reuse it in other MediaPlayerPrivateInterface
+        implementations.
+
+        Now that MediaPlayerPrivateAVFoundationObjC's platform layer can be a WebVideoContainerLayer,
+        this exposes a bug in PlatformCALayerCocoa::clone() where we assumed the platform layer
+        is always an AVPlayerLayer if the PlatformCALayer's layer type is LayerTypeAVPlayerLayer.
+        Add a helper method to get an AVPlayerLayer from a PlatformCALayerCocoa (which also handles
+        WebVideoContainerLayer case) and use it in PlatformCALayerCocoa::clone().
+
+        * WebCore.xcodeproj/project.pbxproj:
+        Add VideoFullscreenLayerManager to the project.
+
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::MediaPlayerPrivateAVFoundationObjC):
+        Create m_videoFullscreenLayerManager. The video inline layer, video fullscreen layer,
+        and the video fullscreen frame are now managed by that class.
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayerLayer):
+        Just call VideoFullscreenLayerManager::setVideoLayer() to handle adding the video
+        layer in either the inline or fullscreen layer.
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::destroyVideoLayer):
+        Call VideoFullscreenLayerManager::didDestroyVideoLayer().
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::platformLayer):
+        Get the video inline layer from VideoFullscreenLayerManager.
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::setVideoFullscreenLayer):
+        Call VideoFullscreenLayerManager::setVideoFullscreenLayer().
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::setVideoFullscreenFrame):
+        Call VideoFullscreenLayerManager::setVideoFullscreenFrame().
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::setVideoFullscreenMode):
+        Guard the iOS specific code properly.
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::updateVideoLayerGravity):
+        Get the video fullscreen layer from VideoFullscreenLayerManager.
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::requiresTextTrackRepresentation):
+        Ditto.
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::syncTextTrackBounds):
+        Get the video fullscreen layer and video fullscreen frame from VideoFullscreenLayerManager.
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::setTextTrackRepresentation):
+        Get the video fullscreen layer from VideoFullscreenLayerManager.
+
+        * platform/graphics/avfoundation/objc/VideoFullscreenLayerManager.h: Added.
+        (WebCore::VideoFullscreenLayerManager::videoInlineLayer):
+        (WebCore::VideoFullscreenLayerManager::videoFullscreenLayer):
+        (WebCore::VideoFullscreenLayerManager::videoFullscreenFrame):
+        * platform/graphics/avfoundation/objc/VideoFullscreenLayerManager.mm: Added.
+        (-[WebVideoContainerLayer setBounds:]):
+        (-[WebVideoContainerLayer setPosition:]):
+        WebVideoContainerLayer was moved from MediaPlayerPrivateAVFoundationObjC.mm.
+        (WebCore::VideoFullscreenLayerManager::create):
+        (WebCore::VideoFullscreenLayerManager::VideoFullscreenLayerManager):
+        (WebCore::VideoFullscreenLayerManager::setVideoLayer):
+        Code moved from MediaPlayerPrivateAVFoundationObjC::createAVPlayerLayer().
+        (WebCore::VideoFullscreenLayerManager::setVideoFullscreenLayer):
+        Code moved from MediaPlayerPrivateAVFoundationObjC::setVideoFullscreenLayer().
+        (WebCore::VideoFullscreenLayerManager::setVideoFullscreenFrame):
+        Code moved from MediaPlayerPrivateAVFoundationObjC::setVideoFullscreenFrame().
+        (WebCore::VideoFullscreenLayerManager::didDestroyVideoLayer):
+        Code moved from MediaPlayerPrivateAVFoundationObjC::destroyVideoLayer().
+
+        * platform/graphics/ca/cocoa/PlatformCALayerCocoa.h:
+        * platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm:
+        (PlatformCALayerCocoa::clone):
+        Use the new PlatformCALayerCocoa::avPlayerLayer() method to get the AVPlayerLayer from both the
+        destination and source PlatformCALayers.
+        (PlatformCALayerCocoa::avPlayerLayer):
+        Return nil if the layer type is not LayerTypeAVPlayerLayer. Otherwise, return the
+        platform layer if it is indeed an AVPlayerLayer. If not, it should be a WebVideoContainerLayer
+        and we should return its sublayer which should be an AVPlayerLayer.
+
</ins><span class="cx"> 2016-01-26  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         First parameter to window.showModalDialog() should be mandatory
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (195594 => 195595)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-01-26 18:04:26 UTC (rev 195594)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-01-26 18:35:36 UTC (rev 195595)
</span><span class="lines">@@ -2273,6 +2273,7 @@
</span><span class="cx">                 52CCA9E815E3F64C0053C77F /* DOMDOMNamedFlowCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = 52CCA9E515E3F64C0053C77F /* DOMDOMNamedFlowCollection.h */; };
</span><span class="cx">                 52CCA9E915E3F64C0053C77F /* DOMDOMNamedFlowCollection.mm in Sources */ = {isa = PBXBuildFile; fileRef = 52CCA9E615E3F64C0053C77F /* DOMDOMNamedFlowCollection.mm */; };
</span><span class="cx">                 52CCA9EA15E3F64C0053C77F /* DOMDOMNamedFlowCollectionInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 52CCA9E715E3F64C0053C77F /* DOMDOMNamedFlowCollectionInternal.h */; };
</span><ins>+                52D5A18F1C54592300DE34A3 /* VideoFullscreenLayerManager.mm in Sources */ = {isa = PBXBuildFile; fileRef = 52D5A18D1C54590300DE34A3 /* VideoFullscreenLayerManager.mm */; };
</ins><span class="cx">                 52E2CAFC19FF0207001EEB4F /* MediaProducer.h in Headers */ = {isa = PBXBuildFile; fileRef = 52E2CAFB19FF0207001EEB4F /* MediaProducer.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 52F10865162B6DA4009AC81E /* MixedContentChecker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 52F10862162B6D82009AC81E /* MixedContentChecker.cpp */; };
</span><span class="cx">                 52F10866162B6DA8009AC81E /* MixedContentChecker.h in Headers */ = {isa = PBXBuildFile; fileRef = 52F10863162B6D82009AC81E /* MixedContentChecker.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="lines">@@ -9752,6 +9753,8 @@
</span><span class="cx">                 52CCA9E515E3F64C0053C77F /* DOMDOMNamedFlowCollection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMDOMNamedFlowCollection.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 52CCA9E615E3F64C0053C77F /* DOMDOMNamedFlowCollection.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMDOMNamedFlowCollection.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 52CCA9E715E3F64C0053C77F /* DOMDOMNamedFlowCollectionInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMDOMNamedFlowCollectionInternal.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                52D5A18D1C54590300DE34A3 /* VideoFullscreenLayerManager.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = VideoFullscreenLayerManager.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
+                52D5A18E1C54590300DE34A3 /* VideoFullscreenLayerManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VideoFullscreenLayerManager.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 52E2CAFB19FF0207001EEB4F /* MediaProducer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaProducer.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 52F10862162B6D82009AC81E /* MixedContentChecker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MixedContentChecker.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 52F10863162B6D82009AC81E /* MixedContentChecker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MixedContentChecker.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -22967,6 +22970,8 @@
</span><span class="cx">                                 7A29F57118C69514004D0F81 /* OutOfBandTextTrackPrivateAVF.h */,
</span><span class="cx">                                 CDC8B5A918047FF10016E685 /* SourceBufferPrivateAVFObjC.h */,
</span><span class="cx">                                 CDC8B5A818047FF10016E685 /* SourceBufferPrivateAVFObjC.mm */,
</span><ins>+                                52D5A18E1C54590300DE34A3 /* VideoFullscreenLayerManager.h */,
+                                52D5A18D1C54590300DE34A3 /* VideoFullscreenLayerManager.mm */,
</ins><span class="cx">                                 CD336F6517FA0AC600DDDCD0 /* VideoTrackPrivateAVFObjC.cpp */,
</span><span class="cx">                                 CD336F6617FA0AC600DDDCD0 /* VideoTrackPrivateAVFObjC.h */,
</span><span class="cx">                                 CD8B5A41180D149A008B8E65 /* VideoTrackPrivateMediaSourceAVFObjC.h */,
</span><span class="lines">@@ -31514,6 +31519,7 @@
</span><span class="cx">                                 2E3BBF071162DA1100B9409A /* UUID.cpp in Sources */,
</span><span class="cx">                                 F5A154271279534D00D0B0C0 /* ValidationMessage.cpp in Sources */,
</span><span class="cx">                                 FD3160AE12B026F700C1A359 /* VectorMath.cpp in Sources */,
</span><ins>+                                52D5A18F1C54592300DE34A3 /* VideoFullscreenLayerManager.mm in Sources */,
</ins><span class="cx">                                 CDE83DB1183C44060031EAA3 /* VideoPlaybackQuality.cpp in Sources */,
</span><span class="cx">                                 BE88E0DE1715D2A200658D98 /* VideoTrack.cpp in Sources */,
</span><span class="cx">                                 BE88E0E11715D2A200658D98 /* VideoTrackList.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsavfoundationobjcMediaPlayerPrivateAVFoundationObjCh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h (195594 => 195595)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h        2016-01-26 18:04:26 UTC (rev 195594)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h        2016-01-26 18:35:36 UTC (rev 195595)
</span><span class="lines">@@ -74,6 +74,10 @@
</span><span class="cx"> class VideoTrackPrivateAVFObjC;
</span><span class="cx"> class WebCoreAVFResourceLoader;
</span><span class="cx"> 
</span><ins>+#if PLATFORM(IOS) || (PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE))
+class VideoFullscreenLayerManager;
+#endif
+
</ins><span class="cx"> class MediaPlayerPrivateAVFoundationObjC : public MediaPlayerPrivateAVFoundation {
</span><span class="cx"> public:
</span><span class="cx">     explicit MediaPlayerPrivateAVFoundationObjC(MediaPlayer*);
</span><span class="lines">@@ -160,12 +164,14 @@
</span><span class="cx">     virtual void paint(GraphicsContext&amp;, const FloatRect&amp;) override;
</span><span class="cx">     virtual void paintCurrentFrameInContext(GraphicsContext&amp;, const FloatRect&amp;) override;
</span><span class="cx">     virtual PlatformLayer* platformLayer() const override;
</span><del>-#if PLATFORM(IOS)
</del><ins>+#if PLATFORM(IOS) || (PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE))
</ins><span class="cx">     virtual void setVideoFullscreenLayer(PlatformLayer*) override;
</span><span class="cx">     virtual void setVideoFullscreenFrame(FloatRect) override;
</span><span class="cx">     virtual void setVideoFullscreenGravity(MediaPlayer::VideoGravity) override;
</span><span class="cx">     virtual void setVideoFullscreenMode(MediaPlayer::VideoFullscreenMode) override;
</span><ins>+#endif
</ins><span class="cx"> 
</span><ins>+#if PLATFORM(IOS)
</ins><span class="cx">     virtual NSArray *timedMetadata() const override;
</span><span class="cx">     virtual String accessLog() const override;
</span><span class="cx">     virtual String errorLog() const override;
</span><span class="lines">@@ -315,10 +321,8 @@
</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><del>-#if PLATFORM(IOS)
-    RetainPtr&lt;PlatformLayer&gt; m_videoInlineLayer;
-    RetainPtr&lt;PlatformLayer&gt; m_videoFullscreenLayer;
-    FloatRect m_videoFullscreenFrame;
</del><ins>+#if PLATFORM(IOS) || (PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE))
+    std::unique_ptr&lt;VideoFullscreenLayerManager&gt; m_videoFullscreenLayerManager;
</ins><span class="cx">     MediaPlayer::VideoGravity m_videoFullscreenGravity;
</span><span class="cx">     RetainPtr&lt;PlatformLayer&gt; m_textTrackRepresentationLayer;
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsavfoundationobjcMediaPlayerPrivateAVFoundationObjCmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (195594 => 195595)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm        2016-01-26 18:04:26 UTC (rev 195594)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm        2016-01-26 18:35:36 UTC (rev 195595)
</span><span class="lines">@@ -85,6 +85,11 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #import &lt;AVFoundation/AVFoundation.h&gt;
</span><ins>+
+#if PLATFORM(IOS) || (PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE))
+#import &quot;VideoFullscreenLayerManager.h&quot;
+#endif
+
</ins><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx"> #import &quot;WAKAppKitStubs.h&quot;
</span><span class="cx"> #import &lt;CoreImage/CoreImage.h&gt;
</span><span class="lines">@@ -113,28 +118,6 @@
</span><span class="cx"> };
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-@interface WebVideoContainerLayer : CALayer
-@end
-
-@implementation WebVideoContainerLayer
-
-- (void)setBounds:(CGRect)bounds
-{
-    [super setBounds:bounds];
-    for (CALayer* layer in self.sublayers)
-        layer.frame = bounds;
-}
-
-- (void)setPosition:(CGPoint)position
-{
-    if (!CATransform3DIsIdentity(self.transform)) {
-        // Pre-apply the transform added in the WebProcess to fix &lt;rdar://problem/18316542&gt; to the position.
-        position = CGPointApplyAffineTransform(position, CATransform3DGetAffineTransform(self.transform));
-    }
-    [super setPosition:position];
-}
-@end
-
</del><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">@@ -474,7 +457,8 @@
</span><span class="cx"> MediaPlayerPrivateAVFoundationObjC::MediaPlayerPrivateAVFoundationObjC(MediaPlayer* player)
</span><span class="cx">     : MediaPlayerPrivateAVFoundation(player)
</span><span class="cx">     , m_weakPtrFactory(this)
</span><del>-#if PLATFORM(IOS)
</del><ins>+#if PLATFORM(IOS) || (PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE))
+    , m_videoFullscreenLayerManager(VideoFullscreenLayerManager::create())
</ins><span class="cx">     , m_videoFullscreenGravity(MediaPlayer::VideoGravityResizeAspect)
</span><span class="cx"> #endif
</span><span class="cx">     , m_objcObserver(adoptNS([[WebCoreAVFMovieObserver alloc] initWithCallback:this]))
</span><span class="lines">@@ -693,22 +677,13 @@
</span><span class="cx">     IntSize defaultSize = snappedIntRect(player()-&gt;client().mediaPlayerContentBoxRect()).size();
</span><span class="cx">     LOG(Media, &quot;MediaPlayerPrivateAVFoundationObjC::createVideoLayer(%p) - returning %p&quot;, this, m_videoLayer.get());
</span><span class="cx"> 
</span><ins>+#if PLATFORM(IOS) || (PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE))
+    m_videoFullscreenLayerManager-&gt;setVideoLayer(m_videoLayer.get(), defaultSize);
+
</ins><span class="cx"> #if PLATFORM(IOS)
</span><del>-    [m_videoLayer web_disableAllActions];
-    m_videoInlineLayer = adoptNS([[WebVideoContainerLayer alloc] init]);
-#ifndef NDEBUG
-    [m_videoInlineLayer setName:@&quot;WebVideoContainerLayer&quot;];
-#endif
-    [m_videoInlineLayer setFrame:CGRectMake(0, 0, defaultSize.width(), defaultSize.height())];
-    if (m_videoFullscreenLayer) {
-        [m_videoLayer setFrame:CGRectMake(0, 0, m_videoFullscreenFrame.width(), m_videoFullscreenFrame.height())];
-        [m_videoFullscreenLayer insertSublayer:m_videoLayer.get() atIndex:0];
-    } else {
-        [m_videoInlineLayer insertSublayer:m_videoLayer.get() atIndex:0];
-        [m_videoLayer setFrame:m_videoInlineLayer.get().bounds];
-    }
</del><span class="cx">     if ([m_videoLayer respondsToSelector:@selector(setPIPModeEnabled:)])
</span><span class="cx">         [m_videoLayer setPIPModeEnabled:(player()-&gt;fullscreenMode() &amp; MediaPlayer::VideoFullscreenModePictureInPicture)];
</span><ins>+#endif
</ins><span class="cx"> #else
</span><span class="cx">     [m_videoLayer setFrame:CGRectMake(0, 0, defaultSize.width(), defaultSize.height())];
</span><span class="cx"> #endif
</span><span class="lines">@@ -724,10 +699,8 @@
</span><span class="cx">     [m_videoLayer.get() removeObserver:m_objcObserver.get() forKeyPath:@&quot;readyForDisplay&quot;];
</span><span class="cx">     [m_videoLayer.get() setPlayer:nil];
</span><span class="cx"> 
</span><del>-#if PLATFORM(IOS)
-    if (m_videoFullscreenLayer)
-        [m_videoLayer removeFromSuperlayer];
-    m_videoInlineLayer = nil;
</del><ins>+#if PLATFORM(IOS) || (PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE))
+    m_videoFullscreenLayerManager-&gt;didDestroyVideoLayer();
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     m_videoLayer = nil;
</span><span class="lines">@@ -1114,49 +1087,24 @@
</span><span class="cx"> 
</span><span class="cx"> PlatformLayer* MediaPlayerPrivateAVFoundationObjC::platformLayer() const
</span><span class="cx"> {
</span><del>-#if PLATFORM(IOS)
-    return m_haveBeenAskedToCreateLayer ? m_videoInlineLayer.get() : nullptr;
</del><ins>+#if PLATFORM(IOS) || (PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE))
+    return m_haveBeenAskedToCreateLayer ? m_videoFullscreenLayerManager-&gt;videoInlineLayer() : nullptr;
</ins><span class="cx"> #else
</span><span class="cx">     return m_haveBeenAskedToCreateLayer ? m_videoLayer.get() : nullptr;
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-#if PLATFORM(IOS)
</del><ins>+#if PLATFORM(IOS) || (PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE))
</ins><span class="cx"> void MediaPlayerPrivateAVFoundationObjC::setVideoFullscreenLayer(PlatformLayer* videoFullscreenLayer)
</span><span class="cx"> {
</span><del>-    if (m_videoFullscreenLayer == videoFullscreenLayer)
</del><ins>+    if (m_videoFullscreenLayerManager-&gt;videoFullscreenLayer() == videoFullscreenLayer)
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    m_videoFullscreenLayer = videoFullscreenLayer;
</del><ins>+    m_videoFullscreenLayerManager-&gt;setVideoFullscreenLayer(videoFullscreenLayer);
</ins><span class="cx"> 
</span><del>-    [CATransaction begin];
-    [CATransaction setDisableActions:YES];
-    
-    CAContext *oldContext = [m_videoLayer context];
-    CAContext *newContext = nil;
-    
-    if (m_videoFullscreenLayer &amp;&amp; m_videoLayer) {
-        [m_videoFullscreenLayer insertSublayer:m_videoLayer.get() atIndex:0];
-        [m_videoLayer setFrame:CGRectMake(0, 0, m_videoFullscreenFrame.width(), m_videoFullscreenFrame.height())];
-        newContext = [m_videoFullscreenLayer context];
-    } 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];
-        newContext = [m_videoInlineLayer context];
-    } else if (m_videoLayer)
-        [m_videoLayer removeFromSuperlayer];
-
-    if (oldContext &amp;&amp; newContext &amp;&amp; oldContext != newContext) {
-        mach_port_t fencePort = [oldContext createFencePort];
-        [newContext setFencePort:fencePort];
-        mach_port_deallocate(mach_task_self(), fencePort);
-    }
-    [CATransaction commit];
-
-    if (m_videoFullscreenLayer &amp;&amp; m_textTrackRepresentationLayer) {
</del><ins>+    if (m_videoFullscreenLayerManager-&gt;videoFullscreenLayer() &amp;&amp; m_textTrackRepresentationLayer) {
</ins><span class="cx">         syncTextTrackBounds();
</span><del>-        [m_videoFullscreenLayer addSublayer:m_textTrackRepresentationLayer.get()];
</del><ins>+        [m_videoFullscreenLayerManager-&gt;videoFullscreenLayer() addSublayer:m_textTrackRepresentationLayer.get()];
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     updateDisableExternalPlayback();
</span><span class="lines">@@ -1164,13 +1112,7 @@
</span><span class="cx"> 
</span><span class="cx"> void MediaPlayerPrivateAVFoundationObjC::setVideoFullscreenFrame(FloatRect frame)
</span><span class="cx"> {
</span><del>-    m_videoFullscreenFrame = frame;
-    if (!m_videoFullscreenLayer)
-        return;
-
-    if (m_videoLayer) {
-        [m_videoLayer setFrame:CGRectMake(0, 0, frame.width(), frame.height())];
-    }
</del><ins>+    m_videoFullscreenLayerManager-&gt;setVideoFullscreenFrame(frame);
</ins><span class="cx">     syncTextTrackBounds();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -1199,10 +1141,17 @@
</span><span class="cx"> 
</span><span class="cx"> void MediaPlayerPrivateAVFoundationObjC::setVideoFullscreenMode(MediaPlayer::VideoFullscreenMode mode)
</span><span class="cx"> {
</span><ins>+#if PLATFORM(IOS)
</ins><span class="cx">     if (m_videoLayer &amp;&amp; [m_videoLayer respondsToSelector:@selector(setPIPModeEnabled:)])
</span><span class="cx">         [m_videoLayer setPIPModeEnabled:(mode &amp; MediaPlayer::VideoFullscreenModePictureInPicture)];
</span><ins>+#else
+    UNUSED_PARAM(mode);
+#endif
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#endif // PLATFORM(IOS) || (PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE))
+
+#if PLATFORM(IOS)
</ins><span class="cx"> NSArray *MediaPlayerPrivateAVFoundationObjC::timedMetadata() const
</span><span class="cx"> {
</span><span class="cx">     if (m_currentMetaData)
</span><span class="lines">@@ -1828,10 +1777,10 @@
</span><span class="cx">     if (!m_videoLayer)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-#if PLATFORM(IOS)
</del><ins>+#if PLATFORM(IOS) || (PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE))
</ins><span class="cx">     // Do not attempt to change the video gravity while in full screen mode.
</span><span class="cx">     // See setVideoFullscreenGravity().
</span><del>-    if (m_videoFullscreenLayer)
</del><ins>+    if (m_videoFullscreenLayerManager-&gt;videoFullscreenLayer())
</ins><span class="cx">         return;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="lines">@@ -2120,8 +2069,8 @@
</span><span class="cx"> 
</span><span class="cx"> bool MediaPlayerPrivateAVFoundationObjC::requiresTextTrackRepresentation() const
</span><span class="cx"> {
</span><del>-#if PLATFORM(IOS)
-    if (m_videoFullscreenLayer)
</del><ins>+#if PLATFORM(IOS) || (PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE))
+    if (m_videoFullscreenLayerManager-&gt;videoFullscreenLayer())
</ins><span class="cx">         return true;
</span><span class="cx"> #endif
</span><span class="cx">     return false;
</span><span class="lines">@@ -2129,18 +2078,19 @@
</span><span class="cx"> 
</span><span class="cx"> void MediaPlayerPrivateAVFoundationObjC::syncTextTrackBounds()
</span><span class="cx"> {
</span><del>-#if PLATFORM(IOS)
-    if (!m_videoFullscreenLayer || !m_textTrackRepresentationLayer)
</del><ins>+#if PLATFORM(IOS) || (PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE))
+    if (!m_videoFullscreenLayerManager-&gt;videoFullscreenLayer() || !m_textTrackRepresentationLayer)
</ins><span class="cx">         return;
</span><del>-    
-    CGRect textFrame = m_videoLayer ? [m_videoLayer videoRect] : CGRectMake(0, 0, m_videoFullscreenFrame.width(), m_videoFullscreenFrame.height());
</del><ins>+
+    FloatRect videoFullscreenFrame = m_videoFullscreenLayerManager-&gt;videoFullscreenFrame();
+    CGRect textFrame = m_videoLayer ? [m_videoLayer videoRect] : CGRectMake(0, 0, videoFullscreenFrame.width(), videoFullscreenFrame.height());
</ins><span class="cx">     [m_textTrackRepresentationLayer setFrame:textFrame];
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void MediaPlayerPrivateAVFoundationObjC::setTextTrackRepresentation(TextTrackRepresentation* representation)
</span><span class="cx"> {
</span><del>-#if PLATFORM(IOS)
</del><ins>+#if PLATFORM(IOS) || (PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE))
</ins><span class="cx">     PlatformLayer* representationLayer = representation ? representation-&gt;platformLayer() : nil;
</span><span class="cx">     if (representationLayer == m_textTrackRepresentationLayer) {
</span><span class="cx">         syncTextTrackBounds();
</span><span class="lines">@@ -2152,9 +2102,9 @@
</span><span class="cx"> 
</span><span class="cx">     m_textTrackRepresentationLayer = representationLayer;
</span><span class="cx"> 
</span><del>-    if (m_videoFullscreenLayer &amp;&amp; m_textTrackRepresentationLayer) {
</del><ins>+    if (m_videoFullscreenLayerManager-&gt;videoFullscreenLayer() &amp;&amp; m_textTrackRepresentationLayer) {
</ins><span class="cx">         syncTextTrackBounds();
</span><del>-        [m_videoFullscreenLayer addSublayer:m_textTrackRepresentationLayer.get()];
</del><ins>+        [m_videoFullscreenLayerManager-&gt;videoFullscreenLayer() addSublayer:m_textTrackRepresentationLayer.get()];
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx"> #else
</span><span class="lines">@@ -3142,7 +3092,7 @@
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS)
</span><del>-    [m_avPlayer setUsesExternalPlaybackWhileExternalScreenIsActive:m_videoFullscreenLayer != nil];
</del><ins>+    [m_avPlayer setUsesExternalPlaybackWhileExternalScreenIsActive:m_videoFullscreenLayerManager-&gt;videoFullscreenLayer() != nil];
</ins><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsavfoundationobjcVideoFullscreenLayerManagerh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/graphics/avfoundation/objc/VideoFullscreenLayerManager.h (0 => 195595)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/VideoFullscreenLayerManager.h                                (rev 0)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/VideoFullscreenLayerManager.h        2016-01-26 18:35:36 UTC (rev 195595)
</span><span class="lines">@@ -0,0 +1,64 @@
</span><ins>+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef VideoFullscreenLayerManager_h
+#define VideoFullscreenLayerManager_h
+
+#if PLATFORM(IOS) || (PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE))
+
+#include &quot;FloatRect.h&quot;
+#include &quot;IntSize.h&quot;
+#include &quot;PlatformLayer.h&quot;
+#include &lt;wtf/RetainPtr.h&gt;
+
+namespace WebCore {
+
+class VideoFullscreenLayerManager {
+    WTF_MAKE_NONCOPYABLE(VideoFullscreenLayerManager);
+public:
+    static std::unique_ptr&lt;VideoFullscreenLayerManager&gt; create();
+
+    PlatformLayer *videoInlineLayer() const { return m_videoInlineLayer.get(); }
+    PlatformLayer *videoFullscreenLayer() const { return m_videoFullscreenLayer.get(); }
+    FloatRect videoFullscreenFrame() const { return m_videoFullscreenFrame; }
+    void setVideoLayer(PlatformLayer *, IntSize contentSize);
+    void setVideoFullscreenLayer(PlatformLayer *);
+    void setVideoFullscreenFrame(FloatRect);
+    void didDestroyVideoLayer();
+
+private:
+    VideoFullscreenLayerManager();
+
+    RetainPtr&lt;PlatformLayer&gt; m_videoInlineLayer;
+    RetainPtr&lt;PlatformLayer&gt; m_videoFullscreenLayer;
+    RetainPtr&lt;PlatformLayer&gt; m_videoLayer;
+    FloatRect m_videoFullscreenFrame;
+};
+
+}
+
+#endif // PLATFORM(IOS) || (PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE))
+
+#endif /* VideoFullscreenLayerManager_h */
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsavfoundationobjcVideoFullscreenLayerManagermm"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/graphics/avfoundation/objc/VideoFullscreenLayerManager.mm (0 => 195595)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/VideoFullscreenLayerManager.mm                                (rev 0)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/VideoFullscreenLayerManager.mm        2016-01-26 18:35:36 UTC (rev 195595)
</span><span class="lines">@@ -0,0 +1,142 @@
</span><ins>+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import &quot;config.h&quot;
+#import &quot;VideoFullscreenLayerManager.h&quot;
+
+#if PLATFORM(IOS) || (PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE))
+
+#import &quot;QuartzCoreSPI.h&quot;
+#import &quot;WebCoreCALayerExtras.h&quot;
+#import &lt;mach/mach_init.h&gt;
+#import &lt;mach/mach_port.h&gt;
+
+@interface WebVideoContainerLayer : CALayer
+@end
+
+@implementation WebVideoContainerLayer
+
+- (void)setBounds:(CGRect)bounds
+{
+    [super setBounds:bounds];
+    for (CALayer* layer in self.sublayers)
+        layer.frame = bounds;
+}
+
+- (void)setPosition:(CGPoint)position
+{
+    if (!CATransform3DIsIdentity(self.transform)) {
+        // Pre-apply the transform added in the WebProcess to fix &lt;rdar://problem/18316542&gt; to the position.
+        position = CGPointApplyAffineTransform(position, CATransform3DGetAffineTransform(self.transform));
+    }
+    [super setPosition:position];
+}
+@end
+
+namespace WebCore {
+
+std::unique_ptr&lt;VideoFullscreenLayerManager&gt; VideoFullscreenLayerManager::create()
+{
+    return std::unique_ptr&lt;VideoFullscreenLayerManager&gt;(new VideoFullscreenLayerManager());
+}
+
+VideoFullscreenLayerManager::VideoFullscreenLayerManager()
+{
+}
+
+void VideoFullscreenLayerManager::setVideoLayer(PlatformLayer *videoLayer, IntSize contentSize)
+{
+    m_videoLayer = videoLayer;
+
+    [m_videoLayer web_disableAllActions];
+    m_videoInlineLayer = adoptNS([[WebVideoContainerLayer alloc] init]);
+#ifndef NDEBUG
+    [m_videoInlineLayer setName:@&quot;WebVideoContainerLayer&quot;];
+#endif
+    [m_videoInlineLayer setFrame:CGRectMake(0, 0, contentSize.width(), contentSize.height())];
+    if (m_videoFullscreenLayer) {
+        [m_videoLayer setFrame:CGRectMake(0, 0, m_videoFullscreenFrame.width(), m_videoFullscreenFrame.height())];
+        [m_videoFullscreenLayer insertSublayer:m_videoLayer.get() atIndex:0];
+    } else {
+        [m_videoInlineLayer insertSublayer:m_videoLayer.get() atIndex:0];
+        [m_videoLayer setFrame:m_videoInlineLayer.get().bounds];
+    }
+}
+
+void VideoFullscreenLayerManager::setVideoFullscreenLayer(PlatformLayer *videoFullscreenLayer)
+{
+    if (m_videoFullscreenLayer == videoFullscreenLayer)
+        return;
+
+    m_videoFullscreenLayer = videoFullscreenLayer;
+
+    [CATransaction begin];
+    [CATransaction setDisableActions:YES];
+
+    CAContext *oldContext = [m_videoLayer context];
+    CAContext *newContext = nil;
+
+    if (m_videoFullscreenLayer &amp;&amp; m_videoLayer) {
+        [m_videoFullscreenLayer insertSublayer:m_videoLayer.get() atIndex:0];
+        [m_videoLayer setFrame:CGRectMake(0, 0, m_videoFullscreenFrame.width(), m_videoFullscreenFrame.height())];
+        newContext = [m_videoFullscreenLayer context];
+    } 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];
+        newContext = [m_videoInlineLayer context];
+    } else if (m_videoLayer)
+        [m_videoLayer removeFromSuperlayer];
+
+    if (oldContext &amp;&amp; newContext &amp;&amp; oldContext != newContext) {
+        mach_port_t fencePort = [oldContext createFencePort];
+        [newContext setFencePort:fencePort];
+        mach_port_deallocate(mach_task_self(), fencePort);
+    }
+    [CATransaction commit];
+}
+
+void VideoFullscreenLayerManager::setVideoFullscreenFrame(FloatRect videoFullscreenFrame)
+{
+    m_videoFullscreenFrame = videoFullscreenFrame;
+    if (!m_videoFullscreenLayer)
+        return;
+
+    if (m_videoLayer)
+        [m_videoLayer setFrame:CGRectMake(0, 0, videoFullscreenFrame.width(), videoFullscreenFrame.height())];
+}
+
+void VideoFullscreenLayerManager::didDestroyVideoLayer()
+{
+    if (m_videoFullscreenLayer)
+        [m_videoLayer removeFromSuperlayer];
+
+    m_videoInlineLayer = nil;
+    m_videoLayer = nil;
+}
+
+}
+
+#endif // PLATFORM(IOS) || (PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE))
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscacocoaPlatformCALayerCocoah"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.h (195594 => 195595)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.h        2016-01-26 18:04:26 UTC (rev 195594)
+++ trunk/Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.h        2016-01-26 18:35:36 UTC (rev 195595)
</span><span class="lines">@@ -173,6 +173,8 @@
</span><span class="cx"> 
</span><span class="cx">     bool requiresCustomAppearanceUpdateOnBoundsChange() const;
</span><span class="cx"> 
</span><ins>+    AVPlayerLayer *avPlayerLayer() const;
+
</ins><span class="cx">     RetainPtr&lt;NSObject&gt; m_delegate;
</span><span class="cx">     std::unique_ptr&lt;PlatformCALayerList&gt; m_customSublayers;
</span><span class="cx">     GraphicsLayer::CustomAppearance m_customAppearance;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscacocoaPlatformCALayerCocoamm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm (195594 => 195595)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm        2016-01-26 18:04:26 UTC (rev 195594)
+++ trunk/Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm        2016-01-26 18:35:36 UTC (rev 195595)
</span><span class="lines">@@ -361,10 +361,11 @@
</span><span class="cx"> 
</span><span class="cx">     if (type == LayerTypeAVPlayerLayer) {
</span><span class="cx">         ASSERT([newLayer-&gt;platformLayer() isKindOfClass:getAVPlayerLayerClass()]);
</span><del>-        ASSERT([platformLayer() isKindOfClass:getAVPlayerLayerClass()]);
</del><span class="cx"> 
</span><del>-        AVPlayerLayer* destinationPlayerLayer = static_cast&lt;AVPlayerLayer *&gt;(newLayer-&gt;platformLayer());
-        AVPlayerLayer* sourcePlayerLayer = static_cast&lt;AVPlayerLayer *&gt;(platformLayer());
</del><ins>+        AVPlayerLayer *destinationPlayerLayer = static_cast&lt;PlatformCALayerCocoa *&gt;(newLayer.get())-&gt;avPlayerLayer();
+        AVPlayerLayer *sourcePlayerLayer = avPlayerLayer();
+        ASSERT(sourcePlayerLayer);
+
</ins><span class="cx">         dispatch_async(dispatch_get_main_queue(), ^{
</span><span class="cx">             [destinationPlayerLayer setPlayer:[sourcePlayerLayer player]];
</span><span class="cx">         });
</span><span class="lines">@@ -1110,3 +1111,21 @@
</span><span class="cx"> {
</span><span class="cx">     wkCALayerEnumerateRectsBeingDrawnWithBlock(m_layer.get(), context, block);
</span><span class="cx"> }
</span><ins>+
+AVPlayerLayer *PlatformCALayerCocoa::avPlayerLayer() const
+{
+    if (layerType() != LayerTypeAVPlayerLayer)
+        return nil;
+
+    if ([platformLayer() isKindOfClass:getAVPlayerLayerClass()])
+        return static_cast&lt;AVPlayerLayer *&gt;(platformLayer());
+
+    if ([platformLayer() isKindOfClass:objc_getClass(&quot;WebVideoContainerLayer&quot;)]) {
+        ASSERT([platformLayer() sublayers].count == 1);
+        ASSERT([[platformLayer() sublayers][0] isKindOfClass:getAVPlayerLayerClass()]);
+        return static_cast&lt;AVPlayerLayer *&gt;([platformLayer() sublayers][0]);
+    }
+
+    ASSERT_NOT_REACHED();
+    return nil;
+}
</ins></span></pre>
</div>
</div>

</body>
</html>