<!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>[184922] 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/184922">184922</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2015-05-27 14:41:02 -0700 (Wed, 27 May 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Refactor WebKit1 specific threading code out of WebVideoFullscreen code that is shared with WebKit2.
https://bugs.webkit.org/show_bug.cgi?id=143954

Patch by Jeremy Jones &lt;jeremyj@apple.com&gt; on 2015-05-27
Reviewed by Darin Adler.

WebVideoFullscreenInterfaceAVKit is used in both WebKit1 and WebKit2. In WebKit1, the model runs in the WebThread, while
the interface is on the main thread. So there is code to dispatch between these two thread when communicating between the
interface and the model. In WebKit2, this is handled automatically by the IPC mechanism. As a result, the threading code
in WebVideoFullscreenbInterfaceAVKit and in WebVideoFullscreenModelVideoElement is redundant in WebKit2 and relies on
WebThreadRun being a no-op in WebKit2.

This change clarifies this and simplifies the WebKit2 path by moving the WebKit1 specific threading code into
WebVideoFullscreenControllerContext, which is the WebKit1 specific controller.

* platform/ios/WebVideoFullscreenControllerAVKit.mm:
(WebVideoFullscreenControllerContext::WebVideoFullscreenControllerContext):
(WebVideoFullscreenControllerContext::setController):
(WebVideoFullscreenControllerContext::didSetupFullscreen):
(WebVideoFullscreenControllerContext::didExitFullscreen):
(WebVideoFullscreenControllerContext::didCleanupFullscreen):
(WebVideoFullscreenControllerContext::fullscreenMayReturnToInline):
(WebVideoFullscreenControllerContext::resetMediaState):
(WebVideoFullscreenControllerContext::setDuration):
(WebVideoFullscreenControllerContext::setCurrentTime):
(WebVideoFullscreenControllerContext::setBufferedTime):
(WebVideoFullscreenControllerContext::setRate):
(WebVideoFullscreenControllerContext::setVideoDimensions):
(WebVideoFullscreenControllerContext::setSeekableRanges):
(WebVideoFullscreenControllerContext::setCanPlayFastReverse):
(WebVideoFullscreenControllerContext::setAudioMediaSelectionOptions):
(WebVideoFullscreenControllerContext::setLegibleMediaSelectionOptions):
(WebVideoFullscreenControllerContext::setExternalPlayback):
(WebVideoFullscreenControllerContext::play):
(WebVideoFullscreenControllerContext::pause):
(WebVideoFullscreenControllerContext::togglePlayState):
(WebVideoFullscreenControllerContext::beginScrubbing):
(WebVideoFullscreenControllerContext::endScrubbing):
(WebVideoFullscreenControllerContext::seekToTime):
(WebVideoFullscreenControllerContext::fastSeek):
(WebVideoFullscreenControllerContext::beginScanningForward):
(WebVideoFullscreenControllerContext::beginScanningBackward):
(WebVideoFullscreenControllerContext::endScanning):
(WebVideoFullscreenControllerContext::requestExitFullscreen):
(WebVideoFullscreenControllerContext::setVideoLayerFrame):
(WebVideoFullscreenControllerContext::setVideoLayerGravity):
(WebVideoFullscreenControllerContext::selectAudioMediaOption):
(WebVideoFullscreenControllerContext::selectLegibleMediaOption):
(WebVideoFullscreenControllerContext::fullscreenModeChanged):
(WebVideoFullscreenControllerContext::setupFullscreen):
(WebVideoFullscreenControllerContext::exitFullscreen):
(WebVideoFullscreenControllerContext::requestHideAndExitFullscreen):
(-[WebVideoFullscreenController init]):
(-[WebVideoFullscreenController dealloc]):
(-[WebVideoFullscreenController enterFullscreen:mode:]):
(-[WebVideoFullscreenController exitFullscreen]):
(-[WebVideoFullscreenController requestHideAndExitFullscreen]):
(-[WebVideoFullscreenController didFinishFullscreen:]):
(WebVideoFullscreenControllerChangeObserver::setTarget): Deleted.
(-[WebVideoFullscreenController didSetupFullscreen]): Deleted.
(-[WebVideoFullscreenController didEnterFullscreen]): Deleted.
(-[WebVideoFullscreenController didExitFullscreen]): Deleted.
(-[WebVideoFullscreenController didCleanupFullscreen]): Deleted.
(-[WebVideoFullscreenController fullscreenMayReturnToInline]): Deleted.
* platform/ios/WebVideoFullscreenInterfaceAVKit.h:
* platform/ios/WebVideoFullscreenInterfaceAVKit.mm:
(-[WebAVVideoLayer setBounds:]):
(-[WebAVVideoLayer resolveBounds]):
(WebVideoFullscreenInterfaceAVKit::resetMediaState):
(WebVideoFullscreenInterfaceAVKit::setDuration):
(WebVideoFullscreenInterfaceAVKit::setCurrentTime):
(WebVideoFullscreenInterfaceAVKit::setBufferedTime):
(WebVideoFullscreenInterfaceAVKit::setRate):
(WebVideoFullscreenInterfaceAVKit::setVideoDimensions):
(WebVideoFullscreenInterfaceAVKit::setSeekableRanges):
(WebVideoFullscreenInterfaceAVKit::setCanPlayFastReverse):
(WebVideoFullscreenInterfaceAVKit::setAudioMediaSelectionOptions):
(WebVideoFullscreenInterfaceAVKit::setLegibleMediaSelectionOptions):
(WebVideoFullscreenInterfaceAVKit::setExternalPlayback):
(WebVideoFullscreenInterfaceAVKit::setupFullscreen):
(WebVideoFullscreenInterfaceAVKit::enterFullscreen):
(WebVideoFullscreenInterfaceAVKit::enterFullscreenStandard):
(WebVideoFullscreenInterfaceAVKit::exitFullscreen):
(WebVideoFullscreenInterfaceAVKit::exitFullscreenInternal):
(WebVideoFullscreenInterfaceAVKit::cleanupFullscreen):
(WebVideoFullscreenInterfaceAVKit::cleanupFullscreenInternal):
(WebVideoFullscreenInterfaceAVKit::requestHideAndExitFullscreen):
(WebVideoFullscreenInterfaceAVKit::preparedToReturnToInline):
(WebVideoFullscreenInterfaceAVKit::willStartOptimizedFullscreen):
(WebVideoFullscreenInterfaceAVKit::didStartOptimizedFullscreen):
(WebVideoFullscreenInterfaceAVKit::willStopOptimizedFullscreen):
(WebVideoFullscreenInterfaceAVKit::didStopOptimizedFullscreen):
(WebVideoFullscreenInterfaceAVKit::willCancelOptimizedFullscreen):
(WebVideoFullscreenInterfaceAVKit::didCancelOptimizedFullscreen):
(WebVideoFullscreenInterfaceAVKit::setVideoLayerFrame):
(WebVideoFullscreenInterfaceAVKit::setupFullscreenInternal): Deleted.
* platform/ios/WebVideoFullscreenModel.h:
* platform/ios/WebVideoFullscreenModelVideoElement.h:
* platform/ios/WebVideoFullscreenModelVideoElement.mm:
(WebVideoFullscreenModelVideoElement::setVideoFullscreenLayer):
(WebVideoFullscreenModelVideoElement::play):
(WebVideoFullscreenModelVideoElement::pause):
(WebVideoFullscreenModelVideoElement::togglePlayState):
(WebVideoFullscreenModelVideoElement::beginScrubbing):
(WebVideoFullscreenModelVideoElement::endScrubbing):
(WebVideoFullscreenModelVideoElement::seekToTime):
(WebVideoFullscreenModelVideoElement::fastSeek):
(WebVideoFullscreenModelVideoElement::beginScanningForward):
(WebVideoFullscreenModelVideoElement::beginScanningBackward):
(WebVideoFullscreenModelVideoElement::endScanning):
(WebVideoFullscreenModelVideoElement::requestExitFullscreen):
(WebVideoFullscreenModelVideoElement::fullscreenModeChanged):
(WebVideoFullscreenModelVideoElement::videoLayerFrame): Deleted.
(WebVideoFullscreenModelVideoElement::videoLayerGravity): Deleted.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformiosWebVideoFullscreenControllerAVKitmm">trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm</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="#trunkSourceWebCoreplatformiosWebVideoFullscreenModelVideoElementmm">trunk/Source/WebCore/platform/ios/WebVideoFullscreenModelVideoElement.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (184921 => 184922)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-05-27 21:32:20 UTC (rev 184921)
+++ trunk/Source/WebCore/ChangeLog        2015-05-27 21:41:02 UTC (rev 184922)
</span><span class="lines">@@ -1,3 +1,119 @@
</span><ins>+2015-05-27  Jeremy Jones  &lt;jeremyj@apple.com&gt;
+
+        Refactor WebKit1 specific threading code out of WebVideoFullscreen code that is shared with WebKit2.
+        https://bugs.webkit.org/show_bug.cgi?id=143954
+
+        Reviewed by Darin Adler.
+
+        WebVideoFullscreenInterfaceAVKit is used in both WebKit1 and WebKit2. In WebKit1, the model runs in the WebThread, while
+        the interface is on the main thread. So there is code to dispatch between these two thread when communicating between the
+        interface and the model. In WebKit2, this is handled automatically by the IPC mechanism. As a result, the threading code
+        in WebVideoFullscreenbInterfaceAVKit and in WebVideoFullscreenModelVideoElement is redundant in WebKit2 and relies on
+        WebThreadRun being a no-op in WebKit2.
+
+        This change clarifies this and simplifies the WebKit2 path by moving the WebKit1 specific threading code into
+        WebVideoFullscreenControllerContext, which is the WebKit1 specific controller.
+
+        * platform/ios/WebVideoFullscreenControllerAVKit.mm:
+        (WebVideoFullscreenControllerContext::WebVideoFullscreenControllerContext):
+        (WebVideoFullscreenControllerContext::setController):
+        (WebVideoFullscreenControllerContext::didSetupFullscreen):
+        (WebVideoFullscreenControllerContext::didExitFullscreen):
+        (WebVideoFullscreenControllerContext::didCleanupFullscreen):
+        (WebVideoFullscreenControllerContext::fullscreenMayReturnToInline):
+        (WebVideoFullscreenControllerContext::resetMediaState):
+        (WebVideoFullscreenControllerContext::setDuration):
+        (WebVideoFullscreenControllerContext::setCurrentTime):
+        (WebVideoFullscreenControllerContext::setBufferedTime):
+        (WebVideoFullscreenControllerContext::setRate):
+        (WebVideoFullscreenControllerContext::setVideoDimensions):
+        (WebVideoFullscreenControllerContext::setSeekableRanges):
+        (WebVideoFullscreenControllerContext::setCanPlayFastReverse):
+        (WebVideoFullscreenControllerContext::setAudioMediaSelectionOptions):
+        (WebVideoFullscreenControllerContext::setLegibleMediaSelectionOptions):
+        (WebVideoFullscreenControllerContext::setExternalPlayback):
+        (WebVideoFullscreenControllerContext::play):
+        (WebVideoFullscreenControllerContext::pause):
+        (WebVideoFullscreenControllerContext::togglePlayState):
+        (WebVideoFullscreenControllerContext::beginScrubbing):
+        (WebVideoFullscreenControllerContext::endScrubbing):
+        (WebVideoFullscreenControllerContext::seekToTime):
+        (WebVideoFullscreenControllerContext::fastSeek):
+        (WebVideoFullscreenControllerContext::beginScanningForward):
+        (WebVideoFullscreenControllerContext::beginScanningBackward):
+        (WebVideoFullscreenControllerContext::endScanning):
+        (WebVideoFullscreenControllerContext::requestExitFullscreen):
+        (WebVideoFullscreenControllerContext::setVideoLayerFrame):
+        (WebVideoFullscreenControllerContext::setVideoLayerGravity):
+        (WebVideoFullscreenControllerContext::selectAudioMediaOption):
+        (WebVideoFullscreenControllerContext::selectLegibleMediaOption):
+        (WebVideoFullscreenControllerContext::fullscreenModeChanged):
+        (WebVideoFullscreenControllerContext::setupFullscreen):
+        (WebVideoFullscreenControllerContext::exitFullscreen):
+        (WebVideoFullscreenControllerContext::requestHideAndExitFullscreen):
+        (-[WebVideoFullscreenController init]):
+        (-[WebVideoFullscreenController dealloc]):
+        (-[WebVideoFullscreenController enterFullscreen:mode:]):
+        (-[WebVideoFullscreenController exitFullscreen]):
+        (-[WebVideoFullscreenController requestHideAndExitFullscreen]):
+        (-[WebVideoFullscreenController didFinishFullscreen:]):
+        (WebVideoFullscreenControllerChangeObserver::setTarget): Deleted.
+        (-[WebVideoFullscreenController didSetupFullscreen]): Deleted.
+        (-[WebVideoFullscreenController didEnterFullscreen]): Deleted.
+        (-[WebVideoFullscreenController didExitFullscreen]): Deleted.
+        (-[WebVideoFullscreenController didCleanupFullscreen]): Deleted.
+        (-[WebVideoFullscreenController fullscreenMayReturnToInline]): Deleted.
+        * platform/ios/WebVideoFullscreenInterfaceAVKit.h:
+        * platform/ios/WebVideoFullscreenInterfaceAVKit.mm:
+        (-[WebAVVideoLayer setBounds:]):
+        (-[WebAVVideoLayer resolveBounds]):
+        (WebVideoFullscreenInterfaceAVKit::resetMediaState):
+        (WebVideoFullscreenInterfaceAVKit::setDuration):
+        (WebVideoFullscreenInterfaceAVKit::setCurrentTime):
+        (WebVideoFullscreenInterfaceAVKit::setBufferedTime):
+        (WebVideoFullscreenInterfaceAVKit::setRate):
+        (WebVideoFullscreenInterfaceAVKit::setVideoDimensions):
+        (WebVideoFullscreenInterfaceAVKit::setSeekableRanges):
+        (WebVideoFullscreenInterfaceAVKit::setCanPlayFastReverse):
+        (WebVideoFullscreenInterfaceAVKit::setAudioMediaSelectionOptions):
+        (WebVideoFullscreenInterfaceAVKit::setLegibleMediaSelectionOptions):
+        (WebVideoFullscreenInterfaceAVKit::setExternalPlayback):
+        (WebVideoFullscreenInterfaceAVKit::setupFullscreen):
+        (WebVideoFullscreenInterfaceAVKit::enterFullscreen):
+        (WebVideoFullscreenInterfaceAVKit::enterFullscreenStandard):
+        (WebVideoFullscreenInterfaceAVKit::exitFullscreen):
+        (WebVideoFullscreenInterfaceAVKit::exitFullscreenInternal):
+        (WebVideoFullscreenInterfaceAVKit::cleanupFullscreen):
+        (WebVideoFullscreenInterfaceAVKit::cleanupFullscreenInternal):
+        (WebVideoFullscreenInterfaceAVKit::requestHideAndExitFullscreen):
+        (WebVideoFullscreenInterfaceAVKit::preparedToReturnToInline):
+        (WebVideoFullscreenInterfaceAVKit::willStartOptimizedFullscreen):
+        (WebVideoFullscreenInterfaceAVKit::didStartOptimizedFullscreen):
+        (WebVideoFullscreenInterfaceAVKit::willStopOptimizedFullscreen):
+        (WebVideoFullscreenInterfaceAVKit::didStopOptimizedFullscreen):
+        (WebVideoFullscreenInterfaceAVKit::willCancelOptimizedFullscreen):
+        (WebVideoFullscreenInterfaceAVKit::didCancelOptimizedFullscreen):
+        (WebVideoFullscreenInterfaceAVKit::setVideoLayerFrame):
+        (WebVideoFullscreenInterfaceAVKit::setupFullscreenInternal): Deleted.
+        * platform/ios/WebVideoFullscreenModel.h:
+        * platform/ios/WebVideoFullscreenModelVideoElement.h:
+        * platform/ios/WebVideoFullscreenModelVideoElement.mm:
+        (WebVideoFullscreenModelVideoElement::setVideoFullscreenLayer):
+        (WebVideoFullscreenModelVideoElement::play):
+        (WebVideoFullscreenModelVideoElement::pause):
+        (WebVideoFullscreenModelVideoElement::togglePlayState):
+        (WebVideoFullscreenModelVideoElement::beginScrubbing):
+        (WebVideoFullscreenModelVideoElement::endScrubbing):
+        (WebVideoFullscreenModelVideoElement::seekToTime):
+        (WebVideoFullscreenModelVideoElement::fastSeek):
+        (WebVideoFullscreenModelVideoElement::beginScanningForward):
+        (WebVideoFullscreenModelVideoElement::beginScanningBackward):
+        (WebVideoFullscreenModelVideoElement::endScanning):
+        (WebVideoFullscreenModelVideoElement::requestExitFullscreen):
+        (WebVideoFullscreenModelVideoElement::fullscreenModeChanged):
+        (WebVideoFullscreenModelVideoElement::videoLayerFrame): Deleted.
+        (WebVideoFullscreenModelVideoElement::videoLayerGravity): Deleted.
+
</ins><span class="cx"> 2015-05-27  Eric Carlson  &lt;eric.carlson@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [Mac] short-circuit MIME type lookup when possible
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformiosWebVideoFullscreenControllerAVKitmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm (184921 => 184922)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm        2015-05-27 21:32:20 UTC (rev 184921)
+++ trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm        2015-05-27 21:41:02 UTC (rev 184922)
</span><span class="lines">@@ -30,6 +30,7 @@
</span><span class="cx"> #import &quot;WebVideoFullscreenControllerAVKit.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #import &quot;Logging.h&quot;
</span><ins>+#import &quot;TimeRanges.h&quot;
</ins><span class="cx"> #import &quot;WebVideoFullscreenInterfaceAVKit.h&quot;
</span><span class="cx"> #import &quot;WebVideoFullscreenModelVideoElement.h&quot;
</span><span class="cx"> #import &lt;QuartzCore/CoreAnimation.h&gt;
</span><span class="lines">@@ -51,7 +52,7 @@
</span><span class="cx">     return nullptr;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)enterFullscreen:(UIView *)view mode:(WebCore::HTMLMediaElement::VideoFullscreenMode)mode
</del><ins>+- (void)enterFullscreen:(UIView *)view mode:(WebCore::HTMLMediaElementEnums::VideoFullscreenMode)mode
</ins><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(view);
</span><span class="cx">     UNUSED_PARAM(mode);
</span><span class="lines">@@ -68,125 +69,535 @@
</span><span class="cx"> 
</span><span class="cx"> #else
</span><span class="cx"> 
</span><del>-@interface WebVideoFullscreenController (FullscreenObservation)
-- (void)didSetupFullscreen;
-- (void)didEnterFullscreen;
-- (void)didExitFullscreen;
-- (void)didCleanupFullscreen;
-- (void)fullscreenMayReturnToInline;
</del><ins>+class WebVideoFullscreenControllerContext;
+
+@interface WebVideoFullscreenController (delegate)
+-(void)didFinishFullscreen:(WebVideoFullscreenControllerContext*)context;
</ins><span class="cx"> @end
</span><span class="cx"> 
</span><del>-class WebVideoFullscreenControllerChangeObserver : public WebVideoFullscreenChangeObserver {
-    WebVideoFullscreenController* _target;
</del><ins>+class WebVideoFullscreenControllerContext final
+    : private WebVideoFullscreenInterface
+    , private WebVideoFullscreenModel
+    , private WebVideoFullscreenChangeObserver
+    , public ThreadSafeRefCounted&lt;WebVideoFullscreenControllerContext&gt; {
+
</ins><span class="cx"> public:
</span><del>-    void setTarget(WebVideoFullscreenController* target) { _target = target; }
-    virtual void didSetupFullscreen() override { [_target didSetupFullscreen]; }
-    virtual void didEnterFullscreen() override { [_target didEnterFullscreen]; }
-    virtual void didExitFullscreen() override { [_target didExitFullscreen]; }
-    virtual void didCleanupFullscreen() override { [_target didCleanupFullscreen]; }
-    virtual void fullscreenMayReturnToInline() override { [_target fullscreenMayReturnToInline]; }
</del><ins>+    static Ref&lt;WebVideoFullscreenControllerContext&gt; create()
+    {
+        return adoptRef(*new WebVideoFullscreenControllerContext);
+    }
+    
+    void setController(WebVideoFullscreenController* controller) { m_controller = controller; }
+    void setUpFullscreen(HTMLVideoElement&amp;, UIView *, HTMLMediaElementEnums::VideoFullscreenMode);
+    void exitFullscreen();
+    void requestHideAndExitFullscreen();
+    void invalidate();
+
+private:
+    WebVideoFullscreenControllerContext() { }
+
+    // WebVideoFullscreenChangeObserver
+    virtual void didSetupFullscreen() override;
+    virtual void didEnterFullscreen() override { }
+    virtual void didExitFullscreen() override;
+    virtual void didCleanupFullscreen() override;
+    virtual void fullscreenMayReturnToInline() override;
+    
+    // WebVideoFullscreenInterface
+    virtual void resetMediaState() override;
+    virtual void setDuration(double) override;
+    virtual void setCurrentTime(double currentTime, double anchorTime) override;
+    virtual void setBufferedTime(double) override;
+    virtual void setRate(bool isPlaying, float playbackRate) override;
+    virtual void setVideoDimensions(bool hasVideo, float width, float height) override;
+    virtual void setSeekableRanges(const TimeRanges&amp;) override;
+    virtual void setCanPlayFastReverse(bool) override;
+    virtual void setAudioMediaSelectionOptions(const Vector&lt;String&gt;&amp; options, uint64_t selectedIndex) override;
+    virtual void setLegibleMediaSelectionOptions(const Vector&lt;String&gt;&amp; options, uint64_t selectedIndex) override;
+    virtual void setExternalPlayback(bool enabled, ExternalPlaybackTargetType, String localizedDeviceName) override;
+    
+    // WebVideoFullscreenModel
+    virtual void play() override;
+    virtual void pause() override;
+    virtual void togglePlayState() override;
+    virtual void beginScrubbing() override;
+    virtual void endScrubbing() override;
+    virtual void seekToTime(double time) override;
+    virtual void fastSeek(double time) override;
+    virtual void beginScanningForward() override;
+    virtual void beginScanningBackward() override;
+    virtual void endScanning() override;
+    virtual void requestExitFullscreen() override;
+    virtual void setVideoLayerFrame(FloatRect) override;
+    virtual FloatRect videoLayerFrame() const override { return m_frame; }
+    virtual void setVideoLayerGravity(WebVideoFullscreenModel::VideoGravity) override;
+    virtual VideoGravity videoLayerGravity() const override { return m_gravity; }
+    virtual void selectAudioMediaOption(uint64_t index) override;
+    virtual void selectLegibleMediaOption(uint64_t index) override;
+    virtual void fullscreenModeChanged(HTMLMediaElementEnums::VideoFullscreenMode) override;
+    
+    RefPtr&lt;WebVideoFullscreenInterfaceAVKit&gt; m_interface;
+    RefPtr&lt;WebVideoFullscreenModelVideoElement&gt; m_model;
+    RefPtr&lt;HTMLVideoElement&gt; m_videoElement;
+    RetainPtr&lt;PlatformLayer&gt; m_videoFullscreenLayer;
+    RetainPtr&lt;WebVideoFullscreenController&gt; m_controller;
+    FloatRect m_frame;
+    VideoGravity m_gravity;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><del>-@implementation WebVideoFullscreenController
</del><ins>+#pragma mark WebVideoFullscreenChangeObserver
+
+void WebVideoFullscreenControllerContext::didSetupFullscreen()
</ins><span class="cx"> {
</span><del>-    RefPtr&lt;HTMLVideoElement&gt; _videoElement;
-    RefPtr&lt;WebVideoFullscreenInterfaceAVKit&gt; _interface;
-    RefPtr&lt;WebVideoFullscreenModelVideoElement&gt; _model;
-    WebVideoFullscreenControllerChangeObserver _changeObserver;
-    RetainPtr&lt;PlatformLayer&gt; _videoFullscreenLayer;
</del><ins>+    ASSERT(isUIThread());
+    RefPtr&lt;WebVideoFullscreenControllerContext&gt; strongThis(this);
+    WebThreadRun([strongThis, this] {
+        m_model-&gt;setVideoFullscreenLayer(m_videoFullscreenLayer.get());
+        dispatch_async(dispatch_get_main_queue(), [strongThis, this] {
+            m_interface-&gt;enterFullscreen();
+        });
+    });
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (instancetype)init
</del><ins>+void WebVideoFullscreenControllerContext::didExitFullscreen()
</ins><span class="cx"> {
</span><del>-    if (!(self = [super init]))
-        return nil;
</del><ins>+    ASSERT(isUIThread());
+    RefPtr&lt;WebVideoFullscreenControllerContext&gt; strongThis(this);
+    WebThreadRun([strongThis, this] {
+        m_model-&gt;setVideoFullscreenLayer(nil);
+        dispatch_async(dispatch_get_main_queue(), [strongThis, this] {
+            m_interface-&gt;cleanupFullscreen();
+        });
+    });
+}
+
+void WebVideoFullscreenControllerContext::didCleanupFullscreen()
+{
+    ASSERT(isUIThread());
+    m_interface-&gt;setWebVideoFullscreenModel(nullptr);
+    m_interface-&gt;setWebVideoFullscreenChangeObserver(nullptr);
+    m_interface = nullptr;
</ins><span class="cx">     
</span><del>-    _changeObserver.setTarget(self);
</del><ins>+    RefPtr&lt;WebVideoFullscreenControllerContext&gt; strongThis(this);
+    WebThreadRun([strongThis, this] {
+        m_model-&gt;setVideoFullscreenLayer(nil);
+        m_model-&gt;setWebVideoFullscreenInterface(nullptr);
+        m_model-&gt;setVideoElement(nullptr);
+        m_model = nullptr;
+        m_videoElement = nullptr;
+        m_videoFullscreenLayer = nil;
+        
+        [m_controller didFinishFullscreen:this];
+    });
+}
</ins><span class="cx"> 
</span><del>-    return self;
</del><ins>+void WebVideoFullscreenControllerContext::fullscreenMayReturnToInline()
+{
+    ASSERT(isUIThread());
+    RefPtr&lt;WebVideoFullscreenControllerContext&gt; strongThis(this);
+    WebThreadRun([strongThis, this] {
+        IntRect clientRect = m_videoElement-&gt;clientRect();
+        dispatch_async(dispatch_get_main_queue(), [strongThis, this, clientRect] {
+            m_interface-&gt;preparedToReturnToInline(true, clientRect);
+        });
+    });
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)dealloc
</del><ins>+#pragma mark WebVideoFullscreenInterface
+
+void WebVideoFullscreenControllerContext::resetMediaState()
</ins><span class="cx"> {
</span><del>-    _videoElement = nullptr;
-    [super dealloc];
</del><ins>+    ASSERT(WebThreadIsCurrent() || isMainThread());
+    RefPtr&lt;WebVideoFullscreenControllerContext&gt; strongThis(this);
+    dispatch_async(dispatch_get_main_queue(), [strongThis, this] {
+        if (m_interface)
+            m_interface-&gt;resetMediaState();
+    });
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)setVideoElement:(HTMLVideoElement*)videoElement
</del><ins>+void WebVideoFullscreenControllerContext::setDuration(double duration)
</ins><span class="cx"> {
</span><del>-    _videoElement = videoElement;
</del><ins>+    ASSERT(WebThreadIsCurrent());
+    RefPtr&lt;WebVideoFullscreenControllerContext&gt; strongThis(this);
+    dispatch_async(dispatch_get_main_queue(), [strongThis, this, duration] {
+        if (m_interface)
+            m_interface-&gt;setDuration(duration);
+    });
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (HTMLVideoElement*)videoElement
</del><ins>+void WebVideoFullscreenControllerContext::setCurrentTime(double currentTime, double anchorTime)
</ins><span class="cx"> {
</span><del>-    return _videoElement.get();
</del><ins>+    ASSERT(WebThreadIsCurrent());
+    RefPtr&lt;WebVideoFullscreenControllerContext&gt; strongThis(this);
+    dispatch_async(dispatch_get_main_queue(), [strongThis, this, currentTime, anchorTime] {
+        if (m_interface)
+            m_interface-&gt;setCurrentTime(currentTime, anchorTime);
+    });
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)enterFullscreen:(UIView *)view mode:(HTMLMediaElementEnums::VideoFullscreenMode)mode
</del><ins>+void WebVideoFullscreenControllerContext::setBufferedTime(double bufferedTime)
</ins><span class="cx"> {
</span><del>-    [self retain]; // Balanced by -release in didExitFullscreen:
</del><ins>+    ASSERT(WebThreadIsCurrent());
+    RefPtr&lt;WebVideoFullscreenControllerContext&gt; strongThis(this);
+    dispatch_async(dispatch_get_main_queue(), [strongThis, this, bufferedTime] {
+        if (m_interface)
+            m_interface-&gt;setBufferedTime(bufferedTime);
+    });
+}
+
+void WebVideoFullscreenControllerContext::setRate(bool isPlaying, float playbackRate)
+{
+    ASSERT(WebThreadIsCurrent());
+    RefPtr&lt;WebVideoFullscreenControllerContext&gt; strongThis(this);
+    dispatch_async(dispatch_get_main_queue(), [strongThis, this, isPlaying, playbackRate] {
+        if (m_interface)
+            m_interface-&gt;setRate(isPlaying, playbackRate);
+    });
+}
+
+void WebVideoFullscreenControllerContext::setVideoDimensions(bool hasVideo, float width, float height)
+{
+    ASSERT(WebThreadIsCurrent());
+    RefPtr&lt;WebVideoFullscreenControllerContext&gt; strongThis(this);
+    dispatch_async(dispatch_get_main_queue(), [strongThis, this, hasVideo, width, height] {
+        if (m_interface)
+            m_interface-&gt;setVideoDimensions(hasVideo, width, height);
+    });
+}
+
+void WebVideoFullscreenControllerContext::setSeekableRanges(const TimeRanges&amp; timeRanges)
+{
+    ASSERT(WebThreadIsCurrent());
+    RefPtr&lt;WebVideoFullscreenControllerContext&gt; strongThis(this);
+    const PlatformTimeRanges&amp; platformTimeRanges = timeRanges.ranges();
+    dispatch_async(dispatch_get_main_queue(), [strongThis, this, platformTimeRanges] {
+        if (m_interface)
+            m_interface-&gt;setSeekableRanges(TimeRanges::create(platformTimeRanges));
+    });
+}
+
+void WebVideoFullscreenControllerContext::setCanPlayFastReverse(bool canPlayFastReverse)
+{
+    ASSERT(WebThreadIsCurrent());
+    RefPtr&lt;WebVideoFullscreenControllerContext&gt; strongThis(this);
+    dispatch_async(dispatch_get_main_queue(), [strongThis, this, canPlayFastReverse] {
+        if (m_interface)
+            m_interface-&gt;setCanPlayFastReverse(canPlayFastReverse);
+    });
+}
+
+void WebVideoFullscreenControllerContext::setAudioMediaSelectionOptions(const Vector&lt;String&gt;&amp; options, uint64_t selectedIndex)
+{
+    ASSERT(WebThreadIsCurrent());
+    RefPtr&lt;WebVideoFullscreenControllerContext&gt; strongThis(this);
+
+    RetainPtr&lt;NSMutableArray&gt; optionsArray = adoptNS([[NSMutableArray alloc] initWithCapacity:options.size()]);
+    for (auto&amp; name : options)
+        [optionsArray addObject:name];
</ins><span class="cx">     
</span><del>-    _interface = WebVideoFullscreenInterfaceAVKit::create();
-    _interface-&gt;setWebVideoFullscreenChangeObserver(&amp;_changeObserver);
-    _model = WebVideoFullscreenModelVideoElement::create();
-    _model-&gt;setWebVideoFullscreenInterface(_interface.get());
-    _interface-&gt;setWebVideoFullscreenModel(_model.get());
-    _model-&gt;setVideoElement(_videoElement.get());
-    _videoFullscreenLayer = [CALayer layer];
-    _interface-&gt;setupFullscreen(*_videoFullscreenLayer.get(), _videoElement-&gt;clientRect(), view, mode, _videoElement-&gt;mediaSession().allowsAlternateFullscreen(*_videoElement.get()));
</del><ins>+    dispatch_async(dispatch_get_main_queue(), [strongThis, this, optionsArray, selectedIndex] {
+        Vector&lt;String&gt; options;
+        for (NSString *name : optionsArray.get())
+            options.append(name);
+        
+        if (m_interface)
+            m_interface-&gt;setAudioMediaSelectionOptions(options, selectedIndex);
+    });
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)exitFullscreen
</del><ins>+void WebVideoFullscreenControllerContext::setLegibleMediaSelectionOptions(const Vector&lt;String&gt;&amp; options, uint64_t selectedIndex)
</ins><span class="cx"> {
</span><del>-    _interface-&gt;exitFullscreen(_videoElement-&gt;screenRect());
</del><ins>+    ASSERT(WebThreadIsCurrent());
+    RefPtr&lt;WebVideoFullscreenControllerContext&gt; strongThis(this);
+    
+    RetainPtr&lt;NSMutableArray&gt; optionsArray = adoptNS([[NSMutableArray alloc] initWithCapacity:options.size()]);
+    for (auto&amp; name : options)
+        [optionsArray addObject:name];
+    
+    dispatch_async(dispatch_get_main_queue(), [strongThis, this, optionsArray, selectedIndex] {
+        Vector&lt;String&gt; options;
+        for (NSString *name : optionsArray.get())
+            options.append(name);
+        
+        if (m_interface)
+            m_interface-&gt;setLegibleMediaSelectionOptions(options, selectedIndex);
+    });
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)requestHideAndExitFullscreen
</del><ins>+void WebVideoFullscreenControllerContext::setExternalPlayback(bool enabled, ExternalPlaybackTargetType type, String localizedDeviceName)
</ins><span class="cx"> {
</span><del>-    if (_interface)
-        _interface-&gt;requestHideAndExitFullscreen();
</del><ins>+    ASSERT(WebThreadIsCurrent());
+    RefPtr&lt;WebVideoFullscreenControllerContext&gt; strongThis(this);
+    StringCapture capturedLocalizedDeviceName(localizedDeviceName);
+    dispatch_async(dispatch_get_main_queue(), [strongThis, this, enabled, type, capturedLocalizedDeviceName] {
+        if (m_interface)
+            m_interface-&gt;setExternalPlayback(enabled, type, capturedLocalizedDeviceName.string());
+    });
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)didSetupFullscreen
</del><ins>+#pragma mark WebVideoFullscreenModel
+
+void WebVideoFullscreenControllerContext::play()
</ins><span class="cx"> {
</span><del>-    WebThreadRun(^{
-        _model-&gt;setVideoFullscreenLayer(_videoFullscreenLayer.get());
-        _interface-&gt;enterFullscreen();
</del><ins>+    ASSERT(isUIThread());
+    RefPtr&lt;WebVideoFullscreenControllerContext&gt; strongThis(this);
+    WebThreadRun([strongThis, this] {
+        if (m_model)
+            m_model-&gt;play();
</ins><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)didEnterFullscreen
</del><ins>+void WebVideoFullscreenControllerContext::pause()
</ins><span class="cx"> {
</span><ins>+    ASSERT(isUIThread());
+    RefPtr&lt;WebVideoFullscreenControllerContext&gt; strongThis(this);
+    WebThreadRun([strongThis, this] {
+        if (m_model)
+            m_model-&gt;pause();
+    });
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)didExitFullscreen
</del><ins>+void WebVideoFullscreenControllerContext::togglePlayState()
</ins><span class="cx"> {
</span><del>-    WebThreadRun(^{
-        _model-&gt;setVideoFullscreenLayer(nil);
-        _interface-&gt;cleanupFullscreen();
</del><ins>+    ASSERT(isUIThread());
+    RefPtr&lt;WebVideoFullscreenControllerContext&gt; strongThis(this);
+    WebThreadRun([strongThis, this] {
+        if (m_model)
+            m_model-&gt;togglePlayState();
</ins><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)didCleanupFullscreen
</del><ins>+void WebVideoFullscreenControllerContext::beginScrubbing()
</ins><span class="cx"> {
</span><del>-    WebThreadRun(^{
-        _model-&gt;setVideoFullscreenLayer(nil);
-        _interface-&gt;setWebVideoFullscreenModel(nullptr);
-        _model-&gt;setWebVideoFullscreenInterface(nullptr);
-        _model-&gt;setVideoElement(nullptr);
-        _interface-&gt;setWebVideoFullscreenChangeObserver(nullptr);
-        _model = nullptr;
-        _interface = nullptr;
</del><ins>+    ASSERT(isUIThread());
+    RefPtr&lt;WebVideoFullscreenControllerContext&gt; strongThis(this);
+    WebThreadRun([strongThis, this] {
+        if (m_model)
+            m_model-&gt;beginScrubbing();
+    });
+}
+
+void WebVideoFullscreenControllerContext::endScrubbing()
+{
+    ASSERT(isUIThread());
+    RefPtr&lt;WebVideoFullscreenControllerContext&gt; strongThis(this);
+    WebThreadRun([strongThis, this] {
+        if (m_model)
+            m_model-&gt;endScrubbing();
+    });
+}
+
+void WebVideoFullscreenControllerContext::seekToTime(double time)
+{
+    ASSERT(isUIThread());
+    RefPtr&lt;WebVideoFullscreenControllerContext&gt; strongThis(this);
+    WebThreadRun([strongThis, this, time] {
+        if (m_model)
+            m_model-&gt;seekToTime(time);
+    });
+}
+
+void WebVideoFullscreenControllerContext::fastSeek(double time)
+{
+    ASSERT(isUIThread());
+    RefPtr&lt;WebVideoFullscreenControllerContext&gt; strongThis(this);
+    WebThreadRun([strongThis, this, time] {
+        if (m_model)
+            m_model-&gt;fastSeek(time);
+    });
+}
+
+void WebVideoFullscreenControllerContext::beginScanningForward()
+{
+    ASSERT(isUIThread());
+    RefPtr&lt;WebVideoFullscreenControllerContext&gt; strongThis(this);
+    WebThreadRun([strongThis, this] {
+        if (m_model)
+            m_model-&gt;beginScanningForward();
+    });
+}
+
+void WebVideoFullscreenControllerContext::beginScanningBackward()
+{
+    ASSERT(isUIThread());
+    RefPtr&lt;WebVideoFullscreenControllerContext&gt; strongThis(this);
+    WebThreadRun([strongThis, this] {
+        if (m_model)
+            m_model-&gt;beginScanningBackward();
+    });
+}
+
+void WebVideoFullscreenControllerContext::endScanning()
+{
+    ASSERT(isUIThread());
+    RefPtr&lt;WebVideoFullscreenControllerContext&gt; strongThis(this);
+    WebThreadRun([strongThis, this] {
+        if (m_model)
+            m_model-&gt;endScanning();
+    });
+}
+
+void WebVideoFullscreenControllerContext::requestExitFullscreen()
+{
+    ASSERT(isUIThread());
+    RefPtr&lt;WebVideoFullscreenControllerContext&gt; strongThis(this);
+    WebThreadRun([strongThis, this] {
+        if (m_model)
+            m_model-&gt;requestExitFullscreen();
+    });
+}
+
+void WebVideoFullscreenControllerContext::setVideoLayerFrame(FloatRect frame)
+{
+    ASSERT(isUIThread());
+    m_frame = frame;
+    RefPtr&lt;WebVideoFullscreenControllerContext&gt; strongThis(this);
+    WebThreadRun([strongThis, this, frame] {
+        if (m_model)
+            m_model-&gt;setVideoLayerFrame(frame);
+    });
+}
+
+void WebVideoFullscreenControllerContext::setVideoLayerGravity(WebVideoFullscreenModel::VideoGravity videoGravity)
+{
+    ASSERT(isUIThread());
+    m_gravity = videoGravity;
+    RefPtr&lt;WebVideoFullscreenControllerContext&gt; strongThis(this);
+    WebThreadRun([strongThis, this, videoGravity] {
+        if (m_model)
+            m_model-&gt;setVideoLayerGravity(videoGravity);
+    });
+}
+
+void WebVideoFullscreenControllerContext::selectAudioMediaOption(uint64_t index)
+{
+    ASSERT(isUIThread());
+    RefPtr&lt;WebVideoFullscreenControllerContext&gt; strongThis(this);
+    WebThreadRun([strongThis, this, index] {
+        if (m_model)
+            m_model-&gt;selectAudioMediaOption(index);
+    });
+}
+
+void WebVideoFullscreenControllerContext::selectLegibleMediaOption(uint64_t index)
+{
+    ASSERT(isUIThread());
+    RefPtr&lt;WebVideoFullscreenControllerContext&gt; strongThis(this);
+    WebThreadRun([strongThis, this, index] {
+        if (m_model)
+            m_model-&gt;selectLegibleMediaOption(index);
+    });
+}
+
+void WebVideoFullscreenControllerContext::fullscreenModeChanged(HTMLMediaElementEnums::VideoFullscreenMode mode)
+{
+    ASSERT(isUIThread());
+    RefPtr&lt;WebVideoFullscreenControllerContext&gt; strongThis(this);
+    WebThreadRun([strongThis, this, mode] {
+        if (m_model)
+            m_model-&gt;fullscreenModeChanged(mode);
+    });
+}
+
+#pragma mark Other
+
+void WebVideoFullscreenControllerContext::setUpFullscreen(HTMLVideoElement&amp; videoElement, UIView *view, HTMLMediaElementEnums::VideoFullscreenMode mode)
+{
+    ASSERT(isMainThread());
+    RetainPtr&lt;UIView&gt; viewRef = view;
+    m_videoElement = &amp;videoElement;
+
+    m_interface = WebVideoFullscreenInterfaceAVKit::create();
+    m_interface-&gt;setWebVideoFullscreenChangeObserver(this);
+    m_interface-&gt;setWebVideoFullscreenModel(this);
+    
+    RefPtr&lt;WebVideoFullscreenControllerContext&gt; strongThis(this);
+    WebThreadRun([strongThis, this, viewRef, mode] {
+        m_model = WebVideoFullscreenModelVideoElement::create();
+        m_model-&gt;setWebVideoFullscreenInterface(this);
+        m_model-&gt;setVideoElement(m_videoElement.get());
+        m_videoFullscreenLayer = [CALayer layer];
</ins><span class="cx">         
</span><del>-        [self release]; // Balance the -retain we did in enterFullscreen:
</del><ins>+        bool allowsAlternateFullscreen = m_videoElement-&gt;mediaSession().allowsAlternateFullscreen(*m_videoElement.get());
+        IntRect videoElementClientRect = m_videoElement-&gt;clientRect();
+        
+        dispatch_async(dispatch_get_main_queue(), [strongThis, this, videoElementClientRect, viewRef, mode, allowsAlternateFullscreen] {
+            m_interface-&gt;setupFullscreen(*m_videoFullscreenLayer.get(), videoElementClientRect, viewRef.get(), mode, allowsAlternateFullscreen);
+        });
</ins><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)fullscreenMayReturnToInline
</del><ins>+void WebVideoFullscreenControllerContext::exitFullscreen()
</ins><span class="cx"> {
</span><del>-    _interface-&gt;preparedToReturnToInline(true, _videoElement-&gt;clientRect());
</del><ins>+    ASSERT(WebThreadIsCurrent());
+    IntRect screenRect = m_videoElement-&gt;screenRect();
+    RefPtr&lt;WebVideoFullscreenControllerContext&gt; strongThis(this);
+    dispatch_async(dispatch_get_main_queue(), [strongThis, this, screenRect] {
+        ASSERT(isUIThread());
+        m_interface-&gt;exitFullscreen(screenRect);
+    });
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebVideoFullscreenControllerContext::requestHideAndExitFullscreen()
+{
+    ASSERT(isUIThread());
+    m_interface-&gt;requestHideAndExitFullscreen();
+}
+
+@implementation WebVideoFullscreenController {
+    RefPtr&lt;WebVideoFullscreenControllerContext&gt; _context;
+    RefPtr&lt;HTMLVideoElement&gt; _videoElement;
+}
+
+- (instancetype)init
+{
+    if (!(self = [super init]))
+        return nil;
+    
+    return self;
+}
+
+- (void)setVideoElement:(HTMLVideoElement*)videoElement
+{
+    _videoElement = videoElement;
+}
+
+- (HTMLVideoElement*)videoElement
+{
+    return _videoElement.get();
+}
+
+- (void)enterFullscreen:(UIView *)view mode:(HTMLMediaElementEnums::VideoFullscreenMode)mode
+{
+    ASSERT(isMainThread());
+    _context = WebVideoFullscreenControllerContext::create();
+    _context-&gt;setController(self);
+    _context-&gt;setUpFullscreen(*_videoElement.get(), view, mode);
+}
+
+- (void)exitFullscreen
+{
+    ASSERT(WebThreadIsCurrent());
+    _context-&gt;exitFullscreen();
+}
+
+- (void)requestHideAndExitFullscreen
+{
+    ASSERT(isUIThread());
+    if (_context)
+        _context-&gt;requestHideAndExitFullscreen();
+}
+
+- (void)didFinishFullscreen:(WebVideoFullscreenControllerContext*)context
+{
+    ASSERT(WebThreadIsCurrent());
+    ASSERT_UNUSED(context, context == _context);
+    [[self retain] autorelease]; // retain self before breaking a retain cycle.
+    _context-&gt;setController(nil);
+    _context = nullptr;
+    _videoElement = nullptr;
+}
+
</ins><span class="cx"> @end
</span><span class="cx"> 
</span><span class="cx"> #endif // __IPHONE_OS_VERSION_MIN_REQUIRED &lt; 80000
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformiosWebVideoFullscreenInterfaceAVKith"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.h (184921 => 184922)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.h        2015-05-27 21:32:20 UTC (rev 184921)
+++ trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.h        2015-05-27 21:41:02 UTC (rev 184922)
</span><span class="lines">@@ -35,9 +35,9 @@
</span><span class="cx"> #include &lt;WebCore/WebVideoFullscreenInterface.h&gt;
</span><span class="cx"> #include &lt;functional&gt;
</span><span class="cx"> #include &lt;objc/objc.h&gt;
</span><ins>+#include &lt;wtf/RefCounted.h&gt;
</ins><span class="cx"> #include &lt;wtf/RefPtr.h&gt;
</span><span class="cx"> #include &lt;wtf/RetainPtr.h&gt;
</span><del>-#include &lt;wtf/ThreadSafeRefCounted.h&gt;
</del><span class="cx"> 
</span><span class="cx"> OBJC_CLASS WebAVPlayerController;
</span><span class="cx"> OBJC_CLASS AVPlayerViewController;
</span><span class="lines">@@ -68,7 +68,7 @@
</span><span class="cx"> 
</span><span class="cx"> class WEBCORE_EXPORT WebVideoFullscreenInterfaceAVKit
</span><span class="cx">     : public WebVideoFullscreenInterface
</span><del>-    , public ThreadSafeRefCounted&lt;WebVideoFullscreenInterfaceAVKit&gt; {
</del><ins>+    , public RefCounted&lt;WebVideoFullscreenInterfaceAVKit&gt; {
</ins><span class="cx"> 
</span><span class="cx"> public:
</span><span class="cx">     static Ref&lt;WebVideoFullscreenInterfaceAVKit&gt; create()
</span><span class="lines">@@ -120,11 +120,8 @@
</span><span class="cx"> protected:
</span><span class="cx">     WEBCORE_EXPORT WebVideoFullscreenInterfaceAVKit();
</span><span class="cx">     void beginSession();
</span><del>-    void setupFullscreenInternal(PlatformLayer&amp;, const IntRect&amp; initialRect, UIView *, HTMLMediaElementEnums::VideoFullscreenMode, bool allowOptimizedFullscreen);
</del><span class="cx">     void enterFullscreenOptimized();
</span><span class="cx">     void enterFullscreenStandard();
</span><del>-    void exitFullscreenInternal(const IntRect&amp; finalRect);
-    void cleanupFullscreenInternal();
</del><span class="cx"> 
</span><span class="cx">     RetainPtr&lt;WebAVPlayerController&gt; m_playerController;
</span><span class="cx">     RetainPtr&lt;AVPlayerViewController&gt; m_playerViewController;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformiosWebVideoFullscreenInterfaceAVKitmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.mm (184921 => 184922)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.mm        2015-05-27 21:32:20 UTC (rev 184921)
+++ trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.mm        2015-05-27 21:41:02 UTC (rev 184922)
</span><span class="lines">@@ -36,7 +36,6 @@
</span><span class="cx"> #import &quot;RuntimeApplicationChecksIOS.h&quot;
</span><span class="cx"> #import &quot;TimeRanges.h&quot;
</span><span class="cx"> #import &quot;WebCoreSystemInterface.h&quot;
</span><del>-#import &quot;WebCoreThreadRun.h&quot;
</del><span class="cx"> #import &quot;WebVideoFullscreenModel.h&quot;
</span><span class="cx"> #import &lt;AVFoundation/AVTime.h&gt;
</span><span class="cx"> #import &lt;UIKit/UIKit.h&gt;
</span><span class="lines">@@ -744,17 +743,13 @@
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenInterfaceAVKit::resetMediaState()
</span><span class="cx"> {
</span><del>-    RefPtr&lt;WebVideoFullscreenInterfaceAVKit&gt; strongThis(this);
-    
-    dispatch_async(dispatch_get_main_queue(), [strongThis] {
-        if (!strongThis-&gt;m_playerController) {
-            strongThis-&gt;m_playerController = adoptNS([[WebAVPlayerController alloc] init]);
-            [strongThis-&gt;m_playerController setDelegate:strongThis-&gt;m_videoFullscreenModel];
-            [strongThis-&gt;m_playerController setFullscreenInterface:strongThis.get()];
-            
-        } else
-            [strongThis-&gt;m_playerController resetState];
-    });
</del><ins>+    if (!m_playerController) {
+        m_playerController = adoptNS([[WebAVPlayerController alloc] init]);
+        [m_playerController setDelegate:m_videoFullscreenModel];
+        [m_playerController setFullscreenInterface:this];
+        
+    } else
+        [m_playerController resetState];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenInterfaceAVKit::setWebVideoFullscreenModel(WebVideoFullscreenModel* model)
</span><span class="lines">@@ -770,72 +765,52 @@
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenInterfaceAVKit::setDuration(double duration)
</span><span class="cx"> {
</span><del>-    RefPtr&lt;WebVideoFullscreenInterfaceAVKit&gt; strongThis(this);
-    
-    dispatch_async(dispatch_get_main_queue(), [strongThis, duration] {
-        WebAVPlayerController* playerController = strongThis-&gt;m_playerController.get();
</del><ins>+    WebAVPlayerController* playerController = m_playerController.get();
</ins><span class="cx"> 
</span><del>-        // 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;
</del><ins>+    // 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;
</ins><span class="cx"> 
</span><del>-        // 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;
-    });
</del><ins>+    // 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;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenInterfaceAVKit::setCurrentTime(double currentTime, double anchorTime)
</span><span class="cx"> {
</span><del>-    RefPtr&lt;WebVideoFullscreenInterfaceAVKit&gt; strongThis(this);
-    
-    dispatch_async(dispatch_get_main_queue(), [strongThis, currentTime, anchorTime] {
-        NSTimeInterval anchorTimeStamp = ![strongThis-&gt;m_playerController rate] ? NAN : anchorTime;
-        AVValueTiming *timing = [getAVValueTimingClass() valueTimingWithAnchorValue:currentTime
-            anchorTimeStamp:anchorTimeStamp rate:0];
-        [strongThis-&gt;m_playerController setTiming:timing];
-    });
</del><ins>+    NSTimeInterval anchorTimeStamp = ![m_playerController rate] ? NAN : anchorTime;
+    AVValueTiming *timing = [getAVValueTimingClass() valueTimingWithAnchorValue:currentTime
+        anchorTimeStamp:anchorTimeStamp rate:0];
+    [m_playerController setTiming:timing];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenInterfaceAVKit::setBufferedTime(double bufferedTime)
</span><span class="cx"> {
</span><del>-    RefPtr&lt;WebVideoFullscreenInterfaceAVKit&gt; strongThis(this);
-
-    dispatch_async(dispatch_get_main_queue(), [strongThis, bufferedTime] {
-        WebAVPlayerController* playerController = strongThis-&gt;m_playerController.get();
-        double duration = playerController.contentDuration;
-        double normalizedBufferedTime;
-        if (!duration)
-            normalizedBufferedTime = 0;
-        else
-            normalizedBufferedTime = bufferedTime / duration;
-        playerController.loadedTimeRanges = @[@0, @(normalizedBufferedTime)];
-    });
</del><ins>+    WebAVPlayerController* playerController = m_playerController.get();
+    double duration = playerController.contentDuration;
+    double normalizedBufferedTime;
+    if (!duration)
+        normalizedBufferedTime = 0;
+    else
+        normalizedBufferedTime = bufferedTime / duration;
+    playerController.loadedTimeRanges = @[@0, @(normalizedBufferedTime)];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenInterfaceAVKit::setRate(bool isPlaying, float playbackRate)
</span><span class="cx"> {
</span><del>-    RefPtr&lt;WebVideoFullscreenInterfaceAVKit&gt; strongThis(this);
-    
-    dispatch_async(dispatch_get_main_queue(), [strongThis, isPlaying, playbackRate] {
-        [strongThis-&gt;m_playerController setRate:isPlaying ? playbackRate : 0.];
-    });
</del><ins>+    [m_playerController setRate:isPlaying ? playbackRate : 0.];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenInterfaceAVKit::setVideoDimensions(bool hasVideo, float width, float height)
</span><span class="cx"> {
</span><del>-    RefPtr&lt;WebVideoFullscreenInterfaceAVKit&gt; strongThis(this);
-    
-    dispatch_async(dispatch_get_main_queue(), [strongThis, hasVideo, width, height] {
-        [strongThis-&gt;m_playerController setHasEnabledVideo:hasVideo];
-        [strongThis-&gt;m_playerController setContentDimensions:CGSizeMake(width, height)];
-    });
</del><ins>+    [m_playerController setHasEnabledVideo:hasVideo];
+    [m_playerController setContentDimensions:CGSizeMake(width, height)];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenInterfaceAVKit::setSeekableRanges(const TimeRanges&amp; timeRanges)
</span><span class="lines">@@ -851,20 +826,12 @@
</span><span class="cx">         [seekableRanges addObject:[NSValue valueWithCMTimeRange:range]];
</span><span class="cx">     }
</span><span class="cx">     
</span><del>-    RefPtr&lt;WebVideoFullscreenInterfaceAVKit&gt; strongThis(this);
-    
-    dispatch_async(dispatch_get_main_queue(), [strongThis, seekableRanges] {
-        [strongThis-&gt;m_playerController setSeekableTimeRanges:seekableRanges.get()];
-    });
</del><ins>+    [m_playerController setSeekableTimeRanges:seekableRanges.get()];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenInterfaceAVKit::setCanPlayFastReverse(bool canPlayFastReverse)
</span><span class="cx"> {
</span><del>-    RefPtr&lt;WebVideoFullscreenInterfaceAVKit&gt; strongThis(this);
-    
-    dispatch_async(dispatch_get_main_queue(), [strongThis, canPlayFastReverse] {
-        [strongThis-&gt;m_playerController setCanScanBackward:canPlayFastReverse];
-    });
</del><ins>+    [m_playerController setCanScanBackward:canPlayFastReverse];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static RetainPtr&lt;NSMutableArray&gt; mediaSelectionOptions(const Vector&lt;String&gt;&amp; options)
</span><span class="lines">@@ -881,25 +848,17 @@
</span><span class="cx"> void WebVideoFullscreenInterfaceAVKit::setAudioMediaSelectionOptions(const Vector&lt;String&gt;&amp; options, uint64_t selectedIndex)
</span><span class="cx"> {
</span><span class="cx">     RetainPtr&lt;NSMutableArray&gt; webOptions = mediaSelectionOptions(options);
</span><del>-    RefPtr&lt;WebVideoFullscreenInterfaceAVKit&gt; strongThis(this);
-    
-    dispatch_async(dispatch_get_main_queue(), [webOptions, strongThis, selectedIndex] {
-        [strongThis-&gt;m_playerController setAudioMediaSelectionOptions:webOptions.get()];
-        if (selectedIndex &lt; [webOptions count])
-            [strongThis-&gt;m_playerController setCurrentAudioMediaSelectionOption:[webOptions objectAtIndex:static_cast&lt;NSUInteger&gt;(selectedIndex)]];
-    });
</del><ins>+    [m_playerController setAudioMediaSelectionOptions:webOptions.get()];
+    if (selectedIndex &lt; [webOptions count])
+        [m_playerController setCurrentAudioMediaSelectionOption:[webOptions objectAtIndex:static_cast&lt;NSUInteger&gt;(selectedIndex)]];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenInterfaceAVKit::setLegibleMediaSelectionOptions(const Vector&lt;String&gt;&amp; options, uint64_t selectedIndex)
</span><span class="cx"> {
</span><span class="cx">     RetainPtr&lt;NSMutableArray&gt; webOptions = mediaSelectionOptions(options);
</span><del>-    RefPtr&lt;WebVideoFullscreenInterfaceAVKit&gt; strongThis(this);
-
-    dispatch_async(dispatch_get_main_queue(), [webOptions, strongThis, selectedIndex] {
-        [strongThis-&gt;m_playerController setLegibleMediaSelectionOptions:webOptions.get()];
-        if (selectedIndex &lt; [webOptions count])
-            [strongThis-&gt;m_playerController setCurrentLegibleMediaSelectionOption:[webOptions objectAtIndex:static_cast&lt;NSUInteger&gt;(selectedIndex)]];
-    });
</del><ins>+    [m_playerController setLegibleMediaSelectionOptions:webOptions.get()];
+    if (selectedIndex &lt; [webOptions count])
+        [m_playerController setCurrentLegibleMediaSelectionOption:[webOptions objectAtIndex:static_cast&lt;NSUInteger&gt;(selectedIndex)]];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenInterfaceAVKit::setExternalPlayback(bool enabled, ExternalPlaybackTargetType targetType, String localizedDeviceName)
</span><span class="lines">@@ -910,41 +869,24 @@
</span><span class="cx">     else if (targetType == TargetTypeTVOut)
</span><span class="cx">         externalPlaybackType = AVPlayerControllerExternalPlaybackTypeTVOut;
</span><span class="cx"> 
</span><del>-    RefPtr&lt;WebVideoFullscreenInterfaceAVKit&gt; strongThis(this);
-
-    dispatch_async(dispatch_get_main_queue(), [strongThis, enabled, localizedDeviceName, externalPlaybackType] {
-        WebAVPlayerController* playerController = strongThis-&gt;m_playerController.get();
-        playerController.externalPlaybackAirPlayDeviceLocalizedName = localizedDeviceName;
-        playerController.externalPlaybackType = externalPlaybackType;
-        playerController.externalPlaybackActive = enabled;
-        [strongThis-&gt;m_videoLayerContainer.get() setHidden:enabled];
-    });
</del><ins>+    WebAVPlayerController* playerController = m_playerController.get();
+    playerController.externalPlaybackAirPlayDeviceLocalizedName = localizedDeviceName;
+    playerController.externalPlaybackType = externalPlaybackType;
+    playerController.externalPlaybackActive = enabled;
+    [m_videoLayerContainer.get() setHidden:enabled];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenInterfaceAVKit::setupFullscreen(PlatformLayer&amp; videoLayer, const WebCore::IntRect&amp; initialRect, UIView* parentView, HTMLMediaElementEnums::VideoFullscreenMode mode, bool allowOptimizedFullscreen)
</span><span class="cx"> {
</span><del>-    RefPtr&lt;WebVideoFullscreenInterfaceAVKit&gt; strongThis(this);
-
</del><span class="cx">     ASSERT(mode != HTMLMediaElementEnums::VideoFullscreenModeNone);
</span><del>-    m_videoLayer = &amp;videoLayer;
</del><ins>+    LOG(Fullscreen, &quot;WebVideoFullscreenInterfaceAVKit::setupFullscreen(%p)&quot;, this);
</ins><span class="cx"> 
</span><del>-    m_mode = mode;
-
-    dispatch_async(dispatch_get_main_queue(), [strongThis, &amp;videoLayer, initialRect, parentView, mode, allowOptimizedFullscreen] {
-        strongThis-&gt;setupFullscreenInternal(videoLayer, initialRect, parentView, mode, allowOptimizedFullscreen);
-    });
-}
-
-void WebVideoFullscreenInterfaceAVKit::setupFullscreenInternal(PlatformLayer&amp; videoLayer, const WebCore::IntRect&amp; initialRect, UIView* parentView, HTMLMediaElementEnums::VideoFullscreenMode mode, bool allowOptimizedFullscreen)
-{
-    LOG(Fullscreen, &quot;WebVideoFullscreenInterfaceAVKit::setupFullscreenInternal(%p)&quot;, this);
-    UNUSED_PARAM(videoLayer);
-    UNUSED_PARAM(mode);
-
</del><span class="cx">     m_allowOptimizedFullscreen = allowOptimizedFullscreen;
</span><span class="cx"> 
</span><span class="cx">     [CATransaction begin];
</span><span class="cx">     [CATransaction setDisableActions:YES];
</span><ins>+    m_videoLayer = &amp;videoLayer;
+    m_mode = mode;
</ins><span class="cx">     m_parentView = parentView;
</span><span class="cx">     m_parentWindow = parentView.window;
</span><span class="cx"> 
</span><span class="lines">@@ -996,11 +938,8 @@
</span><span class="cx"> 
</span><span class="cx">     [CATransaction commit];
</span><span class="cx"> 
</span><del>-    RefPtr&lt;WebVideoFullscreenInterfaceAVKit&gt; strongThis(this);
-    WebThreadRun([strongThis] {
-        if (strongThis-&gt;m_fullscreenChangeObserver)
-            strongThis-&gt;m_fullscreenChangeObserver-&gt;didSetupFullscreen();
-    });
</del><ins>+    if (m_fullscreenChangeObserver)
+        m_fullscreenChangeObserver-&gt;didSetupFullscreen();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenInterfaceAVKit::enterFullscreen()
</span><span class="lines">@@ -1011,22 +950,17 @@
</span><span class="cx">     m_exitRequested = false;
</span><span class="cx">     m_enterRequested = true;
</span><span class="cx"> 
</span><del>-    RefPtr&lt;WebVideoFullscreenInterfaceAVKit&gt; strongThis(this);
-    dispatch_async(dispatch_get_main_queue(), [strongThis] {
-        [strongThis-&gt;m_videoLayerContainer setBackgroundColor:[[getUIColorClass() blackColor] CGColor]];
-        if (strongThis-&gt;mode() == HTMLMediaElementEnums::VideoFullscreenModeOptimized)
-            strongThis-&gt;enterFullscreenOptimized();
-        else if (strongThis-&gt;mode() == HTMLMediaElementEnums::VideoFullscreenModeStandard)
-            strongThis-&gt;enterFullscreenStandard();
-        else
-            ASSERT_NOT_REACHED();
-    });
</del><ins>+    [m_videoLayerContainer setBackgroundColor:[[getUIColorClass() blackColor] CGColor]];
+    if (mode() == HTMLMediaElementEnums::VideoFullscreenModeOptimized)
+        enterFullscreenOptimized();
+    else if (mode() == HTMLMediaElementEnums::VideoFullscreenModeStandard)
+        enterFullscreenStandard();
+    else
+        ASSERT_NOT_REACHED();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenInterfaceAVKit::enterFullscreenOptimized()
</span><span class="cx"> {
</span><del>-    RefPtr&lt;WebVideoFullscreenInterfaceAVKit&gt; strongThis(this);
-
</del><span class="cx">     LOG(Fullscreen, &quot;WebVideoFullscreenInterfaceAVKit::enterFullscreenOptimized(%p)&quot;, this);
</span><span class="cx">     
</span><span class="cx">     if ([m_playerViewController isOptimizedFullscreenPossible])
</span><span class="lines">@@ -1044,34 +978,21 @@
</span><span class="cx">         LOG(Fullscreen, &quot;WebVideoFullscreenInterfaceAVKit::enterFullscreenStandard - lambda(%p) - succeeded(%s)&quot;, this, boolString(succeeded));
</span><span class="cx">         [m_playerViewController setShowsPlaybackControls:YES];
</span><span class="cx"> 
</span><del>-        WebThreadRun([this, strongThis] {
-            if (m_fullscreenChangeObserver)
-                m_fullscreenChangeObserver-&gt;didEnterFullscreen();
-        });
</del><ins>+        if (m_fullscreenChangeObserver)
+            m_fullscreenChangeObserver-&gt;didEnterFullscreen();
</ins><span class="cx">     }];
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenInterfaceAVKit::exitFullscreen(const WebCore::IntRect&amp; finalRect)
</span><span class="cx"> {
</span><del>-    RefPtr&lt;WebVideoFullscreenInterfaceAVKit&gt; strongThis(this);
-
</del><span class="cx">     m_exitRequested = true;
</span><span class="cx">     if (m_exitCompleted) {
</span><del>-        WebThreadRun([strongThis] {
-            if (strongThis-&gt;m_fullscreenChangeObserver)
-                strongThis-&gt;m_fullscreenChangeObserver-&gt;didExitFullscreen();
-        });
</del><ins>+        if (m_fullscreenChangeObserver)
+            m_fullscreenChangeObserver-&gt;didExitFullscreen();
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><del>-
-    dispatch_async(dispatch_get_main_queue(), [strongThis, finalRect] {
-        strongThis-&gt;exitFullscreenInternal(finalRect);
-    });
-}
-
-void WebVideoFullscreenInterfaceAVKit::exitFullscreenInternal(const WebCore::IntRect&amp; finalRect)
-{
-    LOG(Fullscreen, &quot;WebVideoFullscreenInterfaceAVKit::exitFullscreenInternal(%p)&quot;, this);
</del><ins>+    
+    LOG(Fullscreen, &quot;WebVideoFullscreenInterfaceAVKit::exitFullscreen(%p)&quot;, this);
</ins><span class="cx">     [m_playerViewController setShowsPlaybackControls:NO];
</span><span class="cx">     if (m_viewController)
</span><span class="cx">         [m_playerViewController view].frame = [m_parentView convertRect:finalRect toView:nil];
</span><span class="lines">@@ -1088,25 +1009,23 @@
</span><span class="cx">         [m_playerViewController stopOptimizedFullscreen];
</span><span class="cx">     } else if (isMode(HTMLMediaElementEnums::VideoFullscreenModeOptimized | HTMLMediaElementEnums::VideoFullscreenModeStandard)) {
</span><span class="cx">         RefPtr&lt;WebVideoFullscreenInterfaceAVKit&gt; strongThis(this);
</span><del>-        [m_playerViewController exitFullScreenAnimated:NO completionHandler:[strongThis] (BOOL, NSError*) {
-            [strongThis-&gt;m_window setHidden:NO];
-            [strongThis-&gt;m_playerViewController stopOptimizedFullscreen];
</del><ins>+        [m_playerViewController exitFullScreenAnimated:NO completionHandler:[strongThis, this] (BOOL, NSError*) {
+            [m_window setHidden:NO];
+            [m_playerViewController stopOptimizedFullscreen];
</ins><span class="cx">         }];
</span><span class="cx">     } else if (isMode(HTMLMediaElementEnums::VideoFullscreenModeStandard)) {
</span><span class="cx">         RefPtr&lt;WebVideoFullscreenInterfaceAVKit&gt; strongThis(this);
</span><del>-        [m_playerViewController exitFullScreenAnimated:YES completionHandler:[strongThis] (BOOL, NSError*) {
-            strongThis-&gt;m_exitCompleted = true;
</del><ins>+        [m_playerViewController exitFullScreenAnimated:YES completionHandler:[strongThis, this] (BOOL, NSError*) {
+            m_exitCompleted = true;
</ins><span class="cx"> 
</span><span class="cx">             [CATransaction begin];
</span><span class="cx">             [CATransaction setDisableActions:YES];
</span><del>-            [strongThis-&gt;m_videoLayerContainer setBackgroundColor:[[getUIColorClass() clearColor] CGColor]];
-            [[strongThis-&gt;m_playerViewController view] setBackgroundColor:[getUIColorClass() clearColor]];
</del><ins>+            [m_videoLayerContainer setBackgroundColor:[[getUIColorClass() clearColor] CGColor]];
+            [[m_playerViewController view] setBackgroundColor:[getUIColorClass() clearColor]];
</ins><span class="cx">             [CATransaction commit];
</span><span class="cx"> 
</span><del>-            WebThreadRun([strongThis] {
-                if (strongThis-&gt;m_fullscreenChangeObserver)
-                    strongThis-&gt;m_fullscreenChangeObserver-&gt;didExitFullscreen();
-            });
</del><ins>+            if (m_fullscreenChangeObserver)
+                m_fullscreenChangeObserver-&gt;didExitFullscreen();
</ins><span class="cx">         }];
</span><span class="cx">     };
</span><span class="cx"> }
</span><span class="lines">@@ -1121,16 +1040,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenInterfaceAVKit::cleanupFullscreen()
</span><span class="cx"> {
</span><del>-    RefPtr&lt;WebVideoFullscreenInterfaceAVKit&gt; strongThis(this);
-    
-    dispatch_async(dispatch_get_main_queue(), [strongThis] {
-        strongThis-&gt;cleanupFullscreenInternal();
-    });
-}
-
-void WebVideoFullscreenInterfaceAVKit::cleanupFullscreenInternal()
-{
-    LOG(Fullscreen, &quot;WebVideoFullscreenInterfaceAVKit::cleanupFullscreenInternal(%p)&quot;, this);
</del><ins>+    LOG(Fullscreen, &quot;WebVideoFullscreenInterfaceAVKit::cleanupFullscreen(%p)&quot;, this);
</ins><span class="cx">     if (m_window) {
</span><span class="cx">         [m_window setHidden:YES];
</span><span class="cx">         [m_window setRootViewController:nil];
</span><span class="lines">@@ -1170,12 +1080,10 @@
</span><span class="cx">     m_parentView = nil;
</span><span class="cx">     m_parentWindow = nil;
</span><span class="cx">     
</span><del>-    RefPtr&lt;WebVideoFullscreenInterfaceAVKit&gt; strongThis(this);
-    WebThreadRun([strongThis] {
-        if (strongThis-&gt;m_fullscreenChangeObserver)
-            strongThis-&gt;m_fullscreenChangeObserver-&gt;didCleanupFullscreen();
-        strongThis-&gt;m_enterRequested = false;
-    });
</del><ins>+    if (m_fullscreenChangeObserver)
+        m_fullscreenChangeObserver-&gt;didCleanupFullscreen();
+
+    m_enterRequested = false;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenInterfaceAVKit::invalidate()
</span><span class="lines">@@ -1183,7 +1091,7 @@
</span><span class="cx">     m_videoFullscreenModel = nil;
</span><span class="cx">     m_fullscreenChangeObserver = nil;
</span><span class="cx">     
</span><del>-    cleanupFullscreenInternal();
</del><ins>+    cleanupFullscreen();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenInterfaceAVKit::requestHideAndExitFullscreen()
</span><span class="lines">@@ -1196,10 +1104,7 @@
</span><span class="cx">     
</span><span class="cx">     LOG(Fullscreen, &quot;WebVideoFullscreenInterfaceAVKit::requestHideAndExitFullscreen(%p)&quot;, this);
</span><span class="cx"> 
</span><del>-    RefPtr&lt;WebVideoFullscreenInterfaceAVKit&gt; strongThis(this);
-    dispatch_async(dispatch_get_main_queue(), [strongThis] {
-        [strongThis-&gt;m_window setHidden:YES];
-    });
</del><ins>+    [m_window setHidden:YES];
</ins><span class="cx"> 
</span><span class="cx">     if (m_videoFullscreenModel &amp;&amp; !m_exitRequested) {
</span><span class="cx">         m_videoFullscreenModel-&gt;pause();
</span><span class="lines">@@ -1210,19 +1115,16 @@
</span><span class="cx"> void WebVideoFullscreenInterfaceAVKit::preparedToReturnToInline(bool visible, const IntRect&amp; inlineRect)
</span><span class="cx"> {
</span><span class="cx">     LOG(Fullscreen, &quot;WebVideoFullscreenInterfaceAVKit::preparedToReturnToInline(%p) - visible(%s)&quot;, this, boolString(visible));
</span><del>-    RefPtr&lt;WebVideoFullscreenInterfaceAVKit&gt; strongThis(this);
-    dispatch_async(dispatch_get_main_queue(), [strongThis, visible, inlineRect] {
-        if (strongThis-&gt;m_prepareToInlineCallback) {
-            
-            if (strongThis-&gt;m_viewController)
-                [strongThis-&gt;m_playerViewController view].frame = [strongThis-&gt;m_parentView convertRect:inlineRect toView:nil];
-            else
-                [strongThis-&gt;m_playerViewController view].frame = inlineRect;
</del><ins>+    if (m_prepareToInlineCallback) {
+        
+        if (m_viewController)
+            [m_playerViewController view].frame = [m_parentView convertRect:inlineRect toView:nil];
+        else
+            [m_playerViewController view].frame = inlineRect;
</ins><span class="cx"> 
</span><del>-            std::function&lt;void(bool)&gt; callback = WTF::move(strongThis-&gt;m_prepareToInlineCallback);
-            callback(visible);
-        }
-    });
</del><ins>+        std::function&lt;void(bool)&gt; callback = WTF::move(m_prepareToInlineCallback);
+        callback(visible);
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool WebVideoFullscreenInterfaceAVKit::mayAutomaticallyShowVideoOptimized() const
</span><span class="lines">@@ -1246,21 +1148,21 @@
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     RefPtr&lt;WebVideoFullscreenInterfaceAVKit&gt; strongThis(this);
</span><del>-    fullscreenMayReturnToInline([strongThis](bool visible) {
-        LOG(Fullscreen, &quot;WebVideoFullscreenInterfaceAVKit::willStartOptimizedFullscreen - lambda(%p) - visible(%s)&quot;, strongThis.get(), boolString(visible));
</del><ins>+    fullscreenMayReturnToInline([strongThis, this](bool visible) {
+        LOG(Fullscreen, &quot;WebVideoFullscreenInterfaceAVKit::willStartOptimizedFullscreen - lambda(%p) - visible(%s)&quot;, this, boolString(visible));
</ins><span class="cx"> 
</span><span class="cx">         if (!visible) {
</span><del>-            [strongThis-&gt;m_window setHidden:YES];
</del><ins>+            [m_window setHidden:YES];
</ins><span class="cx">             return;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        [[strongThis-&gt;m_playerViewController view] layoutIfNeeded];
</del><ins>+        [[m_playerViewController view] layoutIfNeeded];
</ins><span class="cx"> 
</span><del>-        [strongThis-&gt;m_playerViewController exitFullScreenAnimated:YES completionHandler:[strongThis] (BOOL completed, NSError*) {
</del><ins>+        [m_playerViewController exitFullScreenAnimated:YES completionHandler:[strongThis, this] (BOOL completed, NSError*) {
</ins><span class="cx">             if (!completed)
</span><span class="cx">                 return;
</span><del>-            strongThis-&gt;clearMode(HTMLMediaElementEnums::VideoFullscreenModeStandard);
-            [strongThis-&gt;m_window setHidden:YES];
</del><ins>+            clearMode(HTMLMediaElementEnums::VideoFullscreenModeStandard);
+            [m_window setHidden:YES];
</ins><span class="cx">         }];
</span><span class="cx">     });
</span><span class="cx"> }
</span><span class="lines">@@ -1271,11 +1173,8 @@
</span><span class="cx">     [m_playerViewController setShowsPlaybackControls:YES];
</span><span class="cx">     [m_window setHidden:YES];
</span><span class="cx"> 
</span><del>-    RefPtr&lt;WebVideoFullscreenInterfaceAVKit&gt; strongThis(this);
-    WebThreadRun([strongThis] {
-        if (strongThis-&gt;m_fullscreenChangeObserver)
-            strongThis-&gt;m_fullscreenChangeObserver-&gt;didEnterFullscreen();
-    });
</del><ins>+    if (m_fullscreenChangeObserver)
+        m_fullscreenChangeObserver-&gt;didEnterFullscreen();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenInterfaceAVKit::failedToStartOptimizedFullscreen()
</span><span class="lines">@@ -1283,19 +1182,16 @@
</span><span class="cx">     LOG(Fullscreen, &quot;WebVideoFullscreenInterfaceAVKit::failedToStartOptimizedFullscreen(%p)&quot;, this);
</span><span class="cx">     [m_playerViewController setShowsPlaybackControls:YES];
</span><span class="cx"> 
</span><del>-    RefPtr&lt;WebVideoFullscreenInterfaceAVKit&gt; strongThis(this);
-    WebThreadRun([strongThis, this] {
-        if (hasMode(HTMLMediaElementEnums::VideoFullscreenModeStandard))
-            return;
</del><ins>+    if (hasMode(HTMLMediaElementEnums::VideoFullscreenModeStandard))
+        return;
</ins><span class="cx"> 
</span><del>-        m_exitCompleted = true;
</del><ins>+    m_exitCompleted = true;
</ins><span class="cx"> 
</span><del>-        if (m_fullscreenChangeObserver)
-            m_fullscreenChangeObserver-&gt;didEnterFullscreen();
</del><ins>+    if (m_fullscreenChangeObserver)
+        m_fullscreenChangeObserver-&gt;didEnterFullscreen();
</ins><span class="cx"> 
</span><del>-        if (m_videoFullscreenModel)
-            m_videoFullscreenModel-&gt;requestExitFullscreen();
-    });
</del><ins>+    if (m_videoFullscreenModel)
+        m_videoFullscreenModel-&gt;requestExitFullscreen();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenInterfaceAVKit::willStopOptimizedFullscreen()
</span><span class="lines">@@ -1303,11 +1199,8 @@
</span><span class="cx">     LOG(Fullscreen, &quot;WebVideoFullscreenInterfaceAVKit::willStopOptimizedFullscreen(%p)&quot;, this);
</span><span class="cx">     [m_window setHidden:NO];
</span><span class="cx"> 
</span><del>-    RefPtr&lt;WebVideoFullscreenInterfaceAVKit&gt; strongThis(this);
-    WebThreadRun([strongThis] {
-        if (strongThis-&gt;m_videoFullscreenModel)
-            strongThis-&gt;m_videoFullscreenModel-&gt;requestExitFullscreen();
-    });
</del><ins>+    if (m_videoFullscreenModel)
+        m_videoFullscreenModel-&gt;requestExitFullscreen();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenInterfaceAVKit::didStopOptimizedFullscreen()
</span><span class="lines">@@ -1321,13 +1214,11 @@
</span><span class="cx">     [m_videoLayerContainer setBackgroundColor:[[getUIColorClass() clearColor] CGColor]];
</span><span class="cx">     [[m_playerViewController view] setBackgroundColor:[getUIColorClass() clearColor]];
</span><span class="cx"> 
</span><del>-    RefPtr&lt;WebVideoFullscreenInterfaceAVKit&gt; strongThis(this);
-    WebThreadRun([strongThis] {
-        strongThis-&gt;clearMode(HTMLMediaElementEnums::VideoFullscreenModeOptimized);
-        [strongThis-&gt;m_window setHidden:YES];
-        if (strongThis-&gt;m_fullscreenChangeObserver)
-            strongThis-&gt;m_fullscreenChangeObserver-&gt;didExitFullscreen();
-    });
</del><ins>+    clearMode(HTMLMediaElementEnums::VideoFullscreenModeOptimized);
+    [m_window setHidden:YES];
+    
+    if (m_fullscreenChangeObserver)
+        m_fullscreenChangeObserver-&gt;didExitFullscreen();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenInterfaceAVKit::prepareForOptimizedFullscreenStopWithCompletionHandler(void (^completionHandler)(BOOL restored))
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformiosWebVideoFullscreenModelVideoElementmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/WebVideoFullscreenModelVideoElement.mm (184921 => 184922)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/WebVideoFullscreenModelVideoElement.mm        2015-05-27 21:32:20 UTC (rev 184921)
+++ trunk/Source/WebCore/platform/ios/WebVideoFullscreenModelVideoElement.mm        2015-05-27 21:41:02 UTC (rev 184922)
</span><span class="lines">@@ -179,125 +179,74 @@
</span><span class="cx">     [m_videoFullscreenLayer setAnchorPoint:CGPointMake(0.5, 0.5)];
</span><span class="cx">     [m_videoFullscreenLayer setBounds:m_videoFrame];
</span><span class="cx">     
</span><del>-    __block RefPtr&lt;WebVideoFullscreenModelVideoElement&gt; protect(this);
-    WebThreadRun(^{
-        if (m_videoElement)
-            m_videoElement-&gt;setVideoFullscreenLayer(m_videoFullscreenLayer.get());
-        protect.clear();
-    });
</del><ins>+    if (m_videoElement)
+        m_videoElement-&gt;setVideoFullscreenLayer(m_videoFullscreenLayer.get());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenModelVideoElement::play()
</span><span class="cx"> {
</span><del>-    __block RefPtr&lt;WebVideoFullscreenModelVideoElement&gt; protect(this);
-    WebThreadRun(^{
-        if (m_videoElement)
-            m_videoElement-&gt;play();
-        protect.clear();
-    });
</del><ins>+    if (m_videoElement)
+        m_videoElement-&gt;play();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenModelVideoElement::pause()
</span><span class="cx"> {
</span><del>-    __block RefPtr&lt;WebVideoFullscreenModelVideoElement&gt; protect(this);
-    WebThreadRun(^{
-        if (m_videoElement)
-            m_videoElement-&gt;pause();
-        protect.clear();
-    });
</del><ins>+    if (m_videoElement)
+        m_videoElement-&gt;pause();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenModelVideoElement::togglePlayState()
</span><span class="cx"> {
</span><del>-    __block RefPtr&lt;WebVideoFullscreenModelVideoElement&gt; protect(this);
-    WebThreadRun(^{
-        if (m_videoElement)
-            m_videoElement-&gt;togglePlayState();
-        protect.clear();
-    });
</del><ins>+    if (m_videoElement)
+        m_videoElement-&gt;togglePlayState();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenModelVideoElement::beginScrubbing()
</span><span class="cx"> {
</span><del>-    __block RefPtr&lt;WebVideoFullscreenModelVideoElement&gt; protect(this);
-    WebThreadRun(^{
-        if (m_videoElement)
-            m_videoElement-&gt;beginScrubbing();
-        protect.clear();
-    });
</del><ins>+    if (m_videoElement)
+        m_videoElement-&gt;beginScrubbing();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenModelVideoElement::endScrubbing()
</span><span class="cx"> {
</span><del>-    __block RefPtr&lt;WebVideoFullscreenModelVideoElement&gt; protect(this);
-    WebThreadRun(^{
-        if (m_videoElement)
-            m_videoElement-&gt;endScrubbing();
-        protect.clear();
-    });
</del><ins>+    if (m_videoElement)
+        m_videoElement-&gt;endScrubbing();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenModelVideoElement::seekToTime(double time)
</span><span class="cx"> {
</span><del>-    __block RefPtr&lt;WebVideoFullscreenModelVideoElement&gt; protect(this);
-    WebThreadRun(^{
-        if (m_videoElement)
-            m_videoElement-&gt;setCurrentTime(time);
-        protect.clear();
-    });
</del><ins>+    if (m_videoElement)
+        m_videoElement-&gt;setCurrentTime(time);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenModelVideoElement::fastSeek(double time)
</span><span class="cx"> {
</span><del>-    __block RefPtr&lt;WebVideoFullscreenModelVideoElement&gt; protect(this);
-    WebThreadRun(^{
-        if (m_videoElement)
-            m_videoElement-&gt;fastSeek(time);
-        protect.clear();
-    });
</del><ins>+    if (m_videoElement)
+        m_videoElement-&gt;fastSeek(time);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenModelVideoElement::beginScanningForward()
</span><span class="cx"> {
</span><del>-    __block RefPtr&lt;WebVideoFullscreenModelVideoElement&gt; protect(this);
-    WebThreadRun(^{
-        if (m_videoElement)
-            m_videoElement-&gt;beginScanning(MediaControllerInterface::Forward);
-        protect.clear();
-    });
</del><ins>+    if (m_videoElement)
+        m_videoElement-&gt;beginScanning(MediaControllerInterface::Forward);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenModelVideoElement::beginScanningBackward()
</span><span class="cx"> {
</span><del>-    __block RefPtr&lt;WebVideoFullscreenModelVideoElement&gt; protect(this);
-    WebThreadRun(^{
-        if (m_videoElement)
-            m_videoElement-&gt;beginScanning(MediaControllerInterface::Backward);
-        protect.clear();
-    });
</del><ins>+    if (m_videoElement)
+        m_videoElement-&gt;beginScanning(MediaControllerInterface::Backward);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenModelVideoElement::endScanning()
</span><span class="cx"> {
</span><del>-    __block RefPtr&lt;WebVideoFullscreenModelVideoElement&gt; protect(this);
-    WebThreadRun(^{
-        if (m_videoElement)
-            m_videoElement-&gt;endScanning();
-        protect.clear();
-    });
</del><ins>+    if (m_videoElement)
+        m_videoElement-&gt;endScanning();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenModelVideoElement::requestExitFullscreen()
</span><span class="cx"> {
</span><del>-    if (!m_videoElement)
-        return;
-
-    __block RefPtr&lt;WebVideoFullscreenModelVideoElement&gt; protect(this);
-    WebThreadRun(^{
-        if (m_videoElement &amp;&amp; m_videoElement-&gt;isFullscreen())
-            m_videoElement-&gt;exitFullscreen();
-        protect.clear();
-    });
</del><ins>+    if (m_videoElement &amp;&amp; m_videoElement-&gt;isFullscreen())
+        m_videoElement-&gt;exitFullscreen();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenModelVideoElement::setVideoLayerFrame(FloatRect rect)
</span><span class="lines">@@ -454,12 +403,8 @@
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenModelVideoElement::fullscreenModeChanged(HTMLMediaElementEnums::VideoFullscreenMode videoFullscreenMode)
</span><span class="cx"> {
</span><del>-    __block RefPtr&lt;WebVideoFullscreenModelVideoElement&gt; protect(this);
-    WebThreadRun(^{
-        if (m_videoElement)
-            m_videoElement-&gt;fullscreenModeChanged(videoFullscreenMode);
-        protect.clear();
-    });
</del><ins>+    if (m_videoElement)
+        m_videoElement-&gt;fullscreenModeChanged(videoFullscreenMode);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #endif
</span></span></pre>
</div>
</div>

</body>
</html>