Diff
Modified: trunk/Source/WebCore/ChangeLog (188029 => 188030)
--- trunk/Source/WebCore/ChangeLog 2015-08-06 06:24:09 UTC (rev 188029)
+++ trunk/Source/WebCore/ChangeLog 2015-08-06 07:13:55 UTC (rev 188030)
@@ -1,3 +1,27 @@
+2015-08-04 Matt Rajca <mra...@apple.com>
+
+ Media Session: push paused state to the media session focus manager instead of polling
+ https://bugs.webkit.org/show_bug.cgi?id=147633
+
+ Reviewed by Simon Fraser.
+
+ * dom/Document.cpp:
+ (WebCore::Document::updateIsPlayingMedia): If a valid source element ID is passed in, set the 'IsSourcePlaying'
+ flag accordingly.
+ * dom/Document.h:
+ * html/HTMLMediaElement.cpp:
+ (WebCore::HTMLMediaElement::elementWithID):
+ (WebCore::HTMLMediaElement::setMuted): Pass along the element ID.
+ (WebCore::HTMLMediaElement::mediaPlayerCharacteristicChanged): Ditto.
+ (WebCore::HTMLMediaElement::setPlaying): Ditto.
+ * html/HTMLMediaElement.h:
+ * page/ChromeClient.h:
+ * page/MediaProducer.h:
+ * page/Page.cpp:
+ (WebCore::Page::updateIsPlayingMedia): Pass along the source element ID.
+ (WebCore::Page::isMediaElementPaused): Deleted. We now push media playback state changes instead of polling.
+ * page/Page.h:
+
2015-08-05 Myles C. Maxfield <mmaxfi...@apple.com>
CharacterFallbackMapKey should be locale-specific
Modified: trunk/Source/WebCore/dom/Document.cpp (188029 => 188030)
--- trunk/Source/WebCore/dom/Document.cpp 2015-08-06 06:24:09 UTC (rev 188029)
+++ trunk/Source/WebCore/dom/Document.cpp 2015-08-06 07:13:55 UTC (rev 188030)
@@ -3506,19 +3506,26 @@
updateIsPlayingMedia();
}
-void Document::updateIsPlayingMedia()
+void Document::updateIsPlayingMedia(uint64_t sourceElementID)
{
MediaProducer::MediaStateFlags state = MediaProducer::IsNotPlaying;
for (auto audioProducer : m_audioProducers)
state |= audioProducer->mediaState();
+#if ENABLE(MEDIA_SESSION)
+ if (HTMLMediaElement* sourceElement = HTMLMediaElement::elementWithID(sourceElementID)) {
+ if (sourceElement->isPlaying())
+ state |= MediaProducer::IsSourceElementPlaying;
+ }
+#endif
+
if (state == m_mediaState)
return;
m_mediaState = state;
if (page())
- page()->updateIsPlayingMedia();
+ page()->updateIsPlayingMedia(sourceElementID);
}
void Document::pageMutedStateDidChange()
Modified: trunk/Source/WebCore/dom/Document.h (188029 => 188030)
--- trunk/Source/WebCore/dom/Document.h 2015-08-06 06:24:09 UTC (rev 188029)
+++ trunk/Source/WebCore/dom/Document.h 2015-08-06 07:13:55 UTC (rev 188030)
@@ -226,6 +226,8 @@
class MediaSession;
#endif
+WEBCORE_EXPORT extern const uint64_t HTMLMediaElementInvalidID;
+
enum PageshowEventPersistence {
PageshowEventNotPersisted = 0,
PageshowEventPersisted = 1
@@ -1260,7 +1262,7 @@
WEBCORE_EXPORT void addAudioProducer(MediaProducer*);
WEBCORE_EXPORT void removeAudioProducer(MediaProducer*);
MediaProducer::MediaStateFlags mediaState() const { return m_mediaState; }
- WEBCORE_EXPORT void updateIsPlayingMedia();
+ WEBCORE_EXPORT void updateIsPlayingMedia(uint64_t = HTMLMediaElementInvalidID);
void pageMutedStateDidChange();
WeakPtr<Document> createWeakPtr() { return m_weakFactory.createWeakPtr(); }
Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (188029 => 188030)
--- trunk/Source/WebCore/html/HTMLMediaElement.cpp 2015-08-06 06:24:09 UTC (rev 188029)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp 2015-08-06 07:13:55 UTC (rev 188030)
@@ -202,6 +202,8 @@
static const char* mediaStreamBlobProtocol = "blob";
#endif
+const uint64_t HTMLMediaElementInvalidID = 0;
+
using namespace HTMLNames;
typedef HashMap<Document*, HashSet<HTMLMediaElement*>> DocumentElementSetMap;
@@ -299,6 +301,9 @@
HTMLMediaElement* HTMLMediaElement::elementWithID(uint64_t id)
{
+ if (id == HTMLMediaElementInvalidID)
+ return nullptr;
+
return elementIDsToElements().get(id);
}
@@ -3164,7 +3169,12 @@
}
}
scheduleEvent(eventNames().volumechangeEvent);
+
+#if ENABLE(MEDIA_SESSION)
+ document().updateIsPlayingMedia(m_elementID);
+#else
document().updateIsPlayingMedia();
+#endif
#if ENABLE(WIRELESS_PLAYBACK_TARGET)
updateMediaState(UpdateMediaState::Asynchronously);
@@ -4528,7 +4538,11 @@
if (isPlaying() && !m_mediaSession->playbackPermitted(*this))
pauseInternal();
+#if ENABLE(MEDIA_SESSION)
+ document().updateIsPlayingMedia(m_elementID);
+#else
document().updateIsPlayingMedia();
+#endif
endProcessingMediaPlayerCallback();
}
@@ -4788,7 +4802,12 @@
return;
m_playing = playing;
+
+#if ENABLE(MEDIA_SESSION)
+ document().updateIsPlayingMedia(m_elementID);
+#else
document().updateIsPlayingMedia();
+#endif
#if ENABLE(WIRELESS_PLAYBACK_TARGET)
updateMediaState(UpdateMediaState::Asynchronously);
Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (188029 => 188030)
--- trunk/Source/WebCore/html/HTMLMediaElement.h 2015-08-06 06:24:09 UTC (rev 188029)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h 2015-08-06 07:13:55 UTC (rev 188030)
@@ -98,6 +98,8 @@
class MediaStream;
#endif
+extern const uint64_t HTMLMediaElementInvalidID;
+
class HTMLMediaElement
: public HTMLElement
, private MediaPlayerClient, public MediaPlayerSupportsTypeClient, private MediaCanStartListener, public ActiveDOMObject, public MediaControllerInterface , public PlatformMediaSessionClient, private MediaProducer
Modified: trunk/Source/WebCore/page/ChromeClient.h (188029 => 188030)
--- trunk/Source/WebCore/page/ChromeClient.h 2015-08-06 06:24:09 UTC (rev 188029)
+++ trunk/Source/WebCore/page/ChromeClient.h 2015-08-06 07:13:55 UTC (rev 188030)
@@ -420,7 +420,7 @@
virtual bool shouldUseTiledBackingForFrameView(const FrameView*) const { return false; }
- virtual void isPlayingMediaDidChange(MediaProducer::MediaStateFlags) { }
+ virtual void isPlayingMediaDidChange(MediaProducer::MediaStateFlags, uint64_t) { }
#if ENABLE(MEDIA_SESSION)
virtual void hasMediaSessionWithActiveMediaElementsDidChange(bool) { }
Modified: trunk/Source/WebCore/page/MediaProducer.h (188029 => 188030)
--- trunk/Source/WebCore/page/MediaProducer.h 2015-08-06 06:24:09 UTC (rev 188029)
+++ trunk/Source/WebCore/page/MediaProducer.h 2015-08-06 07:13:55 UTC (rev 188030)
@@ -38,6 +38,7 @@
RequiresPlaybackTargetMonitoring = 1 << 3,
ExternalDeviceAutoPlayCandidate = 1 << 4,
DidPlayToEnd = 1 << 5,
+ IsSourceElementPlaying = 1 << 6,
};
typedef unsigned MediaStateFlags;
Modified: trunk/Source/WebCore/page/Page.cpp (188029 => 188030)
--- trunk/Source/WebCore/page/Page.cpp 2015-08-06 06:24:09 UTC (rev 188029)
+++ trunk/Source/WebCore/page/Page.cpp 2015-08-06 07:13:55 UTC (rev 188030)
@@ -1183,7 +1183,7 @@
setSessionID(privateBrowsingEnabled ? SessionID::legacyPrivateSessionID() : SessionID::defaultSessionID());
}
-void Page::updateIsPlayingMedia()
+void Page::updateIsPlayingMedia(uint64_t sourceElementID)
{
MediaProducer::MediaStateFlags state = MediaProducer::IsNotPlaying;
for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) {
@@ -1195,7 +1195,7 @@
m_mediaState = state;
- chrome().client().isPlayingMediaDidChange(state);
+ chrome().client().isPlayingMediaDidChange(state, sourceElementID);
}
void Page::setMuted(bool muted)
@@ -1224,15 +1224,6 @@
break;
}
}
-
-bool Page::isMediaElementPaused(uint64_t elementID)
-{
- if (HTMLMediaElement* element = HTMLMediaElement::elementWithID(elementID))
- return element->paused();
-
- ASSERT_NOT_REACHED();
- return true;
-}
#endif
#if !ASSERT_DISABLED
Modified: trunk/Source/WebCore/page/Page.h (188029 => 188030)
--- trunk/Source/WebCore/page/Page.h 2015-08-06 06:24:09 UTC (rev 188029)
+++ trunk/Source/WebCore/page/Page.h 2015-08-06 07:13:55 UTC (rev 188030)
@@ -436,13 +436,12 @@
bool usesEphemeralSession() const { return m_sessionID.isEphemeral(); }
MediaProducer::MediaStateFlags mediaState() const { return m_mediaState; }
- void updateIsPlayingMedia();
+ void updateIsPlayingMedia(uint64_t);
bool isMuted() const { return m_muted; }
WEBCORE_EXPORT void setMuted(bool);
#if ENABLE(MEDIA_SESSION)
WEBCORE_EXPORT void handleMediaEvent(MediaEventType);
- WEBCORE_EXPORT bool isMediaElementPaused(uint64_t);
#endif
#if ENABLE(WIRELESS_PLAYBACK_TARGET)
Modified: trunk/Source/WebKit2/ChangeLog (188029 => 188030)
--- trunk/Source/WebKit2/ChangeLog 2015-08-06 06:24:09 UTC (rev 188029)
+++ trunk/Source/WebKit2/ChangeLog 2015-08-06 07:13:55 UTC (rev 188030)
@@ -1,3 +1,38 @@
+2015-08-04 Matt Rajca <mra...@apple.com>
+
+ Media Session: push paused state to the media session focus manager instead of polling
+ https://bugs.webkit.org/show_bug.cgi?id=147633
+
+ Reviewed by Simon Fraser.
+
+ * UIProcess/WebMediaSessionFocusManager.cpp:
+ (WebKit::WebMediaSessionFocusManager::isFocusedContentMediaElementPaused): Report whether the focused media
+ element is currently playing. The callback is no longer necessary and will be removed in a future patch in
+ favor of returning a value directly.
+ (WebKit::WebMediaSessionFocusManager::mediaElementIsPlayingDidChange): Keep track of whether the focused media
+ element is currently playing.
+ * UIProcess/WebMediaSessionFocusManager.h:
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::isPlayingMediaDidChange): If the focused media element begins/ends playing, keep track
+ of its playing state.
+ (WebKit::WebPageProxy::isMediaElementPaused): Deleted. We now push media playback state changes instead of
+ polling.
+ * UIProcess/WebPageProxy.h: isPlayingMediaDidChange is now passed the ID of the media element that triggered
+ the 'playing' state change. This can be used in conjunction with the IsSourcePlaying media flag to identify
+ whether the source element begin/ended playing.
+ * UIProcess/WebPageProxy.messages.in: Ditto.
+ * WebProcess/Plugins/PluginView.cpp:
+ (WebKit::PluginView::setPluginIsPlayingAudio): Since a media element did not trigger this, pass in 0 for the
+ source media element.
+ * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+ (WebKit::WebChromeClient::isPlayingMediaDidChange): isPlayingMediaDidChange is now passed the ID of the media
+ element that triggered the 'playing' state change.
+ * WebProcess/WebCoreSupport/WebChromeClient.h: Ditto.
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::isMediaElementPaused): Deleted. We now push media playback state changes instead of polling.
+ * WebProcess/WebPage/WebPage.h: Ditto.
+ * WebProcess/WebPage/WebPage.messages.in: Ditto.
+
2015-08-05 Tim Horton <timothy_hor...@apple.com>
PDFPlugins are clipped in link previews (and remain so when opened)
Modified: trunk/Source/WebKit2/UIProcess/WebMediaSessionFocusManager.cpp (188029 => 188030)
--- trunk/Source/WebKit2/UIProcess/WebMediaSessionFocusManager.cpp 2015-08-06 06:24:09 UTC (rev 188029)
+++ trunk/Source/WebKit2/UIProcess/WebMediaSessionFocusManager.cpp 2015-08-06 07:13:55 UTC (rev 188030)
@@ -62,12 +62,17 @@
if (!m_focusedMediaElement)
return;
- RefPtr<UnsignedCallback> callback = UnsignedCallback::create(callbackFunction);
- WebPageProxy* proxy = m_focusedMediaElement->first;
- uint64_t elementID = m_focusedMediaElement->second;
- proxy->isMediaElementPaused(elementID, callback);
+ callbackFunction(!m_focusedMediaElementIsPlaying, CallbackBase::Error::None);
}
+void WebMediaSessionFocusManager::mediaElementIsPlayingDidChange(WebPageProxy* proxy, uint64_t elementID, bool isPlaying)
+{
+ if (m_focusedMediaElement) {
+ if (proxy == m_focusedMediaElement->first && elementID == m_focusedMediaElement->second)
+ m_focusedMediaElementIsPlaying = isPlaying;
+ }
+}
+
void WebMediaSessionFocusManager::setFocusedMediaElement(WebPageProxy& proxy, uint64_t elementID)
{
m_focusedMediaElement = std::make_unique<FocusedMediaElement>(&proxy, elementID);
Modified: trunk/Source/WebKit2/UIProcess/WebMediaSessionFocusManager.h (188029 => 188030)
--- trunk/Source/WebKit2/UIProcess/WebMediaSessionFocusManager.h 2015-08-06 06:24:09 UTC (rev 188029)
+++ trunk/Source/WebKit2/UIProcess/WebMediaSessionFocusManager.h 2015-08-06 07:13:55 UTC (rev 188030)
@@ -44,6 +44,7 @@
static PassRefPtr<WebMediaSessionFocusManager> create(WebProcessPool*);
void isFocusedContentMediaElementPaused(std::function<void(bool, CallbackBase::Error)>);
+ void mediaElementIsPlayingDidChange(WebPageProxy*, uint64_t, bool);
void setFocusedMediaElement(WebPageProxy&, uint64_t);
void clearFocusedMediaElement();
@@ -59,6 +60,7 @@
virtual void derefWebContextSupplement() override;
std::unique_ptr<FocusedMediaElement> m_focusedMediaElement;
+ bool m_focusedMediaElementIsPlaying { false };
};
} // namespace WebKit
Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (188029 => 188030)
--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp 2015-08-06 06:24:09 UTC (rev 188029)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp 2015-08-06 07:13:55 UTC (rev 188030)
@@ -3882,19 +3882,6 @@
m_process->send(Messages::WebPage::HandleMediaEvent(eventType), m_pageID);
}
-
-void WebPageProxy::isMediaElementPaused(uint64_t elementID, RefPtr<UnsignedCallback> callback)
-{
- if (!isValid()) {
- callback->invalidate();
- return;
- }
-
- uint64_t callbackID = callback->callbackID();
- m_callbacks.put(callback);
-
- m_process->send(Messages::WebPage::IsMediaElementPaused(elementID, callbackID), m_pageID);
-}
#endif
void WebPageProxy::setMayStartMediaWhenInWindow(bool mayStartMedia)
@@ -5950,8 +5937,14 @@
m_isShowingNavigationGestureSnapshot = false;
}
-void WebPageProxy::isPlayingMediaDidChange(MediaProducer::MediaStateFlags state)
+void WebPageProxy::isPlayingMediaDidChange(MediaProducer::MediaStateFlags state, uint64_t sourceElementID)
{
+#if ENABLE(MEDIA_SESSION)
+ WebMediaSessionFocusManager* focusManager = process().processPool().supplement<WebMediaSessionFocusManager>();
+ ASSERT(focusManager);
+ focusManager->mediaElementIsPlayingDidChange(this, sourceElementID, state & MediaProducer::IsSourceElementPlaying);
+#endif
+
if (state == m_mediaState)
return;
Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (188029 => 188030)
--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h 2015-08-06 06:24:09 UTC (rev 188029)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h 2015-08-06 07:13:55 UTC (rev 188030)
@@ -943,7 +943,6 @@
#if ENABLE(MEDIA_SESSION)
bool hasMediaSessionWithActiveMediaElements() const { return m_hasMediaSessionWithActiveMediaElements; }
void handleMediaEvent(WebCore::MediaEventType);
- void isMediaElementPaused(uint64_t, RefPtr<UnsignedCallback>);
#endif
// WebPopupMenuProxy::Client
@@ -1025,7 +1024,7 @@
bool isShowingNavigationGestureSnapshot() const { return m_isShowingNavigationGestureSnapshot; }
bool isPlayingAudio() const { return !!(m_mediaState & WebCore::MediaProducer::IsPlayingAudio); }
- void isPlayingMediaDidChange(WebCore::MediaProducer::MediaStateFlags);
+ void isPlayingMediaDidChange(WebCore::MediaProducer::MediaStateFlags, uint64_t);
#if ENABLE(MEDIA_SESSION)
void hasMediaSessionWithActiveMediaElementsDidChange(bool);
Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in (188029 => 188030)
--- trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in 2015-08-06 06:24:09 UTC (rev 188029)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in 2015-08-06 07:13:55 UTC (rev 188030)
@@ -422,7 +422,7 @@
ContentFilterDidBlockLoadForFrame(WebCore::ContentFilterUnblockHandler unblockHandler, uint64_t frameID)
#endif
- IsPlayingMediaDidChange(unsigned state)
+ IsPlayingMediaDidChange(unsigned state, uint64_t sourceElementID)
#if ENABLE(MEDIA_SESSION)
HasMediaSessionWithActiveMediaElementsDidChange(bool state)
Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp (188029 => 188030)
--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp 2015-08-06 06:24:09 UTC (rev 188029)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp 2015-08-06 07:13:55 UTC (rev 188030)
@@ -1057,9 +1057,9 @@
return m_page->drawingArea()->shouldUseTiledBackingForFrameView(frameView);
}
-void WebChromeClient::isPlayingMediaDidChange(WebCore::MediaProducer::MediaStateFlags state)
+void WebChromeClient::isPlayingMediaDidChange(WebCore::MediaProducer::MediaStateFlags state, uint64_t sourceElementID)
{
- m_page->send(Messages::WebPageProxy::IsPlayingMediaDidChange(state));
+ m_page->send(Messages::WebPageProxy::IsPlayingMediaDidChange(state, sourceElementID));
}
#if ENABLE(MEDIA_SESSION)
Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h (188029 => 188030)
--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h 2015-08-06 06:24:09 UTC (rev 188029)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h 2015-08-06 07:13:55 UTC (rev 188030)
@@ -291,7 +291,7 @@
virtual bool shouldUseTiledBackingForFrameView(const WebCore::FrameView*) const override;
- virtual void isPlayingMediaDidChange(WebCore::MediaProducer::MediaStateFlags) override;
+ virtual void isPlayingMediaDidChange(WebCore::MediaProducer::MediaStateFlags, uint64_t) override;
virtual void setPageActivityState(WebCore::PageActivityState::Flags) override;
#if ENABLE(MEDIA_SESSION)
Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (188029 => 188030)
--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp 2015-08-06 06:24:09 UTC (rev 188029)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp 2015-08-06 07:13:55 UTC (rev 188030)
@@ -4076,12 +4076,6 @@
{
m_page->handleMediaEvent(static_cast<MediaEventType>(eventType));
}
-
-void WebPage::isMediaElementPaused(uint64_t elementID, uint64_t callbackID)
-{
- bool paused = m_page->isMediaElementPaused(elementID);
- send(Messages::WebPageProxy::UnsignedCallback(paused, callbackID));
-}
#endif
void WebPage::setMayStartMediaWhenInWindow(bool mayStartMedia)
Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (188029 => 188030)
--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h 2015-08-06 06:24:09 UTC (rev 188029)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h 2015-08-06 07:13:55 UTC (rev 188030)
@@ -750,7 +750,6 @@
#if ENABLE(MEDIA_SESSION)
void handleMediaEvent(uint32_t /* WebCore::MediaEventType */);
- void isMediaElementPaused(uint64_t, uint64_t);
#endif
void updateMainFrameScrollOffsetPinning();
Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in (188029 => 188030)
--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in 2015-08-06 06:24:09 UTC (rev 188029)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in 2015-08-06 07:13:55 UTC (rev 188030)
@@ -316,7 +316,6 @@
#if ENABLE(MEDIA_SESSION)
HandleMediaEvent(uint32_t eventType)
- IsMediaElementPaused(uint64_t elementID, uint64_t callbackID)
#endif
// FIXME: This a dummy message, to avoid breaking the build for platforms that don't require