Title: [184922] trunk/Source/WebCore
Revision
184922
Author
[email protected]
Date
2015-05-27 14:41:02 -0700 (Wed, 27 May 2015)

Log Message

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 <[email protected]> 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.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (184921 => 184922)


--- 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)
@@ -1,3 +1,119 @@
+2015-05-27  Jeremy Jones  <[email protected]>
+
+        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.
+
 2015-05-27  Eric Carlson  <[email protected]>
 
         [Mac] short-circuit MIME type lookup when possible

Modified: trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm (184921 => 184922)


--- 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)
@@ -30,6 +30,7 @@
 #import "WebVideoFullscreenControllerAVKit.h"
 
 #import "Logging.h"
+#import "TimeRanges.h"
 #import "WebVideoFullscreenInterfaceAVKit.h"
 #import "WebVideoFullscreenModelVideoElement.h"
 #import <QuartzCore/CoreAnimation.h>
@@ -51,7 +52,7 @@
     return nullptr;
 }
 
-- (void)enterFullscreen:(UIView *)view mode:(WebCore::HTMLMediaElement::VideoFullscreenMode)mode
+- (void)enterFullscreen:(UIView *)view mode:(WebCore::HTMLMediaElementEnums::VideoFullscreenMode)mode
 {
     UNUSED_PARAM(view);
     UNUSED_PARAM(mode);
@@ -68,125 +69,535 @@
 
 #else
 
-@interface WebVideoFullscreenController (FullscreenObservation)
-- (void)didSetupFullscreen;
-- (void)didEnterFullscreen;
-- (void)didExitFullscreen;
-- (void)didCleanupFullscreen;
-- (void)fullscreenMayReturnToInline;
+class WebVideoFullscreenControllerContext;
+
+@interface WebVideoFullscreenController (delegate)
+-(void)didFinishFullscreen:(WebVideoFullscreenControllerContext*)context;
 @end
 
-class WebVideoFullscreenControllerChangeObserver : public WebVideoFullscreenChangeObserver {
-    WebVideoFullscreenController* _target;
+class WebVideoFullscreenControllerContext final
+    : private WebVideoFullscreenInterface
+    , private WebVideoFullscreenModel
+    , private WebVideoFullscreenChangeObserver
+    , public ThreadSafeRefCounted<WebVideoFullscreenControllerContext> {
+
 public:
-    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]; }
+    static Ref<WebVideoFullscreenControllerContext> create()
+    {
+        return adoptRef(*new WebVideoFullscreenControllerContext);
+    }
+    
+    void setController(WebVideoFullscreenController* controller) { m_controller = controller; }
+    void setUpFullscreen(HTMLVideoElement&, 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&) override;
+    virtual void setCanPlayFastReverse(bool) override;
+    virtual void setAudioMediaSelectionOptions(const Vector<String>& options, uint64_t selectedIndex) override;
+    virtual void setLegibleMediaSelectionOptions(const Vector<String>& 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<WebVideoFullscreenInterfaceAVKit> m_interface;
+    RefPtr<WebVideoFullscreenModelVideoElement> m_model;
+    RefPtr<HTMLVideoElement> m_videoElement;
+    RetainPtr<PlatformLayer> m_videoFullscreenLayer;
+    RetainPtr<WebVideoFullscreenController> m_controller;
+    FloatRect m_frame;
+    VideoGravity m_gravity;
 };
 
-@implementation WebVideoFullscreenController
+#pragma mark WebVideoFullscreenChangeObserver
+
+void WebVideoFullscreenControllerContext::didSetupFullscreen()
 {
-    RefPtr<HTMLVideoElement> _videoElement;
-    RefPtr<WebVideoFullscreenInterfaceAVKit> _interface;
-    RefPtr<WebVideoFullscreenModelVideoElement> _model;
-    WebVideoFullscreenControllerChangeObserver _changeObserver;
-    RetainPtr<PlatformLayer> _videoFullscreenLayer;
+    ASSERT(isUIThread());
+    RefPtr<WebVideoFullscreenControllerContext> strongThis(this);
+    WebThreadRun([strongThis, this] {
+        m_model->setVideoFullscreenLayer(m_videoFullscreenLayer.get());
+        dispatch_async(dispatch_get_main_queue(), [strongThis, this] {
+            m_interface->enterFullscreen();
+        });
+    });
 }
 
-- (instancetype)init
+void WebVideoFullscreenControllerContext::didExitFullscreen()
 {
-    if (!(self = [super init]))
-        return nil;
+    ASSERT(isUIThread());
+    RefPtr<WebVideoFullscreenControllerContext> strongThis(this);
+    WebThreadRun([strongThis, this] {
+        m_model->setVideoFullscreenLayer(nil);
+        dispatch_async(dispatch_get_main_queue(), [strongThis, this] {
+            m_interface->cleanupFullscreen();
+        });
+    });
+}
+
+void WebVideoFullscreenControllerContext::didCleanupFullscreen()
+{
+    ASSERT(isUIThread());
+    m_interface->setWebVideoFullscreenModel(nullptr);
+    m_interface->setWebVideoFullscreenChangeObserver(nullptr);
+    m_interface = nullptr;
     
-    _changeObserver.setTarget(self);
+    RefPtr<WebVideoFullscreenControllerContext> strongThis(this);
+    WebThreadRun([strongThis, this] {
+        m_model->setVideoFullscreenLayer(nil);
+        m_model->setWebVideoFullscreenInterface(nullptr);
+        m_model->setVideoElement(nullptr);
+        m_model = nullptr;
+        m_videoElement = nullptr;
+        m_videoFullscreenLayer = nil;
+        
+        [m_controller didFinishFullscreen:this];
+    });
+}
 
-    return self;
+void WebVideoFullscreenControllerContext::fullscreenMayReturnToInline()
+{
+    ASSERT(isUIThread());
+    RefPtr<WebVideoFullscreenControllerContext> strongThis(this);
+    WebThreadRun([strongThis, this] {
+        IntRect clientRect = m_videoElement->clientRect();
+        dispatch_async(dispatch_get_main_queue(), [strongThis, this, clientRect] {
+            m_interface->preparedToReturnToInline(true, clientRect);
+        });
+    });
 }
 
-- (void)dealloc
+#pragma mark WebVideoFullscreenInterface
+
+void WebVideoFullscreenControllerContext::resetMediaState()
 {
-    _videoElement = nullptr;
-    [super dealloc];
+    ASSERT(WebThreadIsCurrent() || isMainThread());
+    RefPtr<WebVideoFullscreenControllerContext> strongThis(this);
+    dispatch_async(dispatch_get_main_queue(), [strongThis, this] {
+        if (m_interface)
+            m_interface->resetMediaState();
+    });
 }
 
-- (void)setVideoElement:(HTMLVideoElement*)videoElement
+void WebVideoFullscreenControllerContext::setDuration(double duration)
 {
-    _videoElement = videoElement;
+    ASSERT(WebThreadIsCurrent());
+    RefPtr<WebVideoFullscreenControllerContext> strongThis(this);
+    dispatch_async(dispatch_get_main_queue(), [strongThis, this, duration] {
+        if (m_interface)
+            m_interface->setDuration(duration);
+    });
 }
 
-- (HTMLVideoElement*)videoElement
+void WebVideoFullscreenControllerContext::setCurrentTime(double currentTime, double anchorTime)
 {
-    return _videoElement.get();
+    ASSERT(WebThreadIsCurrent());
+    RefPtr<WebVideoFullscreenControllerContext> strongThis(this);
+    dispatch_async(dispatch_get_main_queue(), [strongThis, this, currentTime, anchorTime] {
+        if (m_interface)
+            m_interface->setCurrentTime(currentTime, anchorTime);
+    });
 }
 
-- (void)enterFullscreen:(UIView *)view mode:(HTMLMediaElementEnums::VideoFullscreenMode)mode
+void WebVideoFullscreenControllerContext::setBufferedTime(double bufferedTime)
 {
-    [self retain]; // Balanced by -release in didExitFullscreen:
+    ASSERT(WebThreadIsCurrent());
+    RefPtr<WebVideoFullscreenControllerContext> strongThis(this);
+    dispatch_async(dispatch_get_main_queue(), [strongThis, this, bufferedTime] {
+        if (m_interface)
+            m_interface->setBufferedTime(bufferedTime);
+    });
+}
+
+void WebVideoFullscreenControllerContext::setRate(bool isPlaying, float playbackRate)
+{
+    ASSERT(WebThreadIsCurrent());
+    RefPtr<WebVideoFullscreenControllerContext> strongThis(this);
+    dispatch_async(dispatch_get_main_queue(), [strongThis, this, isPlaying, playbackRate] {
+        if (m_interface)
+            m_interface->setRate(isPlaying, playbackRate);
+    });
+}
+
+void WebVideoFullscreenControllerContext::setVideoDimensions(bool hasVideo, float width, float height)
+{
+    ASSERT(WebThreadIsCurrent());
+    RefPtr<WebVideoFullscreenControllerContext> strongThis(this);
+    dispatch_async(dispatch_get_main_queue(), [strongThis, this, hasVideo, width, height] {
+        if (m_interface)
+            m_interface->setVideoDimensions(hasVideo, width, height);
+    });
+}
+
+void WebVideoFullscreenControllerContext::setSeekableRanges(const TimeRanges& timeRanges)
+{
+    ASSERT(WebThreadIsCurrent());
+    RefPtr<WebVideoFullscreenControllerContext> strongThis(this);
+    const PlatformTimeRanges& platformTimeRanges = timeRanges.ranges();
+    dispatch_async(dispatch_get_main_queue(), [strongThis, this, platformTimeRanges] {
+        if (m_interface)
+            m_interface->setSeekableRanges(TimeRanges::create(platformTimeRanges));
+    });
+}
+
+void WebVideoFullscreenControllerContext::setCanPlayFastReverse(bool canPlayFastReverse)
+{
+    ASSERT(WebThreadIsCurrent());
+    RefPtr<WebVideoFullscreenControllerContext> strongThis(this);
+    dispatch_async(dispatch_get_main_queue(), [strongThis, this, canPlayFastReverse] {
+        if (m_interface)
+            m_interface->setCanPlayFastReverse(canPlayFastReverse);
+    });
+}
+
+void WebVideoFullscreenControllerContext::setAudioMediaSelectionOptions(const Vector<String>& options, uint64_t selectedIndex)
+{
+    ASSERT(WebThreadIsCurrent());
+    RefPtr<WebVideoFullscreenControllerContext> strongThis(this);
+
+    RetainPtr<NSMutableArray> optionsArray = adoptNS([[NSMutableArray alloc] initWithCapacity:options.size()]);
+    for (auto& name : options)
+        [optionsArray addObject:name];
     
-    _interface = WebVideoFullscreenInterfaceAVKit::create();
-    _interface->setWebVideoFullscreenChangeObserver(&_changeObserver);
-    _model = WebVideoFullscreenModelVideoElement::create();
-    _model->setWebVideoFullscreenInterface(_interface.get());
-    _interface->setWebVideoFullscreenModel(_model.get());
-    _model->setVideoElement(_videoElement.get());
-    _videoFullscreenLayer = [CALayer layer];
-    _interface->setupFullscreen(*_videoFullscreenLayer.get(), _videoElement->clientRect(), view, mode, _videoElement->mediaSession().allowsAlternateFullscreen(*_videoElement.get()));
+    dispatch_async(dispatch_get_main_queue(), [strongThis, this, optionsArray, selectedIndex] {
+        Vector<String> options;
+        for (NSString *name : optionsArray.get())
+            options.append(name);
+        
+        if (m_interface)
+            m_interface->setAudioMediaSelectionOptions(options, selectedIndex);
+    });
 }
 
-- (void)exitFullscreen
+void WebVideoFullscreenControllerContext::setLegibleMediaSelectionOptions(const Vector<String>& options, uint64_t selectedIndex)
 {
-    _interface->exitFullscreen(_videoElement->screenRect());
+    ASSERT(WebThreadIsCurrent());
+    RefPtr<WebVideoFullscreenControllerContext> strongThis(this);
+    
+    RetainPtr<NSMutableArray> optionsArray = adoptNS([[NSMutableArray alloc] initWithCapacity:options.size()]);
+    for (auto& name : options)
+        [optionsArray addObject:name];
+    
+    dispatch_async(dispatch_get_main_queue(), [strongThis, this, optionsArray, selectedIndex] {
+        Vector<String> options;
+        for (NSString *name : optionsArray.get())
+            options.append(name);
+        
+        if (m_interface)
+            m_interface->setLegibleMediaSelectionOptions(options, selectedIndex);
+    });
 }
 
-- (void)requestHideAndExitFullscreen
+void WebVideoFullscreenControllerContext::setExternalPlayback(bool enabled, ExternalPlaybackTargetType type, String localizedDeviceName)
 {
-    if (_interface)
-        _interface->requestHideAndExitFullscreen();
+    ASSERT(WebThreadIsCurrent());
+    RefPtr<WebVideoFullscreenControllerContext> strongThis(this);
+    StringCapture capturedLocalizedDeviceName(localizedDeviceName);
+    dispatch_async(dispatch_get_main_queue(), [strongThis, this, enabled, type, capturedLocalizedDeviceName] {
+        if (m_interface)
+            m_interface->setExternalPlayback(enabled, type, capturedLocalizedDeviceName.string());
+    });
 }
 
-- (void)didSetupFullscreen
+#pragma mark WebVideoFullscreenModel
+
+void WebVideoFullscreenControllerContext::play()
 {
-    WebThreadRun(^{
-        _model->setVideoFullscreenLayer(_videoFullscreenLayer.get());
-        _interface->enterFullscreen();
+    ASSERT(isUIThread());
+    RefPtr<WebVideoFullscreenControllerContext> strongThis(this);
+    WebThreadRun([strongThis, this] {
+        if (m_model)
+            m_model->play();
     });
 }
 
-- (void)didEnterFullscreen
+void WebVideoFullscreenControllerContext::pause()
 {
+    ASSERT(isUIThread());
+    RefPtr<WebVideoFullscreenControllerContext> strongThis(this);
+    WebThreadRun([strongThis, this] {
+        if (m_model)
+            m_model->pause();
+    });
 }
 
-- (void)didExitFullscreen
+void WebVideoFullscreenControllerContext::togglePlayState()
 {
-    WebThreadRun(^{
-        _model->setVideoFullscreenLayer(nil);
-        _interface->cleanupFullscreen();
+    ASSERT(isUIThread());
+    RefPtr<WebVideoFullscreenControllerContext> strongThis(this);
+    WebThreadRun([strongThis, this] {
+        if (m_model)
+            m_model->togglePlayState();
     });
 }
 
-- (void)didCleanupFullscreen
+void WebVideoFullscreenControllerContext::beginScrubbing()
 {
-    WebThreadRun(^{
-        _model->setVideoFullscreenLayer(nil);
-        _interface->setWebVideoFullscreenModel(nullptr);
-        _model->setWebVideoFullscreenInterface(nullptr);
-        _model->setVideoElement(nullptr);
-        _interface->setWebVideoFullscreenChangeObserver(nullptr);
-        _model = nullptr;
-        _interface = nullptr;
+    ASSERT(isUIThread());
+    RefPtr<WebVideoFullscreenControllerContext> strongThis(this);
+    WebThreadRun([strongThis, this] {
+        if (m_model)
+            m_model->beginScrubbing();
+    });
+}
+
+void WebVideoFullscreenControllerContext::endScrubbing()
+{
+    ASSERT(isUIThread());
+    RefPtr<WebVideoFullscreenControllerContext> strongThis(this);
+    WebThreadRun([strongThis, this] {
+        if (m_model)
+            m_model->endScrubbing();
+    });
+}
+
+void WebVideoFullscreenControllerContext::seekToTime(double time)
+{
+    ASSERT(isUIThread());
+    RefPtr<WebVideoFullscreenControllerContext> strongThis(this);
+    WebThreadRun([strongThis, this, time] {
+        if (m_model)
+            m_model->seekToTime(time);
+    });
+}
+
+void WebVideoFullscreenControllerContext::fastSeek(double time)
+{
+    ASSERT(isUIThread());
+    RefPtr<WebVideoFullscreenControllerContext> strongThis(this);
+    WebThreadRun([strongThis, this, time] {
+        if (m_model)
+            m_model->fastSeek(time);
+    });
+}
+
+void WebVideoFullscreenControllerContext::beginScanningForward()
+{
+    ASSERT(isUIThread());
+    RefPtr<WebVideoFullscreenControllerContext> strongThis(this);
+    WebThreadRun([strongThis, this] {
+        if (m_model)
+            m_model->beginScanningForward();
+    });
+}
+
+void WebVideoFullscreenControllerContext::beginScanningBackward()
+{
+    ASSERT(isUIThread());
+    RefPtr<WebVideoFullscreenControllerContext> strongThis(this);
+    WebThreadRun([strongThis, this] {
+        if (m_model)
+            m_model->beginScanningBackward();
+    });
+}
+
+void WebVideoFullscreenControllerContext::endScanning()
+{
+    ASSERT(isUIThread());
+    RefPtr<WebVideoFullscreenControllerContext> strongThis(this);
+    WebThreadRun([strongThis, this] {
+        if (m_model)
+            m_model->endScanning();
+    });
+}
+
+void WebVideoFullscreenControllerContext::requestExitFullscreen()
+{
+    ASSERT(isUIThread());
+    RefPtr<WebVideoFullscreenControllerContext> strongThis(this);
+    WebThreadRun([strongThis, this] {
+        if (m_model)
+            m_model->requestExitFullscreen();
+    });
+}
+
+void WebVideoFullscreenControllerContext::setVideoLayerFrame(FloatRect frame)
+{
+    ASSERT(isUIThread());
+    m_frame = frame;
+    RefPtr<WebVideoFullscreenControllerContext> strongThis(this);
+    WebThreadRun([strongThis, this, frame] {
+        if (m_model)
+            m_model->setVideoLayerFrame(frame);
+    });
+}
+
+void WebVideoFullscreenControllerContext::setVideoLayerGravity(WebVideoFullscreenModel::VideoGravity videoGravity)
+{
+    ASSERT(isUIThread());
+    m_gravity = videoGravity;
+    RefPtr<WebVideoFullscreenControllerContext> strongThis(this);
+    WebThreadRun([strongThis, this, videoGravity] {
+        if (m_model)
+            m_model->setVideoLayerGravity(videoGravity);
+    });
+}
+
+void WebVideoFullscreenControllerContext::selectAudioMediaOption(uint64_t index)
+{
+    ASSERT(isUIThread());
+    RefPtr<WebVideoFullscreenControllerContext> strongThis(this);
+    WebThreadRun([strongThis, this, index] {
+        if (m_model)
+            m_model->selectAudioMediaOption(index);
+    });
+}
+
+void WebVideoFullscreenControllerContext::selectLegibleMediaOption(uint64_t index)
+{
+    ASSERT(isUIThread());
+    RefPtr<WebVideoFullscreenControllerContext> strongThis(this);
+    WebThreadRun([strongThis, this, index] {
+        if (m_model)
+            m_model->selectLegibleMediaOption(index);
+    });
+}
+
+void WebVideoFullscreenControllerContext::fullscreenModeChanged(HTMLMediaElementEnums::VideoFullscreenMode mode)
+{
+    ASSERT(isUIThread());
+    RefPtr<WebVideoFullscreenControllerContext> strongThis(this);
+    WebThreadRun([strongThis, this, mode] {
+        if (m_model)
+            m_model->fullscreenModeChanged(mode);
+    });
+}
+
+#pragma mark Other
+
+void WebVideoFullscreenControllerContext::setUpFullscreen(HTMLVideoElement& videoElement, UIView *view, HTMLMediaElementEnums::VideoFullscreenMode mode)
+{
+    ASSERT(isMainThread());
+    RetainPtr<UIView> viewRef = view;
+    m_videoElement = &videoElement;
+
+    m_interface = WebVideoFullscreenInterfaceAVKit::create();
+    m_interface->setWebVideoFullscreenChangeObserver(this);
+    m_interface->setWebVideoFullscreenModel(this);
+    
+    RefPtr<WebVideoFullscreenControllerContext> strongThis(this);
+    WebThreadRun([strongThis, this, viewRef, mode] {
+        m_model = WebVideoFullscreenModelVideoElement::create();
+        m_model->setWebVideoFullscreenInterface(this);
+        m_model->setVideoElement(m_videoElement.get());
+        m_videoFullscreenLayer = [CALayer layer];
         
-        [self release]; // Balance the -retain we did in enterFullscreen:
+        bool allowsAlternateFullscreen = m_videoElement->mediaSession().allowsAlternateFullscreen(*m_videoElement.get());
+        IntRect videoElementClientRect = m_videoElement->clientRect();
+        
+        dispatch_async(dispatch_get_main_queue(), [strongThis, this, videoElementClientRect, viewRef, mode, allowsAlternateFullscreen] {
+            m_interface->setupFullscreen(*m_videoFullscreenLayer.get(), videoElementClientRect, viewRef.get(), mode, allowsAlternateFullscreen);
+        });
     });
 }
 
-- (void)fullscreenMayReturnToInline
+void WebVideoFullscreenControllerContext::exitFullscreen()
 {
-    _interface->preparedToReturnToInline(true, _videoElement->clientRect());
+    ASSERT(WebThreadIsCurrent());
+    IntRect screenRect = m_videoElement->screenRect();
+    RefPtr<WebVideoFullscreenControllerContext> strongThis(this);
+    dispatch_async(dispatch_get_main_queue(), [strongThis, this, screenRect] {
+        ASSERT(isUIThread());
+        m_interface->exitFullscreen(screenRect);
+    });
 }
 
+void WebVideoFullscreenControllerContext::requestHideAndExitFullscreen()
+{
+    ASSERT(isUIThread());
+    m_interface->requestHideAndExitFullscreen();
+}
+
+@implementation WebVideoFullscreenController {
+    RefPtr<WebVideoFullscreenControllerContext> _context;
+    RefPtr<HTMLVideoElement> _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->setController(self);
+    _context->setUpFullscreen(*_videoElement.get(), view, mode);
+}
+
+- (void)exitFullscreen
+{
+    ASSERT(WebThreadIsCurrent());
+    _context->exitFullscreen();
+}
+
+- (void)requestHideAndExitFullscreen
+{
+    ASSERT(isUIThread());
+    if (_context)
+        _context->requestHideAndExitFullscreen();
+}
+
+- (void)didFinishFullscreen:(WebVideoFullscreenControllerContext*)context
+{
+    ASSERT(WebThreadIsCurrent());
+    ASSERT_UNUSED(context, context == _context);
+    [[self retain] autorelease]; // retain self before breaking a retain cycle.
+    _context->setController(nil);
+    _context = nullptr;
+    _videoElement = nullptr;
+}
+
 @end
 
 #endif // __IPHONE_OS_VERSION_MIN_REQUIRED < 80000

Modified: trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.h (184921 => 184922)


--- 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)
@@ -35,9 +35,9 @@
 #include <WebCore/WebVideoFullscreenInterface.h>
 #include <functional>
 #include <objc/objc.h>
+#include <wtf/RefCounted.h>
 #include <wtf/RefPtr.h>
 #include <wtf/RetainPtr.h>
-#include <wtf/ThreadSafeRefCounted.h>
 
 OBJC_CLASS WebAVPlayerController;
 OBJC_CLASS AVPlayerViewController;
@@ -68,7 +68,7 @@
 
 class WEBCORE_EXPORT WebVideoFullscreenInterfaceAVKit
     : public WebVideoFullscreenInterface
-    , public ThreadSafeRefCounted<WebVideoFullscreenInterfaceAVKit> {
+    , public RefCounted<WebVideoFullscreenInterfaceAVKit> {
 
 public:
     static Ref<WebVideoFullscreenInterfaceAVKit> create()
@@ -120,11 +120,8 @@
 protected:
     WEBCORE_EXPORT WebVideoFullscreenInterfaceAVKit();
     void beginSession();
-    void setupFullscreenInternal(PlatformLayer&, const IntRect& initialRect, UIView *, HTMLMediaElementEnums::VideoFullscreenMode, bool allowOptimizedFullscreen);
     void enterFullscreenOptimized();
     void enterFullscreenStandard();
-    void exitFullscreenInternal(const IntRect& finalRect);
-    void cleanupFullscreenInternal();
 
     RetainPtr<WebAVPlayerController> m_playerController;
     RetainPtr<AVPlayerViewController> m_playerViewController;

Modified: trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.mm (184921 => 184922)


--- 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)
@@ -36,7 +36,6 @@
 #import "RuntimeApplicationChecksIOS.h"
 #import "TimeRanges.h"
 #import "WebCoreSystemInterface.h"
-#import "WebCoreThreadRun.h"
 #import "WebVideoFullscreenModel.h"
 #import <AVFoundation/AVTime.h>
 #import <UIKit/UIKit.h>
@@ -744,17 +743,13 @@
 
 void WebVideoFullscreenInterfaceAVKit::resetMediaState()
 {
-    RefPtr<WebVideoFullscreenInterfaceAVKit> strongThis(this);
-    
-    dispatch_async(dispatch_get_main_queue(), [strongThis] {
-        if (!strongThis->m_playerController) {
-            strongThis->m_playerController = adoptNS([[WebAVPlayerController alloc] init]);
-            [strongThis->m_playerController setDelegate:strongThis->m_videoFullscreenModel];
-            [strongThis->m_playerController setFullscreenInterface:strongThis.get()];
-            
-        } else
-            [strongThis->m_playerController resetState];
-    });
+    if (!m_playerController) {
+        m_playerController = adoptNS([[WebAVPlayerController alloc] init]);
+        [m_playerController setDelegate:m_videoFullscreenModel];
+        [m_playerController setFullscreenInterface:this];
+        
+    } else
+        [m_playerController resetState];
 }
 
 void WebVideoFullscreenInterfaceAVKit::setWebVideoFullscreenModel(WebVideoFullscreenModel* model)
@@ -770,72 +765,52 @@
 
 void WebVideoFullscreenInterfaceAVKit::setDuration(double duration)
 {
-    RefPtr<WebVideoFullscreenInterfaceAVKit> strongThis(this);
-    
-    dispatch_async(dispatch_get_main_queue(), [strongThis, duration] {
-        WebAVPlayerController* playerController = strongThis->m_playerController.get();
+    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;
+    // 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;
 
-        // 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;
-    });
+    // 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)
 {
-    RefPtr<WebVideoFullscreenInterfaceAVKit> strongThis(this);
-    
-    dispatch_async(dispatch_get_main_queue(), [strongThis, currentTime, anchorTime] {
-        NSTimeInterval anchorTimeStamp = ![strongThis->m_playerController rate] ? NAN : anchorTime;
-        AVValueTiming *timing = [getAVValueTimingClass() valueTimingWithAnchorValue:currentTime
-            anchorTimeStamp:anchorTimeStamp rate:0];
-        [strongThis->m_playerController setTiming:timing];
-    });
+    NSTimeInterval anchorTimeStamp = ![m_playerController rate] ? NAN : anchorTime;
+    AVValueTiming *timing = [getAVValueTimingClass() valueTimingWithAnchorValue:currentTime
+        anchorTimeStamp:anchorTimeStamp rate:0];
+    [m_playerController setTiming:timing];
 }
 
 void WebVideoFullscreenInterfaceAVKit::setBufferedTime(double bufferedTime)
 {
-    RefPtr<WebVideoFullscreenInterfaceAVKit> strongThis(this);
-
-    dispatch_async(dispatch_get_main_queue(), [strongThis, bufferedTime] {
-        WebAVPlayerController* playerController = strongThis->m_playerController.get();
-        double duration = playerController.contentDuration;
-        double normalizedBufferedTime;
-        if (!duration)
-            normalizedBufferedTime = 0;
-        else
-            normalizedBufferedTime = bufferedTime / duration;
-        playerController.loadedTimeRanges = @[@0, @(normalizedBufferedTime)];
-    });
+    WebAVPlayerController* playerController = m_playerController.get();
+    double duration = playerController.contentDuration;
+    double normalizedBufferedTime;
+    if (!duration)
+        normalizedBufferedTime = 0;
+    else
+        normalizedBufferedTime = bufferedTime / duration;
+    playerController.loadedTimeRanges = @[@0, @(normalizedBufferedTime)];
 }
 
 void WebVideoFullscreenInterfaceAVKit::setRate(bool isPlaying, float playbackRate)
 {
-    RefPtr<WebVideoFullscreenInterfaceAVKit> strongThis(this);
-    
-    dispatch_async(dispatch_get_main_queue(), [strongThis, isPlaying, playbackRate] {
-        [strongThis->m_playerController setRate:isPlaying ? playbackRate : 0.];
-    });
+    [m_playerController setRate:isPlaying ? playbackRate : 0.];
 }
 
 void WebVideoFullscreenInterfaceAVKit::setVideoDimensions(bool hasVideo, float width, float height)
 {
-    RefPtr<WebVideoFullscreenInterfaceAVKit> strongThis(this);
-    
-    dispatch_async(dispatch_get_main_queue(), [strongThis, hasVideo, width, height] {
-        [strongThis->m_playerController setHasEnabledVideo:hasVideo];
-        [strongThis->m_playerController setContentDimensions:CGSizeMake(width, height)];
-    });
+    [m_playerController setHasEnabledVideo:hasVideo];
+    [m_playerController setContentDimensions:CGSizeMake(width, height)];
 }
 
 void WebVideoFullscreenInterfaceAVKit::setSeekableRanges(const TimeRanges& timeRanges)
@@ -851,20 +826,12 @@
         [seekableRanges addObject:[NSValue valueWithCMTimeRange:range]];
     }
     
-    RefPtr<WebVideoFullscreenInterfaceAVKit> strongThis(this);
-    
-    dispatch_async(dispatch_get_main_queue(), [strongThis, seekableRanges] {
-        [strongThis->m_playerController setSeekableTimeRanges:seekableRanges.get()];
-    });
+    [m_playerController setSeekableTimeRanges:seekableRanges.get()];
 }
 
 void WebVideoFullscreenInterfaceAVKit::setCanPlayFastReverse(bool canPlayFastReverse)
 {
-    RefPtr<WebVideoFullscreenInterfaceAVKit> strongThis(this);
-    
-    dispatch_async(dispatch_get_main_queue(), [strongThis, canPlayFastReverse] {
-        [strongThis->m_playerController setCanScanBackward:canPlayFastReverse];
-    });
+    [m_playerController setCanScanBackward:canPlayFastReverse];
 }
 
 static RetainPtr<NSMutableArray> mediaSelectionOptions(const Vector<String>& options)
@@ -881,25 +848,17 @@
 void WebVideoFullscreenInterfaceAVKit::setAudioMediaSelectionOptions(const Vector<String>& options, uint64_t selectedIndex)
 {
     RetainPtr<NSMutableArray> webOptions = mediaSelectionOptions(options);
-    RefPtr<WebVideoFullscreenInterfaceAVKit> strongThis(this);
-    
-    dispatch_async(dispatch_get_main_queue(), [webOptions, strongThis, selectedIndex] {
-        [strongThis->m_playerController setAudioMediaSelectionOptions:webOptions.get()];
-        if (selectedIndex < [webOptions count])
-            [strongThis->m_playerController setCurrentAudioMediaSelectionOption:[webOptions objectAtIndex:static_cast<NSUInteger>(selectedIndex)]];
-    });
+    [m_playerController setAudioMediaSelectionOptions:webOptions.get()];
+    if (selectedIndex < [webOptions count])
+        [m_playerController setCurrentAudioMediaSelectionOption:[webOptions objectAtIndex:static_cast<NSUInteger>(selectedIndex)]];
 }
 
 void WebVideoFullscreenInterfaceAVKit::setLegibleMediaSelectionOptions(const Vector<String>& options, uint64_t selectedIndex)
 {
     RetainPtr<NSMutableArray> webOptions = mediaSelectionOptions(options);
-    RefPtr<WebVideoFullscreenInterfaceAVKit> strongThis(this);
-
-    dispatch_async(dispatch_get_main_queue(), [webOptions, strongThis, selectedIndex] {
-        [strongThis->m_playerController setLegibleMediaSelectionOptions:webOptions.get()];
-        if (selectedIndex < [webOptions count])
-            [strongThis->m_playerController setCurrentLegibleMediaSelectionOption:[webOptions objectAtIndex:static_cast<NSUInteger>(selectedIndex)]];
-    });
+    [m_playerController setLegibleMediaSelectionOptions:webOptions.get()];
+    if (selectedIndex < [webOptions count])
+        [m_playerController setCurrentLegibleMediaSelectionOption:[webOptions objectAtIndex:static_cast<NSUInteger>(selectedIndex)]];
 }
 
 void WebVideoFullscreenInterfaceAVKit::setExternalPlayback(bool enabled, ExternalPlaybackTargetType targetType, String localizedDeviceName)
@@ -910,41 +869,24 @@
     else if (targetType == TargetTypeTVOut)
         externalPlaybackType = AVPlayerControllerExternalPlaybackTypeTVOut;
 
-    RefPtr<WebVideoFullscreenInterfaceAVKit> strongThis(this);
-
-    dispatch_async(dispatch_get_main_queue(), [strongThis, enabled, localizedDeviceName, externalPlaybackType] {
-        WebAVPlayerController* playerController = strongThis->m_playerController.get();
-        playerController.externalPlaybackAirPlayDeviceLocalizedName = localizedDeviceName;
-        playerController.externalPlaybackType = externalPlaybackType;
-        playerController.externalPlaybackActive = enabled;
-        [strongThis->m_videoLayerContainer.get() setHidden:enabled];
-    });
+    WebAVPlayerController* playerController = m_playerController.get();
+    playerController.externalPlaybackAirPlayDeviceLocalizedName = localizedDeviceName;
+    playerController.externalPlaybackType = externalPlaybackType;
+    playerController.externalPlaybackActive = enabled;
+    [m_videoLayerContainer.get() setHidden:enabled];
 }
 
 void WebVideoFullscreenInterfaceAVKit::setupFullscreen(PlatformLayer& videoLayer, const WebCore::IntRect& initialRect, UIView* parentView, HTMLMediaElementEnums::VideoFullscreenMode mode, bool allowOptimizedFullscreen)
 {
-    RefPtr<WebVideoFullscreenInterfaceAVKit> strongThis(this);
-
     ASSERT(mode != HTMLMediaElementEnums::VideoFullscreenModeNone);
-    m_videoLayer = &videoLayer;
+    LOG(Fullscreen, "WebVideoFullscreenInterfaceAVKit::setupFullscreen(%p)", this);
 
-    m_mode = mode;
-
-    dispatch_async(dispatch_get_main_queue(), [strongThis, &videoLayer, initialRect, parentView, mode, allowOptimizedFullscreen] {
-        strongThis->setupFullscreenInternal(videoLayer, initialRect, parentView, mode, allowOptimizedFullscreen);
-    });
-}
-
-void WebVideoFullscreenInterfaceAVKit::setupFullscreenInternal(PlatformLayer& videoLayer, const WebCore::IntRect& initialRect, UIView* parentView, HTMLMediaElementEnums::VideoFullscreenMode mode, bool allowOptimizedFullscreen)
-{
-    LOG(Fullscreen, "WebVideoFullscreenInterfaceAVKit::setupFullscreenInternal(%p)", this);
-    UNUSED_PARAM(videoLayer);
-    UNUSED_PARAM(mode);
-
     m_allowOptimizedFullscreen = allowOptimizedFullscreen;
 
     [CATransaction begin];
     [CATransaction setDisableActions:YES];
+    m_videoLayer = &videoLayer;
+    m_mode = mode;
     m_parentView = parentView;
     m_parentWindow = parentView.window;
 
@@ -996,11 +938,8 @@
 
     [CATransaction commit];
 
-    RefPtr<WebVideoFullscreenInterfaceAVKit> strongThis(this);
-    WebThreadRun([strongThis] {
-        if (strongThis->m_fullscreenChangeObserver)
-            strongThis->m_fullscreenChangeObserver->didSetupFullscreen();
-    });
+    if (m_fullscreenChangeObserver)
+        m_fullscreenChangeObserver->didSetupFullscreen();
 }
 
 void WebVideoFullscreenInterfaceAVKit::enterFullscreen()
@@ -1011,22 +950,17 @@
     m_exitRequested = false;
     m_enterRequested = true;
 
-    RefPtr<WebVideoFullscreenInterfaceAVKit> strongThis(this);
-    dispatch_async(dispatch_get_main_queue(), [strongThis] {
-        [strongThis->m_videoLayerContainer setBackgroundColor:[[getUIColorClass() blackColor] CGColor]];
-        if (strongThis->mode() == HTMLMediaElementEnums::VideoFullscreenModeOptimized)
-            strongThis->enterFullscreenOptimized();
-        else if (strongThis->mode() == HTMLMediaElementEnums::VideoFullscreenModeStandard)
-            strongThis->enterFullscreenStandard();
-        else
-            ASSERT_NOT_REACHED();
-    });
+    [m_videoLayerContainer setBackgroundColor:[[getUIColorClass() blackColor] CGColor]];
+    if (mode() == HTMLMediaElementEnums::VideoFullscreenModeOptimized)
+        enterFullscreenOptimized();
+    else if (mode() == HTMLMediaElementEnums::VideoFullscreenModeStandard)
+        enterFullscreenStandard();
+    else
+        ASSERT_NOT_REACHED();
 }
 
 void WebVideoFullscreenInterfaceAVKit::enterFullscreenOptimized()
 {
-    RefPtr<WebVideoFullscreenInterfaceAVKit> strongThis(this);
-
     LOG(Fullscreen, "WebVideoFullscreenInterfaceAVKit::enterFullscreenOptimized(%p)", this);
     
     if ([m_playerViewController isOptimizedFullscreenPossible])
@@ -1044,34 +978,21 @@
         LOG(Fullscreen, "WebVideoFullscreenInterfaceAVKit::enterFullscreenStandard - lambda(%p) - succeeded(%s)", this, boolString(succeeded));
         [m_playerViewController setShowsPlaybackControls:YES];
 
-        WebThreadRun([this, strongThis] {
-            if (m_fullscreenChangeObserver)
-                m_fullscreenChangeObserver->didEnterFullscreen();
-        });
+        if (m_fullscreenChangeObserver)
+            m_fullscreenChangeObserver->didEnterFullscreen();
     }];
 }
 
 void WebVideoFullscreenInterfaceAVKit::exitFullscreen(const WebCore::IntRect& finalRect)
 {
-    RefPtr<WebVideoFullscreenInterfaceAVKit> strongThis(this);
-
     m_exitRequested = true;
     if (m_exitCompleted) {
-        WebThreadRun([strongThis] {
-            if (strongThis->m_fullscreenChangeObserver)
-                strongThis->m_fullscreenChangeObserver->didExitFullscreen();
-        });
+        if (m_fullscreenChangeObserver)
+            m_fullscreenChangeObserver->didExitFullscreen();
         return;
     }
-
-    dispatch_async(dispatch_get_main_queue(), [strongThis, finalRect] {
-        strongThis->exitFullscreenInternal(finalRect);
-    });
-}
-
-void WebVideoFullscreenInterfaceAVKit::exitFullscreenInternal(const WebCore::IntRect& finalRect)
-{
-    LOG(Fullscreen, "WebVideoFullscreenInterfaceAVKit::exitFullscreenInternal(%p)", this);
+    
+    LOG(Fullscreen, "WebVideoFullscreenInterfaceAVKit::exitFullscreen(%p)", this);
     [m_playerViewController setShowsPlaybackControls:NO];
     if (m_viewController)
         [m_playerViewController view].frame = [m_parentView convertRect:finalRect toView:nil];
@@ -1088,25 +1009,23 @@
         [m_playerViewController stopOptimizedFullscreen];
     } else if (isMode(HTMLMediaElementEnums::VideoFullscreenModeOptimized | HTMLMediaElementEnums::VideoFullscreenModeStandard)) {
         RefPtr<WebVideoFullscreenInterfaceAVKit> strongThis(this);
-        [m_playerViewController exitFullScreenAnimated:NO completionHandler:[strongThis] (BOOL, NSError*) {
-            [strongThis->m_window setHidden:NO];
-            [strongThis->m_playerViewController stopOptimizedFullscreen];
+        [m_playerViewController exitFullScreenAnimated:NO completionHandler:[strongThis, this] (BOOL, NSError*) {
+            [m_window setHidden:NO];
+            [m_playerViewController stopOptimizedFullscreen];
         }];
     } else if (isMode(HTMLMediaElementEnums::VideoFullscreenModeStandard)) {
         RefPtr<WebVideoFullscreenInterfaceAVKit> strongThis(this);
-        [m_playerViewController exitFullScreenAnimated:YES completionHandler:[strongThis] (BOOL, NSError*) {
-            strongThis->m_exitCompleted = true;
+        [m_playerViewController exitFullScreenAnimated:YES completionHandler:[strongThis, this] (BOOL, NSError*) {
+            m_exitCompleted = true;
 
             [CATransaction begin];
             [CATransaction setDisableActions:YES];
-            [strongThis->m_videoLayerContainer setBackgroundColor:[[getUIColorClass() clearColor] CGColor]];
-            [[strongThis->m_playerViewController view] setBackgroundColor:[getUIColorClass() clearColor]];
+            [m_videoLayerContainer setBackgroundColor:[[getUIColorClass() clearColor] CGColor]];
+            [[m_playerViewController view] setBackgroundColor:[getUIColorClass() clearColor]];
             [CATransaction commit];
 
-            WebThreadRun([strongThis] {
-                if (strongThis->m_fullscreenChangeObserver)
-                    strongThis->m_fullscreenChangeObserver->didExitFullscreen();
-            });
+            if (m_fullscreenChangeObserver)
+                m_fullscreenChangeObserver->didExitFullscreen();
         }];
     };
 }
@@ -1121,16 +1040,7 @@
 
 void WebVideoFullscreenInterfaceAVKit::cleanupFullscreen()
 {
-    RefPtr<WebVideoFullscreenInterfaceAVKit> strongThis(this);
-    
-    dispatch_async(dispatch_get_main_queue(), [strongThis] {
-        strongThis->cleanupFullscreenInternal();
-    });
-}
-
-void WebVideoFullscreenInterfaceAVKit::cleanupFullscreenInternal()
-{
-    LOG(Fullscreen, "WebVideoFullscreenInterfaceAVKit::cleanupFullscreenInternal(%p)", this);
+    LOG(Fullscreen, "WebVideoFullscreenInterfaceAVKit::cleanupFullscreen(%p)", this);
     if (m_window) {
         [m_window setHidden:YES];
         [m_window setRootViewController:nil];
@@ -1170,12 +1080,10 @@
     m_parentView = nil;
     m_parentWindow = nil;
     
-    RefPtr<WebVideoFullscreenInterfaceAVKit> strongThis(this);
-    WebThreadRun([strongThis] {
-        if (strongThis->m_fullscreenChangeObserver)
-            strongThis->m_fullscreenChangeObserver->didCleanupFullscreen();
-        strongThis->m_enterRequested = false;
-    });
+    if (m_fullscreenChangeObserver)
+        m_fullscreenChangeObserver->didCleanupFullscreen();
+
+    m_enterRequested = false;
 }
 
 void WebVideoFullscreenInterfaceAVKit::invalidate()
@@ -1183,7 +1091,7 @@
     m_videoFullscreenModel = nil;
     m_fullscreenChangeObserver = nil;
     
-    cleanupFullscreenInternal();
+    cleanupFullscreen();
 }
 
 void WebVideoFullscreenInterfaceAVKit::requestHideAndExitFullscreen()
@@ -1196,10 +1104,7 @@
     
     LOG(Fullscreen, "WebVideoFullscreenInterfaceAVKit::requestHideAndExitFullscreen(%p)", this);
 
-    RefPtr<WebVideoFullscreenInterfaceAVKit> strongThis(this);
-    dispatch_async(dispatch_get_main_queue(), [strongThis] {
-        [strongThis->m_window setHidden:YES];
-    });
+    [m_window setHidden:YES];
 
     if (m_videoFullscreenModel && !m_exitRequested) {
         m_videoFullscreenModel->pause();
@@ -1210,19 +1115,16 @@
 void WebVideoFullscreenInterfaceAVKit::preparedToReturnToInline(bool visible, const IntRect& inlineRect)
 {
     LOG(Fullscreen, "WebVideoFullscreenInterfaceAVKit::preparedToReturnToInline(%p) - visible(%s)", this, boolString(visible));
-    RefPtr<WebVideoFullscreenInterfaceAVKit> strongThis(this);
-    dispatch_async(dispatch_get_main_queue(), [strongThis, visible, inlineRect] {
-        if (strongThis->m_prepareToInlineCallback) {
-            
-            if (strongThis->m_viewController)
-                [strongThis->m_playerViewController view].frame = [strongThis->m_parentView convertRect:inlineRect toView:nil];
-            else
-                [strongThis->m_playerViewController view].frame = inlineRect;
+    if (m_prepareToInlineCallback) {
+        
+        if (m_viewController)
+            [m_playerViewController view].frame = [m_parentView convertRect:inlineRect toView:nil];
+        else
+            [m_playerViewController view].frame = inlineRect;
 
-            std::function<void(bool)> callback = WTF::move(strongThis->m_prepareToInlineCallback);
-            callback(visible);
-        }
-    });
+        std::function<void(bool)> callback = WTF::move(m_prepareToInlineCallback);
+        callback(visible);
+    }
 }
 
 bool WebVideoFullscreenInterfaceAVKit::mayAutomaticallyShowVideoOptimized() const
@@ -1246,21 +1148,21 @@
         return;
 
     RefPtr<WebVideoFullscreenInterfaceAVKit> strongThis(this);
-    fullscreenMayReturnToInline([strongThis](bool visible) {
-        LOG(Fullscreen, "WebVideoFullscreenInterfaceAVKit::willStartOptimizedFullscreen - lambda(%p) - visible(%s)", strongThis.get(), boolString(visible));
+    fullscreenMayReturnToInline([strongThis, this](bool visible) {
+        LOG(Fullscreen, "WebVideoFullscreenInterfaceAVKit::willStartOptimizedFullscreen - lambda(%p) - visible(%s)", this, boolString(visible));
 
         if (!visible) {
-            [strongThis->m_window setHidden:YES];
+            [m_window setHidden:YES];
             return;
         }
 
-        [[strongThis->m_playerViewController view] layoutIfNeeded];
+        [[m_playerViewController view] layoutIfNeeded];
 
-        [strongThis->m_playerViewController exitFullScreenAnimated:YES completionHandler:[strongThis] (BOOL completed, NSError*) {
+        [m_playerViewController exitFullScreenAnimated:YES completionHandler:[strongThis, this] (BOOL completed, NSError*) {
             if (!completed)
                 return;
-            strongThis->clearMode(HTMLMediaElementEnums::VideoFullscreenModeStandard);
-            [strongThis->m_window setHidden:YES];
+            clearMode(HTMLMediaElementEnums::VideoFullscreenModeStandard);
+            [m_window setHidden:YES];
         }];
     });
 }
@@ -1271,11 +1173,8 @@
     [m_playerViewController setShowsPlaybackControls:YES];
     [m_window setHidden:YES];
 
-    RefPtr<WebVideoFullscreenInterfaceAVKit> strongThis(this);
-    WebThreadRun([strongThis] {
-        if (strongThis->m_fullscreenChangeObserver)
-            strongThis->m_fullscreenChangeObserver->didEnterFullscreen();
-    });
+    if (m_fullscreenChangeObserver)
+        m_fullscreenChangeObserver->didEnterFullscreen();
 }
 
 void WebVideoFullscreenInterfaceAVKit::failedToStartOptimizedFullscreen()
@@ -1283,19 +1182,16 @@
     LOG(Fullscreen, "WebVideoFullscreenInterfaceAVKit::failedToStartOptimizedFullscreen(%p)", this);
     [m_playerViewController setShowsPlaybackControls:YES];
 
-    RefPtr<WebVideoFullscreenInterfaceAVKit> strongThis(this);
-    WebThreadRun([strongThis, this] {
-        if (hasMode(HTMLMediaElementEnums::VideoFullscreenModeStandard))
-            return;
+    if (hasMode(HTMLMediaElementEnums::VideoFullscreenModeStandard))
+        return;
 
-        m_exitCompleted = true;
+    m_exitCompleted = true;
 
-        if (m_fullscreenChangeObserver)
-            m_fullscreenChangeObserver->didEnterFullscreen();
+    if (m_fullscreenChangeObserver)
+        m_fullscreenChangeObserver->didEnterFullscreen();
 
-        if (m_videoFullscreenModel)
-            m_videoFullscreenModel->requestExitFullscreen();
-    });
+    if (m_videoFullscreenModel)
+        m_videoFullscreenModel->requestExitFullscreen();
 }
 
 void WebVideoFullscreenInterfaceAVKit::willStopOptimizedFullscreen()
@@ -1303,11 +1199,8 @@
     LOG(Fullscreen, "WebVideoFullscreenInterfaceAVKit::willStopOptimizedFullscreen(%p)", this);
     [m_window setHidden:NO];
 
-    RefPtr<WebVideoFullscreenInterfaceAVKit> strongThis(this);
-    WebThreadRun([strongThis] {
-        if (strongThis->m_videoFullscreenModel)
-            strongThis->m_videoFullscreenModel->requestExitFullscreen();
-    });
+    if (m_videoFullscreenModel)
+        m_videoFullscreenModel->requestExitFullscreen();
 }
 
 void WebVideoFullscreenInterfaceAVKit::didStopOptimizedFullscreen()
@@ -1321,13 +1214,11 @@
     [m_videoLayerContainer setBackgroundColor:[[getUIColorClass() clearColor] CGColor]];
     [[m_playerViewController view] setBackgroundColor:[getUIColorClass() clearColor]];
 
-    RefPtr<WebVideoFullscreenInterfaceAVKit> strongThis(this);
-    WebThreadRun([strongThis] {
-        strongThis->clearMode(HTMLMediaElementEnums::VideoFullscreenModeOptimized);
-        [strongThis->m_window setHidden:YES];
-        if (strongThis->m_fullscreenChangeObserver)
-            strongThis->m_fullscreenChangeObserver->didExitFullscreen();
-    });
+    clearMode(HTMLMediaElementEnums::VideoFullscreenModeOptimized);
+    [m_window setHidden:YES];
+    
+    if (m_fullscreenChangeObserver)
+        m_fullscreenChangeObserver->didExitFullscreen();
 }
 
 void WebVideoFullscreenInterfaceAVKit::prepareForOptimizedFullscreenStopWithCompletionHandler(void (^completionHandler)(BOOL restored))

Modified: trunk/Source/WebCore/platform/ios/WebVideoFullscreenModelVideoElement.mm (184921 => 184922)


--- 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)
@@ -179,125 +179,74 @@
     [m_videoFullscreenLayer setAnchorPoint:CGPointMake(0.5, 0.5)];
     [m_videoFullscreenLayer setBounds:m_videoFrame];
     
-    __block RefPtr<WebVideoFullscreenModelVideoElement> protect(this);
-    WebThreadRun(^{
-        if (m_videoElement)
-            m_videoElement->setVideoFullscreenLayer(m_videoFullscreenLayer.get());
-        protect.clear();
-    });
+    if (m_videoElement)
+        m_videoElement->setVideoFullscreenLayer(m_videoFullscreenLayer.get());
 }
 
 void WebVideoFullscreenModelVideoElement::play()
 {
-    __block RefPtr<WebVideoFullscreenModelVideoElement> protect(this);
-    WebThreadRun(^{
-        if (m_videoElement)
-            m_videoElement->play();
-        protect.clear();
-    });
+    if (m_videoElement)
+        m_videoElement->play();
 }
 
 void WebVideoFullscreenModelVideoElement::pause()
 {
-    __block RefPtr<WebVideoFullscreenModelVideoElement> protect(this);
-    WebThreadRun(^{
-        if (m_videoElement)
-            m_videoElement->pause();
-        protect.clear();
-    });
+    if (m_videoElement)
+        m_videoElement->pause();
 }
 
 void WebVideoFullscreenModelVideoElement::togglePlayState()
 {
-    __block RefPtr<WebVideoFullscreenModelVideoElement> protect(this);
-    WebThreadRun(^{
-        if (m_videoElement)
-            m_videoElement->togglePlayState();
-        protect.clear();
-    });
+    if (m_videoElement)
+        m_videoElement->togglePlayState();
 }
 
 void WebVideoFullscreenModelVideoElement::beginScrubbing()
 {
-    __block RefPtr<WebVideoFullscreenModelVideoElement> protect(this);
-    WebThreadRun(^{
-        if (m_videoElement)
-            m_videoElement->beginScrubbing();
-        protect.clear();
-    });
+    if (m_videoElement)
+        m_videoElement->beginScrubbing();
 }
 
 void WebVideoFullscreenModelVideoElement::endScrubbing()
 {
-    __block RefPtr<WebVideoFullscreenModelVideoElement> protect(this);
-    WebThreadRun(^{
-        if (m_videoElement)
-            m_videoElement->endScrubbing();
-        protect.clear();
-    });
+    if (m_videoElement)
+        m_videoElement->endScrubbing();
 }
 
 void WebVideoFullscreenModelVideoElement::seekToTime(double time)
 {
-    __block RefPtr<WebVideoFullscreenModelVideoElement> protect(this);
-    WebThreadRun(^{
-        if (m_videoElement)
-            m_videoElement->setCurrentTime(time);
-        protect.clear();
-    });
+    if (m_videoElement)
+        m_videoElement->setCurrentTime(time);
 }
 
 void WebVideoFullscreenModelVideoElement::fastSeek(double time)
 {
-    __block RefPtr<WebVideoFullscreenModelVideoElement> protect(this);
-    WebThreadRun(^{
-        if (m_videoElement)
-            m_videoElement->fastSeek(time);
-        protect.clear();
-    });
+    if (m_videoElement)
+        m_videoElement->fastSeek(time);
 }
 
 void WebVideoFullscreenModelVideoElement::beginScanningForward()
 {
-    __block RefPtr<WebVideoFullscreenModelVideoElement> protect(this);
-    WebThreadRun(^{
-        if (m_videoElement)
-            m_videoElement->beginScanning(MediaControllerInterface::Forward);
-        protect.clear();
-    });
+    if (m_videoElement)
+        m_videoElement->beginScanning(MediaControllerInterface::Forward);
 }
 
 void WebVideoFullscreenModelVideoElement::beginScanningBackward()
 {
-    __block RefPtr<WebVideoFullscreenModelVideoElement> protect(this);
-    WebThreadRun(^{
-        if (m_videoElement)
-            m_videoElement->beginScanning(MediaControllerInterface::Backward);
-        protect.clear();
-    });
+    if (m_videoElement)
+        m_videoElement->beginScanning(MediaControllerInterface::Backward);
 }
 
 void WebVideoFullscreenModelVideoElement::endScanning()
 {
-    __block RefPtr<WebVideoFullscreenModelVideoElement> protect(this);
-    WebThreadRun(^{
-        if (m_videoElement)
-            m_videoElement->endScanning();
-        protect.clear();
-    });
+    if (m_videoElement)
+        m_videoElement->endScanning();
 }
 
 void WebVideoFullscreenModelVideoElement::requestExitFullscreen()
 {
-    if (!m_videoElement)
-        return;
-
-    __block RefPtr<WebVideoFullscreenModelVideoElement> protect(this);
-    WebThreadRun(^{
-        if (m_videoElement && m_videoElement->isFullscreen())
-            m_videoElement->exitFullscreen();
-        protect.clear();
-    });
+    if (m_videoElement && m_videoElement->isFullscreen())
+        m_videoElement->exitFullscreen();
 }
 
 void WebVideoFullscreenModelVideoElement::setVideoLayerFrame(FloatRect rect)
@@ -454,12 +403,8 @@
 
 void WebVideoFullscreenModelVideoElement::fullscreenModeChanged(HTMLMediaElementEnums::VideoFullscreenMode videoFullscreenMode)
 {
-    __block RefPtr<WebVideoFullscreenModelVideoElement> protect(this);
-    WebThreadRun(^{
-        if (m_videoElement)
-            m_videoElement->fullscreenModeChanged(videoFullscreenMode);
-        protect.clear();
-    });
+    if (m_videoElement)
+        m_videoElement->fullscreenModeChanged(videoFullscreenMode);
 }
 
 #endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to