<!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>[165344] 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/165344">165344</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2014-03-08 18:16:11 -0800 (Sat, 08 Mar 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Allow media element to supply the video layer after fullscreen transition has already begun.
https://bugs.webkit.org/show_bug.cgi?id=129870

Patch by Jeremy Jones &lt;jeremyj@apple.com&gt; on 2014-03-08
Reviewed by Eric Carlson.

Source/WebCore:

Instead of borrowing the videolayer from the HTMLMediaElement, WebVideoFullscreen now supplies a layer to HTMLMediaElement to fill in as needed and at the appropriate time.

This allows fullscreen even if the video layer hasn't yet been created. And in the future it allows MediaPlayer to supply other layers such as closed captions.

* WebCore.exp.in:
Remove exports related to borrowing and lend the video layer.
Add exports for supplying a layer to fullscreen and keepying the frame and gravity properties in sync.

* html/HTMLMediaElement.cpp:
Remove the concept of borrowing the platform layer.
Add the concept of a supplied m_videoFullscreenLayer, into which the media player can add layers.
When the m_videoFullscreenFrame is supplied, don't show the video layer inline any more.
Stash video layer properties in case the media player is not yet created.

(WebCore::HTMLMediaElement::HTMLMediaElement):
Initialize gravity to the default. Remove m_platformLayerBorrowed.

(WebCore::HTMLMediaElement::platformLayer):
When we have a m_videoFullscreenLayer, don't show video inline.

(WebCore::HTMLMediaElement::setVideoFullscreenLayer):
Pass along the m_videoFullscreenLayer to the MediaPlayer if available or just stash it for later.

(WebCore::HTMLMediaElement::createMediaPlayer):
Pass along video fullscreen properties that we may have accumulated before the MediaPlayer was created.

(WebCore::HTMLMediaElement::setVideoFullscreenGravity):
Stash the gravity property, pass it along to the media player if possible.

* html/HTMLMediaElement.h:
Remove concept of borrowing the video layer. Add properties for a supplied videoFullscreenLayer.

* platform/graphics/MediaPlayer.cpp:
(WebCore::MediaPlayer::setVideoFullscreenLayer):
Forward on to internal implementation.

(WebCore::MediaPlayer::setVideoFullscreenFrame):
Forward on to internal implementation.

(WebCore::MediaPlayer::setVideoFullscreenGravity):
Forward on to internal implementation.

* platform/graphics/MediaPlayer.h:
Add methods for video fullscreen Layer, Frame and Gravity.

* platform/graphics/MediaPlayerPrivate.h:
(WebCore::MediaPlayerPrivateInterface::setVideoFullscreenLayer):
Add default implementation.

(WebCore::MediaPlayerPrivateInterface::setVideoFullscreenFrame):
Add default implementation.

(WebCore::MediaPlayerPrivateInterface::setVideoFullscreenGravity):
Add default implementation.

* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
Add support for fullscreen video layer, frame and gravity.

* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::MediaPlayerPrivateAVFoundationObjC):
Init m_videoFullscreenGravity.

(WebCore::MediaPlayerPrivateAVFoundationObjC::createVideoLayer):
Apply cached properties once video layer is created and add to the fullscreen layer.

(WebCore::MediaPlayerPrivateAVFoundationObjC::setVideoFullscreenLayer):
Cache the property value. Add video layer right away available.

(WebCore::MediaPlayerPrivateAVFoundationObjC::setVideoFullscreenFrame):
Cache the property value. Apply to video layer right away if available.

(WebCore::MediaPlayerPrivateAVFoundationObjC::setVideoFullscreenGravity):
Cache the property value. Apply to video layer right away if available.

* platform/ios/WebVideoFullscreenControllerAVKit.mm:
Supply a fullscreen video layer to the WebVideoFullscreenModel and to the WebVideoFullscreenInterface.

(-[WebVideoFullscreenController enterFullscreen:]):
Supply a fullscreen video layer to the WebVideoFullscreenModel and to the WebVideoFullscreenInterface.

(-[WebVideoFullscreenController didExitFullscreen]):
Clean up the videoFullscreenLayer.

* platform/ios/WebVideoFullscreenInterface.h:
Remove methods related to lending the video layer.

* platform/ios/WebVideoFullscreenInterfaceAVKit.h:
Rename WebAVPlayer layer to WebAVVideoLayer to match the AVKit name.
Remove functions related to lending the video layer.
Supply a layer directly to enterFullscreen.

* platform/ios/WebVideoFullscreenInterfaceAVKit.mm:
(+[WebAVVideoLayer videoLayer]):
Rename WebAVPlayer layer to WebAVVideoLayer to match the AVKit name.

(-[WebAVVideoLayer setPlayerController:]):
Store the AVPlayerController to prevent AVKit's default behavior.

(-[WebAVVideoLayer setBounds:]):
Forward this onto the WebVideoFullscreenModel

(-[WebAVVideoLayer setVideoLayerGravity:]):
Forward this onto the WebVideoFullscreenModel

(-[WebAVVideoLayer videoLayerGravity]):
Forward this onto the WebVideoFullscreenModel

(WebVideoFullscreenInterfaceAVKit::enterFullscreen):
Supply a video layer directly instead of relying on one being previously loaned.

(WebVideoFullscreenInterfaceAVKit::exitFullscreen):
Clean-up now assumes there is a video layer.

* platform/ios/WebVideoFullscreenModel.h:
Remove methods for borrowing and returning video layers.
Add methods for keeping video layer state in sync.

* platform/ios/WebVideoFullscreenModelMediaElement.h:
Remove methods for borrowing and returning video layers.
Add method for supplying a video fullscreen layer.
Add methods for keeping video layer state in sync.

* platform/ios/WebVideoFullscreenModelMediaElement.mm:
(WebVideoFullscreenModelMediaElement::setMediaElement):
Handle audio element case by setting hasVideo to false.

(WebVideoFullscreenModelMediaElement::setVideoFullscreenLayer):
Pass along the video fullscreen layer to the media element.

(WebVideoFullscreenModelMediaElement::setVideoLayerFrame):
Pass along the video layer frame to the media element.

(WebVideoFullscreenModelMediaElement::setVideoLayerGravity):
Pass along the video layer gravity to the media element.

Source/WebKit2:

WebVideoFullscreenManager and WebVideoFullscreenManagerProxy do their own remote hosting of the video layer instead of needing the video layer to have already been hosted elsewhere. This allows the removal of the coordination with WebPageProxy via a RemoteLayerTreeTransaction.

* Shared/mac/RemoteLayerTreeTransaction.h:
Remove m_videoLayerIDsPendingFullscreen and accessors.

* Shared/mac/RemoteLayerTreeTransaction.mm:
(WebKit::RemoteLayerTreeTransaction::encode):
Don't encode m_videoLayerIDsPendingFullscreen

(WebKit::RemoteLayerTreeTransaction::decode):
Don't decode m_videoLayerIDsPendingFullscreen

* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::didCommitLayerTree):
Don't forward didCommitLayerTree to m_videoFullscreenManager.

* UIProcess/ios/WebVideoFullscreenManagerProxy.h:
Remove code for synchronizing with the RenderTree.
Add a hosting layer and methods to keep video layer frame and video gravity synchronized.

* UIProcess/ios/WebVideoFullscreenManagerProxy.messages.in:
Change IPC interface to fascilitate rehosting video layer with a instead of coordinating with the RenderTree by PlatformLayerID.

* UIProcess/ios/WebVideoFullscreenManagerProxy.mm:
(WebKit::WebVideoFullscreenManagerProxy::WebVideoFullscreenManagerProxy):
Remove initialization for removed members.

(WebKit::WebVideoFullscreenManagerProxy::enterFullscreenWithID):
Rehost the video layer by id and pass on the layer.
This replaces didCommitLayerTree() and  willLendVideoLayerWithID().

(WebKit::WebVideoFullscreenManagerProxy::didExitFullscreen):
Cleanup the hosting layer.

(WebKit::WebVideoFullscreenManagerProxy::setVideoLayerFrame):
Forward on the video layer's frame to keep the hosted layer in sync with the interface.

(WebKit::WebVideoFullscreenManagerProxy::setVideoLayerGravity):
Forward the videolayer gravity.

* WebKit2.xcodeproj/project.pbxproj:
Rename WebVideoFullscreenManager.cpp to WebVideoFullscreenManager.mm

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::willCommitLayerTree):
Don't invovle the m_videoFullscreenManager in layer tree transactions.

* WebProcess/ios/WebVideoFullscreenManager.h:
Remove code that synchronizes with the render tree via RemoteLayerTreeTransaction.
Instead rehost the video layer directly.
Instead of hoping the WebVideoFullscreenModel has a videoLayer, supply one into which
it can add whatever it likes as needed.

* WebProcess/ios/WebVideoFullscreenManager.messages.in:
No more explicit borrowing and returning video layers.
Add functions to keep video layer bounds and gravity in sync with the UI.

* WebProcess/ios/WebVideoFullscreenManager.mm: Renamed from Source/WebKit2/WebProcess/ios/WebVideoFullscreenManager.cpp.
Removed code for synchronizing via RemoteLAyerTreeTransaction.

(WebKit::WebVideoFullscreenManager::WebVideoFullscreenManager):
Remove initialization for removed memeber m_sendUnparentVideoLayerTransaction.

(WebKit::WebVideoFullscreenManager::enterFullscreenForNode):
Creates a fullscreen layer, gives it to the WebVideoFullscreenModel to fill in,
and hosts it in a context to send to the UIProcess.

(WebKit::WebVideoFullscreenManager::exitFullscreenForNode):
remove enterFullscreen() and just directly send the IPC message.

(WebKit::WebVideoFullscreenManager::didExitFullscreen):
Clean up the hosting context.

