Diff
Modified: tags/Safari-602.1.30.4/Source/WebCore/ChangeLog (200378 => 200379)
--- tags/Safari-602.1.30.4/Source/WebCore/ChangeLog 2016-05-03 17:24:48 UTC (rev 200378)
+++ tags/Safari-602.1.30.4/Source/WebCore/ChangeLog 2016-05-03 17:31:04 UTC (rev 200379)
@@ -1,3 +1,54 @@
+2016-05-03 Babak Shafiei <[email protected]>
+
+ Merge r200157.
+
+ 2016-04-26 Ada Chan <[email protected]>
+
+ Set WebVideoFullscreenInterfaceMac up as a client of WebPlaybackSessionInterfaceMac to listen for playback state changes
+ https://bugs.webkit.org/show_bug.cgi?id=157008
+
+ Reviewed by Jer Noble.
+
+ For WebVideoFullscreenInterfaceMac to be notified when the playback rate changes in
+ WebPlaybackSessionInterfaceMac, add a new WebPlaybackSessionInterfaceMacClient base
+ class that WebVideoFullscreenInterfaceMac implements, similar to the WebPlaybackSessionInterfaceAVKitClient
+ on iOS. WebVideoFullscreenInterfaceMac sets itself as a client of WebPlaybackSessionInterfaceMac
+ so WebPlaybackSessionInterfaceMac can notify WebVideoFullscreenInterfaceMac whenever the
+ playback rate changes.
+
+ * platform/cocoa/WebVideoFullscreenModelVideoElement.mm:
+ (WebVideoFullscreenModelVideoElement::setWebVideoFullscreenInterface):
+ We should not change the WebPlaybackSessionModelMediaElement's interface here since WebPlaybackSessionManager
+ has already set that up when creating the context for this media element.
+ (WebVideoFullscreenModelVideoElement::setVideoElement):
+ We should not change the WebPlaybackSessionModelMediaElement's media element here because
+ this will be called with NULL when the fullscreen context is cleaned up, but the
+ WebPlaybackSessionModelMediaElement might still need to stay around. We'll make sure the
+ WebPlaybackSessionModelMediaElement's media element is set when setting up the fullscreen
+ context in WebVideoFullscreenManager::enterVideoFullscreenForVideoElement().
+
+ * platform/mac/WebPlaybackSessionInterfaceMac.h:
+ (WebCore::WebPlaybackSessionInterfaceMacClient::~WebPlaybackSessionInterfaceMacClient):
+
+ * platform/mac/WebPlaybackSessionInterfaceMac.mm:
+ (WebCore::WebPlaybackSessionInterfaceMac::setClient):
+ Set the client. Notify the client about the current playback state.
+ (WebCore::WebPlaybackSessionInterfaceMac::setRate):
+ If a client is set, let that client know about the change in playback rate.
+
+ * platform/mac/WebVideoFullscreenInterfaceMac.h:
+ * platform/mac/WebVideoFullscreenInterfaceMac.mm:
+ (WebCore::WebVideoFullscreenInterfaceMac::WebVideoFullscreenInterfaceMac):
+ Set itself as a client of WebPlaybackSessionInterfaceMac.
+ (WebCore::WebVideoFullscreenInterfaceMac::~WebVideoFullscreenInterfaceMac):
+ Make sure WebPlaybackSessionInterfaceMac won't hold onto a stale pointer to itself.
+ (WebCore::WebVideoFullscreenInterfaceMac::setRate):
+ We don't have to update the WebVideoFullscreenInterfaceMac's rate here anymore. The change
+ in playback rate in WebPlaybackSessionInterfaceMac should trigger
+ WebVideoFullscreenInterfaceMac::rateChanged() to be called.
+ (WebCore::WebVideoFullscreenInterfaceMac::rateChanged):
+ Pass in both the isPlaying state and the playback rate to WebVideoFullscreenInterfaceMacObjC.
+
2016-04-28 Matthew Hanson <[email protected]>
Merge r200201. rdar://problem/25995376
Modified: tags/Safari-602.1.30.4/Source/WebCore/platform/cocoa/WebVideoFullscreenModelVideoElement.mm (200378 => 200379)
--- tags/Safari-602.1.30.4/Source/WebCore/platform/cocoa/WebVideoFullscreenModelVideoElement.mm 2016-05-03 17:24:48 UTC (rev 200378)
+++ tags/Safari-602.1.30.4/Source/WebCore/platform/cocoa/WebVideoFullscreenModelVideoElement.mm 2016-05-03 17:31:04 UTC (rev 200379)
@@ -67,7 +67,6 @@
return;
m_videoFullscreenInterface = interface;
- m_playbackSessionModel->setWebPlaybackSessionInterface(interface);
if (m_videoFullscreenInterface && m_videoElement)
m_videoFullscreenInterface->setVideoDimensions(true, m_videoElement->videoWidth(), m_videoElement->videoHeight());
@@ -75,7 +74,6 @@
void WebVideoFullscreenModelVideoElement::setVideoElement(HTMLVideoElement* videoElement)
{
- m_playbackSessionModel->setMediaElement(videoElement);
if (m_videoElement == videoElement)
return;
Modified: tags/Safari-602.1.30.4/Source/WebCore/platform/mac/WebPlaybackSessionInterfaceMac.h (200378 => 200379)
--- tags/Safari-602.1.30.4/Source/WebCore/platform/mac/WebPlaybackSessionInterfaceMac.h 2016-05-03 17:24:48 UTC (rev 200378)
+++ tags/Safari-602.1.30.4/Source/WebCore/platform/mac/WebPlaybackSessionInterfaceMac.h 2016-05-03 17:31:04 UTC (rev 200379)
@@ -40,6 +40,13 @@
class IntRect;
class WebPlaybackSessionModel;
+class WebPlaybackSessionInterfaceMacClient {
+public:
+ virtual ~WebPlaybackSessionInterfaceMacClient() { }
+
+ virtual void rateChanged(bool isPlaying, float playbackRate) = 0;
+};
+
class WEBCORE_EXPORT WebPlaybackSessionInterfaceMac final
: public WebPlaybackSessionInterface
, public RefCounted<WebPlaybackSessionInterfaceMac> {
@@ -51,6 +58,8 @@
virtual ~WebPlaybackSessionInterfaceMac();
WebPlaybackSessionModel* webPlaybackSessionModel() const { return m_playbackSessionModel; }
WEBCORE_EXPORT void setWebPlaybackSessionModel(WebPlaybackSessionModel*);
+ WebPlaybackSessionInterfaceMacClient* client() const { return m_client; }
+ void setClient(WebPlaybackSessionInterfaceMacClient*);
WEBCORE_EXPORT void resetMediaState() final { }
WEBCORE_EXPORT void setDuration(double) final;
@@ -70,6 +79,7 @@
private:
WebPlaybackSessionModel* m_playbackSessionModel { nullptr };
RetainPtr<WebPlaybackControlsManager> m_playbackControlsManager;
+ WebPlaybackSessionInterfaceMacClient* m_client { nullptr };
};
}
Modified: tags/Safari-602.1.30.4/Source/WebCore/platform/mac/WebPlaybackSessionInterfaceMac.mm (200378 => 200379)
--- tags/Safari-602.1.30.4/Source/WebCore/platform/mac/WebPlaybackSessionInterfaceMac.mm 2016-05-03 17:24:48 UTC (rev 200378)
+++ tags/Safari-602.1.30.4/Source/WebCore/platform/mac/WebPlaybackSessionInterfaceMac.mm 2016-05-03 17:31:04 UTC (rev 200379)
@@ -132,6 +132,16 @@
m_playbackSessionModel = model;
}
+void WebPlaybackSessionInterfaceMac::setClient(WebPlaybackSessionInterfaceMacClient* client)
+{
+ m_client = client;
+
+ if (m_client) {
+ float rate = [playBackControlsManager() rate];
+ m_client->rateChanged(!!rate, rate);
+ }
+}
+
void WebPlaybackSessionInterfaceMac::setDuration(double duration)
{
WebPlaybackControlsManager* controlsManager = playBackControlsManager();
@@ -157,8 +167,10 @@
void WebPlaybackSessionInterfaceMac::setRate(bool isPlaying, float playbackRate)
{
WebPlaybackControlsManager* controlsManager = playBackControlsManager();
+ [controlsManager setRate:isPlaying ? playbackRate : 0.];
- [controlsManager setRate:isPlaying ? playbackRate : 0.];
+ if (m_client)
+ m_client->rateChanged(isPlaying, playbackRate);
}
void WebPlaybackSessionInterfaceMac::setSeekableRanges(const TimeRanges& timeRanges)
Modified: tags/Safari-602.1.30.4/Source/WebCore/platform/mac/WebVideoFullscreenInterfaceMac.h (200378 => 200379)
--- tags/Safari-602.1.30.4/Source/WebCore/platform/mac/WebVideoFullscreenInterfaceMac.h 2016-05-03 17:24:48 UTC (rev 200378)
+++ tags/Safari-602.1.30.4/Source/WebCore/platform/mac/WebVideoFullscreenInterfaceMac.h 2016-05-03 17:31:04 UTC (rev 200379)
@@ -29,6 +29,7 @@
#if PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)
#include "HTMLMediaElementEnums.h"
+#include "WebPlaybackSessionInterfaceMac.h"
#include "WebVideoFullscreenInterface.h"
#include <wtf/RefCounted.h>
#include <wtf/RetainPtr.h>
@@ -48,6 +49,7 @@
class WEBCORE_EXPORT WebVideoFullscreenInterfaceMac
: public WebVideoFullscreenInterface
+ , private WebPlaybackSessionInterfaceMacClient
, public RefCounted<WebVideoFullscreenInterfaceMac> {
public:
@@ -93,6 +95,8 @@
WEBCORE_EXPORT bool mayAutomaticallyShowVideoPictureInPicture() const { return false; }
void applicationDidBecomeActive() { }
+ void rateChanged(bool isPlaying, float playbackRate) override;
+
#if USE(APPLE_INTERNAL_SDK)
WEBCORE_EXPORT WebVideoFullscreenInterfaceMacObjC *videoFullscreenInterfaceObjC();
#endif
Modified: tags/Safari-602.1.30.4/Source/WebCore/platform/mac/WebVideoFullscreenInterfaceMac.mm (200378 => 200379)
--- tags/Safari-602.1.30.4/Source/WebCore/platform/mac/WebVideoFullscreenInterfaceMac.mm 2016-05-03 17:24:48 UTC (rev 200378)
+++ tags/Safari-602.1.30.4/Source/WebCore/platform/mac/WebVideoFullscreenInterfaceMac.mm 2016-05-03 17:31:04 UTC (rev 200379)
@@ -51,16 +51,18 @@
WebVideoFullscreenInterfaceMac::WebVideoFullscreenInterfaceMac(WebPlaybackSessionInterfaceMac& playbackSessionInterface)
: m_playbackSessionInterface(playbackSessionInterface)
{
+ m_playbackSessionInterface->setClient(this);
}
WebVideoFullscreenInterfaceMac::~WebVideoFullscreenInterfaceMac()
{
+ if (m_playbackSessionInterface->client() == this)
+ m_playbackSessionInterface->setClient(nullptr);
}
void WebVideoFullscreenInterfaceMac::setWebVideoFullscreenModel(WebVideoFullscreenModel* model)
{
m_videoFullscreenModel = model;
- m_playbackSessionInterface->setWebPlaybackSessionModel(model);
}
void WebVideoFullscreenInterfaceMac::setWebVideoFullscreenChangeObserver(WebVideoFullscreenChangeObserver* observer)
@@ -103,9 +105,12 @@
void WebVideoFullscreenInterfaceMac::setRate(bool isPlaying, float playbackRate)
{
m_playbackSessionInterface->setRate(isPlaying, playbackRate);
+}
+void WebVideoFullscreenInterfaceMac::rateChanged(bool isPlaying, float playbackRate)
+{
#if USE(APPLE_INTERNAL_SDK)
- [videoFullscreenInterfaceObjC() setRate:isPlaying ? playbackRate : 0.];
+ [videoFullscreenInterfaceObjC() updateIsPlaying:isPlaying newPlaybackRate:playbackRate];
#endif
}
Modified: tags/Safari-602.1.30.4/Source/WebKit2/ChangeLog (200378 => 200379)
--- tags/Safari-602.1.30.4/Source/WebKit2/ChangeLog 2016-05-03 17:24:48 UTC (rev 200378)
+++ tags/Safari-602.1.30.4/Source/WebKit2/ChangeLog 2016-05-03 17:31:04 UTC (rev 200379)
@@ -1,3 +1,42 @@
+2016-05-03 Babak Shafiei <[email protected]>
+
+ Merge r200157.
+
+ 2016-04-26 Ada Chan <[email protected]>
+
+ Set WebVideoFullscreenInterfaceMac up as a client of WebPlaybackSessionInterfaceMac to listen for playback state changes
+ https://bugs.webkit.org/show_bug.cgi?id=157008
+
+ Reviewed by Jer Noble.
+
+ Since WebVideoFullscreenInterfaceMac holds onto WebPlaybackSessionInterfaceMac, we can't let
+ WebPlaybackSessionManagerProxy unregister the context for that media element while
+ WebVideoFullscreenInterfaceMac is still using it. WebVideoFullscreenInterfaceMac should add
+ to the client count for that WebPlaybackSession context.
+
+ * UIProcess/Cocoa/WebVideoFullscreenManagerProxy.mm:
+ (WebKit::WebVideoFullscreenManagerProxy::createModelAndInterface):
+ When the context for the media element is created with the WebVideoFullscreenManagerProxy, it should
+ add one to the client count for the media element context in WebPlaybackSessionManagerProxy.
+ (WebKit::WebVideoFullscreenManagerProxy::removeClientForContext):
+ When WebVideoFullscreenManagerProxy unregisters the context for this media element, it should
+ subtract one from the client count for the media element context in WebPlaybackSessionManagerProxy.
+
+ * WebProcess/cocoa/WebPlaybackSessionManager.mm:
+ (WebKit::WebPlaybackSessionManager::clearPlaybackControlsManager):
+ Bail early if m_controlsManagerContextId is zero. Otherwise, we'd end up sending a
+ ClearPlaybackControlsManager message to the UI process inadvertently.
+ (WebKit::WebPlaybackSessionManager::contextIdForMediaElement):
+ Make sure the model element for the context ID is set to the media element.
+
+ * WebProcess/cocoa/WebVideoFullscreenManager.mm:
+ (WebKit::WebVideoFullscreenManager::createModelAndInterface):
+ When the context for the media element is created with the WebVideoFullscreenManager, it should
+ add one to the client count for the media element context in WebPlaybackSessionManager.
+ (WebKit::WebVideoFullscreenManager::removeContext):
+ When WebVideoFullscreenManager unregisters the context for this media element, it should
+ subtract one from the client count for the media element context in WebPlaybackSessionManager.
+
2016-04-28 Matthew Hanson <[email protected]>
Merge r200201. rdar://problem/25995376
Modified: tags/Safari-602.1.30.4/Source/WebKit2/UIProcess/Cocoa/WebVideoFullscreenManagerProxy.mm (200378 => 200379)
--- tags/Safari-602.1.30.4/Source/WebKit2/UIProcess/Cocoa/WebVideoFullscreenManagerProxy.mm 2016-05-03 17:24:48 UTC (rev 200378)
+++ tags/Safari-602.1.30.4/Source/WebKit2/UIProcess/Cocoa/WebVideoFullscreenManagerProxy.mm 2016-05-03 17:31:04 UTC (rev 200379)
@@ -318,6 +318,7 @@
Ref<WebVideoFullscreenModelContext> model = WebVideoFullscreenModelContext::create(*this, playbackSessionModel, contextId);
auto& playbackSessionInterface = m_playbackSessionManagerProxy->ensureInterface(contextId);
Ref<PlatformWebVideoFullscreenInterface> interface = PlatformWebVideoFullscreenInterface::create(playbackSessionInterface);
+ m_playbackSessionManagerProxy->addClientForContext(contextId);
interface->setWebVideoFullscreenModel(&model.get());
interface->setWebVideoFullscreenChangeObserver(&model.get());
@@ -359,6 +360,7 @@
clientCount--;
if (clientCount <= 0) {
+ m_playbackSessionManagerProxy->removeClientForContext(contextId);
m_clientCounts.remove(contextId);
m_contextMap.remove(contextId);
return;
Modified: tags/Safari-602.1.30.4/Source/WebKit2/WebProcess/cocoa/WebPlaybackSessionManager.mm (200378 => 200379)
--- tags/Safari-602.1.30.4/Source/WebKit2/WebProcess/cocoa/WebPlaybackSessionManager.mm 2016-05-03 17:24:48 UTC (rev 200378)
+++ tags/Safari-602.1.30.4/Source/WebKit2/WebProcess/cocoa/WebPlaybackSessionManager.mm 2016-05-03 17:31:04 UTC (rev 200379)
@@ -261,7 +261,7 @@
if (foundIterator == m_mediaElements.end())
return;
- if (m_controlsManagerContextId != foundIterator->value)
+ if (!m_controlsManagerContextId || m_controlsManagerContextId != foundIterator->value)
return;
removeClientForContext(m_controlsManagerContextId);
@@ -273,7 +273,9 @@
uint64_t WebPlaybackSessionManager::contextIdForMediaElement(WebCore::HTMLMediaElement& mediaElement)
{
auto addResult = m_mediaElements.ensure(&mediaElement, [&] { return nextContextId(); });
- return addResult.iterator->value;
+ uint64_t contextId = addResult.iterator->value;
+ ensureModel(contextId).setMediaElement(&mediaElement);
+ return contextId;
}
#pragma mark Interface to WebPlaybackSessionInterfaceContext:
Modified: tags/Safari-602.1.30.4/Source/WebKit2/WebProcess/cocoa/WebVideoFullscreenManager.mm (200378 => 200379)
--- tags/Safari-602.1.30.4/Source/WebKit2/WebProcess/cocoa/WebVideoFullscreenManager.mm 2016-05-03 17:24:48 UTC (rev 200378)
+++ tags/Safari-602.1.30.4/Source/WebKit2/WebProcess/cocoa/WebVideoFullscreenManager.mm 2016-05-03 17:31:04 UTC (rev 200379)
@@ -179,6 +179,7 @@
RefPtr<WebVideoFullscreenModelVideoElement> model = WebVideoFullscreenModelVideoElement::create(playbackSessionModel);
auto& playbackSessionInterface = m_playbackSessionManager->ensureInterface(contextId);
RefPtr<WebVideoFullscreenInterfaceContext> interface = WebVideoFullscreenInterfaceContext::create(*this, playbackSessionInterface, contextId);
+ m_playbackSessionManager->addClientForContext(contextId);
interface->setLayerHostingContext(LayerHostingContext::createForExternalHostingProcess());
model->setWebVideoFullscreenInterface(interface.get());
@@ -210,6 +211,8 @@
RefPtr<WebVideoFullscreenInterfaceContext> interface;
std::tie(model, interface) = ensureModelAndInterface(contextId);
+ m_playbackSessionManager->removeClientForContext(contextId);
+
RefPtr<HTMLVideoElement> videoElement = model->videoElement();
model->setVideoElement(nullptr);
model->setWebVideoFullscreenInterface(nullptr);