<!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>[163097] trunk/Source/WebCore</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/163097">163097</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2014-01-30 11:50:03 -0800 (Thu, 30 Jan 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Refactor WebVideoFullscreenController separating AVKit from MediaElement.
https://bugs.webkit.org/show_bug.cgi?id=127762
Patch by Jeremy Jones <jeremyj@apple.com> on 2014-01-30
Reviewed by Jer Noble.
Refactor WebVideoFullscreenControllerAVKit implementation into two abstract interfaces with concrete implementations:
WebVideoFullscreenModel, WebVideoFullscreenInterface, WebVideoFullscreenModelMediaElement, WebVideoFullscreenInterfaceAVKit.
* WebCore.xcodeproj/project.pbxproj:
* platform/ios/WebVideoFullscreenControllerAVKit.h:
* platform/ios/WebVideoFullscreenControllerAVKit.mm:
(-[WebVideoFullscreenController init]):
(-[WebVideoFullscreenController dealloc]):
(-[WebVideoFullscreenController enterFullscreen:]):
(-[WebVideoFullscreenController exitFullscreen]):
* platform/ios/WebVideoFullscreenInterface.h: Copied from Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.h.
(WebCore::WebVideoFullscreenInterface::~WebVideoFullscreenInterface):
* platform/ios/WebVideoFullscreenInterfaceAVKit.h: Added.
(WebCore::WebVideoFullscreenInterfaceAVKit::~WebVideoFullscreenInterfaceAVKit):
* platform/ios/WebVideoFullscreenInterfaceAVKit.mm: Added.
(NS_ENUM):
(-[WebAVPlayerController init]):
(-[WebAVPlayerController dealloc]):
(-[WebAVPlayerController forwardingTargetForSelector:]):
(-[WebAVPlayerController playerViewController:shouldDismissWithReason:]):
(-[WebAVPlayerController play:]):
(-[WebAVPlayerController pause:]):
(-[WebAVPlayerController togglePlayback:]):
(-[WebAVPlayerController isPlaying]):
(-[WebAVPlayerController setPlaying:]):
(+[WebAVPlayerController keyPathsForValuesAffectingPlaying]):
(-[WebAVPlayerController seekToTime:]):
(:m_videoFullscreenModel):
(WebVideoFullscreenInterfaceAVKit::setWebVideoFullscreenModel):
(WebVideoFullscreenInterfaceAVKit::setDuration):
(WebVideoFullscreenInterfaceAVKit::setCurrentTime):
(WebVideoFullscreenInterfaceAVKit::setRate):
(WebVideoFullscreenInterfaceAVKit::setVideoDimensions):
(WebVideoFullscreenInterfaceAVKit::setVideoLayer):
(WebVideoFullscreenInterfaceAVKit::enterFullscreen):
(WebVideoFullscreenInterfaceAVKit::exitFullscreen):
* platform/ios/WebVideoFullscreenModel.h: Copied from Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.h.
(WebCore::WebVideoFullscreenModel::~WebVideoFullscreenModel):
* platform/ios/WebVideoFullscreenModelMediaElement.h: Copied from Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.h.
(WebCore::WebVideoFullscreenModelMediaElement::~WebVideoFullscreenModelMediaElement):
(WebCore::WebVideoFullscreenModelMediaElement::setWebVideoFullscreenInterface):
* platform/ios/WebVideoFullscreenModelMediaElement.mm: Added.
(WebVideoFullscreenModelMediaElement::setMediaElement):
(WebVideoFullscreenModelMediaElement::handleEvent):
(WebVideoFullscreenModelMediaElement::requestExitFullScreen):
(WebVideoFullscreenModelMediaElement::play):
(WebVideoFullscreenModelMediaElement::pause):
(WebVideoFullscreenModelMediaElement::togglePlayState):
(WebVideoFullscreenModelMediaElement::seekToTime):
(WebVideoFullscreenModelMediaElement::didExitFullscreen):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCoreplatformiosWebVideoFullscreenControllerAVKith">trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.h</a></li>
<li><a href="#trunkSourceWebCoreplatformiosWebVideoFullscreenControllerAVKitmm">trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<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>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (163096 => 163097)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-01-30 19:37:32 UTC (rev 163096)
+++ trunk/Source/WebCore/ChangeLog        2014-01-30 19:50:03 UTC (rev 163097)
</span><span class="lines">@@ -1,3 +1,61 @@
</span><ins>+2014-01-30 Jeremy Jones <jeremyj@apple.com>
+
+ Refactor WebVideoFullscreenController separating AVKit from MediaElement.
+ https://bugs.webkit.org/show_bug.cgi?id=127762
+
+ Reviewed by Jer Noble.
+
+ Refactor WebVideoFullscreenControllerAVKit implementation into two abstract interfaces with concrete implementations:
+ WebVideoFullscreenModel, WebVideoFullscreenInterface, WebVideoFullscreenModelMediaElement, WebVideoFullscreenInterfaceAVKit.
+
+ * WebCore.xcodeproj/project.pbxproj:
+ * platform/ios/WebVideoFullscreenControllerAVKit.h:
+ * platform/ios/WebVideoFullscreenControllerAVKit.mm:
+ (-[WebVideoFullscreenController init]):
+ (-[WebVideoFullscreenController dealloc]):
+ (-[WebVideoFullscreenController enterFullscreen:]):
+ (-[WebVideoFullscreenController exitFullscreen]):
+ * platform/ios/WebVideoFullscreenInterface.h: Copied from Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.h.
+ (WebCore::WebVideoFullscreenInterface::~WebVideoFullscreenInterface):
+ * platform/ios/WebVideoFullscreenInterfaceAVKit.h: Added.
+ (WebCore::WebVideoFullscreenInterfaceAVKit::~WebVideoFullscreenInterfaceAVKit):
+ * platform/ios/WebVideoFullscreenInterfaceAVKit.mm: Added.
+ (NS_ENUM):
+ (-[WebAVPlayerController init]):
+ (-[WebAVPlayerController dealloc]):
+ (-[WebAVPlayerController forwardingTargetForSelector:]):
+ (-[WebAVPlayerController playerViewController:shouldDismissWithReason:]):
+ (-[WebAVPlayerController play:]):
+ (-[WebAVPlayerController pause:]):
+ (-[WebAVPlayerController togglePlayback:]):
+ (-[WebAVPlayerController isPlaying]):
+ (-[WebAVPlayerController setPlaying:]):
+ (+[WebAVPlayerController keyPathsForValuesAffectingPlaying]):
+ (-[WebAVPlayerController seekToTime:]):
+ (:m_videoFullscreenModel):
+ (WebVideoFullscreenInterfaceAVKit::setWebVideoFullscreenModel):
+ (WebVideoFullscreenInterfaceAVKit::setDuration):
+ (WebVideoFullscreenInterfaceAVKit::setCurrentTime):
+ (WebVideoFullscreenInterfaceAVKit::setRate):
+ (WebVideoFullscreenInterfaceAVKit::setVideoDimensions):
+ (WebVideoFullscreenInterfaceAVKit::setVideoLayer):
+ (WebVideoFullscreenInterfaceAVKit::enterFullscreen):
+ (WebVideoFullscreenInterfaceAVKit::exitFullscreen):
+ * platform/ios/WebVideoFullscreenModel.h: Copied from Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.h.
+ (WebCore::WebVideoFullscreenModel::~WebVideoFullscreenModel):
+ * platform/ios/WebVideoFullscreenModelMediaElement.h: Copied from Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.h.
+ (WebCore::WebVideoFullscreenModelMediaElement::~WebVideoFullscreenModelMediaElement):
+ (WebCore::WebVideoFullscreenModelMediaElement::setWebVideoFullscreenInterface):
+ * platform/ios/WebVideoFullscreenModelMediaElement.mm: Added.
+ (WebVideoFullscreenModelMediaElement::setMediaElement):
+ (WebVideoFullscreenModelMediaElement::handleEvent):
+ (WebVideoFullscreenModelMediaElement::requestExitFullScreen):
+ (WebVideoFullscreenModelMediaElement::play):
+ (WebVideoFullscreenModelMediaElement::pause):
+ (WebVideoFullscreenModelMediaElement::togglePlayState):
+ (WebVideoFullscreenModelMediaElement::seekToTime):
+ (WebVideoFullscreenModelMediaElement::didExitFullscreen):
+
</ins><span class="cx"> 2014-01-30 Jer Noble <jer.noble@apple.com>
</span><span class="cx">
</span><span class="cx"> [MediaControls][iOS] Add a "start load" button.
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (163096 => 163097)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2014-01-30 19:37:32 UTC (rev 163096)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2014-01-30 19:50:03 UTC (rev 163097)
</span><span class="lines">@@ -1300,6 +1300,12 @@
</span><span class="cx">                 3F2B33EF165AF15600E3987C /* JSWebKitCSSViewportRule.h in Headers */ = {isa = PBXBuildFile; fileRef = 3F2B33EA165AF15500E3987C /* JSWebKitCSSViewportRule.h */; };
</span><span class="cx">                 3F42B31D1881191B00278AAC /* WebVideoFullscreenControllerAVKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 3F42B31B1881191B00278AAC /* WebVideoFullscreenControllerAVKit.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 3F42B31E1881191B00278AAC /* WebVideoFullscreenControllerAVKit.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3F42B31C1881191B00278AAC /* WebVideoFullscreenControllerAVKit.mm */; };
</span><ins>+                3FBC4AEA189880EF0046EE38 /* WebVideoFullscreenModel.h in Headers */ = {isa = PBXBuildFile; fileRef = 3FBC4AE9189880EF0046EE38 /* WebVideoFullscreenModel.h */; settings = {ATTRIBUTES = (Private, ); }; };
+                3FBC4AEC1898810E0046EE38 /* WebVideoFullscreenInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 3FBC4AEB1898810E0046EE38 /* WebVideoFullscreenInterface.h */; settings = {ATTRIBUTES = (Private, ); }; };
+                3FBC4AEF189881380046EE38 /* WebVideoFullscreenModelMediaElement.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3FBC4AED189881380046EE38 /* WebVideoFullscreenModelMediaElement.mm */; };
+                3FBC4AF0189881380046EE38 /* WebVideoFullscreenModelMediaElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 3FBC4AEE189881380046EE38 /* WebVideoFullscreenModelMediaElement.h */; settings = {ATTRIBUTES = (Private, ); }; };
+                3FBC4AF3189881560046EE38 /* WebVideoFullscreenInterfaceAVKit.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3FBC4AF1189881560046EE38 /* WebVideoFullscreenInterfaceAVKit.mm */; };
+                3FBC4AF4189881560046EE38 /* WebVideoFullscreenInterfaceAVKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 3FBC4AF2189881560046EE38 /* WebVideoFullscreenInterfaceAVKit.h */; settings = {ATTRIBUTES = (Private, ); }; };
</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">@@ -8124,6 +8130,12 @@
</span><span class="cx">                 3F2B33EA165AF15500E3987C /* JSWebKitCSSViewportRule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWebKitCSSViewportRule.h; sourceTree = "<group>"; };
</span><span class="cx">                 3F42B31B1881191B00278AAC /* WebVideoFullscreenControllerAVKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebVideoFullscreenControllerAVKit.h; path = ios/WebVideoFullscreenControllerAVKit.h; sourceTree = "<group>"; };
</span><span class="cx">                 3F42B31C1881191B00278AAC /* WebVideoFullscreenControllerAVKit.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WebVideoFullscreenControllerAVKit.mm; path = ios/WebVideoFullscreenControllerAVKit.mm; sourceTree = "<group>"; };
</span><ins>+                3FBC4AE9189880EF0046EE38 /* WebVideoFullscreenModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebVideoFullscreenModel.h; path = ios/WebVideoFullscreenModel.h; sourceTree = "<group>"; };
+                3FBC4AEB1898810E0046EE38 /* WebVideoFullscreenInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebVideoFullscreenInterface.h; path = ios/WebVideoFullscreenInterface.h; sourceTree = "<group>"; };
+                3FBC4AED189881380046EE38 /* WebVideoFullscreenModelMediaElement.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WebVideoFullscreenModelMediaElement.mm; path = ios/WebVideoFullscreenModelMediaElement.mm; sourceTree = "<group>"; };
+                3FBC4AEE189881380046EE38 /* WebVideoFullscreenModelMediaElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebVideoFullscreenModelMediaElement.h; path = ios/WebVideoFullscreenModelMediaElement.h; sourceTree = "<group>"; };
+                3FBC4AF1189881560046EE38 /* WebVideoFullscreenInterfaceAVKit.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WebVideoFullscreenInterfaceAVKit.mm; path = ios/WebVideoFullscreenInterfaceAVKit.mm; sourceTree = "<group>"; };
+                3FBC4AF2189881560046EE38 /* WebVideoFullscreenInterfaceAVKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebVideoFullscreenInterfaceAVKit.h; path = ios/WebVideoFullscreenInterfaceAVKit.h; sourceTree = "<group>"; };
</ins><span class="cx">                 3FFFF9A6159D9A550020BBD5 /* WebKitCSSViewportRule.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebKitCSSViewportRule.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 3FFFF9A7159D9A550020BBD5 /* WebKitCSSViewportRule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebKitCSSViewportRule.h; sourceTree = "<group>"; };
</span><span class="cx">                 3FFFF9AB159D9B060020BBD5 /* ViewportStyleResolver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ViewportStyleResolver.cpp; sourceTree = "<group>"; };
</span><span class="lines">@@ -17950,6 +17962,12 @@
</span><span class="cx">                                 3F42B31B1881191B00278AAC /* WebVideoFullscreenControllerAVKit.h */,
</span><span class="cx">                                 3F42B31C1881191B00278AAC /* WebVideoFullscreenControllerAVKit.mm */,
</span><span class="cx">                                 E453903C0EAFD637003695C8 /* WidgetIOS.mm */,
</span><ins>+                                3FBC4AE9189880EF0046EE38 /* WebVideoFullscreenModel.h */,
+                                3FBC4AEB1898810E0046EE38 /* WebVideoFullscreenInterface.h */,
+                                3FBC4AED189881380046EE38 /* WebVideoFullscreenModelMediaElement.mm */,
+                                3FBC4AEE189881380046EE38 /* WebVideoFullscreenModelMediaElement.h */,
+                                3FBC4AF1189881560046EE38 /* WebVideoFullscreenInterfaceAVKit.mm */,
+                                3FBC4AF2189881560046EE38 /* WebVideoFullscreenInterfaceAVKit.h */,
</ins><span class="cx">                         );
</span><span class="cx">                         name = ios;
</span><span class="cx">                         sourceTree = "<group>";
</span><span class="lines">@@ -23530,6 +23548,7 @@
</span><span class="cx">                                 A74BB76B13BDA86300FF7BF0 /* ExceptionCodePlaceholder.h in Headers */,
</span><span class="cx">                                 148AFDA50AF58360008CC700 /* ExceptionHandlers.h in Headers */,
</span><span class="cx">                                 9767CE0B145ABC13005E64DB /* ExceptionHeaders.h in Headers */,
</span><ins>+                                3FBC4AEC1898810E0046EE38 /* WebVideoFullscreenInterface.h in Headers */,
</ins><span class="cx">                                 9767CE0C145ABC13005E64DB /* ExceptionInterfaces.h in Headers */,
</span><span class="cx">                                 A024575216CEAA27000E5671 /* EXTDrawBuffers.h in Headers */,
</span><span class="cx">                                 6E67D2A91280E8BD008758F7 /* Extensions3D.h in Headers */,
</span><span class="lines">@@ -23814,6 +23833,7 @@
</span><span class="cx">                                 977B3875122883E900B81FF8 /* HTMLScriptRunner.h in Headers */,
</span><span class="cx">                                 977B3876122883E900B81FF8 /* HTMLScriptRunnerHost.h in Headers */,
</span><span class="cx">                                 A81369D8097374F600D74463 /* HTMLSelectElement.h in Headers */,
</span><ins>+                                3FBC4AEA189880EF0046EE38 /* WebVideoFullscreenModel.h in Headers */,
</ins><span class="cx">                                 E44613A80CD6331000FADA75 /* HTMLSourceElement.h in Headers */,
</span><span class="cx">                                 977E2DCE12F0E28300C13379 /* HTMLSourceTracker.h in Headers */,
</span><span class="cx">                                 978AD67514130A8D00C7CAE3 /* HTMLSpanElement.h in Headers */,
</span><span class="lines">@@ -24028,6 +24048,7 @@
</span><span class="cx">                                 B59DD699119029E5007E9684 /* JSDatabaseCallback.h in Headers */,
</span><span class="cx">                                 B58CEB6911913607002A6790 /* JSDatabaseSync.h in Headers */,
</span><span class="cx">                                 4162A4581011464700DFF3ED /* JSDedicatedWorkerGlobalScope.h in Headers */,
</span><ins>+                                3FBC4AF0189881380046EE38 /* WebVideoFullscreenModelMediaElement.h in Headers */,
</ins><span class="cx">                                 FDA15ED212B03F94003A583A /* JSDelayNode.h in Headers */,
</span><span class="cx">                                 31FB1A66120A5D3F00DC02A0 /* JSDeviceMotionEvent.h in Headers */,
</span><span class="cx">                                 59A86008119DAFA100DEF1EF /* JSDeviceOrientationEvent.h in Headers */,
</span><span class="lines">@@ -24241,6 +24262,7 @@
</span><span class="cx">                                 6EBF0E7712A9868800DB1709 /* JSOESTextureFloat.h in Headers */,
</span><span class="cx">                                 A31C4E5416E02B40002F7957 /* JSOESTextureHalfFloat.h in Headers */,
</span><span class="cx">                                 77A17AA712F28B2A004E02F6 /* JSOESVertexArrayObject.h in Headers */,
</span><ins>+                                3FBC4AF4189881560046EE38 /* WebVideoFullscreenInterfaceAVKit.h in Headers */,
</ins><span class="cx">                                 FDF6BAF9134A4C9800822920 /* JSOfflineAudioCompletionEvent.h in Headers */,
</span><span class="cx">                                 FDA9326716703BA9008982DC /* JSOfflineAudioContext.h in Headers */,
</span><span class="cx">                                 FDEA6243152102E200479DF0 /* JSOscillatorNode.h in Headers */,
</span><span class="lines">@@ -27701,6 +27723,7 @@
</span><span class="cx">                                 24D9129513CA956100D21915 /* JSSVGAltGlyphItemElement.cpp in Sources */,
</span><span class="cx">                                 B222F6980AB771950022EFAD /* JSSVGAngle.cpp in Sources */,
</span><span class="cx">                                 51D719C3181106E00016DC51 /* IDBCursorWithValue.cpp in Sources */,
</span><ins>+                                3FBC4AEF189881380046EE38 /* WebVideoFullscreenModelMediaElement.mm in Sources */,
</ins><span class="cx">                                 B2FA3D360AB75A6F000E5AC4 /* JSSVGAnimateColorElement.cpp in Sources */,
</span><span class="cx">                                 B2FA3D380AB75A6F000E5AC4 /* JSSVGAnimatedAngle.cpp in Sources */,
</span><span class="cx">                                 B2FA3D3A0AB75A6F000E5AC4 /* JSSVGAnimatedBoolean.cpp in Sources */,
</span><span class="lines">@@ -28693,6 +28716,7 @@
</span><span class="cx">                                 B25599840D00D8BA00BB825C /* SVGFEImage.cpp in Sources */,
</span><span class="cx">                                 B22279EE0D00BF220071B782 /* SVGFEImageElement.cpp in Sources */,
</span><span class="cx">                                 51D719EB181106E00016DC51 /* IDBRequest.cpp in Sources */,
</span><ins>+                                3FBC4AF3189881560046EE38 /* WebVideoFullscreenInterfaceAVKit.mm in Sources */,
</ins><span class="cx">                                 0FDA7C1A188322EB00C954B5 /* JSTouchList.cpp in Sources */,
</span><span class="cx">                                 A584FE2B1863870F00843B10 /* CommandLineAPIModule.cpp in Sources */,
</span><span class="cx">                                 B22279F10D00BF220071B782 /* SVGFELightElement.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformiosWebVideoFullscreenControllerAVKith"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.h (163096 => 163097)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.h        2014-01-30 19:37:32 UTC (rev 163096)
+++ trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.h        2014-01-30 19:50:03 UTC (rev 163097)
</span><span class="lines">@@ -28,19 +28,13 @@
</span><span class="cx">
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">
</span><del>-#import <wtf/RefPtr.h>
</del><ins>+#import <WebCore/HTMLMediaElement.h>
</ins><span class="cx">
</span><del>-@class UIScreen;
</del><ins>+OBJC_CLASS UIScreen;
</ins><span class="cx">
</span><del>-namespace WebCore {
-class HTMLMediaElement;
-}
-
</del><span class="cx"> @interface WebVideoFullscreenController : NSObject
</span><del>-
</del><span class="cx"> - (void)setMediaElement:(WebCore::HTMLMediaElement*)mediaElement;
</span><span class="cx"> - (WebCore::HTMLMediaElement*)mediaElement;
</span><del>-
</del><span class="cx"> - (void)enterFullscreen:(UIScreen *)screen;
</span><span class="cx"> - (void)exitFullscreen;
</span><span class="cx"> @end
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformiosWebVideoFullscreenControllerAVKitmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm (163096 => 163097)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm        2014-01-30 19:37:32 UTC (rev 163096)
+++ trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm        2014-01-30 19:50:03 UTC (rev 163097)
</span><span class="lines">@@ -29,312 +29,18 @@
</span><span class="cx">
</span><span class="cx"> #import "WebVideoFullscreenControllerAVKit.h"
</span><span class="cx">
</span><del>-#import "DOMEventInternal.h"
</del><span class="cx"> #import "Logging.h"
</span><del>-#import <CoreMedia/CMTime.h>
-#import <UIKit/UIKit.h>
-#import <WebCore/DOMEventListener.h>
-#import <WebCore/Event.h>
-#import <WebCore/EventListener.h>
-#import <WebCore/EventNames.h>
-#import <WebCore/HTMLElement.h>
-#import <WebCore/HTMLVideoElement.h>
-#import <WebCore/ObjCEventListener.h>
-#import <WebCore/SoftLinking.h>
</del><ins>+#import "WebVideoFullscreenInterfaceAVKit.h"
+#import "WebVideoFullscreenModelMediaElement.h"
</ins><span class="cx"> #import <WebCore/WebCoreThreadRun.h>
</span><del>-#import <WebCore/RenderElement.h>
-#import <wtf/RetainPtr.h>
</del><span class="cx">
</span><span class="cx"> using namespace WebCore;
</span><span class="cx">
</span><del>-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 <NSCoding, NSCopying, NSMutableCopying>
-+ (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 <AVPlayerViewControllerDelegate> 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 <DOMEventListener, AVPlayerViewControllerDelegate>
-
-@property(retain) AVPlayerController* playerControllerProxy;
-@property(retain) CALayer<AVPlayerLayer> *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<HTMLMediaElement> _mediaElement;
- RefPtr<EventListener> _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->pause();
- _mediaElement->exitFullscreen();
- });
- return NO;
-}
-
-- (void)play:(id)sender
-{
- UNUSED_PARAM(sender);
- WebThreadRun(^{
- _mediaElement->play();
- });
-}
-
-- (void)pause:(id)sender
-{
- UNUSED_PARAM(sender);
- WebThreadRun(^{
- _mediaElement->pause();
- });
-}
-
-- (void)togglePlayback:(id)sender
-{
- UNUSED_PARAM(sender);
- WebThreadRun(^{
- _mediaElement->togglePlayState();
- });
-}
-
-- (BOOL)isPlaying
-{
- return [self rate] != 0;
-}
-
-- (void)setPlaying:(BOOL)playing
-{
- WebThreadRun(^{
- if (playing)
- _mediaElement->play();
- else
- _mediaElement->pause();
- });
-}
-
-+ (NSSet *)keyPathsForValuesAffectingPlaying
-{
- return [NSSet setWithObject:@"rate"];
-}
-
-- (void)seekToTime:(NSTimeInterval)time
-{
- WebThreadRun(^{
- _mediaElement->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->isPlaying() ? _mediaElement->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->duration();
- self.contentDuration = duration;
- self.maxTime = duration;
- self.contentDurationWithinEndTimes = duration;
- self.loadedTimeRanges = @[@0, @(duration)];
-}
-
-- (void)setMediaElement:(PassRefPtr<HTMLMediaElement>)passedMediaElement
-{
- RefPtr<HTMLMediaElement> mediaElement = passedMediaElement;
-
- if (_mediaElement == mediaElement)
- return;
-
- if (_mediaElement && _listener)
- {
- _mediaElement->removeEventListener(eventNames().durationchangeEvent, _listener.get(), false);
- _mediaElement->removeEventListener(eventNames().pauseEvent, _listener.get(), false);
- _mediaElement->removeEventListener(eventNames().playEvent, _listener.get(), false);
- _mediaElement->removeEventListener(eventNames().ratechangeEvent, _listener.get(), false);
- _mediaElement->removeEventListener(eventNames().timeupdateEvent, _listener.get(), false);
- }
-
- if (_mediaElement)
- {
- [self.playerLayer removeFromSuperlayer];
- _mediaElement->returnPlatformLayer(self.playerLayer);
- self.playerLayer = nil;
- }
-
- _mediaElement = mediaElement;
- _listener = nullptr;
-
- if (!_mediaElement)
- return;
-
- _listener = ObjCEventListener::wrap(self);
-
- _mediaElement->addEventListener(eventNames().durationchangeEvent, _listener, false);
- _mediaElement->addEventListener(eventNames().pauseEvent, _listener, false);
- _mediaElement->addEventListener(eventNames().playEvent, _listener, false);
- _mediaElement->addEventListener(eventNames().ratechangeEvent, _listener, false);
- _mediaElement->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<AVPlayerLayer> *)_mediaElement->borrowPlatformLayer();
- ASSERT([self.playerLayer isKindOfClass:classAVPlayerLayer]);
- [self.playerLayer removeFromSuperlayer];
-
- [self updateTimingWithCurrentTime:_mediaElement->currentTime()];
-
- if (isHTMLVideoElement(_mediaElement.get())) {
- HTMLVideoElement *videoElement = toHTMLVideoElement(_mediaElement.get());
- self.hasEnabledVideo = YES;
- self.contentDimensions = CGSizeMake(videoElement->videoWidth(), videoElement->videoHeight());
- }
-}
-
-- (void)handleEvent:(DOMEvent *)evnt
-{
- Event* event = core(evnt);
-
- if (!_mediaElement)
- return;
-
- LOG(Media, "handleEvent %s", event->type().characters8());
-
- if (event->type() == eventNames().durationchangeEvent)
- [self updateDuration];
- else if (event->type() == eventNames().pauseEvent
- || event->type() == eventNames().playEvent
- || event->type() == eventNames().ratechangeEvent)
- self.rate = [self effectiveRate];
- else if (event->type() == eventNames().timeupdateEvent)
- [self updateTimingWithCurrentTime:_mediaElement->currentTime()];
-}
-
-@end
-
-@interface WebVideoFullscreenController () <UIViewControllerTransitioningDelegate>
-@property(retain) UIWindow *window;
-@property(retain) UIViewController *viewController;
-@property(retain) AVPlayerViewController *playerViewController;
-@property(retain) WebAVPlayerController *playerController;
-@end
-
</del><span class="cx"> @implementation WebVideoFullscreenController
</span><span class="cx"> {
</span><span class="cx"> RefPtr<HTMLMediaElement> _mediaElement;
</span><ins>+ RefPtr<WebVideoFullscreenInterfaceAVKit> _interface;
+ RefPtr<WebVideoFullscreenModelMediaElement> _model;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (instancetype)init
</span><span class="lines">@@ -342,24 +48,11 @@
</span><span class="cx"> if (!(self = [super init]))
</span><span class="cx"> return nil;
</span><span class="cx">
</span><del>- initUIScreen();
- initUIView();
- initUIColor();
- initUIWindow();
- initAVPlayerController();
- initAVPlayerViewController();
- initAVValueTiming();
- initUIViewController();
- initAVPlayerLayer();
</del><span class="cx"> return self;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (void)dealloc
</span><span class="cx"> {
</span><del>- self.window = nil;
- self.viewController = nil;
- self.playerViewController = nil;
- self.playerController = nil;
</del><span class="cx"> _mediaElement = nullptr;
</span><span class="cx"> [super dealloc];
</span><span class="cx"> }
</span><span class="lines">@@ -376,47 +69,28 @@
</span><span class="cx">
</span><span class="cx"> - (void)enterFullscreen:(UIScreen *)screen
</span><span class="cx"> {
</span><del>- 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];
- });
</del><ins>+ UNUSED_PARAM(screen);
+ _interface = adoptRef(new WebVideoFullscreenInterfaceAVKit);
+ _model = adoptRef(new WebVideoFullscreenModelMediaElement);
+ _model->setWebVideoFullscreenInterface(_interface.get());
+ _interface->setWebVideoFullscreenModel(_model.get());
+ _model->setMediaElement(_mediaElement.get());
+ _interface->enterFullscreen();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (void)exitFullscreen
</span><span class="cx"> {
</span><del>- 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;
- });
-
- }];
</del><ins>+ __block RetainPtr<WebVideoFullscreenController> protect{self};
+
+ _interface->exitFullscreen(^{
+ WebThreadRun(^{
+ _model->setMediaElement(nullptr);
+ _interface->setWebVideoFullscreenModel(nullptr);
+ _model->setWebVideoFullscreenInterface(nullptr);
+ _model = nullptr;
+ _interface = nullptr;
+ protect.clear();
+ });
</ins><span class="cx"> });
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformiosWebVideoFullscreenInterfacehfromrev163096trunkSourceWebCoreplatformiosWebVideoFullscreenControllerAVKith"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterface.h (from rev 163096, trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.h) (0 => 163097)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterface.h         (rev 0)
+++ trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterface.h        2014-01-30 19:50:03 UTC (rev 163097)
</span><span class="lines">@@ -0,0 +1,52 @@
</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. ``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 WebVideoFullscreenInterface_h
+#define WebVideoFullscreenInterface_h
+
+#if PLATFORM(IOS)
+
+#import <WebCore/PlatformLayer.h>
+
+namespace WebCore {
+
+class WebVideoFullscreenInterface {
+public:
+ virtual ~WebVideoFullscreenInterface() { };
+ virtual void setDuration(double) = 0;
+ virtual void setCurrentTime(double currentTime, double anchorTime) = 0;
+ virtual void setRate(bool isPlaying, float playbackRate) = 0;
+ virtual void setVideoDimensions(bool hasVideo, float width, float height) = 0;
+ virtual void setVideoLayer(PlatformLayer*) = 0;
+ virtual void setVideoLayerID(uint32_t) = 0;
+ virtual void enterFullscreen() = 0;
+ virtual void exitFullscreen() = 0;
+};
+
+}
+
+#endif
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformiosWebVideoFullscreenInterfaceAVKith"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.h (0 => 163097)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.h         (rev 0)
+++ trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.h        2014-01-30 19:50:03 UTC (rev 163097)
</span><span class="lines">@@ -0,0 +1,78 @@
</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. ``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 WebVideoFullscreenInterfaceAVKit_h
+#define WebVideoFullscreenInterfaceAVKit_h
+
+#if PLATFORM(IOS)
+
+#include <WebCore/EventListener.h>
+#include <WebCore/HTMLMediaElement.h>
+#include <WebCore/PlatformLayer.h>
+#include <WebCore/WebVideoFullscreenInterface.h>
+#include <wtf/RefPtr.h>
+#include <wtf/RetainPtr.h>
+
+OBJC_CLASS WebAVPlayerController;
+OBJC_CLASS AVPlayerViewController;
+OBJC_CLASS UIViewController;
+OBJC_CLASS UIWindow;
+
+namespace WebCore {
+class WebVideoFullscreenModel;
+
+class WebVideoFullscreenInterfaceAVKit
+ : public WebVideoFullscreenInterface
+ , public RefCounted<WebVideoFullscreenInterfaceAVKit> {
+
+ RetainPtr<WebAVPlayerController> m_playerController;
+ RetainPtr<AVPlayerViewController> m_playerViewController;
+ RetainPtr<UIViewController> m_viewController;
+ RetainPtr<UIWindow> m_window;
+ WebVideoFullscreenModel* m_videoFullscreenModel;
+
+public:
+ WebVideoFullscreenInterfaceAVKit();
+ virtual ~WebVideoFullscreenInterfaceAVKit() { }
+ void setWebVideoFullscreenModel(WebVideoFullscreenModel*);
+
+ void setDuration(double) override;
+ void setCurrentTime(double currentTime, double anchorTime) override;
+ void setRate(bool isPlaying, float playbackRate) override;
+ void setVideoDimensions(bool hasVideo, float width, float height) override;
+ void setVideoLayer(PlatformLayer*) override;
+ void setVideoLayerID(uint32_t videoContextID) override {UNUSED_PARAM(videoContextID);};
+ void enterFullscreen() override;
+ void enterFullscreen(std::function<void()> completion);
+ void exitFullscreen() override;
+ void exitFullscreen(std::function<void()> completion);
+};
+
+}
+
+#endif
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformiosWebVideoFullscreenInterfaceAVKitmm"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.mm (0 => 163097)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.mm         (rev 0)
+++ trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.mm        2014-01-30 19:50:03 UTC (rev 163097)
</span><span class="lines">@@ -0,0 +1,329 @@
</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. ``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 "config.h"
+
+#if PLATFORM(IOS)
+
+#import "WebVideoFullscreenInterfaceAVKit.h"
+
+#import "Logging.h"
+#import <CoreMedia/CMTime.h>
+#import <UIKit/UIKit.h>
+#import <WebCore/SoftLinking.h>
+#import <WebCore/WebCoreThreadRun.h>
+#import <wtf/RetainPtr.h>
+#import "WebVideoFullscreenModel.h"
+
+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 <NSCoding, NSCopying, NSMutableCopying>
++ (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 <AVPlayerViewControllerDelegate> 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 <AVPlayerViewControllerDelegate>
+
+@property(retain) AVPlayerController* playerControllerProxy;
+@property(retain) CALayer<AVPlayerLayer> *playerLayer;
+@property(assign) WebVideoFullscreenModel* delegate;
+
+@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;
+
+- (BOOL)playerViewController:(AVPlayerViewController *)playerViewController shouldDismissWithReason:(AVPlayerViewControllerDismissalReason)reason;
+@end
+
+@implementation WebAVPlayerController
+
+- (instancetype)init
+{
+ if (!(self = [super init]))
+ return self;
+
+ initAVPlayerController();
+ self.playerControllerProxy = [[classAVPlayerController alloc] init];
+ return self;
+}
+
+- (void)dealloc
+{
+ self.delegate = nil;
+ 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);
+ ASSERT(self.delegate);
+ self.delegate->requestExitFullScreen();
+ return NO;
+}
+
+- (void)play:(id)sender
+{
+ UNUSED_PARAM(sender);
+ ASSERT(self.delegate);
+ self.delegate->play();
+}
+
+- (void)pause:(id)sender
+{
+ UNUSED_PARAM(sender);
+ ASSERT(self.delegate);
+ self.delegate->pause();
+}
+
+- (void)togglePlayback:(id)sender
+{
+ UNUSED_PARAM(sender);
+ ASSERT(self.delegate);
+ self.delegate->togglePlayState();
+}
+
+- (BOOL)isPlaying
+{
+ return [self rate] != 0;
+}
+
+- (void)setPlaying:(BOOL)playing
+{
+ ASSERT(self.delegate);
+ if (playing)
+ self.delegate->play();
+ else
+ self.delegate->pause();
+ }
+
++ (NSSet *)keyPathsForValuesAffectingPlaying
+{
+ return [NSSet setWithObject:@"rate"];
+}
+
+- (void)seekToTime:(NSTimeInterval)time
+{
+ ASSERT(self.delegate);
+ self.delegate->seekToTime(time);
+}
+
+@end
+
+WebVideoFullscreenInterfaceAVKit::WebVideoFullscreenInterfaceAVKit()
+ : m_videoFullscreenModel(nullptr)
+{
+ initUIScreen();
+ initUIView();
+ initUIColor();
+ initUIWindow();
+ initAVPlayerController();
+ initAVPlayerViewController();
+ initAVValueTiming();
+ initUIViewController();
+ initAVPlayerLayer();
+
+ m_playerController = adoptNS([[WebAVPlayerController alloc] init]);
+}
+
+void WebVideoFullscreenInterfaceAVKit::setWebVideoFullscreenModel(WebVideoFullscreenModel* model)
+{
+ m_videoFullscreenModel = model;
+ m_playerController.get().delegate = m_videoFullscreenModel;
+}
+
+void WebVideoFullscreenInterfaceAVKit::setDuration(double duration)
+{
+ WebAVPlayerController* playerController = m_playerController.get();
+
+ // FIXME: https://bugs.webkit.org/show_bug.cgi?id=127017 use correct values instead of duration for all these
+ playerController.contentDuration = duration;
+ playerController.maxTime = duration;
+ playerController.contentDurationWithinEndTimes = duration;
+ playerController.loadedTimeRanges = @[@0, @(duration)];
+
+ // FIXME: we take this as an indication that playback is ready.
+ playerController.canPlay = YES;
+ playerController.canPause = YES;
+ playerController.canTogglePlayback = YES;
+ playerController.hasEnabledAudio = YES;
+ playerController.canSeek = YES;
+ playerController.minTime = 0;
+ playerController.status = AVPlayerControllerStatusReadyToPlay;
+}
+
+void WebVideoFullscreenInterfaceAVKit::setCurrentTime(double currentTime, double anchorTime)
+{
+ NSTimeInterval anchorTimeStamp = ![m_playerController rate] ? NAN : anchorTime;
+ AVValueTiming *timing = [classAVValueTiming valueTimingWithAnchorValue:currentTime
+ anchorTimeStamp:anchorTimeStamp rate:0];
+ m_playerController.get().timing = timing;
+}
+
+void WebVideoFullscreenInterfaceAVKit::setRate(bool isPlaying, float playbackRate)
+{
+ m_playerController.get().rate = isPlaying ? playbackRate : 0.;
+}
+
+void WebVideoFullscreenInterfaceAVKit::setVideoDimensions(bool hasVideo, float width, float height)
+{
+ m_playerController.get().hasEnabledVideo = hasVideo;
+ m_playerController.get().contentDimensions = CGSizeMake(width, height);
+}
+
+void WebVideoFullscreenInterfaceAVKit::setVideoLayer(PlatformLayer* videoLayer)
+{
+ [m_playerController.get().playerLayer removeFromSuperlayer];
+ [videoLayer removeFromSuperlayer];
+ ASSERT([videoLayer isKindOfClass:[classAVPlayerLayer class]]
+ || ([videoLayer isKindOfClass:[CALayer class]] && [videoLayer conformsToProtocol:@protocol(AVPlayerLayer)]));
+ m_playerController.get().playerLayer = (CALayer<AVPlayerLayer>*)videoLayer;
+}
+
+void WebVideoFullscreenInterfaceAVKit::enterFullscreen(std::function<void()> completion)
+{
+ __block RefPtr<WebVideoFullscreenInterfaceAVKit> protect(this);
+
+ dispatch_async(dispatch_get_main_queue(), ^{
+ m_playerViewController = [[[classAVPlayerViewController alloc] init] autorelease];
+ m_playerViewController.get().playerController = (AVPlayerController *)m_playerController.get();
+
+ if ([m_playerViewController respondsToSelector:@selector(setDelegate:)])
+ m_playerViewController.get().delegate = m_playerController.get();
+
+ m_viewController = adoptNS([[classUIViewController alloc] init]);
+
+ m_window = [[[classUIWindow alloc] initWithFrame:[[classUIScreen mainScreen] bounds]] autorelease];
+ m_window.get().backgroundColor = [classUIColor clearColor];
+ m_window.get().rootViewController = m_viewController.get();
+ [m_window makeKeyAndVisible];
+
+ [m_viewController presentViewController:m_playerViewController.get() animated:YES completion:nil];
+ completion();
+ protect.clear();
+ });
+}
+
+void WebVideoFullscreenInterfaceAVKit::enterFullscreen()
+{
+ enterFullscreen(^{ });
+}
+
+void WebVideoFullscreenInterfaceAVKit::exitFullscreen(std::function<void()> completion)
+{
+ m_playerController.clear();
+ __block RefPtr<WebVideoFullscreenInterfaceAVKit> protect(this);
+
+ dispatch_async(dispatch_get_main_queue(), ^{
+ [m_viewController dismissViewControllerAnimated:YES completion:^{
+ m_window.get().hidden = YES;
+ m_window.get().rootViewController = nil;
+ m_playerViewController = nil;
+ m_viewController = nil;
+ m_window = nil;
+ if (m_videoFullscreenModel)
+ m_videoFullscreenModel->didExitFullscreen();
+ completion();
+ protect.clear();
+ }];
+ });
+}
+
+void WebVideoFullscreenInterfaceAVKit::exitFullscreen()
+{
+ exitFullscreen(^{ });
+}
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformiosWebVideoFullscreenModelhfromrev163096trunkSourceWebCoreplatformiosWebVideoFullscreenControllerAVKith"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/platform/ios/WebVideoFullscreenModel.h (from rev 163096, trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.h) (0 => 163097)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/WebVideoFullscreenModel.h         (rev 0)
+++ trunk/Source/WebCore/platform/ios/WebVideoFullscreenModel.h        2014-01-30 19:50:03 UTC (rev 163097)
</span><span class="lines">@@ -0,0 +1,49 @@
</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. ``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 WebVideoFullscreenModel_h
+#define WebVideoFullscreenModel_h
+
+#if PLATFORM(IOS)
+
+namespace WebCore {
+
+class WebVideoFullscreenModel {
+public:
+ virtual ~WebVideoFullscreenModel() { };
+ virtual void requestExitFullScreen() = 0;
+ virtual void play() = 0;
+ virtual void pause() = 0;
+ virtual void togglePlayState() = 0;
+ virtual void seekToTime(double time) = 0;
+ virtual void didExitFullscreen() = 0;
+};
+
+}
+
+#endif
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformiosWebVideoFullscreenModelMediaElementhfromrev163096trunkSourceWebCoreplatformiosWebVideoFullscreenControllerAVKith"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/platform/ios/WebVideoFullscreenModelMediaElement.h (from rev 163096, trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.h) (0 => 163097)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/WebVideoFullscreenModelMediaElement.h         (rev 0)
+++ trunk/Source/WebCore/platform/ios/WebVideoFullscreenModelMediaElement.h        2014-01-30 19:50:03 UTC (rev 163097)
</span><span class="lines">@@ -0,0 +1,70 @@
</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. ``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 WebVideoFullscreenModelMediaElement_h
+#define WebVideoFullscreenModelMediaElement_h
+
+#if PLATFORM(IOS)
+
+#include <WebCore/EventListener.h>
+#include <WebCore/PlatformLayer.h>
+#include <WebCore/WebVideoFullscreenModel.h>
+#include <wtf/RefPtr.h>
+#include <wtf/RetainPtr.h>
+
+namespace WebCore {
+class HTMLMediaElement;
+class WebVideoFullscreenInterface;
+
+class WebVideoFullscreenModelMediaElement : public WebVideoFullscreenModel, public EventListener {
+ RefPtr<HTMLMediaElement> m_mediaElement;
+ RetainPtr<PlatformLayer> m_borrowedVideoLayer;
+ bool m_isListening;
+ WebVideoFullscreenInterface* m_videoFullscreenInterface;
+
+public:
+ WebVideoFullscreenModelMediaElement();
+ virtual ~WebVideoFullscreenModelMediaElement() { }
+ void setWebVideoFullscreenInterface(WebVideoFullscreenInterface* interface) {m_videoFullscreenInterface = interface;}
+ void setMediaElement(HTMLMediaElement*);
+
+ void handleEvent(WebCore::ScriptExecutionContext*, WebCore::Event*) override;
+ bool operator==(const EventListener& rhs) override
+ {return static_cast<WebCore::EventListener*>(this) == &rhs;}
+
+ void requestExitFullScreen() override;
+ void play() override;
+ void pause() override;
+ void togglePlayState() override;
+ void seekToTime(double time) override;
+ void didExitFullscreen();
+};
+
+}
+
+#endif
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformiosWebVideoFullscreenModelMediaElementmm"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/ios/WebVideoFullscreenModelMediaElement.mm (0 => 163097)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/WebVideoFullscreenModelMediaElement.mm         (rev 0)
+++ trunk/Source/WebCore/platform/ios/WebVideoFullscreenModelMediaElement.mm        2014-01-30 19:50:03 UTC (rev 163097)
</span><span class="lines">@@ -0,0 +1,174 @@
</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. ``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 "config.h"
+
+#if PLATFORM(IOS)
+
+#import "WebVideoFullscreenModelMediaElement.h"
+
+#import "DOMEventInternal.h"
+#import "Logging.h"
+#import "WebVideoFullscreenInterface.h"
+#import <WebCore/DOMEventListener.h>
+#import <WebCore/Event.h>
+#import <WebCore/EventListener.h>
+#import <WebCore/EventNames.h>
+#import <WebCore/HTMLElement.h>
+#import <WebCore/HTMLVideoElement.h>
+#import <WebCore/SoftLinking.h>
+#import <WebCore/WebCoreThreadRun.h>
+#import <wtf/RetainPtr.h>
+
+using namespace WebCore;
+
+WebVideoFullscreenModelMediaElement::WebVideoFullscreenModelMediaElement()
+ : EventListener(EventListener::CPPEventListenerType)
+ , m_isListening{false}
+{
+}
+
+void WebVideoFullscreenModelMediaElement::setMediaElement(HTMLMediaElement* mediaElement)
+{
+ if (m_mediaElement == mediaElement)
+ return;
+
+ if (m_mediaElement && m_isListening) {
+ m_mediaElement->removeEventListener(eventNames().durationchangeEvent, this, false);
+ m_mediaElement->removeEventListener(eventNames().pauseEvent, this, false);
+ m_mediaElement->removeEventListener(eventNames().playEvent, this, false);
+ m_mediaElement->removeEventListener(eventNames().ratechangeEvent, this, false);
+ m_mediaElement->removeEventListener(eventNames().timeupdateEvent, this, false);
+ }
+ m_isListening = false;
+
+ if (m_mediaElement && m_borrowedVideoLayer) {
+ if (m_videoFullscreenInterface)
+ m_videoFullscreenInterface->setVideoLayer(nullptr);
+ m_mediaElement->returnPlatformLayer(m_borrowedVideoLayer.get());
+ m_borrowedVideoLayer.clear();
+ }
+
+ m_mediaElement = mediaElement;
+
+ if (!m_mediaElement)
+ return;
+
+ m_mediaElement->addEventListener(eventNames().durationchangeEvent, this, false);
+ m_mediaElement->addEventListener(eventNames().pauseEvent, this, false);
+ m_mediaElement->addEventListener(eventNames().playEvent, this, false);
+ m_mediaElement->addEventListener(eventNames().ratechangeEvent, this, false);
+ m_mediaElement->addEventListener(eventNames().timeupdateEvent, this, false);
+ m_isListening = true;
+
+ if (!m_videoFullscreenInterface)
+ return;
+
+ m_videoFullscreenInterface->setDuration(m_mediaElement->duration());
+ m_videoFullscreenInterface->setRate(m_mediaElement->isPlaying(), m_mediaElement->playbackRate());
+
+ m_borrowedVideoLayer = m_mediaElement->borrowPlatformLayer();
+ m_videoFullscreenInterface->setVideoLayer(m_borrowedVideoLayer.get());
+
+ m_videoFullscreenInterface->setCurrentTime(m_mediaElement->currentTime(), [[NSProcessInfo processInfo] systemUptime]);
+
+ if (isHTMLVideoElement(m_mediaElement.get())) {
+ HTMLVideoElement *videoElement = toHTMLVideoElement(m_mediaElement.get());
+ m_videoFullscreenInterface->setVideoDimensions(true, videoElement->videoWidth(), videoElement->videoHeight());
+ }
+}
+
+void WebVideoFullscreenModelMediaElement::handleEvent(WebCore::ScriptExecutionContext*, WebCore::Event* event)
+{
+ if (!m_mediaElement)
+ return;
+
+ LOG(Media, "handleEvent %s", event->type().characters8());
+
+ if (event->type() == eventNames().durationchangeEvent)
+ m_videoFullscreenInterface->setDuration(m_mediaElement->duration());
+ else if (event->type() == eventNames().pauseEvent
+ || event->type() == eventNames().playEvent
+ || event->type() == eventNames().ratechangeEvent)
+ m_videoFullscreenInterface->setRate(m_mediaElement->isPlaying(), m_mediaElement->playbackRate());
+ else if (event->type() == eventNames().timeupdateEvent)
+ m_videoFullscreenInterface->setCurrentTime(m_mediaElement->currentTime(), [[NSProcessInfo processInfo] systemUptime]);
+}
+
+void WebVideoFullscreenModelMediaElement::requestExitFullScreen()
+{
+ __block RefPtr<WebVideoFullscreenModelMediaElement> protect(this);
+ WebThreadRun(^{
+ m_mediaElement->pause();
+ m_mediaElement->exitFullscreen();
+ protect.clear();
+ });
+}
+
+void WebVideoFullscreenModelMediaElement::play() {
+ __block RefPtr<WebVideoFullscreenModelMediaElement> protect(this);
+ WebThreadRun(^{
+ m_mediaElement->play();
+ protect.clear();
+ });
+}
+
+void WebVideoFullscreenModelMediaElement::pause()
+{
+ __block RefPtr<WebVideoFullscreenModelMediaElement> protect(this);
+ WebThreadRun(^{
+ m_mediaElement->pause();
+ protect.clear();
+ });
+}
+
+void WebVideoFullscreenModelMediaElement::togglePlayState()
+{
+ __block RefPtr<WebVideoFullscreenModelMediaElement> protect(this);
+ WebThreadRun(^{
+ m_mediaElement->togglePlayState();
+ protect.clear();
+ });
+}
+
+void WebVideoFullscreenModelMediaElement::seekToTime(double time)
+{
+ __block RefPtr<WebVideoFullscreenModelMediaElement> protect(this);
+ WebThreadRun(^{
+ m_mediaElement->setCurrentTime(time);
+ protect.clear();
+ });
+}
+
+void WebVideoFullscreenModelMediaElement::didExitFullscreen()
+{
+ __block RefPtr<WebVideoFullscreenModelMediaElement> protect(this);
+ WebThreadRun(^{
+ setMediaElement(nullptr);
+ protect.clear();
+ });
+}
+
+#endif
</ins></span></pre>
</div>
</div>
</body>
</html>