(WebKit::WebVideoFullscreenManager::setVideoLayerGravityEnum):
Forward on the video gravity. Type convert from unsigned to MediaPlayer::VideoGravity.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCoreexpin">trunk/Source/WebCore/WebCore.exp.in</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLMediaElementcpp">trunk/Source/WebCore/html/HTMLMediaElement.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLMediaElementh">trunk/Source/WebCore/html/HTMLMediaElement.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsMediaPlayercpp">trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsMediaPlayerh">trunk/Source/WebCore/platform/graphics/MediaPlayer.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsMediaPlayerPrivateh">trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h</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="#trunkSourceWebCoreplatformiosWebVideoFullscreenControllerAVKitmm">trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformiosWebVideoFullscreenInterfaceh">trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterface.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>
<li><a href="#trunkSourceWebCoreplatformiosWebVideoFullscreenModelh">trunk/Source/WebCore/platform/ios/WebVideoFullscreenModel.h</a></li>
<li><a href="#trunkSourceWebCoreplatformiosWebVideoFullscreenModelMediaElementh">trunk/Source/WebCore/platform/ios/WebVideoFullscreenModelMediaElement.h</a></li>
<li><a href="#trunkSourceWebCoreplatformiosWebVideoFullscreenModelMediaElementmm">trunk/Source/WebCore/platform/ios/WebVideoFullscreenModelMediaElement.mm</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2SharedmacRemoteLayerTreeTransactionh">trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosWebPageProxyIOSmm">trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosWebVideoFullscreenManagerProxyh">trunk/Source/WebKit2/UIProcess/ios/WebVideoFullscreenManagerProxy.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosWebVideoFullscreenManagerProxymessagesin">trunk/Source/WebKit2/UIProcess/ios/WebVideoFullscreenManagerProxy.messages.in</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosWebVideoFullscreenManagerProxymm">trunk/Source/WebKit2/UIProcess/ios/WebVideoFullscreenManagerProxy.mm</a></li>
<li><a href="#trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj">trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageWebPagecpp">trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessiosWebVideoFullscreenManagerh">trunk/Source/WebKit2/WebProcess/ios/WebVideoFullscreenManager.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessiosWebVideoFullscreenManagermessagesin">trunk/Source/WebKit2/WebProcess/ios/WebVideoFullscreenManager.messages.in</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2WebProcessiosWebVideoFullscreenManagermm">trunk/Source/WebKit2/WebProcess/ios/WebVideoFullscreenManager.mm</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2WebProcessiosWebVideoFullscreenManagercpp">trunk/Source/WebKit2/WebProcess/ios/WebVideoFullscreenManager.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (165343 => 165344)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-03-09 01:47:09 UTC (rev 165343)
+++ trunk/Source/WebCore/ChangeLog        2014-03-09 02:16:11 UTC (rev 165344)
</span><span class="lines">@@ -1,3 +1,145 @@
</span><ins>+2014-03-08  Jeremy Jones  &lt;jeremyj@apple.com&gt;
+
+        Allow media element to supply the video layer after fullscreen transition has already begun.
+        https://bugs.webkit.org/show_bug.cgi?id=129870
+
+        Reviewed by Eric Carlson.
+
+        Instead of borrowing the videolayer from the HTMLMediaElement, WebVideoFullscreen now supplies a layer to HTMLMediaElement to fill in as needed and at the appropriate time.
+
+        This allows fullscreen even if the video layer hasn't yet been created. And in the future it allows MediaPlayer to supply other layers such as closed captions. 
+
+        * WebCore.exp.in:
+        Remove exports related to borrowing and lend the video layer.
+        Add exports for supplying a layer to fullscreen and keepying the frame and gravity properties in sync.
+
+        * html/HTMLMediaElement.cpp:
+        Remove the concept of borrowing the platform layer.
+        Add the concept of a supplied m_videoFullscreenLayer, into which the media player can add layers.
+        When the m_videoFullscreenFrame is supplied, don't show the video layer inline any more.
+        Stash video layer properties in case the media player is not yet created.
+
+        (WebCore::HTMLMediaElement::HTMLMediaElement):
+        Initialize gravity to the default. Remove m_platformLayerBorrowed.
+
+        (WebCore::HTMLMediaElement::platformLayer):
+        When we have a m_videoFullscreenLayer, don't show video inline.
+
+        (WebCore::HTMLMediaElement::setVideoFullscreenLayer):
+        Pass along the m_videoFullscreenLayer to the MediaPlayer if available or just stash it for later.
+
+        (WebCore::HTMLMediaElement::createMediaPlayer):
+        Pass along video fullscreen properties that we may have accumulated before the MediaPlayer was created.
+
+        (WebCore::HTMLMediaElement::setVideoFullscreenGravity):
+        Stash the gravity property, pass it along to the media player if possible.
+
+        * html/HTMLMediaElement.h:
+        Remove concept of borrowing the video layer. Add properties for a supplied videoFullscreenLayer.
+
+        * platform/graphics/MediaPlayer.cpp:
+        (WebCore::MediaPlayer::setVideoFullscreenLayer):
+        Forward on to internal implementation.
+
+        (WebCore::MediaPlayer::setVideoFullscreenFrame):
+        Forward on to internal implementation.
+
+        (WebCore::MediaPlayer::setVideoFullscreenGravity):
+        Forward on to internal implementation.
+
+        * platform/graphics/MediaPlayer.h:
+        Add methods for video fullscreen Layer, Frame and Gravity.
+
+        * platform/graphics/MediaPlayerPrivate.h:
+        (WebCore::MediaPlayerPrivateInterface::setVideoFullscreenLayer):
+        Add default implementation.
+
+        (WebCore::MediaPlayerPrivateInterface::setVideoFullscreenFrame):
+        Add default implementation.
+        
+        (WebCore::MediaPlayerPrivateInterface::setVideoFullscreenGravity):
+        Add default implementation.
+        
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
+        Add support for fullscreen video layer, frame and gravity.
+
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::MediaPlayerPrivateAVFoundationObjC):
+        Init m_videoFullscreenGravity. 
+
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::createVideoLayer):
+        Apply cached properties once video layer is created and add to the fullscreen layer.
+
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::setVideoFullscreenLayer):
+        Cache the property value. Add video layer right away available.
+
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::setVideoFullscreenFrame):
+        Cache the property value. Apply to video layer right away if available.
+
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::setVideoFullscreenGravity):
+        Cache the property value. Apply to video layer right away if available.
+
+        * platform/ios/WebVideoFullscreenControllerAVKit.mm:
+        Supply a fullscreen video layer to the WebVideoFullscreenModel and to the WebVideoFullscreenInterface.
+
+        (-[WebVideoFullscreenController enterFullscreen:]):
+        Supply a fullscreen video layer to the WebVideoFullscreenModel and to the WebVideoFullscreenInterface.
+
+        (-[WebVideoFullscreenController didExitFullscreen]):
+        Clean up the videoFullscreenLayer.
+
+        * platform/ios/WebVideoFullscreenInterface.h:
+        Remove methods related to lending the video layer.
+
+        * platform/ios/WebVideoFullscreenInterfaceAVKit.h:
+        Rename WebAVPlayer layer to WebAVVideoLayer to match the AVKit name.
+        Remove functions related to lending the video layer.
+        Supply a layer directly to enterFullscreen.
+
+        * platform/ios/WebVideoFullscreenInterfaceAVKit.mm:
+        (+[WebAVVideoLayer videoLayer]):
+        Rename WebAVPlayer layer to WebAVVideoLayer to match the AVKit name.
+
+        (-[WebAVVideoLayer setPlayerController:]):
+        Store the AVPlayerController to prevent AVKit's default behavior.
+
+        (-[WebAVVideoLayer setBounds:]):
+        Forward this onto the WebVideoFullscreenModel
+
+        (-[WebAVVideoLayer setVideoLayerGravity:]):
+        Forward this onto the WebVideoFullscreenModel
+
+        (-[WebAVVideoLayer videoLayerGravity]):
+        Forward this onto the WebVideoFullscreenModel
+
+        (WebVideoFullscreenInterfaceAVKit::enterFullscreen):
+        Supply a video layer directly instead of relying on one being previously loaned.
+
+        (WebVideoFullscreenInterfaceAVKit::exitFullscreen):
+        Clean-up now assumes there is a video layer.
+
+        * platform/ios/WebVideoFullscreenModel.h:
+        Remove methods for borrowing and returning video layers.
+        Add methods for keeping video layer state in sync.
+
+        * platform/ios/WebVideoFullscreenModelMediaElement.h:
+        Remove methods for borrowing and returning video layers.
+        Add method for supplying a video fullscreen layer.
+        Add methods for keeping video layer state in sync.
+
+        * platform/ios/WebVideoFullscreenModelMediaElement.mm:
+        (WebVideoFullscreenModelMediaElement::setMediaElement):
+        Handle audio element case by setting hasVideo to false.
+
+        (WebVideoFullscreenModelMediaElement::setVideoFullscreenLayer):
+        Pass along the video fullscreen layer to the media element.
+
+        (WebVideoFullscreenModelMediaElement::setVideoLayerFrame):
+        Pass along the video layer frame to the media element.
+
+        (WebVideoFullscreenModelMediaElement::setVideoLayerGravity):
+        Pass along the video layer gravity to the media element.
+
</ins><span class="cx"> 2014-03-08  Jae Hyun Park  &lt;jaepark@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Clean up PlatformLayer.h
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCoreexpin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.exp.in (165343 => 165344)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.exp.in        2014-03-09 01:47:09 UTC (rev 165343)
+++ trunk/Source/WebCore/WebCore.exp.in        2014-03-09 02:16:11 UTC (rev 165344)
</span><span class="lines">@@ -3209,10 +3209,8 @@
</span><span class="cx"> __ZN7WebCore32WebVideoFullscreenInterfaceAVKit11setDurationEd
</span><span class="cx"> __ZN7WebCore32WebVideoFullscreenInterfaceAVKit14exitFullscreenEv
</span><span class="cx"> __ZN7WebCore32WebVideoFullscreenInterfaceAVKit14setCurrentTimeEdd
</span><del>-__ZN7WebCore32WebVideoFullscreenInterfaceAVKit15enterFullscreenEv
-__ZN7WebCore32WebVideoFullscreenInterfaceAVKit17didLendVideoLayerEv
</del><ins>+__ZN7WebCore32WebVideoFullscreenInterfaceAVKit15enterFullscreenER7CALayer
</ins><span class="cx"> __ZN7WebCore32WebVideoFullscreenInterfaceAVKit18setVideoDimensionsEbff
</span><del>-__ZN7WebCore32WebVideoFullscreenInterfaceAVKit18willLendVideoLayerEP7CALayer
</del><span class="cx"> __ZN7WebCore32WebVideoFullscreenInterfaceAVKit26setWebVideoFullscreenModelEPNS_23WebVideoFullscreenModelE
</span><span class="cx"> __ZN7WebCore32WebVideoFullscreenInterfaceAVKit35setWebVideoFullscreenChangeObserverEPNS_32WebVideoFullscreenChangeObserverE
</span><span class="cx"> __ZN7WebCore32WebVideoFullscreenInterfaceAVKit7setRateEbf
</span><span class="lines">@@ -3221,9 +3219,10 @@
</span><span class="cx"> __ZN7WebCore35WebVideoFullscreenModelMediaElement11handleEventEPNS_22ScriptExecutionContextEPNS_5EventE
</span><span class="cx"> __ZN7WebCore35WebVideoFullscreenModelMediaElement15setMediaElementEPNS_16HTMLMediaElementE
</span><span class="cx"> __ZN7WebCore35WebVideoFullscreenModelMediaElement15togglePlayStateEv
</span><del>-__ZN7WebCore35WebVideoFullscreenModelMediaElement16borrowVideoLayerEv
-__ZN7WebCore35WebVideoFullscreenModelMediaElement16returnVideoLayerEv
</del><ins>+__ZN7WebCore35WebVideoFullscreenModelMediaElement18setVideoLayerFrameENS_9FloatRectE
+__ZN7WebCore35WebVideoFullscreenModelMediaElement20setVideoLayerGravityENS_23WebVideoFullscreenModel12VideoGravityE
</ins><span class="cx"> __ZN7WebCore35WebVideoFullscreenModelMediaElement21requestExitFullscreenEv
</span><ins>+__ZN7WebCore35WebVideoFullscreenModelMediaElement23setVideoFullscreenLayerEP7CALayer
</ins><span class="cx"> __ZN7WebCore35WebVideoFullscreenModelMediaElement4playEv
</span><span class="cx"> __ZN7WebCore35WebVideoFullscreenModelMediaElement5pauseEv
</span><span class="cx"> __ZN7WebCore35WebVideoFullscreenModelMediaElementC2Ev
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLMediaElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (165343 => 165344)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLMediaElement.cpp        2014-03-09 01:47:09 UTC (rev 165343)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp        2014-03-09 02:16:11 UTC (rev 165344)
</span><span class="lines">@@ -276,6 +276,9 @@
</span><span class="cx">     , m_clockTimeAtLastUpdateEvent(0)
</span><span class="cx">     , m_lastTimeUpdateEventMovieTime(std::numeric_limits&lt;double&gt;::max())
</span><span class="cx">     , m_loadState(WaitingForSource)
</span><ins>+#if PLATFORM(IOS)
+    , m_videoFullscreenGravity(MediaPlayer::VideoGravityResizeAspect)
+#endif
</ins><span class="cx"> #if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
</span><span class="cx">     , m_proxyWidget(0)
</span><span class="cx"> #endif
</span><span class="lines">@@ -319,7 +322,6 @@
</span><span class="cx"> #endif
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">     , m_requestingPlay(false)
</span><del>-    , m_platformLayerBorrowed(false)
</del><span class="cx"> #endif
</span><span class="cx"> #if ENABLE(VIDEO_TRACK)
</span><span class="cx">     , m_tracksAreReady(true)
</span><span class="lines">@@ -4947,29 +4949,35 @@
</span><span class="cx"> PlatformLayer* HTMLMediaElement::platformLayer() const
</span><span class="cx"> {
</span><span class="cx"> #if PLATFORM(IOS)
</span><del>-    if (m_platformLayerBorrowed)
</del><ins>+    if (m_videoFullscreenLayer)
</ins><span class="cx">         return nullptr;
</span><span class="cx"> #endif
</span><span class="cx">     return m_player ? m_player-&gt;platformLayer() : nullptr;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS)
</span><del>-PlatformLayer* HTMLMediaElement::borrowPlatformLayer()
</del><ins>+void HTMLMediaElement::setVideoFullscreenLayer(PlatformLayer* platformLayer)
</ins><span class="cx"> {
</span><del>-    ASSERT(!m_platformLayerBorrowed);
-    m_platformLayerBorrowed = true;
-    if (renderer())
-        renderer()-&gt;updateFromElement();
-    return m_player ? m_player-&gt;platformLayer() : nullptr;
</del><ins>+    m_videoFullscreenLayer = platformLayer;
+    if (!m_player)
+        return;
+    
+    m_player-&gt;setVideoFullscreenLayer(platformLayer);
+    setNeedsStyleRecalc(SyntheticStyleChange);
</ins><span class="cx"> }
</span><ins>+    
+void HTMLMediaElement::setVideoFullscreenFrame(FloatRect frame)
+{
+    m_videoFullscreenFrame = frame;
+    if (m_player)
+        m_player-&gt;setVideoFullscreenFrame(frame);
+}
</ins><span class="cx"> 
</span><del>-void HTMLMediaElement::returnPlatformLayer(PlatformLayer* platformLayer)
</del><ins>+void HTMLMediaElement::setVideoFullscreenGravity(MediaPlayer::VideoGravity gravity)
</ins><span class="cx"> {
</span><del>-    ASSERT_UNUSED(platformLayer, platformLayer == (m_player ? m_player-&gt;platformLayer() : nullptr));
-    ASSERT(m_platformLayerBorrowed);
-    m_platformLayerBorrowed = false;
-    if (renderer())
-        renderer()-&gt;updateFromElement();
</del><ins>+    m_videoFullscreenGravity = gravity;
+    if (m_player)
+        m_player-&gt;setVideoFullscreenGravity(gravity);
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="lines">@@ -5349,6 +5357,12 @@
</span><span class="cx">         enqueuePlaybackTargetAvailabilityChangedEvent(); // Ensure the event listener gets at least one event.
</span><span class="cx">     }
</span><span class="cx"> #endif
</span><ins>+    
+#if PLATFORM(IOS)
+    m_player-&gt;setVideoFullscreenFrame(m_videoFullscreenFrame);
+    m_player-&gt;setVideoFullscreenGravity(m_videoFullscreenGravity);
+    m_player-&gt;setVideoFullscreenLayer(m_videoFullscreenLayer.get());
+#endif
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(WEB_AUDIO)
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLMediaElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (165343 => 165344)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLMediaElement.h        2014-03-09 01:47:09 UTC (rev 165343)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h        2014-03-09 02:16:11 UTC (rev 165344)
</span><span class="lines">@@ -134,8 +134,9 @@
</span><span class="cx">     PlatformMedia platformMedia() const;
</span><span class="cx">     PlatformLayer* platformLayer() const;
</span><span class="cx"> #if PLATFORM(IOS)
</span><del>-    PlatformLayer* borrowPlatformLayer();
-    void returnPlatformLayer(PlatformLayer*);
</del><ins>+    void setVideoFullscreenLayer(PlatformLayer*);
+    void setVideoFullscreenFrame(FloatRect);
+    void setVideoFullscreenGravity(MediaPlayer::VideoGravity);
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     enum DelayedActionType {
</span><span class="lines">@@ -728,6 +729,12 @@
</span><span class="cx">     RefPtr&lt;HTMLSourceElement&gt; m_currentSourceNode;
</span><span class="cx">     RefPtr&lt;Node&gt; m_nextChildNodeToConsider;
</span><span class="cx"> 
</span><ins>+#if PLATFORM(IOS)
+    RetainPtr&lt;PlatformLayer&gt; m_videoFullscreenLayer;
+    FloatRect m_videoFullscreenFrame;
+    MediaPlayer::VideoGravity m_videoFullscreenGravity;
+#endif
+
</ins><span class="cx">     OwnPtr&lt;MediaPlayer&gt; m_player;
</span><span class="cx"> #if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
</span><span class="cx">     RefPtr&lt;Widget&gt; m_proxyWidget;
</span><span class="lines">@@ -796,7 +803,6 @@
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">     bool m_requestingPlay : 1;
</span><del>-    bool m_platformLayerBorrowed : 1;
</del><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(VIDEO_TRACK)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsMediaPlayercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp (165343 => 165344)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp        2014-03-09 01:47:09 UTC (rev 165343)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp        2014-03-09 02:16:11 UTC (rev 165344)
</span><span class="lines">@@ -624,7 +624,24 @@
</span><span class="cx"> {
</span><span class="cx">     return m_private-&gt;platformLayer();
</span><span class="cx"> }
</span><ins>+    
+#if PLATFORM(IOS)
+void MediaPlayer::setVideoFullscreenLayer(PlatformLayer* layer)
+{
+    m_private-&gt;setVideoFullscreenLayer(layer);
+}
</ins><span class="cx"> 
</span><ins>+void MediaPlayer::setVideoFullscreenFrame(FloatRect frame)
+{
+    m_private-&gt;setVideoFullscreenFrame(frame);
+}
+
+void MediaPlayer::setVideoFullscreenGravity(MediaPlayer::VideoGravity gravity)
+{
+    m_private-&gt;setVideoFullscreenGravity(gravity);
+}
+#endif
+
</ins><span class="cx"> MediaPlayer::NetworkState MediaPlayer::networkState()
</span><span class="cx"> {
</span><span class="cx">     return m_private-&gt;networkState();
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsMediaPlayerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/MediaPlayer.h (165343 => 165344)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/MediaPlayer.h        2014-03-09 01:47:09 UTC (rev 165343)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayer.h        2014-03-09 02:16:11 UTC (rev 165344)
</span><span class="lines">@@ -300,7 +300,12 @@
</span><span class="cx">     bool requiresImmediateCompositing() const;
</span><span class="cx">     PlatformMedia platformMedia() const;
</span><span class="cx">     PlatformLayer* platformLayer() const;
</span><del>-
</del><ins>+#if PLATFORM(IOS)
+    void setVideoFullscreenLayer(PlatformLayer*);
+    void setVideoFullscreenFrame(FloatRect);
+    enum VideoGravity { VideoGravityResize, VideoGravityResizeAspect, VideoGravityResizeAspectFill };
+    void setVideoFullscreenGravity(VideoGravity);
+#endif
</ins><span class="cx">     IntSize naturalSize();
</span><span class="cx">     bool hasVideo() const;
</span><span class="cx">     bool hasAudio() const;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsMediaPlayerPrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h (165343 => 165344)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h        2014-03-09 01:47:09 UTC (rev 165343)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h        2014-03-09 02:16:11 UTC (rev 165344)
</span><span class="lines">@@ -54,7 +54,11 @@
</span><span class="cx">     virtual void prepareToPlay() { }
</span><span class="cx">     virtual PlatformMedia platformMedia() const { return NoPlatformMedia; }
</span><span class="cx">     virtual PlatformLayer* platformLayer() const { return 0; }
</span><del>-
</del><ins>+#if PLATFORM(IOS)
+    virtual void setVideoFullscreenLayer(PlatformLayer*) { }
+    virtual void setVideoFullscreenFrame(FloatRect) { }
+    virtual void setVideoFullscreenGravity(MediaPlayer::VideoGravity) { }
+#endif
</ins><span class="cx">     virtual void play() = 0;
</span><span class="cx">     virtual void pause() = 0;    
</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 (165343 => 165344)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h        2014-03-09 01:47:09 UTC (rev 165343)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h        2014-03-09 02:16:11 UTC (rev 165344)
</span><span class="lines">@@ -148,6 +148,11 @@
</span><span class="cx">     virtual void paint(GraphicsContext*, const IntRect&amp;);
</span><span class="cx">     virtual void paintCurrentFrameInContext(GraphicsContext*, const IntRect&amp;);
</span><span class="cx">     virtual PlatformLayer* platformLayer() const;
</span><ins>+#if PLATFORM(IOS)
+    virtual void setVideoFullscreenLayer(PlatformLayer*);
+    virtual void setVideoFullscreenFrame(FloatRect);
+    virtual void setVideoFullscreenGravity(MediaPlayer::VideoGravity);
+#endif
</ins><span class="cx">     virtual bool supportsAcceleratedRendering() const { return true; }
</span><span class="cx">     virtual float mediaTimeForTimeValue(float) const;
</span><span class="cx">     virtual double maximumDurationToCacheMediaTime() const { return 5; }
</span><span class="lines">@@ -245,6 +250,11 @@
</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>+#if PLATFORM(IOS)
+    RetainPtr&lt;PlatformLayer&gt; m_videoFullscreenLayer;
+    FloatRect m_videoFullscreenFrame;
+    MediaPlayer::VideoGravity m_videoFullscreenGravity;
+#endif
</ins><span class="cx">     RetainPtr&lt;WebCoreAVFMovieObserver&gt; m_objcObserver;
</span><span class="cx">     RetainPtr&lt;id&gt; m_timeObserver;
</span><span class="cx">     mutable String m_languageOfPrimaryAudioTrack;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsavfoundationobjcMediaPlayerPrivateAVFoundationObjCmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (165343 => 165344)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm        2014-03-09 01:47:09 UTC (rev 165343)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm        2014-03-09 02:16:11 UTC (rev 165344)
</span><span class="lines">@@ -135,6 +135,7 @@
</span><span class="cx"> SOFT_LINK_POINTER(AVFoundation, AVAssetImageGeneratorApertureModeCleanAperture, NSString *)
</span><span class="cx"> SOFT_LINK_POINTER(AVFoundation, AVURLAssetReferenceRestrictionsKey, NSString *)
</span><span class="cx"> SOFT_LINK_POINTER(AVFoundation, AVLayerVideoGravityResizeAspect, NSString *)
</span><ins>+SOFT_LINK_POINTER(AVFoundation, AVLayerVideoGravityResizeAspectFill, NSString *)
</ins><span class="cx"> SOFT_LINK_POINTER(AVFoundation, AVLayerVideoGravityResize, NSString *)
</span><span class="cx"> SOFT_LINK_POINTER(CoreVideo, kCVPixelBufferPixelFormatTypeKey, NSString *)
</span><span class="cx"> 
</span><span class="lines">@@ -155,6 +156,7 @@
</span><span class="cx"> #define AVAssetImageGeneratorApertureModeCleanAperture getAVAssetImageGeneratorApertureModeCleanAperture()
</span><span class="cx"> #define AVURLAssetReferenceRestrictionsKey getAVURLAssetReferenceRestrictionsKey()
</span><span class="cx"> #define AVLayerVideoGravityResizeAspect getAVLayerVideoGravityResizeAspect()
</span><ins>+#define AVLayerVideoGravityResizeAspectFill getAVLayerVideoGravityResizeAspectFill()
</ins><span class="cx"> #define AVLayerVideoGravityResize getAVLayerVideoGravityResize()
</span><span class="cx"> #define kCVPixelBufferPixelFormatTypeKey getkCVPixelBufferPixelFormatTypeKey()
</span><span class="cx"> 
</span><span class="lines">@@ -313,6 +315,9 @@
</span><span class="cx"> MediaPlayerPrivateAVFoundationObjC::MediaPlayerPrivateAVFoundationObjC(MediaPlayer* player)
</span><span class="cx">     : MediaPlayerPrivateAVFoundation(player)
</span><span class="cx">     , m_weakPtrFactory(this)
</span><ins>+#if PLATFORM(IOS)
+    , m_videoFullscreenGravity(MediaPlayer::VideoGravityResizeAspect)
+#endif
</ins><span class="cx">     , m_objcObserver(adoptNS([[WebCoreAVFMovieObserver alloc] initWithCallback:this]))
</span><span class="cx">     , m_videoFrameHasDrawn(false)
</span><span class="cx">     , m_haveCheckedPlayability(false)
</span><span class="lines">@@ -494,6 +499,12 @@
</span><span class="cx">         updateVideoLayerGravity();
</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)
+        if (m_videoFullscreenLayer) {
+            [m_videoLayer setFrame:CGRectMake(0, 0, m_videoFullscreenFrame.width(), m_videoFullscreenFrame.height())];
+            [m_videoFullscreenLayer addSublayer:m_videoLayer.get()];
+        }
+#endif
</ins><span class="cx">         player()-&gt;mediaPlayerClient()-&gt;mediaPlayerRenderingModeChanged(player());
</span><span class="cx">     });
</span><span class="cx"> }
</span><span class="lines">@@ -755,6 +766,53 @@
</span><span class="cx">     return m_videoLayer.get();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#if PLATFORM(IOS)
+void MediaPlayerPrivateAVFoundationObjC::setVideoFullscreenLayer(PlatformLayer* videoFullscreenLayer)
+{
+    if (m_videoFullscreenLayer == videoFullscreenLayer)
+        return;
+
+    if (m_videoFullscreenLayer)
+       [m_videoLayer removeFromSuperlayer];
+
+    m_videoFullscreenLayer = videoFullscreenLayer;
+
+    if (!m_videoFullscreenLayer || !m_videoLayer)
+        return;
+
+    [m_videoLayer setFrame:CGRectMake(0, 0, m_videoFullscreenFrame.width(), m_videoFullscreenFrame.height())];
+    [m_videoFullscreenLayer addSublayer:m_videoLayer.get()];
+}
+
+void MediaPlayerPrivateAVFoundationObjC::setVideoFullscreenFrame(FloatRect frame)
+{
+    m_videoFullscreenFrame = frame;
+    if (!m_videoFullscreenLayer || !m_videoLayer)
+        return;
+    
+    [m_videoLayer setFrame:CGRectMake(0, 0, frame.width(), frame.height())];
+}
+
+void MediaPlayerPrivateAVFoundationObjC::setVideoFullscreenGravity(MediaPlayer::VideoGravity gravity)
+{
+    m_videoFullscreenGravity = gravity;
+    if (!m_videoLayer)
+        return;
+
+    NSString *videoGravity = AVLayerVideoGravityResizeAspect;
+    if (gravity == MediaPlayer::VideoGravityResize)
+        videoGravity = AVLayerVideoGravityResize;
+    else if (gravity == MediaPlayer::VideoGravityResizeAspect)
+        videoGravity = AVLayerVideoGravityResizeAspect;
+    else if (gravity == MediaPlayer::VideoGravityResizeAspectFill)
+        videoGravity = AVLayerVideoGravityResizeAspectFill;
+    else
+        ASSERT_NOT_REACHED();
+
+    [m_videoLayer setVideoGravity:videoGravity];
+}
+#endif
+
</ins><span class="cx"> void MediaPlayerPrivateAVFoundationObjC::platformSetVisible(bool isVisible)
</span><span class="cx"> {
</span><span class="cx">     [CATransaction begin];
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformiosWebVideoFullscreenControllerAVKitmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm (165343 => 165344)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm        2014-03-09 01:47:09 UTC (rev 165343)
+++ trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm        2014-03-09 02:16:11 UTC (rev 165344)
</span><span class="lines">@@ -32,6 +32,7 @@
</span><span class="cx"> #import &quot;Logging.h&quot;
</span><span class="cx"> #import &quot;WebVideoFullscreenInterfaceAVKit.h&quot;
</span><span class="cx"> #import &quot;WebVideoFullscreenModelMediaElement.h&quot;
</span><ins>+#import &lt;QuartzCore/CoreAnimation.h&gt;
</ins><span class="cx"> #import &lt;WebCore/WebCoreThreadRun.h&gt;
</span><span class="cx"> 
</span><span class="cx"> using namespace WebCore;
</span><span class="lines">@@ -55,6 +56,7 @@
</span><span class="cx">     RefPtr&lt;WebVideoFullscreenInterfaceAVKit&gt; _interface;
</span><span class="cx">     RefPtr&lt;WebVideoFullscreenModelMediaElement&gt; _model;
</span><span class="cx">     WebVideoFullscreenControllerChangeObserver _changeObserver;
</span><ins>+    RetainPtr&lt;PlatformLayer&gt; _videoFullscreenLayer;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (instancetype)init
</span><span class="lines">@@ -88,13 +90,15 @@
</span><span class="cx">     [self retain]; // Balanced by -release in didExitFullscreen:
</span><span class="cx">     
</span><span class="cx">     UNUSED_PARAM(screen);
</span><ins>+    _videoFullscreenLayer = [CALayer layer];
</ins><span class="cx">     _interface = adoptRef(new WebVideoFullscreenInterfaceAVKit);
</span><span class="cx">     _interface-&gt;setWebVideoFullscreenChangeObserver(&amp;_changeObserver);
</span><span class="cx">     _model = adoptRef(new WebVideoFullscreenModelMediaElement);
</span><span class="cx">     _model-&gt;setWebVideoFullscreenInterface(_interface.get());
</span><span class="cx">     _interface-&gt;setWebVideoFullscreenModel(_model.get());
</span><span class="cx">     _model-&gt;setMediaElement(_mediaElement.get());
</span><del>-    _interface-&gt;enterFullscreen();
</del><ins>+    _model-&gt;setVideoFullscreenLayer(_videoFullscreenLayer.get());
+    _interface-&gt;enterFullscreen(*_videoFullscreenLayer.get());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)exitFullscreen
</span><span class="lines">@@ -109,10 +113,11 @@
</span><span class="cx"> - (void)didExitFullscreen
</span><span class="cx"> {
</span><span class="cx">     WebThreadRun(^{
</span><ins>+        _interface-&gt;setWebVideoFullscreenModel(nullptr);
+        _model-&gt;setWebVideoFullscreenInterface(nullptr);
+        _model-&gt;setVideoFullscreenLayer(nullptr);
</ins><span class="cx">         _model-&gt;setMediaElement(nullptr);
</span><del>-        _interface-&gt;setWebVideoFullscreenModel(nullptr);
</del><span class="cx">         _interface-&gt;setWebVideoFullscreenChangeObserver(nullptr);
</span><del>-        _model-&gt;setWebVideoFullscreenInterface(nullptr);
</del><span class="cx">         _model = nullptr;
</span><span class="cx">         _interface = nullptr;
</span><span class="cx">         
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformiosWebVideoFullscreenInterfaceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterface.h (165343 => 165344)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterface.h        2014-03-09 01:47:09 UTC (rev 165343)
+++ trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterface.h        2014-03-09 02:16:11 UTC (rev 165344)
</span><span class="lines">@@ -40,8 +40,6 @@
</span><span class="cx">     virtual void setCurrentTime(double currentTime, double anchorTime) = 0;
</span><span class="cx">     virtual void setRate(bool isPlaying, float playbackRate) = 0;
</span><span class="cx">     virtual void setVideoDimensions(bool hasVideo, float width, float height) = 0;
</span><del>-    virtual void willLendVideoLayer(PlatformLayer*) = 0;
-    virtual void didLendVideoLayer() = 0;
</del><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformiosWebVideoFullscreenInterfaceAVKith"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.h (165343 => 165344)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.h        2014-03-09 01:47:09 UTC (rev 165343)
+++ trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.h        2014-03-09 02:16:11 UTC (rev 165344)
</span><span class="lines">@@ -41,7 +41,7 @@
</span><span class="cx"> OBJC_CLASS UIViewController;
</span><span class="cx"> OBJC_CLASS UIWindow;
</span><span class="cx"> OBJC_CLASS CALayer;
</span><del>-OBJC_CLASS WebAVPlayerLayer;
</del><ins>+OBJC_CLASS WebAVVideoLayer;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> class WebVideoFullscreenModel;
</span><span class="lines">@@ -62,7 +62,7 @@
</span><span class="cx">     RetainPtr&lt;UIViewController&gt; m_viewController;
</span><span class="cx">     RetainPtr&lt;UIWindow&gt; m_window;
</span><span class="cx">     RetainPtr&lt;CALayer&gt; m_videoLayer;
</span><del>-    RetainPtr&lt;WebAVPlayerLayer&gt; m_videoLayerContainer;
</del><ins>+    RetainPtr&lt;WebAVVideoLayer&gt; m_videoLayerContainer;
</ins><span class="cx">     WebVideoFullscreenModel* m_videoFullscreenModel;
</span><span class="cx">     WebVideoFullscreenChangeObserver* m_fullscreenChangeObserver;
</span><span class="cx">         
</span><span class="lines">@@ -81,10 +81,7 @@
</span><span class="cx">     virtual void setRate(bool isPlaying, float playbackRate) override;
</span><span class="cx">     virtual void setVideoDimensions(bool hasVideo, float width, float height) override;
</span><span class="cx"> 
</span><del>-    virtual void willLendVideoLayer(PlatformLayer*) override;
-    virtual void didLendVideoLayer() override;
-
-    virtual void enterFullscreen();
</del><ins>+    virtual void enterFullscreen(PlatformLayer&amp;);
</ins><span class="cx">     virtual void exitFullscreen();
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformiosWebVideoFullscreenInterfaceAVKitmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.mm (165343 => 165344)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.mm        2014-03-09 01:47:09 UTC (rev 165343)
+++ trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.mm        2014-03-09 02:16:11 UTC (rev 165344)
</span><span class="lines">@@ -31,18 +31,18 @@
</span><span class="cx"> #import &quot;WebVideoFullscreenInterfaceAVKit.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #import &quot;Logging.h&quot;
</span><ins>+#import &quot;WebVideoFullscreenModel.h&quot;
+#import &lt;AVKit/AVKit.h&gt;
+#import &lt;AVKit/AVPlayerController.h&gt;
+#import &lt;AVKit/AVPlayerViewController_Private.h&gt;
+#import &lt;AVKit/AVPlayerViewController_WebKitOnly.h&gt;
+#import &lt;AVKit/AVValueTiming.h&gt;
+#import &lt;AVKit/AVVideoLayer.h&gt;
</ins><span class="cx"> #import &lt;CoreMedia/CMTime.h&gt;
</span><span class="cx"> #import &lt;UIKit/UIKit.h&gt;
</span><span class="cx"> #import &lt;WebCore/SoftLinking.h&gt;
</span><span class="cx"> #import &lt;WebCore/WebCoreThreadRun.h&gt;
</span><span class="cx"> #import &lt;wtf/RetainPtr.h&gt;
</span><del>-#import &quot;WebVideoFullscreenModel.h&quot;
-#import &lt;AVKit/AVKit.h&gt;
-#import &lt;AVKit/AVPlayerController.h&gt;
-#import &lt;AVKit/AVPlayerViewController_WebKitOnly.h&gt;
-#import &lt;AVKit/AVVideoLayer.h&gt;
-#import &lt;AVKit/AVValueTiming.h&gt;
-#import &lt;AVKit/AVPlayerViewController_Private.h&gt;
</del><span class="cx"> 
</span><span class="cx"> using namespace WebCore;
</span><span class="cx"> 
</span><span class="lines">@@ -176,25 +176,63 @@
</span><span class="cx"> 
</span><span class="cx"> @end
</span><span class="cx"> 
</span><del>-@interface WebAVPlayerLayer : CALayer &lt;AVVideoLayer&gt;
-+(WebAVPlayerLayer *)playerLayer;
</del><ins>+@interface WebAVVideoLayer : CALayer &lt;AVVideoLayer&gt;
++(WebAVVideoLayer *)videoLayer;
</ins><span class="cx"> @property (nonatomic) AVVideoLayerGravity videoLayerGravity;
</span><span class="cx"> @property (nonatomic, getter = isReadyForDisplay) BOOL readyForDisplay;
</span><span class="cx"> @property (nonatomic) CGRect videoRect;
</span><span class="cx"> - (void)setPlayerController:(AVPlayerController *)playerController;
</span><span class="cx"> @end
</span><span class="cx"> 
</span><del>-@implementation WebAVPlayerLayer
-+(WebAVPlayerLayer *)playerLayer
</del><ins>+@implementation WebAVVideoLayer
</ins><span class="cx"> {
</span><del>-    return [[[WebAVPlayerLayer alloc] init] autorelease];
</del><ins>+    RetainPtr&lt;WebAVPlayerController&gt; _avPlayerController;
+    AVVideoLayerGravity _videoLayerGravity;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>++(WebAVVideoLayer *)videoLayer
+{
+    return [[[WebAVVideoLayer alloc] init] autorelease];
+}
+
</ins><span class="cx"> - (void)setPlayerController:(AVPlayerController *)playerController
</span><span class="cx"> {
</span><del>-    UNUSED_PARAM(playerController);
</del><ins>+    ASSERT(!playerController || [playerController isKindOfClass:[WebAVPlayerController class]]);
+    _avPlayerController = (WebAVPlayerController *)playerController;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (void)setBounds:(CGRect)bounds
+{
+    [super setBounds:bounds];
+    if ([_avPlayerController delegate])
+        [_avPlayerController delegate]-&gt;setVideoLayerFrame(FloatRect(0, 0, bounds.size.width, bounds.size.height));
+}
+
+- (void)setVideoLayerGravity:(AVVideoLayerGravity)videoLayerGravity
+{
+    _videoLayerGravity = videoLayerGravity;
+    
+    if (![_avPlayerController delegate])
+        return;
+
+    WebCore::WebVideoFullscreenModel::VideoGravity gravity = WebCore::WebVideoFullscreenModel::VideoGravityResizeAspect;
+    if (videoLayerGravity == AVVideoLayerGravityResize)
+        gravity = WebCore::WebVideoFullscreenModel::VideoGravityResize;
+    if (videoLayerGravity == AVVideoLayerGravityResizeAspect)
+        gravity = WebCore::WebVideoFullscreenModel::VideoGravityResizeAspect;
+    else if (videoLayerGravity == AVVideoLayerGravityResizeAspectFill)
+        gravity = WebCore::WebVideoFullscreenModel::VideoGravityResizeAspectFill;
+    else
+        ASSERT_NOT_REACHED();
+    
+    [_avPlayerController delegate]-&gt;setVideoLayerGravity(gravity);
+}
+
+- (AVVideoLayerGravity)videoLayerGravity
+{
+    return _videoLayerGravity;
+}
+
</ins><span class="cx"> @end
</span><span class="cx"> 
</span><span class="cx"> WebVideoFullscreenInterfaceAVKit::WebVideoFullscreenInterfaceAVKit()
</span><span class="lines">@@ -273,21 +311,17 @@
</span><span class="cx">     playerController().contentDimensions = CGSizeMake(width, height);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebVideoFullscreenInterfaceAVKit::enterFullscreen()
</del><ins>+void WebVideoFullscreenInterfaceAVKit::enterFullscreen(PlatformLayer&amp; videoLayer)
</ins><span class="cx"> {
</span><del>-    m_videoFullscreenModel-&gt;borrowVideoLayer();
-}
-
-void WebVideoFullscreenInterfaceAVKit::doEnterFullscreen()
-{
</del><span class="cx">     __block RefPtr&lt;WebVideoFullscreenInterfaceAVKit&gt; protect(this);
</span><span class="cx">     
</span><ins>+    m_videoLayer = &amp;videoLayer;
+    
</ins><span class="cx">     dispatch_async(dispatch_get_main_queue(), ^{
</span><span class="cx">         [m_videoLayer removeFromSuperlayer];
</span><span class="cx">         
</span><del>-        m_videoLayerContainer = [WebAVPlayerLayer playerLayer];
-        if (m_videoLayer.get())
-            [m_videoLayerContainer addSublayer:m_videoLayer.get()];
</del><ins>+        m_videoLayerContainer = [WebAVVideoLayer videoLayer];
+        [m_videoLayerContainer addSublayer:m_videoLayer.get()];
</ins><span class="cx">         
</span><span class="cx">         CGSize videoSize = playerController().contentDimensions;
</span><span class="cx">         CGRect videoRect = CGRectMake(0, 0, videoSize.width, videoSize.height);
</span><span class="lines">@@ -315,21 +349,6 @@
</span><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebVideoFullscreenInterfaceAVKit::willLendVideoLayer(PlatformLayer* videoLayer)
-{
-    ASSERT(!m_videoLayer);
-    
-    m_videoLayer = videoLayer;
-    if (!videoLayer)
-        doEnterFullscreen();
-}
-
-void WebVideoFullscreenInterfaceAVKit::didLendVideoLayer()
-{
-    if (m_videoLayer)
-        doEnterFullscreen();
-}
-
</del><span class="cx"> void WebVideoFullscreenInterfaceAVKit::exitFullscreen()
</span><span class="cx"> {
</span><span class="cx">     __block RefPtr&lt;WebVideoFullscreenInterfaceAVKit&gt; protect(this);
</span><span class="lines">@@ -343,12 +362,11 @@
</span><span class="cx">             m_playerViewController = nil;
</span><span class="cx">             m_viewController = nil;
</span><span class="cx">             m_window = nil;
</span><del>-            if (m_videoLayer.get())
-            {
-                [m_videoLayer removeFromSuperlayer];
-                m_videoFullscreenModel-&gt;returnVideoLayer();
-                m_videoLayer = nil;
-            }
</del><ins>+            [m_videoLayer removeFromSuperlayer];
+            m_videoLayer = nil;
+            [m_videoLayerContainer removeFromSuperlayer];
+            m_videoLayerContainer = nil;
+
</ins><span class="cx">             if (m_fullscreenChangeObserver)
</span><span class="cx">                 m_fullscreenChangeObserver-&gt;didExitFullscreen();
</span><span class="cx">             protect.clear();
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformiosWebVideoFullscreenModelh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/WebVideoFullscreenModel.h (165343 => 165344)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/WebVideoFullscreenModel.h        2014-03-09 01:47:09 UTC (rev 165343)
+++ trunk/Source/WebCore/platform/ios/WebVideoFullscreenModel.h        2014-03-09 02:16:11 UTC (rev 165344)
</span><span class="lines">@@ -29,18 +29,21 @@
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx"> 
</span><ins>+#include &lt;WebCore/FloatRect.h&gt;
+
</ins><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="cx"> class WebVideoFullscreenModel {
</span><span class="cx"> public:
</span><span class="cx">     virtual ~WebVideoFullscreenModel() { };
</span><del>-    virtual void borrowVideoLayer() = 0;
-    virtual void returnVideoLayer() = 0;
</del><span class="cx">     virtual void play() = 0;
</span><span class="cx">     virtual void pause() = 0;
</span><span class="cx">     virtual void togglePlayState() = 0;
</span><span class="cx">     virtual void seekToTime(double time) = 0;
</span><span class="cx">     virtual void requestExitFullscreen() = 0;
</span><ins>+    virtual void setVideoLayerFrame(FloatRect) = 0;
+    enum VideoGravity { VideoGravityResize, VideoGravityResizeAspect, VideoGravityResizeAspectFill };
+    virtual void setVideoLayerGravity(VideoGravity) = 0;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformiosWebVideoFullscreenModelMediaElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/WebVideoFullscreenModelMediaElement.h (165343 => 165344)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/WebVideoFullscreenModelMediaElement.h        2014-03-09 01:47:09 UTC (rev 165343)
+++ trunk/Source/WebCore/platform/ios/WebVideoFullscreenModelMediaElement.h        2014-03-09 02:16:11 UTC (rev 165344)
</span><span class="lines">@@ -30,6 +30,7 @@
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx"> 
</span><span class="cx"> #include &lt;WebCore/EventListener.h&gt;
</span><ins>+#include &lt;WebCore/FloatRect.h&gt;
</ins><span class="cx"> #include &lt;WebCore/PlatformLayer.h&gt;
</span><span class="cx"> #include &lt;WebCore/WebVideoFullscreenModel.h&gt;
</span><span class="cx"> #include &lt;wtf/RefPtr.h&gt;
</span><span class="lines">@@ -41,27 +42,30 @@
</span><span class="cx"> 
</span><span class="cx"> class WebVideoFullscreenModelMediaElement : public WebVideoFullscreenModel, public EventListener {
</span><span class="cx">     RefPtr&lt;HTMLMediaElement&gt; m_mediaElement;
</span><del>-    RetainPtr&lt;PlatformLayer&gt; m_borrowedVideoLayer;
</del><ins>+    RetainPtr&lt;PlatformLayer&gt; m_videoFullscreenLayer;
</ins><span class="cx">     bool m_isListening;
</span><span class="cx">     WebVideoFullscreenInterface* m_videoFullscreenInterface;
</span><ins>+    FloatRect m_videoFrame;
</ins><span class="cx">     
</span><span class="cx"> public:
</span><span class="cx">     WebVideoFullscreenModelMediaElement();
</span><span class="cx">     virtual ~WebVideoFullscreenModelMediaElement();
</span><span class="cx">     void setWebVideoFullscreenInterface(WebVideoFullscreenInterface* interface) {m_videoFullscreenInterface = interface;}
</span><span class="cx">     void setMediaElement(HTMLMediaElement*);
</span><ins>+    void setVideoFullscreenLayer(PlatformLayer*);
</ins><span class="cx">     
</span><span class="cx">     virtual void handleEvent(WebCore::ScriptExecutionContext*, WebCore::Event*) override;
</span><span class="cx">     bool operator==(const EventListener&amp; rhs) override
</span><span class="cx">         {return static_cast&lt;WebCore::EventListener*&gt;(this) == &amp;rhs;}
</span><span class="cx"> 
</span><del>-    virtual void borrowVideoLayer() override;
-    virtual void returnVideoLayer() override;
</del><span class="cx">     virtual void play() override;
</span><span class="cx">     virtual void pause() override;
</span><span class="cx">     virtual void togglePlayState() override;
</span><span class="cx">     virtual void seekToTime(double time) override;
</span><span class="cx">     virtual void requestExitFullscreen() override;
</span><ins>+    virtual void setVideoLayerFrame(FloatRect) override;
+    virtual void setVideoLayerGravity(WebVideoFullscreenModel::VideoGravity) override;
+
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformiosWebVideoFullscreenModelMediaElementmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/WebVideoFullscreenModelMediaElement.mm (165343 => 165344)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/WebVideoFullscreenModelMediaElement.mm        2014-03-09 01:47:09 UTC (rev 165343)
+++ trunk/Source/WebCore/platform/ios/WebVideoFullscreenModelMediaElement.mm        2014-03-09 02:16:11 UTC (rev 165344)
</span><span class="lines">@@ -41,6 +41,7 @@
</span><span class="cx"> #import &lt;WebCore/HTMLVideoElement.h&gt;
</span><span class="cx"> #import &lt;WebCore/SoftLinking.h&gt;
</span><span class="cx"> #import &lt;WebCore/WebCoreThreadRun.h&gt;
</span><ins>+#import &lt;QuartzCore/CoreAnimation.h&gt;
</ins><span class="cx"> #import &lt;wtf/RetainPtr.h&gt;
</span><span class="cx"> 
</span><span class="cx"> using namespace WebCore;
</span><span class="lines">@@ -89,7 +90,8 @@
</span><span class="cx">     if (isHTMLVideoElement(m_mediaElement.get())) {
</span><span class="cx">         HTMLVideoElement *videoElement = toHTMLVideoElement(m_mediaElement.get());
</span><span class="cx">         m_videoFullscreenInterface-&gt;setVideoDimensions(true, videoElement-&gt;videoWidth(), videoElement-&gt;videoHeight());
</span><del>-    }
</del><ins>+    } else
+        m_videoFullscreenInterface-&gt;setVideoDimensions(false, 0, 0);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenModelMediaElement::handleEvent(WebCore::ScriptExecutionContext*, WebCore::Event* event)
</span><span class="lines">@@ -109,29 +111,16 @@
</span><span class="cx">         m_videoFullscreenInterface-&gt;setCurrentTime(m_mediaElement-&gt;currentTime(), [[NSProcessInfo processInfo] systemUptime]);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebVideoFullscreenModelMediaElement::borrowVideoLayer()
</del><ins>+void WebVideoFullscreenModelMediaElement::setVideoFullscreenLayer(PlatformLayer* videoLayer)
</ins><span class="cx"> {
</span><del>-    ASSERT(!m_borrowedVideoLayer);
</del><ins>+    if (m_videoFullscreenLayer == videoLayer)
+        return;
</ins><span class="cx">     
</span><del>-    __block RefPtr&lt;WebVideoFullscreenModelMediaElement&gt; protect(this);
-    WebThreadRun(^{
-        m_videoFullscreenInterface-&gt;willLendVideoLayer(m_mediaElement-&gt;platformLayer());
-        m_borrowedVideoLayer = m_mediaElement-&gt;borrowPlatformLayer();
-        if (m_borrowedVideoLayer.get())
-            m_videoFullscreenInterface-&gt;didLendVideoLayer();
-        protect.clear();
-    });
-}
-
-void WebVideoFullscreenModelMediaElement::returnVideoLayer()
-{
-    ASSERT(m_borrowedVideoLayer.get());
</del><ins>+    m_videoFullscreenLayer = videoLayer;
</ins><span class="cx">     
</span><span class="cx">     __block RefPtr&lt;WebVideoFullscreenModelMediaElement&gt; protect(this);
</span><span class="cx">     WebThreadRun(^{
</span><del>-        ASSERT(m_mediaElement);
-        m_mediaElement-&gt;returnPlatformLayer(m_borrowedVideoLayer.get());
-        m_borrowedVideoLayer.clear();
</del><ins>+        m_mediaElement-&gt;setVideoFullscreenLayer(m_videoFullscreenLayer.get());
</ins><span class="cx">         protect.clear();
</span><span class="cx">     });
</span><span class="cx"> }
</span><span class="lines">@@ -180,4 +169,26 @@
</span><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebVideoFullscreenModelMediaElement::setVideoLayerFrame(FloatRect rect)
+{
+    m_videoFrame = rect;
+    [m_videoFullscreenLayer setFrame:CGRect(rect)];
+    m_mediaElement-&gt;setVideoFullscreenFrame(rect);
+}
+
+void WebVideoFullscreenModelMediaElement::setVideoLayerGravity(WebVideoFullscreenModel::VideoGravity gravity)
+{
+    MediaPlayer::VideoGravity videoGravity = MediaPlayer::VideoGravityResizeAspect;
+    if (gravity == WebVideoFullscreenModel::VideoGravityResize)
+        videoGravity = MediaPlayer::VideoGravityResize;
+    else if (gravity == WebVideoFullscreenModel::VideoGravityResizeAspect)
+        videoGravity = MediaPlayer::VideoGravityResizeAspect;
+    else if (gravity == WebVideoFullscreenModel::VideoGravityResizeAspectFill)
+        videoGravity = MediaPlayer::VideoGravityResizeAspectFill;
+    else
+        ASSERT_NOT_REACHED();
+    
+    m_mediaElement-&gt;setVideoFullscreenGravity(videoGravity);
+}
+
</ins><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (165343 => 165344)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-03-09 01:47:09 UTC (rev 165343)
+++ trunk/Source/WebKit2/ChangeLog        2014-03-09 02:16:11 UTC (rev 165344)
</span><span class="lines">@@ -1,3 +1,86 @@
</span><ins>+2014-03-08  Jeremy Jones  &lt;jeremyj@apple.com&gt;
+
+        Allow media element to supply the video layer after fullscreen transition has already begun.
+        https://bugs.webkit.org/show_bug.cgi?id=129870
+
+        Reviewed by Eric Carlson.
+
+        WebVideoFullscreenManager and WebVideoFullscreenManagerProxy do their own remote hosting of the video layer instead of needing the video layer to have already been hosted elsewhere. This allows the removal of the coordination with WebPageProxy via a RemoteLayerTreeTransaction.
+
+        * Shared/mac/RemoteLayerTreeTransaction.h:
+        Remove m_videoLayerIDsPendingFullscreen and accessors.
+
+        * Shared/mac/RemoteLayerTreeTransaction.mm:
+        (WebKit::RemoteLayerTreeTransaction::encode):
+        Don't encode m_videoLayerIDsPendingFullscreen
+
+        (WebKit::RemoteLayerTreeTransaction::decode):
+        Don't decode m_videoLayerIDsPendingFullscreen
+
+        * UIProcess/ios/WebPageProxyIOS.mm:
+        (WebKit::WebPageProxy::didCommitLayerTree):
+        Don't forward didCommitLayerTree to m_videoFullscreenManager.
+
+        * UIProcess/ios/WebVideoFullscreenManagerProxy.h:
+        Remove code for synchronizing with the RenderTree.
+        Add a hosting layer and methods to keep video layer frame and video gravity synchronized.
+
+        * UIProcess/ios/WebVideoFullscreenManagerProxy.messages.in:
+        Change IPC interface to fascilitate rehosting video layer with a instead of coordinating with the RenderTree by PlatformLayerID.
+
+        * UIProcess/ios/WebVideoFullscreenManagerProxy.mm:
+        (WebKit::WebVideoFullscreenManagerProxy::WebVideoFullscreenManagerProxy):
+        Remove initialization for removed members.
+
+        (WebKit::WebVideoFullscreenManagerProxy::enterFullscreenWithID):
+        Rehost the video layer by id and pass on the layer.
+        This replaces didCommitLayerTree() and  willLendVideoLayerWithID(). 
+
+        (WebKit::WebVideoFullscreenManagerProxy::didExitFullscreen):
+        Cleanup the hosting layer.
+
+        (WebKit::WebVideoFullscreenManagerProxy::setVideoLayerFrame):
+        Forward on the video layer's frame to keep the hosted layer in sync with the interface.
+
+        (WebKit::WebVideoFullscreenManagerProxy::setVideoLayerGravity):
+        Forward the videolayer gravity.
+
+        * WebKit2.xcodeproj/project.pbxproj:
+        Rename WebVideoFullscreenManager.cpp to WebVideoFullscreenManager.mm
+
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::willCommitLayerTree):
+        Don't invovle the m_videoFullscreenManager in layer tree transactions.
+
+        * WebProcess/ios/WebVideoFullscreenManager.h:
+        Remove code that synchronizes with the render tree via RemoteLayerTreeTransaction.
+        Instead rehost the video layer directly.
+        Instead of hoping the WebVideoFullscreenModel has a videoLayer, supply one into which
+        it can add whatever it likes as needed.
+
+        * WebProcess/ios/WebVideoFullscreenManager.messages.in:
+        No more explicit borrowing and returning video layers.
+        Add functions to keep video layer bounds and gravity in sync with the UI. 
+
+        * WebProcess/ios/WebVideoFullscreenManager.mm: Renamed from Source/WebKit2/WebProcess/ios/WebVideoFullscreenManager.cpp.
+        Removed code for synchronizing via RemoteLAyerTreeTransaction.
+
+        (WebKit::WebVideoFullscreenManager::WebVideoFullscreenManager):
+        Remove initialization for removed memeber m_sendUnparentVideoLayerTransaction.
+
+        (WebKit::WebVideoFullscreenManager::enterFullscreenForNode):
+        Creates a fullscreen layer, gives it to the WebVideoFullscreenModel to fill in,
+        and hosts it in a context to send to the UIProcess.
+
+        (WebKit::WebVideoFullscreenManager::exitFullscreenForNode):
+        remove enterFullscreen() and just directly send the IPC message. 
+
+        (WebKit::WebVideoFullscreenManager::didExitFullscreen):
+        Clean up the hosting context.
+
+        (WebKit::WebVideoFullscreenManager::setVideoLayerGravityEnum):
+        Forward on the video gravity. Type convert from unsigned to MediaPlayer::VideoGravity.
+
</ins><span class="cx"> 2014-03-08  Andreas Kling  &lt;akling@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [WK2] Improve the network process low memory handler.
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedmacRemoteLayerTreeTransactionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.h (165343 => 165344)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.h        2014-03-09 01:47:09 UTC (rev 165343)
+++ trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.h        2014-03-09 02:16:11 UTC (rev 165344)
</span><span class="lines">@@ -183,9 +183,6 @@
</span><span class="cx">     bool allowsUserScaling() const { return m_allowsUserScaling; }
</span><span class="cx">     void setAllowsUserScaling(bool allowsUserScaling) { m_allowsUserScaling = allowsUserScaling; }
</span><span class="cx">     
</span><del>-    bool isVideoLayerIDPendingFullscreen(WebCore::GraphicsLayer::PlatformLayerID layerID) const { return m_videoLayerIDsPendingFullscreen.contains(layerID); }
-    void addVideoLayerIDPendingFullscreen(WebCore::GraphicsLayer::PlatformLayerID layerID) { m_videoLayerIDsPendingFullscreen.append(layerID); }
-
</del><span class="cx"> private:
</span><span class="cx">     WebCore::GraphicsLayer::PlatformLayerID m_rootLayerID;
</span><span class="cx">     LayerPropertiesMap m_changedLayerProperties;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosWebPageProxyIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm (165343 => 165344)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm        2014-03-09 01:47:09 UTC (rev 165343)
+++ trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm        2014-03-09 02:16:11 UTC (rev 165344)
</span><span class="lines">@@ -252,8 +252,6 @@
</span><span class="cx"> void WebPageProxy::didCommitLayerTree(const WebKit::RemoteLayerTreeTransaction&amp; layerTreeTransaction)
</span><span class="cx"> {
</span><span class="cx">     m_pageClient.didCommitLayerTree(layerTreeTransaction);
</span><del>-    if (m_videoFullscreenManager)
-        m_videoFullscreenManager-&gt;didCommitLayerTree(layerTreeTransaction);
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebPageProxy::selectWithGesture(const WebCore::IntPoint point, WebCore::TextGranularity granularity, uint32_t gestureType, uint32_t gestureState, PassRefPtr&lt;GestureCallback&gt; callback)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosWebVideoFullscreenManagerProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/WebVideoFullscreenManagerProxy.h (165343 => 165344)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/WebVideoFullscreenManagerProxy.h        2014-03-09 01:47:09 UTC (rev 165343)
+++ trunk/Source/WebKit2/UIProcess/ios/WebVideoFullscreenManagerProxy.h        2014-03-09 02:16:11 UTC (rev 165344)
</span><span class="lines">@@ -41,21 +41,18 @@
</span><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><span class="cx"> class WebPageProxy;
</span><del>-class RemoteLayerTreeTransaction;
</del><span class="cx"> 
</span><span class="cx"> class WebVideoFullscreenManagerProxy : public WebCore::WebVideoFullscreenInterfaceAVKit, public WebCore::WebVideoFullscreenChangeObserver, public WebCore::WebVideoFullscreenModel, private IPC::MessageReceiver {
</span><span class="cx"> public:
</span><span class="cx">     static PassRefPtr&lt;WebVideoFullscreenManagerProxy&gt; create(WebPageProxy&amp;);
</span><span class="cx">     virtual ~WebVideoFullscreenManagerProxy();
</span><span class="cx"> 
</span><del>-    void didCommitLayerTree(const RemoteLayerTreeTransaction&amp;);
-    
</del><span class="cx"> private:
</span><span class="cx">     explicit WebVideoFullscreenManagerProxy(WebPageProxy&amp;);
</span><span class="cx">     virtual void didReceiveMessage(IPC::Connection*, IPC::MessageDecoder&amp;) override;
</span><span class="cx"> 
</span><span class="cx">     // Translate to FullscreenInterface
</span><del>-    virtual void willLendVideoLayerWithID(WebCore::GraphicsLayer::PlatformLayerID);
</del><ins>+    virtual void enterFullscreenWithID(uint32_t);
</ins><span class="cx"> 
</span><span class="cx">     // Fullscreen Observer
</span><span class="cx">     virtual void requestExitFullscreen() override;
</span><span class="lines">@@ -67,13 +64,11 @@
</span><span class="cx">     virtual void pause() override;
</span><span class="cx">     virtual void togglePlayState() override;
</span><span class="cx">     virtual void seekToTime(double) override;
</span><del>-    virtual void borrowVideoLayer() override;
-    virtual void returnVideoLayer() override;
</del><ins>+    virtual void setVideoLayerFrame(WebCore::FloatRect) override;
+    virtual void setVideoLayerGravity(WebCore::WebVideoFullscreenModel::VideoGravity) override;
</ins><span class="cx"> 
</span><span class="cx">     WebPageProxy* m_page;
</span><del>-    bool m_enterFullscreenAfterVideoLayerUnparentedTransaction;
-    WebCore::GraphicsLayer::PlatformLayerID m_videoLayerID;
-    RetainPtr&lt;UIView&gt; m_videoView;
</del><ins>+    RetainPtr&lt;PlatformLayer&gt; m_layerHost;
</ins><span class="cx"> };
</span><span class="cx">     
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosWebVideoFullscreenManagerProxymessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/WebVideoFullscreenManagerProxy.messages.in (165343 => 165344)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/WebVideoFullscreenManagerProxy.messages.in        2014-03-09 01:47:09 UTC (rev 165343)
+++ trunk/Source/WebKit2/UIProcess/ios/WebVideoFullscreenManagerProxy.messages.in        2014-03-09 02:16:11 UTC (rev 165344)
</span><span class="lines">@@ -26,8 +26,7 @@
</span><span class="cx">     SetVideoDimensions(bool hasVideo, unsigned width, unsigned height)
</span><span class="cx">     SetDuration(double duration)
</span><span class="cx">     SetRate(bool isPlaying, double rate)
</span><del>-    EnterFullscreen()
-    WillLendVideoLayerWithID(WebCore::GraphicsLayer::PlatformLayerID videoLayerID)
</del><ins>+    EnterFullscreenWithID(uint32_t videoLayerID)
</ins><span class="cx">     ExitFullscreen()
</span><span class="cx"> }
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosWebVideoFullscreenManagerProxymm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/WebVideoFullscreenManagerProxy.mm (165343 => 165344)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/WebVideoFullscreenManagerProxy.mm        2014-03-09 01:47:09 UTC (rev 165343)
+++ trunk/Source/WebKit2/UIProcess/ios/WebVideoFullscreenManagerProxy.mm        2014-03-09 02:16:11 UTC (rev 165344)
</span><span class="lines">@@ -28,14 +28,12 @@
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx"> 
</span><del>-#include &quot;DrawingAreaProxy.h&quot;
-#include &quot;RemoteLayerTreeDrawingAreaProxy.h&quot;
-#include &quot;RemoteLayerTreeTransaction.h&quot;
</del><span class="cx"> #include &quot;WebPageProxy.h&quot;
</span><span class="cx"> #include &quot;WebProcessProxy.h&quot;
</span><span class="cx"> #include &quot;WebVideoFullscreenManagerMessages.h&quot;
</span><span class="cx"> #include &quot;WebVideoFullscreenManagerProxyMessages.h&quot;
</span><del>-#include &lt;UIKit/UIView.h&gt;
</del><ins>+#include &lt;QuartzCore/CoreAnimation.h&gt;
+#include &lt;WebKitSystemInterface.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> using namespace WebCore;
</span><span class="cx"> 
</span><span class="lines">@@ -48,8 +46,6 @@
</span><span class="cx"> 
</span><span class="cx"> WebVideoFullscreenManagerProxy::WebVideoFullscreenManagerProxy(WebPageProxy&amp; page)
</span><span class="cx">     : m_page(&amp;page)
</span><del>-    , m_enterFullscreenAfterVideoLayerUnparentedTransaction(false)
-    , m_videoLayerID(0)
</del><span class="cx"> {
</span><span class="cx">     m_page-&gt;process().addMessageReceiver(Messages::WebVideoFullscreenManagerProxy::messageReceiverName(), m_page-&gt;pageID(), *this);
</span><span class="cx">     setWebVideoFullscreenModel(this);
</span><span class="lines">@@ -61,24 +57,13 @@
</span><span class="cx">     m_page-&gt;process().removeMessageReceiver(Messages::WebVideoFullscreenManagerProxy::messageReceiverName(), m_page-&gt;pageID());
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebVideoFullscreenManagerProxy::didCommitLayerTree(const RemoteLayerTreeTransaction&amp; layerTreeTransaction)
</del><ins>+void WebVideoFullscreenManagerProxy::enterFullscreenWithID(uint32_t videoLayerID)
</ins><span class="cx"> {
</span><del>-    if (m_enterFullscreenAfterVideoLayerUnparentedTransaction &amp;&amp; layerTreeTransaction.isVideoLayerIDPendingFullscreen(m_videoLayerID)) {
-        m_enterFullscreenAfterVideoLayerUnparentedTransaction = false;
-        [m_videoView removeFromSuperview];
-        didLendVideoLayer();
-    }
</del><ins>+    ASSERT(videoLayerID);
+    m_layerHost = WKMakeRenderLayer(videoLayerID);
+    enterFullscreen(*m_layerHost.get());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebVideoFullscreenManagerProxy::willLendVideoLayerWithID(GraphicsLayer::PlatformLayerID videoLayerID)
-{
-    RemoteLayerTreeDrawingAreaProxy* remoteDrawingAreaProxy = toRemoteLayerTreeDrawingAreaProxy(m_page-&gt;drawingArea());
-    m_videoView = remoteDrawingAreaProxy-&gt;remoteLayerTreeHost().getLayer(videoLayerID);
-    willLendVideoLayer(m_videoView.get().layer);
-    m_videoLayerID = videoLayerID;
-    m_enterFullscreenAfterVideoLayerUnparentedTransaction = true;
-}
-
</del><span class="cx"> void WebVideoFullscreenManagerProxy::requestExitFullscreen()
</span><span class="cx"> {
</span><span class="cx">     m_page-&gt;send(Messages::WebVideoFullscreenManager::RequestExitFullscreen(), m_page-&gt;pageID());
</span><span class="lines">@@ -87,6 +72,8 @@
</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><ins>+    [m_layerHost removeFromSuperlayer];
+    m_layerHost.clear();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenManagerProxy::didEnterFullscreen()
</span><span class="lines">@@ -113,16 +100,15 @@
</span><span class="cx"> {
</span><span class="cx">     m_page-&gt;send(Messages::WebVideoFullscreenManager::SeekToTime(time), m_page-&gt;pageID());
</span><span class="cx"> }
</span><del>-    
-void WebVideoFullscreenManagerProxy::borrowVideoLayer()
</del><ins>+
+void WebVideoFullscreenManagerProxy::setVideoLayerFrame(WebCore::FloatRect frame)
</ins><span class="cx"> {
</span><del>-    m_page-&gt;send(Messages::WebVideoFullscreenManager::BorrowVideoLayer(), m_page-&gt;pageID());
</del><ins>+    m_page-&gt;send(Messages::WebVideoFullscreenManager::SetVideoLayerFrame(frame), m_page-&gt;pageID());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebVideoFullscreenManagerProxy::returnVideoLayer()
</del><ins>+void WebVideoFullscreenManagerProxy::setVideoLayerGravity(WebCore::WebVideoFullscreenModel::VideoGravity gravity)
</ins><span class="cx"> {
</span><del>-    m_page-&gt;send(Messages::WebVideoFullscreenManager::ReturnVideoLayer(), m_page-&gt;pageID());
-    m_videoView.clear();
</del><ins>+    m_page-&gt;send(Messages::WebVideoFullscreenManager::SetVideoLayerGravityEnum((unsigned)gravity), m_page-&gt;pageID());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (165343 => 165344)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2014-03-09 01:47:09 UTC (rev 165343)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2014-03-09 02:16:11 UTC (rev 165344)
</span><span class="lines">@@ -683,7 +683,7 @@
</span><span class="cx">                 3F87B9C0158940D80090FF62 /* WebColorPicker.h in Headers */ = {isa = PBXBuildFile; fileRef = 3F87B9BF158940D80090FF62 /* WebColorPicker.h */; };
</span><span class="cx">                 3F889D14188778C900FEADAF /* WebVideoFullscreenManagerProxy.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3F889D12188778C900FEADAF /* WebVideoFullscreenManagerProxy.mm */; };
</span><span class="cx">                 3F889D15188778C900FEADAF /* WebVideoFullscreenManagerProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 3F889D13188778C900FEADAF /* WebVideoFullscreenManagerProxy.h */; };
</span><del>-                3F889D171887859300FEADAF /* WebVideoFullscreenManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3F889D0D1887699C00FEADAF /* WebVideoFullscreenManager.cpp */; };
</del><ins>+                3F889D171887859300FEADAF /* WebVideoFullscreenManager.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3F889D0D1887699C00FEADAF /* WebVideoFullscreenManager.mm */; };
</ins><span class="cx">                 4F601432155C5AA2001FBDE0 /* BlockingResponseMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 4F601430155C5A32001FBDE0 /* BlockingResponseMap.h */; };
</span><span class="cx">                 51021E9C12B16788005C033C /* WebContextMenuClientMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51021E9B12B16788005C033C /* WebContextMenuClientMac.mm */; };
</span><span class="cx">                 51032F18180F73BB00961BB7 /* WebToDatabaseProcessConnection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51032F16180F73BB00961BB7 /* WebToDatabaseProcessConnection.cpp */; };
</span><span class="lines">@@ -2454,7 +2454,7 @@
</span><span class="cx">                 3F87B9BA15893F630090FF62 /* WebColorChooser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebColorChooser.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 3F87B9BB15893F630090FF62 /* WebColorChooser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebColorChooser.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 3F87B9BF158940D80090FF62 /* WebColorPicker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebColorPicker.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><del>-                3F889D0D1887699C00FEADAF /* WebVideoFullscreenManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebVideoFullscreenManager.cpp; path = ios/WebVideoFullscreenManager.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</del><ins>+                3F889D0D1887699C00FEADAF /* WebVideoFullscreenManager.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WebVideoFullscreenManager.mm; path = ios/WebVideoFullscreenManager.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 3F889D0E1887699C00FEADAF /* WebVideoFullscreenManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebVideoFullscreenManager.h; path = ios/WebVideoFullscreenManager.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 3F889D101887710000FEADAF /* WebVideoFullscreenManager.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = WebVideoFullscreenManager.messages.in; path = ios/WebVideoFullscreenManager.messages.in; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 3F889D12188778C900FEADAF /* WebVideoFullscreenManagerProxy.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WebVideoFullscreenManagerProxy.mm; path = ios/WebVideoFullscreenManagerProxy.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -4393,7 +4393,7 @@
</span><span class="cx">                 2DA944B11884E9DF00ED86DB /* ios */ = {
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span><del>-                                3F889D0D1887699C00FEADAF /* WebVideoFullscreenManager.cpp */,
</del><ins>+                                3F889D0D1887699C00FEADAF /* WebVideoFullscreenManager.mm */,
</ins><span class="cx">                                 3F889D0E1887699C00FEADAF /* WebVideoFullscreenManager.h */,
</span><span class="cx">                                 3F889D101887710000FEADAF /* WebVideoFullscreenManager.messages.in */,
</span><span class="cx">                         );
</span><span class="lines">@@ -8508,7 +8508,7 @@
</span><span class="cx">                                 51FCB18817BBFE0300394CD8 /* SynchronousNetworkLoaderClient.cpp in Sources */,
</span><span class="cx">                                 3F418EFB1887BD97002795FD /* WebVideoFullscreenManagerProxyMessageReceiver.cpp in Sources */,
</span><span class="cx">                                 BCD597D6112B56DC00EC8C23 /* WKPage.cpp in Sources */,
</span><del>-                                3F889D171887859300FEADAF /* WebVideoFullscreenManager.cpp in Sources */,
</del><ins>+                                3F889D171887859300FEADAF /* WebVideoFullscreenManager.mm in Sources */,
</ins><span class="cx">                                 BC7B633812A45ABA00D174A4 /* WKPageGroup.cpp in Sources */,
</span><span class="cx">                                 BCE17B7D1381F1170012A641 /* WKPagePrivateMac.cpp in Sources */,
</span><span class="cx">                                 7C135AA8173B0BCA00586AE2 /* WKPluginInformation.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageWebPagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (165343 => 165344)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp        2014-03-09 01:47:09 UTC (rev 165343)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp        2014-03-09 02:16:11 UTC (rev 165344)
</span><span class="lines">@@ -2638,8 +2638,6 @@
</span><span class="cx">     layerTransaction.setMinimumScaleFactor(minimumPageScaleFactor());
</span><span class="cx">     layerTransaction.setMaximumScaleFactor(maximumPageScaleFactor());
</span><span class="cx">     layerTransaction.setAllowsUserScaling(allowsUserScaling());
</span><del>-    if (m_videoFullscreenManager)
-        m_videoFullscreenManager-&gt;willCommitLayerTree(layerTransaction);
</del><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessiosWebVideoFullscreenManagercpp"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebKit2/WebProcess/ios/WebVideoFullscreenManager.cpp (165343 => 165344)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/ios/WebVideoFullscreenManager.cpp        2014-03-09 01:47:09 UTC (rev 165343)
+++ trunk/Source/WebKit2/WebProcess/ios/WebVideoFullscreenManager.cpp        2014-03-09 02:16:11 UTC (rev 165344)
</span><span class="lines">@@ -1,186 +0,0 @@
</span><del>-/*
- * Copyright (C) 2014 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include &quot;config.h&quot;
-#include &quot;WebVideoFullscreenManager.h&quot;
-
-#if PLATFORM(IOS)
-
-#include &quot;RemoteLayerTreeTransaction.h&quot;
-#include &quot;WebPage.h&quot;
-#include &quot;WebProcess.h&quot;
-#include &quot;WebVideoFullscreenManagerMessages.h&quot;
-#include &quot;WebVideoFullscreenManagerProxyMessages.h&quot;
-#include &lt;WebCore/Event.h&gt;
-#include &lt;WebCore/EventNames.h&gt;
-#include &lt;WebCore/HTMLVideoElement.h&gt;
-#include &lt;WebCore/PlatformCALayer.h&gt;
-#include &lt;WebCore/Settings.h&gt;
-#include &lt;WebCore/WebCoreThreadRun.h&gt;
-
-using namespace WebCore;
-
-namespace WebKit {
-    
-PassRefPtr&lt;WebVideoFullscreenManager&gt; WebVideoFullscreenManager::create(PassRefPtr&lt;WebPage&gt; page)
-{
-    return adoptRef(new WebVideoFullscreenManager(page));
-}
-
-WebVideoFullscreenManager::WebVideoFullscreenManager(PassRefPtr&lt;WebPage&gt; page)
-    : m_page(page.get())
-    , m_sendUnparentVideoLayerTransaction(false)
-    , m_isAnimating(false)
-    , m_targetIsFullscreen(false)
-    , m_isFullscreen(false)
-{
-    setWebVideoFullscreenInterface(this);
-    WebProcess::shared().addMessageReceiver(Messages::WebVideoFullscreenManager::messageReceiverName(), page-&gt;pageID(), *this);
-}
-
-WebVideoFullscreenManager::~WebVideoFullscreenManager()
-{
-    WebProcess::shared().removeMessageReceiver(Messages::WebVideoFullscreenManager::messageReceiverName(), m_page-&gt;pageID());
-}
-
-void WebVideoFullscreenManager::willCommitLayerTree(RemoteLayerTreeTransaction&amp; transaction)
-{
-    if (m_sendUnparentVideoLayerTransaction) {
-        transaction.addVideoLayerIDPendingFullscreen(m_platformCALayer-&gt;layerID());
-        m_sendUnparentVideoLayerTransaction = false;
-    }
-}
-    
-bool WebVideoFullscreenManager::supportsFullscreen(const Node* node) const
-{
-    if (!Settings::avKitEnabled())
-        return false;
-    return isHTMLVideoElement(node);
-}
-
-void WebVideoFullscreenManager::enterFullscreenForNode(Node* node)
-{
-    ASSERT(node);
-    m_node = node;
-    m_targetIsFullscreen = true;
-    
-    if (m_isAnimating)
-        return;
-    
-    m_isAnimating = true;
-    setMediaElement(toHTMLMediaElement(node));
-    enterFullscreen();
-}
-
-void WebVideoFullscreenManager::exitFullscreenForNode(Node*)
-{
-    m_node.clear();
-    m_targetIsFullscreen = false;
-    
-    if (m_isAnimating)
-        return;
-    
-    m_isAnimating = true;
-    exitFullscreen();
-}
-
-void WebVideoFullscreenManager::setDuration(double duration)
-{
-    m_page-&gt;send(Messages::WebVideoFullscreenManagerProxy::SetDuration(duration), m_page-&gt;pageID());
-}
-    
-void WebVideoFullscreenManager::setCurrentTime(double currentTime, double anchorTime)
-{
-    m_page-&gt;send(Messages::WebVideoFullscreenManagerProxy::SetCurrentTime(currentTime, anchorTime), m_page-&gt;pageID());
-}
-    
-void WebVideoFullscreenManager::setRate(bool isPlaying, float playbackRate)
-{
-    m_page-&gt;send(Messages::WebVideoFullscreenManagerProxy::SetRate(isPlaying, playbackRate), m_page-&gt;pageID());
-}
-
-void WebVideoFullscreenManager::setVideoDimensions(bool hasVideo, float width, float height)
-{
-    m_page-&gt;send(Messages::WebVideoFullscreenManagerProxy::SetVideoDimensions(hasVideo, width, height), m_page-&gt;pageID());
-}
-    
-void WebVideoFullscreenManager::willLendVideoLayer(PlatformLayer* videoLayer)
-{
-    m_platformCALayer = PlatformCALayer::platformCALayer(videoLayer);
-    m_sendUnparentVideoLayerTransaction = !!m_platformCALayer;
-    
-    m_page-&gt;send(Messages::WebVideoFullscreenManagerProxy::WillLendVideoLayerWithID(m_platformCALayer ? m_platformCALayer-&gt;layerID() : 0), m_page-&gt;pageID());
-}
-    
-void WebVideoFullscreenManager::didLendVideoLayer()
-{
-    // no-op
-    // this will be sent through a RemoteLayerTreeTransaction
-}
-
-void WebVideoFullscreenManager::enterFullscreen()
-{
-    m_page-&gt;send(Messages::WebVideoFullscreenManagerProxy::EnterFullscreen(), m_page-&gt;pageID());
-}
-    
-void WebVideoFullscreenManager::exitFullscreen()
-{
-    m_page-&gt;send(Messages::WebVideoFullscreenManagerProxy::ExitFullscreen(), m_page-&gt;pageID());
-}
-    
-void WebVideoFullscreenManager::didEnterFullscreen()
-{
-    m_isAnimating = false;
-    m_isFullscreen = false;
-    
-    if (m_targetIsFullscreen)
-        return;
-
-    __block RefPtr&lt;WebVideoFullscreenModelMediaElement&gt; protect(this);
-    WebThreadRun(^ {
-        exitFullscreenForNode(m_node.get());
-        protect.clear();
-    });
-}
-
-void WebVideoFullscreenManager::didExitFullscreen()
-{
-    m_isAnimating = false;
-    m_isFullscreen = false;
-
-    setMediaElement(nullptr);
-
-    if (!m_targetIsFullscreen)
-        return;
-
-    __block RefPtr&lt;WebVideoFullscreenModelMediaElement&gt; protect(this);
-    WebThreadRun(^ {
-        enterFullscreenForNode(m_node.get());
-        protect.clear();
-    });
-}
-
-} // namespace WebKit
-
-#endif // PLATFORM(IOS)
</del></span></pre></div>
<a id="trunkSourceWebKit2WebProcessiosWebVideoFullscreenManagerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/ios/WebVideoFullscreenManager.h (165343 => 165344)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/ios/WebVideoFullscreenManager.h        2014-03-09 01:47:09 UTC (rev 165343)
+++ trunk/Source/WebKit2/WebProcess/ios/WebVideoFullscreenManager.h        2014-03-09 02:16:11 UTC (rev 165344)
</span><span class="lines">@@ -47,8 +47,8 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><ins>+class LayerHostingContext;
</ins><span class="cx"> class WebPage;
</span><del>-class RemoteLayerTreeTransaction;
</del><span class="cx"> 
</span><span class="cx"> class WebVideoFullscreenManager : public WebCore::WebVideoFullscreenModelMediaElement, public WebCore::WebVideoFullscreenInterface, private IPC::MessageReceiver {
</span><span class="cx"> public:
</span><span class="lines">@@ -57,8 +57,6 @@
</span><span class="cx">     
</span><span class="cx">     void didReceiveMessage(IPC::Connection*, IPC::MessageDecoder&amp;);
</span><span class="cx">     
</span><del>-    void willCommitLayerTree(RemoteLayerTreeTransaction&amp;);
-
</del><span class="cx">     bool supportsFullscreen(const WebCore::Node*) const;
</span><span class="cx">     void enterFullscreenForNode(WebCore::Node*);
</span><span class="cx">     void exitFullscreenForNode(WebCore::Node*);
</span><span class="lines">@@ -72,21 +70,15 @@
</span><span class="cx">     virtual void setCurrentTime(double currentTime, double anchorTime) override;
</span><span class="cx">     virtual void setRate(bool isPlaying, float playbackRate) override;
</span><span class="cx">     virtual void setVideoDimensions(bool hasVideo, float width, float height) override;
</span><del>-    virtual void willLendVideoLayer(PlatformLayer*) override;
-    virtual void didLendVideoLayer() override;
-
-    // forward to interface
-    virtual void enterFullscreen();
-    virtual void exitFullscreen();
</del><span class="cx">     
</span><span class="cx">     // additional incoming
</span><span class="cx">     virtual void didEnterFullscreen();
</span><span class="cx">     virtual void didExitFullscreen();
</span><ins>+    virtual void setVideoLayerGravityEnum(unsigned);
</ins><span class="cx">     
</span><span class="cx">     WebPage* m_page;
</span><span class="cx">     RefPtr&lt;WebCore::Node&gt; m_node;
</span><del>-    RefPtr&lt;WebCore::PlatformCALayer&gt; m_platformCALayer;
-    bool m_sendUnparentVideoLayerTransaction;
</del><ins>+    std::unique_ptr&lt;LayerHostingContext&gt; m_layerHostingContext;
</ins><span class="cx">     
</span><span class="cx">     bool m_isAnimating;
</span><span class="cx">     bool m_targetIsFullscreen;
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessiosWebVideoFullscreenManagermessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/ios/WebVideoFullscreenManager.messages.in (165343 => 165344)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/ios/WebVideoFullscreenManager.messages.in        2014-03-09 01:47:09 UTC (rev 165343)
+++ trunk/Source/WebKit2/WebProcess/ios/WebVideoFullscreenManager.messages.in        2014-03-09 02:16:11 UTC (rev 165344)
</span><span class="lines">@@ -26,11 +26,10 @@
</span><span class="cx">     Pause()
</span><span class="cx">     TogglePlayState()
</span><span class="cx">     SeekToTime(double time)
</span><del>-    BorrowVideoLayer()
-    ReturnVideoLayer()
</del><span class="cx">     RequestExitFullscreen()
</span><del>-
</del><span class="cx">     DidExitFullscreen()
</span><span class="cx">     DidEnterFullscreen()
</span><ins>+    SetVideoLayerFrame(WebCore::FloatRect bounds)
+    SetVideoLayerGravityEnum(unsigned gravity)
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessiosWebVideoFullscreenManagermmfromrev165343trunkSourceWebKit2WebProcessiosWebVideoFullscreenManagercpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebKit2/WebProcess/ios/WebVideoFullscreenManager.mm (from rev 165343, trunk/Source/WebKit2/WebProcess/ios/WebVideoFullscreenManager.cpp) (0 => 165344)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/ios/WebVideoFullscreenManager.mm                                (rev 0)
+++ trunk/Source/WebKit2/WebProcess/ios/WebVideoFullscreenManager.mm        2014-03-09 02:16:11 UTC (rev 165344)
</span><span class="lines">@@ -0,0 +1,168 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include &quot;config.h&quot;
+#include &quot;WebVideoFullscreenManager.h&quot;
+
+#if PLATFORM(IOS)
+
+#include &quot;WebPage.h&quot;
+#include &quot;WebProcess.h&quot;
+#include &quot;WebVideoFullscreenManagerMessages.h&quot;
+#include &quot;WebVideoFullscreenManagerProxyMessages.h&quot;
+#include &lt;QuartzCore/CoreAnimation.h&gt;
+#include &lt;WebCore/Event.h&gt;
+#include &lt;WebCore/EventNames.h&gt;
+#include &lt;WebCore/HTMLVideoElement.h&gt;
+#include &lt;WebCore/PlatformCALayer.h&gt;
+#include &lt;WebCore/Settings.h&gt;
+#include &lt;WebCore/WebCoreThreadRun.h&gt;
+
+using namespace WebCore;
+
+namespace WebKit {
+
+PassRefPtr&lt;WebVideoFullscreenManager&gt; WebVideoFullscreenManager::create(PassRefPtr&lt;WebPage&gt; page)
+{
+    return adoptRef(new WebVideoFullscreenManager(page));
+}
+
+WebVideoFullscreenManager::WebVideoFullscreenManager(PassRefPtr&lt;WebPage&gt; page)
+    : m_page(page.get())
+    , m_isAnimating(false)
+    , m_targetIsFullscreen(false)
+    , m_isFullscreen(false)
+{
+    setWebVideoFullscreenInterface(this);
+    WebProcess::shared().addMessageReceiver(Messages::WebVideoFullscreenManager::messageReceiverName(), page-&gt;pageID(), *this);
+}
+
+WebVideoFullscreenManager::~WebVideoFullscreenManager()
+{
+    WebProcess::shared().removeMessageReceiver(Messages::WebVideoFullscreenManager::messageReceiverName(), m_page-&gt;pageID());
+}
+
+bool WebVideoFullscreenManager::supportsFullscreen(const Node* node) const
+{
+    return Settings::avKitEnabled() &amp;&amp; isHTMLVideoElement(node);
+}
+
+void WebVideoFullscreenManager::enterFullscreenForNode(Node* node)
+{
+    ASSERT(node);
+    m_node = node;
+    m_targetIsFullscreen = true;
+
+    if (m_isAnimating)
+        return;
+
+    m_isAnimating = true;
+    setMediaElement(toHTMLMediaElement(node));
+
+    PlatformLayer* videoLayer = [CALayer layer];
+    m_layerHostingContext = LayerHostingContext::createForExternalHostingProcess();
+    m_layerHostingContext-&gt;setRootLayer(videoLayer);
+    setVideoFullscreenLayer(videoLayer);
+
+    m_page-&gt;send(Messages::WebVideoFullscreenManagerProxy::EnterFullscreenWithID(m_layerHostingContext-&gt;contextID()), m_page-&gt;pageID());
+}
+
+void WebVideoFullscreenManager::exitFullscreenForNode(Node*)
+{
+    m_node.clear();
+    m_targetIsFullscreen = false;
+
+    if (m_isAnimating)
+        return;
+
+    m_isAnimating = true;
+    m_page-&gt;send(Messages::WebVideoFullscreenManagerProxy::ExitFullscreen(), m_page-&gt;pageID());
+}
+
+void WebVideoFullscreenManager::setDuration(double duration)
+{
+    m_page-&gt;send(Messages::WebVideoFullscreenManagerProxy::SetDuration(duration), m_page-&gt;pageID());
+}
+
+void WebVideoFullscreenManager::setCurrentTime(double currentTime, double anchorTime)
+{
+    m_page-&gt;send(Messages::WebVideoFullscreenManagerProxy::SetCurrentTime(currentTime, anchorTime), m_page-&gt;pageID());
+}
+
+void WebVideoFullscreenManager::setRate(bool isPlaying, float playbackRate)
+{
+    m_page-&gt;send(Messages::WebVideoFullscreenManagerProxy::SetRate(isPlaying, playbackRate), m_page-&gt;pageID());
+}
+
+void WebVideoFullscreenManager::setVideoDimensions(bool hasVideo, float width, float height)
+{
+    m_page-&gt;send(Messages::WebVideoFullscreenManagerProxy::SetVideoDimensions(hasVideo, width, height), m_page-&gt;pageID());
+}
+
+void WebVideoFullscreenManager::didEnterFullscreen()
+{
+    m_isAnimating = false;
+    m_isFullscreen = false;
+
+    if (m_targetIsFullscreen)
+        return;
+
+    // exit fullscreen now if it was previously requested during an animation.
+    __block RefPtr&lt;WebVideoFullscreenModelMediaElement&gt; protect(this);
+    WebThreadRun(^ {
+        exitFullscreenForNode(m_node.get());
+        protect.clear();
+    });
+}
+
+void WebVideoFullscreenManager::didExitFullscreen()
+{
+    m_isAnimating = false;
+    m_isFullscreen = false;
+
+    m_layerHostingContext-&gt;setRootLayer(nullptr);
+    m_layerHostingContext = nullptr;
+    setVideoFullscreenLayer(nullptr);
+
+    setMediaElement(nullptr);
+
+    if (!m_targetIsFullscreen)
+        return;
+
+    // enter fullscreen now if it was previously requested during an animation.
+    __block RefPtr&lt;WebVideoFullscreenModelMediaElement&gt; protect(this);
+    WebThreadRun(^ {
+        enterFullscreenForNode(m_node.get());
+        protect.clear();
+    });
+}
+    
+void WebVideoFullscreenManager::setVideoLayerGravityEnum(unsigned gravity)
+{
+    setVideoLayerGravity((WebVideoFullscreenModel::VideoGravity)gravity);
+}
+
+} // namespace WebKit
+
+#endif // PLATFORM(IOS)
</ins></span></pre>
</div>
</div>

</body>
</html>