<!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>[162379] 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/162379">162379</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2014-01-20 14:41:25 -0800 (Mon, 20 Jan 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Add AVKit fullscreen video interface.
https://bugs.webkit.org/show_bug.cgi?id=126818

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

Source/WebCore:

No new tests, no observable change in functionality.

* WebCore.exp.in:
* WebCore.xcodeproj/project.pbxproj:
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::parseAttribute):
* html/HTMLMediaElement.h:
Add ability for fullscreen to borrow the AVPlayerLayer.
* page/Settings.cpp:
* page/Settings.h:
(WebCore::Settings::setMediaPlaybackFullscreenAVKit):
(WebCore::Settings::mediaPlaybackFullscreenAVKit):
Add a disabled setting.
* platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:
(WebCore::MediaPlayerPrivateAVFoundation::supportsFullscreen):
Enabled fullscreen for iOS.
* platform/ios/WebVideoFullscreenControllerAVKit.h: Added.
* platform/ios/WebVideoFullscreenControllerAVKit.mm: Added.
(-[WebAVPlayerController init]):
(-[WebAVPlayerController dealloc]):
(-[WebAVPlayerController forwardingTargetForSelector:]):
(-[WebAVPlayerController shouldDismissForDone]):
(-[WebAVPlayerController play:]):
(-[WebAVPlayerController pause:]):
(-[WebAVPlayerController togglePlayback:]):
(-[WebAVPlayerController isPlaying]):
(-[WebAVPlayerController setPlaying:]):
(+[WebAVPlayerController keyPathsForValuesAffectingPlaying]):
(-[WebAVPlayerController seekToTime:]):
(-[WebAVPlayerController updateTimingWithCurrentTime:]):
(-[WebAVPlayerController effectiveRate]):
(-[WebAVPlayerController setMediaElement:]):
(-[WebAVPlayerController handleEvent:]):
(-[WebVideoFullscreenController init]):
(-[WebVideoFullscreenController dealloc]):
(-[WebVideoFullscreenController setMediaElement:]):
(-[WebVideoFullscreenController mediaElement]):
(-[WebVideoFullscreenController enterFullscreen:]):
(-[WebVideoFullscreenController exitFullscreen]):
Add WebAVPlayerController for HTMLMediaElememt to interface with AVPlayerViewController.

Source/WebKit/mac:

* WebCoreSupport/WebChromeClient.h:
* WebCoreSupport/WebChromeClient.mm:
(WebChromeClient::supportsFullscreenForNode):
Enable *FullscreenForNode for HTMLMediaElement for iOS

* WebView/WebPreferenceKeysPrivate.h:
* WebView/WebPreferences.mm:
(+[WebPreferences initialize]):
(-[WebPreferences mediaPlaybackFullscreenAVKit]):
(-[WebPreferences setMediaPlaybackFullscreenAVKit:]):
* WebView/WebPreferencesPrivate.h:
* WebView/WebView.mm:
(-[WebView _preferencesChanged:]):
(-[WebView _enterFullscreenForNode:WebCore::]):
* WebView/WebViewInternal.h:
Add a disabled pref mediaPlaybackFullscreenAVKit.
Use WebVideoFullscreenControllerAVKit on iOS</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="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</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="#trunkSourceWebCorepageSettingscpp">trunk/Source/WebCore/page/Settings.cpp</a></li>
<li><a href="#trunkSourceWebCorepageSettingsh">trunk/Source/WebCore/page/Settings.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsavfoundationMediaPlayerPrivateAVFoundationcpp">trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp</a></li>
<li><a href="#trunkSourceWebKitmacChangeLog">trunk/Source/WebKit/mac/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitmacWebCoreSupportWebChromeClienth">trunk/Source/WebKit/mac/WebCoreSupport/WebChromeClient.h</a></li>
<li><a href="#trunkSourceWebKitmacWebCoreSupportWebChromeClientmm">trunk/Source/WebKit/mac/WebCoreSupport/WebChromeClient.mm</a></li>
<li><a href="#trunkSourceWebKitmacWebViewWebPreferenceKeysPrivateh">trunk/Source/WebKit/mac/WebView/WebPreferenceKeysPrivate.h</a></li>
<li><a href="#trunkSourceWebKitmacWebViewWebPreferencesmm">trunk/Source/WebKit/mac/WebView/WebPreferences.mm</a></li>
<li><a href="#trunkSourceWebKitmacWebViewWebPreferencesPrivateh">trunk/Source/WebKit/mac/WebView/WebPreferencesPrivate.h</a></li>
<li><a href="#trunkSourceWebKitmacWebViewWebViewmm">trunk/Source/WebKit/mac/WebView/WebView.mm</a></li>
<li><a href="#trunkSourceWebKitmacWebViewWebViewInternalh">trunk/Source/WebKit/mac/WebView/WebViewInternal.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreplatformiosWebVideoFullscreenControllerAVKith">trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.h</a></li>
<li><a href="#trunkSourceWebCoreplatformiosWebVideoFullscreenControllerAVKitmm">trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (162378 => 162379)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-01-20 22:33:23 UTC (rev 162378)
+++ trunk/Source/WebCore/ChangeLog        2014-01-20 22:41:25 UTC (rev 162379)
</span><span class="lines">@@ -1,3 +1,51 @@
</span><ins>+2014-01-20  Jeremy Jones  &lt;jeremyj@apple.com&gt;
+
+        Add AVKit fullscreen video interface.
+        https://bugs.webkit.org/show_bug.cgi?id=126818
+
+        Reviewed by Eric Carlson.
+
+        No new tests, no observable change in functionality.
+
+        * WebCore.exp.in:
+        * WebCore.xcodeproj/project.pbxproj:
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::parseAttribute):
+        * html/HTMLMediaElement.h:
+        Add ability for fullscreen to borrow the AVPlayerLayer.
+        * page/Settings.cpp:
+        * page/Settings.h:
+        (WebCore::Settings::setMediaPlaybackFullscreenAVKit):
+        (WebCore::Settings::mediaPlaybackFullscreenAVKit):
+        Add a disabled setting.
+        * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:
+        (WebCore::MediaPlayerPrivateAVFoundation::supportsFullscreen):
+        Enabled fullscreen for iOS.
+        * platform/ios/WebVideoFullscreenControllerAVKit.h: Added.
+        * platform/ios/WebVideoFullscreenControllerAVKit.mm: Added.
+        (-[WebAVPlayerController init]):
+        (-[WebAVPlayerController dealloc]):
+        (-[WebAVPlayerController forwardingTargetForSelector:]):
+        (-[WebAVPlayerController shouldDismissForDone]):
+        (-[WebAVPlayerController play:]):
+        (-[WebAVPlayerController pause:]):
+        (-[WebAVPlayerController togglePlayback:]):
+        (-[WebAVPlayerController isPlaying]):
+        (-[WebAVPlayerController setPlaying:]):
+        (+[WebAVPlayerController keyPathsForValuesAffectingPlaying]):
+        (-[WebAVPlayerController seekToTime:]):
+        (-[WebAVPlayerController updateTimingWithCurrentTime:]):
+        (-[WebAVPlayerController effectiveRate]):
+        (-[WebAVPlayerController setMediaElement:]):
+        (-[WebAVPlayerController handleEvent:]):
+        (-[WebVideoFullscreenController init]):
+        (-[WebVideoFullscreenController dealloc]):
+        (-[WebVideoFullscreenController setMediaElement:]):
+        (-[WebVideoFullscreenController mediaElement]):
+        (-[WebVideoFullscreenController enterFullscreen:]):
+        (-[WebVideoFullscreenController exitFullscreen]):
+        Add WebAVPlayerController for HTMLMediaElememt to interface with AVPlayerViewController.
+
</ins><span class="cx"> 2014-01-20  Zan Dobersek  &lt;zdobersek@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Replace uses of std::forward&lt;T&gt;(), std::unique_ptr&lt;T&gt;::clear() that landed in r162368
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCoreexpin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.exp.in (162378 => 162379)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.exp.in        2014-01-20 22:33:23 UTC (rev 162378)
+++ trunk/Source/WebCore/WebCore.exp.in        2014-01-20 22:41:25 UTC (rev 162379)
</span><span class="lines">@@ -2463,6 +2463,7 @@
</span><span class="cx"> __ZN7WebCore8IntPointC1ERK7CGPoint
</span><span class="cx"> __ZN7WebCore8PositionC1EN3WTF10PassRefPtrINS_4NodeEEENS0_19LegacyEditingOffsetE
</span><span class="cx"> __ZN7WebCore8SVGNames4initEv
</span><ins>+__ZN7WebCore8Settings13gAVKitEnabledE
</ins><span class="cx"> __ZN7WebCore8Settings13setStandaloneEb
</span><span class="cx"> __ZN7WebCore8Settings23setNetworkInterfaceNameERKN3WTF6StringE
</span><span class="cx"> __ZN7WebCore8Settings31setAudioSessionCategoryOverrideEj
</span><span class="lines">@@ -3052,7 +3053,7 @@
</span><span class="cx"> __ZNK7WebCore10TimeRanges7nearestEd
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-#if ENABLE(VIDEO) &amp;&amp; !PLATFORM(IOS)
</del><ins>+#if ENABLE(VIDEO)
</ins><span class="cx"> __ZNK7WebCore16HTMLMediaElement5endedEv
</span><span class="cx"> __ZNK7WebCore16HTMLMediaElement6pausedEv
</span><span class="cx"> .objc_class_name_WebVideoFullscreenController
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (162378 => 162379)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2014-01-20 22:33:23 UTC (rev 162378)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2014-01-20 22:41:25 UTC (rev 162379)
</span><span class="lines">@@ -1301,6 +1301,8 @@
</span><span class="cx">                 3F2B33ED165AF15600E3987C /* DOMWebKitCSSViewportRuleInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 3F2B33E8165AF15500E3987C /* DOMWebKitCSSViewportRuleInternal.h */; };
</span><span class="cx">                 3F2B33EE165AF15600E3987C /* JSWebKitCSSViewportRule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3F2B33E9165AF15500E3987C /* JSWebKitCSSViewportRule.cpp */; };
</span><span class="cx">                 3F2B33EF165AF15600E3987C /* JSWebKitCSSViewportRule.h in Headers */ = {isa = PBXBuildFile; fileRef = 3F2B33EA165AF15500E3987C /* JSWebKitCSSViewportRule.h */; };
</span><ins>+                3F42B31D1881191B00278AAC /* WebVideoFullscreenControllerAVKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 3F42B31B1881191B00278AAC /* WebVideoFullscreenControllerAVKit.h */; settings = {ATTRIBUTES = (Private, ); }; };
+                3F42B31E1881191B00278AAC /* WebVideoFullscreenControllerAVKit.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3F42B31C1881191B00278AAC /* WebVideoFullscreenControllerAVKit.mm */; };
</ins><span class="cx">                 3FFFF9A8159D9A550020BBD5 /* WebKitCSSViewportRule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3FFFF9A6159D9A550020BBD5 /* WebKitCSSViewportRule.cpp */; };
</span><span class="cx">                 3FFFF9A9159D9A550020BBD5 /* WebKitCSSViewportRule.h in Headers */ = {isa = PBXBuildFile; fileRef = 3FFFF9A7159D9A550020BBD5 /* WebKitCSSViewportRule.h */; };
</span><span class="cx">                 3FFFF9AD159D9B060020BBD5 /* ViewportStyleResolver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3FFFF9AB159D9B060020BBD5 /* ViewportStyleResolver.cpp */; };
</span><span class="lines">@@ -8184,6 +8186,8 @@
</span><span class="cx">                 3F2B33E8165AF15500E3987C /* DOMWebKitCSSViewportRuleInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMWebKitCSSViewportRuleInternal.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 3F2B33E9165AF15500E3987C /* JSWebKitCSSViewportRule.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebKitCSSViewportRule.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 3F2B33EA165AF15500E3987C /* JSWebKitCSSViewportRule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWebKitCSSViewportRule.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                3F42B31B1881191B00278AAC /* WebVideoFullscreenControllerAVKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebVideoFullscreenControllerAVKit.h; path = ios/WebVideoFullscreenControllerAVKit.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                3F42B31C1881191B00278AAC /* WebVideoFullscreenControllerAVKit.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WebVideoFullscreenControllerAVKit.mm; path = ios/WebVideoFullscreenControllerAVKit.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 3FFFF9A6159D9A550020BBD5 /* WebKitCSSViewportRule.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebKitCSSViewportRule.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 3FFFF9A7159D9A550020BBD5 /* WebKitCSSViewportRule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebKitCSSViewportRule.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 3FFFF9AB159D9B060020BBD5 /* ViewportStyleResolver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ViewportStyleResolver.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -18075,6 +18079,8 @@
</span><span class="cx">                                 FE0D84EA1048436E001A179E /* WebEvent.mm */,
</span><span class="cx">                                 A502C5DD13049B3500FC7D53 /* WebSafeGCActivityCallbackIOS.h */,
</span><span class="cx">                                 C2C4CB1D161A131200D214DA /* WebSafeIncrementalSweeperIOS.h */,
</span><ins>+                                3F42B31B1881191B00278AAC /* WebVideoFullscreenControllerAVKit.h */,
+                                3F42B31C1881191B00278AAC /* WebVideoFullscreenControllerAVKit.mm */,
</ins><span class="cx">                                 E453903C0EAFD637003695C8 /* WidgetIOS.mm */,
</span><span class="cx">                         );
</span><span class="cx">                         name = ios;
</span><span class="lines">@@ -25040,6 +25046,7 @@
</span><span class="cx">                                 A9C6E4F40D745E48006442E9 /* PluginData.h in Headers */,
</span><span class="cx">                                 97205ABC1239292700B17380 /* PluginDocument.h in Headers */,
</span><span class="cx">                                 1ADA14110E1AE5D900023EE5 /* PluginMainThreadScheduler.h in Headers */,
</span><ins>+                                3F42B31D1881191B00278AAC /* WebVideoFullscreenControllerAVKit.h in Headers */,
</ins><span class="cx">                                 71E2183A17359FB8006E6E4D /* PlugInsResources.h in Headers */,
</span><span class="cx">                                 1AA8799011CBE846003C664F /* PluginStrategy.h in Headers */,
</span><span class="cx">                                 0AFDAC3D10F5448C00E1F3D2 /* PluginViewBase.h in Headers */,
</span><span class="lines">@@ -29027,6 +29034,7 @@
</span><span class="cx">                                 B2227A900D00BF220071B782 /* SVGPolygonElement.cpp in Sources */,
</span><span class="cx">                                 B2227A930D00BF220071B782 /* SVGPolylineElement.cpp in Sources */,
</span><span class="cx">                                 B543B85717EB758F003BE93A /* SVGPropertyInfo.cpp in Sources */,
</span><ins>+                                3F42B31E1881191B00278AAC /* WebVideoFullscreenControllerAVKit.mm in Sources */,
</ins><span class="cx">                                 B2227A960D00BF220071B782 /* SVGPreserveAspectRatio.cpp in Sources */,
</span><span class="cx">                                 B2227A990D00BF220071B782 /* SVGRadialGradientElement.cpp in Sources */,
</span><span class="cx">                                 B2227A9D0D00BF220071B782 /* SVGRectElement.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLMediaElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (162378 => 162379)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLMediaElement.cpp        2014-01-20 22:33:23 UTC (rev 162378)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp        2014-01-20 22:41:25 UTC (rev 162379)
</span><span class="lines">@@ -4846,11 +4846,12 @@
</span><span class="cx">     if (hasMediaControls())
</span><span class="cx">         mediaControls()-&gt;enteredFullscreen();
</span><span class="cx">     if (document().page()) {
</span><del>-#if !PLATFORM(IOS)
-        document().page()-&gt;chrome().client().enterFullscreenForNode(this);
-        scheduleEvent(eventNames().webkitbeginfullscreenEvent);
-#else
-        if (m_player)
</del><ins>+        if (document().page()-&gt;chrome().client().supportsFullscreenForNode(this)) {
+            document().page()-&gt;chrome().client().enterFullscreenForNode(this);
+            scheduleEvent(eventNames().webkitbeginfullscreenEvent);
+        }
+#if PLATFORM(IOS)
+        else if (m_player)
</ins><span class="cx">             m_player-&gt;enterFullscreen();
</span><span class="cx"> #endif
</span><span class="cx">     }
</span><span class="lines">@@ -4874,11 +4875,13 @@
</span><span class="cx">     if (document().page()) {
</span><span class="cx">         if (document().page()-&gt;chrome().requiresFullscreenForVideoPlayback())
</span><span class="cx">             pauseInternal();
</span><del>-#if !PLATFORM(IOS)
-        document().page()-&gt;chrome().client().exitFullscreenForNode(this);
-        scheduleEvent(eventNames().webkitendfullscreenEvent);
-#else
-        if (m_player)
</del><ins>+
+        if (document().page()-&gt;chrome().client().supportsFullscreenForNode(this)) {
+            document().page()-&gt;chrome().client().exitFullscreenForNode(this);
+            scheduleEvent(eventNames().webkitendfullscreenEvent);
+        }
+#if PLATFORM(IOS)
+        else if (m_player)
</ins><span class="cx">             m_player-&gt;exitFullscreen();
</span><span class="cx"> #endif
</span><span class="cx">     }
</span><span class="lines">@@ -4904,9 +4907,32 @@
</span><span class="cx"> #if USE(ACCELERATED_COMPOSITING)
</span><span class="cx"> PlatformLayer* HTMLMediaElement::platformLayer() const
</span><span class="cx"> {
</span><del>-    return m_player ? m_player-&gt;platformLayer() : 0;
</del><ins>+#if PLATFORM(IOS)
+    if (m_platformLayerBorrowed)
+        return nullptr;
+#endif
+    return m_player ? m_player-&gt;platformLayer() : nullptr;
</ins><span class="cx"> }
</span><ins>+
+#if PLATFORM(IOS)
+PlatformLayer* HTMLMediaElement::borrowPlatformLayer()
+{
+    ASSERT(!m_platformLayerBorrowed);
+    m_platformLayerBorrowed = true;
+    if (renderer())
+        renderer()-&gt;updateFromElement();
+    return m_player ? m_player-&gt;platformLayer() : nullptr;
+}
+
+void HTMLMediaElement::returnPlatformLayer(PlatformLayer* platformLayer)
+{
+    ASSERT(m_platformLayerBorrowed &amp;&amp; platformLayer == (m_player ? m_player-&gt;platformLayer() : nullptr));
+    m_platformLayerBorrowed = false;
+    if (renderer())
+        renderer()-&gt;updateFromElement();
+}
</ins><span class="cx"> #endif
</span><ins>+#endif
</ins><span class="cx"> 
</span><span class="cx"> bool HTMLMediaElement::hasClosedCaptions() const
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLMediaElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (162378 => 162379)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLMediaElement.h        2014-01-20 22:33:23 UTC (rev 162378)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h        2014-01-20 22:41:25 UTC (rev 162379)
</span><span class="lines">@@ -132,7 +132,11 @@
</span><span class="cx">     PlatformMedia platformMedia() const;
</span><span class="cx"> #if USE(ACCELERATED_COMPOSITING)
</span><span class="cx">     PlatformLayer* platformLayer() const;
</span><ins>+#if PLATFORM(IOS)
+    PlatformLayer* borrowPlatformLayer();
+    void returnPlatformLayer(PlatformLayer*);
</ins><span class="cx"> #endif
</span><ins>+#endif
</ins><span class="cx"> 
</span><span class="cx">     enum DelayedActionType {
</span><span class="cx">         LoadMediaResource = 1 &lt;&lt; 0,
</span><span class="lines">@@ -777,6 +781,7 @@
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">     bool m_requestingPlay : 1;
</span><ins>+    bool m_platformLayerBorrowed : 1;
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     bool m_resumePlaybackAfterInterruption : 1;
</span></span></pre></div>
<a id="trunkSourceWebCorepageSettingscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/Settings.cpp (162378 => 162379)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/Settings.cpp        2014-01-20 22:33:23 UTC (rev 162378)
+++ trunk/Source/WebCore/page/Settings.cpp        2014-01-20 22:41:25 UTC (rev 162379)
</span><span class="lines">@@ -98,6 +98,7 @@
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx"> bool Settings::gNetworkDataUsageTrackingEnabled = false;
</span><ins>+bool Settings::gAVKitEnabled = false;
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> // NOTEs
</span></span></pre></div>
<a id="trunkSourceWebCorepageSettingsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/Settings.h (162378 => 162379)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/Settings.h        2014-01-20 22:33:23 UTC (rev 162378)
+++ trunk/Source/WebCore/page/Settings.h        2014-01-20 22:41:25 UTC (rev 162379)
</span><span class="lines">@@ -307,6 +307,9 @@
</span><span class="cx"> 
</span><span class="cx">     static void setNetworkInterfaceName(const String&amp;);
</span><span class="cx">     static const String&amp; networkInterfaceName();
</span><ins>+
+    static void setAVKitEnabled(bool flag) { gAVKitEnabled = flag; }
+    static bool avKitEnabled() { return gAVKitEnabled; }
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> private:
</span><span class="lines">@@ -405,6 +408,7 @@
</span><span class="cx">     static bool gShouldRespectPriorityInCSSAttributeSetters;
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">     static bool gNetworkDataUsageTrackingEnabled;
</span><ins>+    static bool gAVKitEnabled;
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     static double gHiddenPageDOMTimerAlignmentInterval;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsavfoundationMediaPlayerPrivateAVFoundationcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp (162378 => 162379)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp        2014-01-20 22:33:23 UTC (rev 162378)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp        2014-01-20 22:41:25 UTC (rev 162379)
</span><span class="lines">@@ -38,6 +38,7 @@
</span><span class="cx"> #include &quot;URL.h&quot;
</span><span class="cx"> #include &quot;Logging.h&quot;
</span><span class="cx"> #include &quot;PlatformLayer.h&quot;
</span><ins>+#include &quot;Settings.h&quot;
</ins><span class="cx"> #include &quot;SoftLinking.h&quot;
</span><span class="cx"> #include &quot;TimeRanges.h&quot;
</span><span class="cx"> #include &lt;CoreMedia/CoreMedia.h&gt;
</span><span class="lines">@@ -474,6 +475,10 @@
</span><span class="cx">     return true;
</span><span class="cx"> #else
</span><span class="cx">     // FIXME: WebVideoFullscreenController assumes a QTKit/QuickTime media engine
</span><ins>+#if PLATFORM(IOS)
+    if (Settings::avKitEnabled())
+        return true;
+#endif
</ins><span class="cx">     return false;
</span><span class="cx"> #endif
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformiosWebVideoFullscreenControllerAVKith"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.h (0 => 162379)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.h                                (rev 0)
+++ trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.h        2014-01-20 22:41:25 UTC (rev 162379)
</span><span class="lines">@@ -0,0 +1,49 @@
</span><ins>+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebVideoFullscreenControllerAVKit_h
+#define WebVideoFullscreenControllerAVKit_h
+
+#if PLATFORM(IOS)
+
+#import &lt;wtf/RefPtr.h&gt;
+
+@class UIScreen;
+
+namespace WebCore {
+class HTMLMediaElement;
+}
+
+@interface WebVideoFullscreenController : NSObject
+
+- (void)setMediaElement:(WebCore::HTMLMediaElement*)mediaElement;
+- (WebCore::HTMLMediaElement*)mediaElement;
+
+- (void)enterFullscreen:(UIScreen *)screen;
+- (void)exitFullscreen;
+@end
+
+#endif
+#endif // WebVideoFullscreenControllerAVKit_h
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformiosWebVideoFullscreenControllerAVKitmm"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm (0 => 162379)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm                                (rev 0)
+++ trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm        2014-01-20 22:41:25 UTC (rev 162379)
</span><span class="lines">@@ -0,0 +1,425 @@
</span><ins>+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import &quot;config.h&quot;
+
+#if PLATFORM(IOS)
+
+#import &quot;WebVideoFullscreenControllerAVKit.h&quot;
+
+#import &quot;DOMEventInternal.h&quot;
+#import &quot;Logging.h&quot;
+#import &lt;CoreMedia/CMTime.h&gt;
+#import &lt;UIKit/UIKit.h&gt;
+#import &lt;WebCore/DOMEventListener.h&gt;
+#import &lt;WebCore/Event.h&gt;
+#import &lt;WebCore/EventListener.h&gt;
+#import &lt;WebCore/EventNames.h&gt;
+#import &lt;WebCore/HTMLElement.h&gt;
+#import &lt;WebCore/HTMLVideoElement.h&gt;
+#import &lt;WebCore/ObjCEventListener.h&gt;
+#import &lt;WebCore/SoftLinking.h&gt;
+#import &lt;WebCore/WebCoreThreadRun.h&gt;
+#import &lt;WebCore/RenderElement.h&gt;
+#import &lt;wtf/RetainPtr.h&gt;
+
+using namespace WebCore;
+
+SOFT_LINK_FRAMEWORK(AVFoundation)
+SOFT_LINK_CLASS(AVFoundation, AVPlayerLayer)
+
+SOFT_LINK_FRAMEWORK(AVKit)
+SOFT_LINK_CLASS(AVKit, AVPlayerController)
+SOFT_LINK_CLASS(AVKit, AVPlayerViewController)
+SOFT_LINK_CLASS(AVKit, AVValueTiming)
+
+SOFT_LINK_FRAMEWORK(UIKit)
+SOFT_LINK_CLASS(UIKit, UIScreen)
+SOFT_LINK_CLASS(UIKit, UIWindow)
+SOFT_LINK_CLASS(UIKit, UIView)
+SOFT_LINK_CLASS(UIKit, UIViewController)
+SOFT_LINK_CLASS(UIKit, UIColor)
+
+SOFT_LINK_FRAMEWORK(CoreMedia)
+SOFT_LINK(CoreMedia, CMTimeMakeWithSeconds, CMTime, (Float64 seconds, int32_t preferredTimeScale), (seconds, preferredTimeScale))
+SOFT_LINK(CoreMedia, CMTimeGetSeconds, Float64, (CMTime time), (time))
+
+@interface AVValueTiming : NSObject &lt;NSCoding, NSCopying, NSMutableCopying&gt;
++ (id)valueTimingWithAnchorValue:(double)anchorValue anchorTimeStamp:(NSTimeInterval) timeStamp rate:(double)rate;
++ (NSTimeInterval)currentTimeStamp;
+@end
+
+@protocol AVPlayerViewControllerDelegate
+@end
+
+@protocol AVPlayerLayer
+@end
+
+@interface AVPlayerController : UIResponder
+@end
+
+@interface AVPlayerViewController : UIViewController
+@property (nonatomic, weak) id &lt;AVPlayerViewControllerDelegate&gt; delegate;
+@property (nonatomic, strong) AVPlayerController *playerController;
+@end
+
+typedef NS_ENUM(NSInteger, AVPlayerViewControllerDismissalReason) {
+    AVPlayerViewControllerDismissalReasonDoneButtonTapped,
+    AVPlayerViewControllerDismissalReasonRemoteControlStopEventReceived,
+    AVPlayerViewControllerDismissalReasonError
+} NS_ENUM_AVAILABLE_IOS(8_0);
+
+typedef NS_ENUM(NSInteger, AVPlayerControllerStatus) {
+    AVPlayerControllerStatusUnknown,
+    AVPlayerControllerStatusLoading,
+    AVPlayerControllerStatusReadyToPlay,
+    AVPlayerControllerStatusFailed
+} NS_ENUM_AVAILABLE(10_10, 8_0);
+
+@interface WebAVPlayerController : NSObject &lt;DOMEventListener, AVPlayerViewControllerDelegate&gt;
+
+@property(retain) AVPlayerController* playerControllerProxy;
+@property(retain) CALayer&lt;AVPlayerLayer&gt; *playerLayer;
+
+@property BOOL canPlay;
+@property(getter=isPlaying) BOOL playing;
+@property BOOL canPause;
+@property BOOL canTogglePlayback;
+@property double rate;
+@property BOOL canSeek;
+@property NSTimeInterval contentDuration;
+@property NSSize contentDimensions;
+@property BOOL hasEnabledAudio;
+@property BOOL hasEnabledVideo;
+@property NSTimeInterval minTime;
+@property NSTimeInterval maxTime;
+@property NSTimeInterval contentDurationWithinEndTimes;
+@property(retain) NSArray *loadedTimeRanges;
+@property AVPlayerControllerStatus status;
+@property(retain) AVValueTiming *timing;
+
+- (void)handleEvent:(DOMEvent *)evt;
+
+- (BOOL)playerViewController:(AVPlayerViewController *)playerViewController shouldDismissWithReason:(AVPlayerViewControllerDismissalReason)reason;
+
+@end
+
+
+@implementation WebAVPlayerController
+{
+    RefPtr&lt;HTMLMediaElement&gt; _mediaElement;
+    RefPtr&lt;EventListener&gt; _listener;
+}
+
+- (instancetype)init
+{
+    if (!(self = [super init]))
+        return self;
+    
+    initAVPlayerController();
+    self.playerControllerProxy = [[classAVPlayerController alloc] init];
+    return self;
+}
+
+- (void)dealloc
+{
+    self.playerControllerProxy = nil;
+    self.playerLayer = nil;
+    self.loadedTimeRanges = nil;
+    self.timing = nil;
+    [super dealloc];
+}
+
+- (id)forwardingTargetForSelector:(SEL)selector
+{
+    UNUSED_PARAM(selector);
+    return self.playerControllerProxy;
+}
+
+- (BOOL)playerViewController:(AVPlayerViewController *)playerViewController shouldDismissWithReason:(AVPlayerViewControllerDismissalReason)reason
+{
+    UNUSED_PARAM(playerViewController);
+    UNUSED_PARAM(reason);
+
+    WebThreadRun(^{
+        _mediaElement-&gt;pause();
+        _mediaElement-&gt;exitFullscreen();
+    });
+    return NO;
+}
+
+- (void)play:(id)sender
+{
+    UNUSED_PARAM(sender);
+    WebThreadRun(^{
+        _mediaElement-&gt;play();
+    });
+}
+
+- (void)pause:(id)sender
+{
+    UNUSED_PARAM(sender);
+    WebThreadRun(^{
+        _mediaElement-&gt;pause();
+    });
+}
+
+- (void)togglePlayback:(id)sender
+{
+    UNUSED_PARAM(sender);
+    WebThreadRun(^{
+        _mediaElement-&gt;togglePlayState();
+    });
+}
+
+- (BOOL)isPlaying
+{
+    return [self rate] != 0;
+}
+
+- (void)setPlaying:(BOOL)playing
+{
+    WebThreadRun(^{
+        if (playing)
+            _mediaElement-&gt;play();
+        else
+            _mediaElement-&gt;pause();
+    });
+}
+
++ (NSSet *)keyPathsForValuesAffectingPlaying
+{
+    return [NSSet setWithObject:@&quot;rate&quot;];
+}
+
+- (void)seekToTime:(NSTimeInterval)time
+{
+    WebThreadRun(^{
+        _mediaElement-&gt;setCurrentTime(time);
+    });
+}
+
+- (void)updateTimingWithCurrentTime:(NSTimeInterval)currentTime
+{
+    NSTimeInterval anchorTimeStamp = (![self rate]) ? NAN : [classAVValueTiming currentTimeStamp];
+    AVValueTiming *timing = [classAVValueTiming valueTimingWithAnchorValue:currentTime
+      anchorTimeStamp:anchorTimeStamp rate:0];
+    [self setTiming:timing];
+}
+
+- (double)effectiveRate
+{
+    return _mediaElement-&gt;isPlaying() ? _mediaElement-&gt;playbackRate() : 0.;
+}
+
+- (void)updateDuration
+{
+    // FIXME: https://bugs.webkit.org/show_bug.cgi?id=127017 use correct values instead of duration for all these
+    NSTimeInterval duration = _mediaElement-&gt;duration();
+    self.contentDuration = duration;
+    self.maxTime = duration;
+    self.contentDurationWithinEndTimes = duration;
+    self.loadedTimeRanges = @[@0, @(duration)];
+}
+
+- (void)setMediaElement:(PassRefPtr&lt;HTMLMediaElement&gt;)passedMediaElement
+{
+    RefPtr&lt;HTMLMediaElement&gt; mediaElement = passedMediaElement;
+
+    if (_mediaElement == mediaElement)
+        return;
+    
+    if (_mediaElement &amp;&amp; _listener)
+    {
+        _mediaElement-&gt;removeEventListener(eventNames().durationchangeEvent, _listener.get(), false);
+        _mediaElement-&gt;removeEventListener(eventNames().pauseEvent, _listener.get(), false);
+        _mediaElement-&gt;removeEventListener(eventNames().playEvent, _listener.get(), false);
+        _mediaElement-&gt;removeEventListener(eventNames().ratechangeEvent, _listener.get(), false);
+        _mediaElement-&gt;removeEventListener(eventNames().timeupdateEvent, _listener.get(), false);
+    }
+    
+    if (_mediaElement)
+    {
+        [self.playerLayer removeFromSuperlayer];
+        _mediaElement-&gt;returnPlatformLayer(self.playerLayer);
+        self.playerLayer = nil;
+    }
+    
+    _mediaElement = mediaElement;
+    _listener = nullptr;
+    
+    if (!_mediaElement)
+        return;
+
+    _listener = ObjCEventListener::wrap(self);
+
+    _mediaElement-&gt;addEventListener(eventNames().durationchangeEvent, _listener, false);
+    _mediaElement-&gt;addEventListener(eventNames().pauseEvent, _listener, false);
+    _mediaElement-&gt;addEventListener(eventNames().playEvent, _listener, false);
+    _mediaElement-&gt;addEventListener(eventNames().ratechangeEvent, _listener, false);
+    _mediaElement-&gt;addEventListener(eventNames().timeupdateEvent, _listener, false);
+
+    [self updateDuration];
+    self.canPlay = YES;
+    self.canPause = YES;
+    self.canTogglePlayback = YES;
+    self.hasEnabledAudio = YES;
+    self.canSeek = YES;
+    self.minTime = 0;
+    self.rate = [self effectiveRate];
+    self.status = AVPlayerControllerStatusReadyToPlay;
+
+    self.playerLayer = (CALayer&lt;AVPlayerLayer&gt; *)_mediaElement-&gt;borrowPlatformLayer();
+    ASSERT([self.playerLayer isKindOfClass:classAVPlayerLayer]);
+    [self.playerLayer removeFromSuperlayer];
+
+    [self updateTimingWithCurrentTime:_mediaElement-&gt;currentTime()];
+
+    if (isHTMLVideoElement(_mediaElement.get())) {
+        HTMLVideoElement *videoElement = toHTMLVideoElement(_mediaElement.get());
+        self.hasEnabledVideo = YES;
+        self.contentDimensions = CGSizeMake(videoElement-&gt;videoWidth(), videoElement-&gt;videoHeight());
+    }
+}
+
+- (void)handleEvent:(DOMEvent *)evnt
+{
+    Event* event = core(evnt);
+    
+    if (!_mediaElement)
+        return;
+
+    LOG(Media, &quot;handleEvent %s&quot;, event-&gt;type().characters8());
+
+    if (event-&gt;type() == eventNames().durationchangeEvent)
+        [self updateDuration];
+    else if (event-&gt;type() == eventNames().pauseEvent
+        || event-&gt;type() == eventNames().playEvent
+        || event-&gt;type() == eventNames().ratechangeEvent)
+        self.rate = [self effectiveRate];
+    else if (event-&gt;type() == eventNames().timeupdateEvent)
+        [self updateTimingWithCurrentTime:_mediaElement-&gt;currentTime()];
+}
+
+@end
+
+@interface WebVideoFullscreenController () &lt;UIViewControllerTransitioningDelegate&gt;
+@property(retain) UIWindow *window;
+@property(retain) UIViewController *viewController;
+@property(retain) AVPlayerViewController *playerViewController;
+@property(retain) WebAVPlayerController *playerController;
+@end
+
+@implementation WebVideoFullscreenController
+{
+    RefPtr&lt;HTMLMediaElement&gt; _mediaElement;
+}
+
+- (instancetype)init
+{
+    if (!(self = [super init]))
+        return nil;
+
+    initUIScreen();
+    initUIView();
+    initUIColor();
+    initUIWindow();
+    initAVPlayerController();
+    initAVPlayerViewController();
+    initAVValueTiming();
+    initUIViewController();
+    initAVPlayerLayer();
+    return self;
+}
+
+- (void)dealloc
+{
+    self.window = nil;
+    self.viewController = nil;
+    self.playerViewController = nil;
+    self.playerController = nil;
+    _mediaElement = nullptr;
+    [super dealloc];
+}
+
+- (void)setMediaElement:(HTMLMediaElement*)mediaElement
+{
+    _mediaElement = mediaElement;
+}
+
+- (HTMLMediaElement*)mediaElement
+{
+    return _mediaElement.get();
+}
+
+- (void)enterFullscreen:(UIScreen *)screen
+{
+    if (!screen)
+        screen = [classUIScreen mainScreen];
+
+    self.playerController = [[[WebAVPlayerController alloc] init] autorelease];
+    self.playerController.mediaElement = _mediaElement;
+
+    dispatch_async(dispatch_get_main_queue(), ^{
+        self.playerViewController = [[[classAVPlayerViewController alloc] init] autorelease];
+        self.playerViewController.playerController = (AVPlayerController *)self.playerController;
+        
+        if ([self.playerViewController respondsToSelector:@selector(setDelegate:)])
+            self.playerViewController.delegate = self.playerController;
+       
+        self.viewController = [[[classUIViewController alloc] init] autorelease];
+        
+        self.window = [[[classUIWindow alloc] initWithFrame:[screen bounds]] autorelease];
+        self.window.backgroundColor = [classUIColor clearColor];
+        self.window.rootViewController = (UIViewController *)self.viewController;
+        [self.window makeKeyAndVisible];
+        
+        [self.viewController presentViewController:self.playerViewController animated:YES completion:nil];
+    });
+}
+
+- (void)exitFullscreen
+{
+    self.playerController.mediaElement = nullptr;
+
+    dispatch_async(dispatch_get_main_queue(), ^{
+        [self.viewController dismissViewControllerAnimated:YES completion:^{
+            self.window.hidden = YES;
+            self.window.rootViewController = nil;
+            
+            self.playerViewController = nil;
+            self.viewController = nil;
+            self.window = nil;
+            WebThreadRun(^{
+                _mediaElement = nullptr;
+            });
+            
+        }];
+    });
+}
+
+@end
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebKitmacChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/ChangeLog (162378 => 162379)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/ChangeLog        2014-01-20 22:33:23 UTC (rev 162378)
+++ trunk/Source/WebKit/mac/ChangeLog        2014-01-20 22:41:25 UTC (rev 162379)
</span><span class="lines">@@ -1,3 +1,28 @@
</span><ins>+2014-01-20  Jeremy Jones  &lt;jeremyj@apple.com&gt;
+
+        Add AVKit fullscreen video interface.
+        https://bugs.webkit.org/show_bug.cgi?id=126818
+
+        Reviewed by Eric Carlson.
+
+        * WebCoreSupport/WebChromeClient.h:
+        * WebCoreSupport/WebChromeClient.mm:
+        (WebChromeClient::supportsFullscreenForNode):
+        Enable *FullscreenForNode for HTMLMediaElement for iOS
+
+        * WebView/WebPreferenceKeysPrivate.h:
+        * WebView/WebPreferences.mm:
+        (+[WebPreferences initialize]):
+        (-[WebPreferences mediaPlaybackFullscreenAVKit]):
+        (-[WebPreferences setMediaPlaybackFullscreenAVKit:]):
+        * WebView/WebPreferencesPrivate.h:
+        * WebView/WebView.mm:
+        (-[WebView _preferencesChanged:]):
+        (-[WebView _enterFullscreenForNode:WebCore::]):
+        * WebView/WebViewInternal.h:
+        Add a disabled pref mediaPlaybackFullscreenAVKit.
+        Use WebVideoFullscreenControllerAVKit on iOS
+
</ins><span class="cx"> 2014-01-18  Brian Burg  &lt;bburg@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Web Inspector: Page should use std::unique_ptr for InspectorController
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebCoreSupportWebChromeClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebChromeClient.h (162378 => 162379)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebCoreSupport/WebChromeClient.h        2014-01-20 22:33:23 UTC (rev 162378)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebChromeClient.h        2014-01-20 22:41:25 UTC (rev 162379)
</span><span class="lines">@@ -185,7 +185,7 @@
</span><span class="cx">     }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-#if ENABLE(VIDEO) &amp;&amp; !PLATFORM(IOS)
</del><ins>+#if ENABLE(VIDEO)
</ins><span class="cx">     virtual bool supportsFullscreenForNode(const WebCore::Node*) override;
</span><span class="cx">     virtual void enterFullscreenForNode(WebCore::Node*) override;
</span><span class="cx">     virtual void exitFullscreenForNode(WebCore::Node*) override;
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebCoreSupportWebChromeClientmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebChromeClient.mm (162378 => 162379)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebCoreSupport/WebChromeClient.mm        2014-01-20 22:33:23 UTC (rev 162378)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebChromeClient.mm        2014-01-20 22:41:25 UTC (rev 162379)
</span><span class="lines">@@ -967,10 +967,14 @@
</span><span class="cx"> 
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-#if ENABLE(VIDEO) &amp;&amp; !PLATFORM(IOS)
</del><ins>+#if ENABLE(VIDEO)
</ins><span class="cx"> 
</span><span class="cx"> bool WebChromeClient::supportsFullscreenForNode(const Node* node)
</span><span class="cx"> {
</span><ins>+#if PLATFORM(IOS)
+    if (!Settings::avKitEnabled())
+        return false;
+#endif
</ins><span class="cx">     return isHTMLVideoElement(node);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebViewWebPreferenceKeysPrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebView/WebPreferenceKeysPrivate.h (162378 => 162379)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebView/WebPreferenceKeysPrivate.h        2014-01-20 22:33:23 UTC (rev 162378)
+++ trunk/Source/WebKit/mac/WebView/WebPreferenceKeysPrivate.h        2014-01-20 22:41:25 UTC (rev 162379)
</span><span class="lines">@@ -133,6 +133,7 @@
</span><span class="cx"> #if TARGET_OS_IPHONE
</span><span class="cx"> #define WebKitMediaPlaybackAllowsAirPlayPreferenceKey @&quot;WebKitMediaPlaybackAllowsAirPlay&quot;
</span><span class="cx"> #define WebKitAudioSessionCategoryOverride @&quot;WebKitAudioSessionCategoryOverride&quot;
</span><ins>+#define WebKitAVKitEnabled @&quot;WebKitAVKitEnabled&quot;
</ins><span class="cx"> #endif
</span><span class="cx"> #define WebKitRegionBasedColumnsEnabledKey @&quot;WebKitRegionBasedColumnsEnabled&quot;
</span><span class="cx"> #define WebKitShouldRespectImageOrientationKey @&quot;WebKitShouldRespectImageOrientation&quot;
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebViewWebPreferencesmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebView/WebPreferences.mm (162378 => 162379)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebView/WebPreferences.mm        2014-01-20 22:33:23 UTC (rev 162378)
+++ trunk/Source/WebKit/mac/WebView/WebPreferences.mm        2014-01-20 22:41:25 UTC (rev 162379)
</span><span class="lines">@@ -531,6 +531,7 @@
</span><span class="cx">         [NSNumber numberWithBool:NO],   WebKitMediaPlaybackAllowsInlinePreferenceKey,
</span><span class="cx">         [NSNumber numberWithBool:YES],  WebKitMediaPlaybackAllowsAirPlayPreferenceKey,
</span><span class="cx">         [NSNumber numberWithUnsignedInt:AudioSession::None],  WebKitAudioSessionCategoryOverride,
</span><ins>+        [NSNumber numberWithBool:NO],   WebKitAVKitEnabled,
</ins><span class="cx">         [NSNumber numberWithLongLong:WebCore::ApplicationCacheStorage::noQuota()], WebKitApplicationCacheTotalQuota,
</span><span class="cx"> 
</span><span class="cx">         // Per-Origin Quota on iOS is 25MB. When the quota is reached for a particular origin
</span><span class="lines">@@ -2218,6 +2219,16 @@
</span><span class="cx">     [self _setUnsignedIntValue:override forKey:WebKitAudioSessionCategoryOverride];
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (BOOL)avKitEnabled
+{
+    return [self _boolValueForKey:WebKitAVKitEnabled];
+}
+
+- (void)setAVKitEnabled:(bool)flag
+{
+    [self _setBoolValue:flag forKey:WebKitAVKitEnabled];
+}
+
</ins><span class="cx"> - (BOOL)networkDataUsageTrackingEnabled
</span><span class="cx"> {
</span><span class="cx">     return [self _boolValueForKey:WebKitNetworkDataUsageTrackingEnabledPreferenceKey];
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebViewWebPreferencesPrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebView/WebPreferencesPrivate.h (162378 => 162379)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebView/WebPreferencesPrivate.h        2014-01-20 22:33:23 UTC (rev 162378)
+++ trunk/Source/WebKit/mac/WebView/WebPreferencesPrivate.h        2014-01-20 22:41:25 UTC (rev 162379)
</span><span class="lines">@@ -259,6 +259,9 @@
</span><span class="cx"> - (unsigned)audioSessionCategoryOverride;
</span><span class="cx"> - (void)setAudioSessionCategoryOverride:(unsigned)override;
</span><span class="cx"> 
</span><ins>+- (BOOL)avKitEnabled;
+- (void)setAVKitEnabled:(bool)flag;
+
</ins><span class="cx"> // WARNING: this affect network performance. This must not be enabled for production use.
</span><span class="cx"> // Enabling this makes WebCore reports the network data usage.
</span><span class="cx"> // This is a global setting.
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebViewWebViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebView/WebView.mm (162378 => 162379)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebView/WebView.mm        2014-01-20 22:33:23 UTC (rev 162378)
+++ trunk/Source/WebKit/mac/WebView/WebView.mm        2014-01-20 22:41:25 UTC (rev 162379)
</span><span class="lines">@@ -242,6 +242,7 @@
</span><span class="cx"> #import &lt;WebCore/WebCoreThreadMessage.h&gt;
</span><span class="cx"> #import &lt;WebCore/WebCoreThreadRun.h&gt;
</span><span class="cx"> #import &lt;WebCore/WebEvent.h&gt;
</span><ins>+#import &lt;WebCore/WebVideoFullscreenControllerAVKit.h&gt;
</ins><span class="cx"> #import &lt;dispatch/private.h&gt;
</span><span class="cx"> #import &lt;wtf/FastMalloc.h&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -2354,6 +2355,7 @@
</span><span class="cx">     settings.setAudioSessionCategoryOverride([preferences audioSessionCategoryOverride]);
</span><span class="cx">     settings.setNetworkDataUsageTrackingEnabled([preferences networkDataUsageTrackingEnabled]);
</span><span class="cx">     settings.setNetworkInterfaceName([preferences networkInterfaceName]);
</span><ins>+    settings.setAVKitEnabled([preferences avKitEnabled]);
</ins><span class="cx"> #endif
</span><span class="cx">     settings.setMediaPlaybackRequiresUserGesture([preferences mediaPlaybackRequiresUserGesture]);
</span><span class="cx">     settings.setMediaPlaybackAllowsInline([preferences mediaPlaybackAllowsInline]);
</span><span class="lines">@@ -8467,7 +8469,7 @@
</span><span class="cx"> 
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-#if ENABLE(VIDEO) &amp;&amp; !PLATFORM(IOS)
</del><ins>+#if ENABLE(VIDEO)
</ins><span class="cx"> - (void)_enterFullscreenForNode:(WebCore::Node*)node
</span><span class="cx"> {
</span><span class="cx">     ASSERT(isHTMLVideoElement(node));
</span><span class="lines">@@ -8490,7 +8492,11 @@
</span><span class="cx">     if (!_private-&gt;fullscreenController) {
</span><span class="cx">         _private-&gt;fullscreenController = [[WebVideoFullscreenController alloc] init];
</span><span class="cx">         [_private-&gt;fullscreenController setMediaElement:videoElement];
</span><del>-        [_private-&gt;fullscreenController enterFullscreen:[[self window] screen]];        
</del><ins>+#if PLATFORM(IOS)
+        [_private-&gt;fullscreenController enterFullscreen:nil];
+#else
+        [_private-&gt;fullscreenController enterFullscreen:[[self window] screen]];
+#endif
</ins><span class="cx">     }
</span><span class="cx">     else
</span><span class="cx">         [_private-&gt;fullscreenController setMediaElement:videoElement];
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebViewWebViewInternalh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebView/WebViewInternal.h (162378 => 162379)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebView/WebViewInternal.h        2014-01-20 22:33:23 UTC (rev 162378)
+++ trunk/Source/WebKit/mac/WebView/WebViewInternal.h        2014-01-20 22:41:25 UTC (rev 162379)
</span><span class="lines">@@ -236,7 +236,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_preferencesChanged:(WebPreferences *)preferences;
</span><span class="cx"> 
</span><del>-#if ENABLE(VIDEO) &amp;&amp; !PLATFORM(IOS) &amp;&amp; defined(__cplusplus)
</del><ins>+#if ENABLE(VIDEO) &amp;&amp; defined(__cplusplus)
</ins><span class="cx"> - (void)_enterFullscreenForNode:(WebCore::Node*)node;
</span><span class="cx"> - (void)_exitFullscreen;
</span><span class="cx"> #endif
</span></span></pre>
</div>
</div>

</body>
</html>