Changeset 188030 in webkit
- Timestamp:
- Aug 6, 2015 12:13:55 AM (9 years ago)
- Location:
- trunk/Source
- Files:
-
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r188025 r188030 1 2015-08-04 Matt Rajca <mrajca@apple.com> 2 3 Media Session: push paused state to the media session focus manager instead of polling 4 https://bugs.webkit.org/show_bug.cgi?id=147633 5 6 Reviewed by Simon Fraser. 7 8 * dom/Document.cpp: 9 (WebCore::Document::updateIsPlayingMedia): If a valid source element ID is passed in, set the 'IsSourcePlaying' 10 flag accordingly. 11 * dom/Document.h: 12 * html/HTMLMediaElement.cpp: 13 (WebCore::HTMLMediaElement::elementWithID): 14 (WebCore::HTMLMediaElement::setMuted): Pass along the element ID. 15 (WebCore::HTMLMediaElement::mediaPlayerCharacteristicChanged): Ditto. 16 (WebCore::HTMLMediaElement::setPlaying): Ditto. 17 * html/HTMLMediaElement.h: 18 * page/ChromeClient.h: 19 * page/MediaProducer.h: 20 * page/Page.cpp: 21 (WebCore::Page::updateIsPlayingMedia): Pass along the source element ID. 22 (WebCore::Page::isMediaElementPaused): Deleted. We now push media playback state changes instead of polling. 23 * page/Page.h: 24 1 25 2015-08-05 Myles C. Maxfield <mmaxfield@apple.com> 2 26 -
trunk/Source/WebCore/dom/Document.cpp
r187706 r188030 3507 3507 } 3508 3508 3509 void Document::updateIsPlayingMedia( )3509 void Document::updateIsPlayingMedia(uint64_t sourceElementID) 3510 3510 { 3511 3511 MediaProducer::MediaStateFlags state = MediaProducer::IsNotPlaying; … … 3513 3513 state |= audioProducer->mediaState(); 3514 3514 3515 #if ENABLE(MEDIA_SESSION) 3516 if (HTMLMediaElement* sourceElement = HTMLMediaElement::elementWithID(sourceElementID)) { 3517 if (sourceElement->isPlaying()) 3518 state |= MediaProducer::IsSourceElementPlaying; 3519 } 3520 #endif 3521 3515 3522 if (state == m_mediaState) 3516 3523 return; … … 3519 3526 3520 3527 if (page()) 3521 page()->updateIsPlayingMedia( );3528 page()->updateIsPlayingMedia(sourceElementID); 3522 3529 } 3523 3530 -
trunk/Source/WebCore/dom/Document.h
r187706 r188030 227 227 #endif 228 228 229 WEBCORE_EXPORT extern const uint64_t HTMLMediaElementInvalidID; 230 229 231 enum PageshowEventPersistence { 230 232 PageshowEventNotPersisted = 0, … … 1261 1263 WEBCORE_EXPORT void removeAudioProducer(MediaProducer*); 1262 1264 MediaProducer::MediaStateFlags mediaState() const { return m_mediaState; } 1263 WEBCORE_EXPORT void updateIsPlayingMedia( );1265 WEBCORE_EXPORT void updateIsPlayingMedia(uint64_t = HTMLMediaElementInvalidID); 1264 1266 void pageMutedStateDidChange(); 1265 1267 WeakPtr<Document> createWeakPtr() { return m_weakFactory.createWeakPtr(); } -
trunk/Source/WebCore/html/HTMLMediaElement.cpp
r187892 r188030 203 203 #endif 204 204 205 const uint64_t HTMLMediaElementInvalidID = 0; 206 205 207 using namespace HTMLNames; 206 208 … … 300 302 HTMLMediaElement* HTMLMediaElement::elementWithID(uint64_t id) 301 303 { 304 if (id == HTMLMediaElementInvalidID) 305 return nullptr; 306 302 307 return elementIDsToElements().get(id); 303 308 } … … 3165 3170 } 3166 3171 scheduleEvent(eventNames().volumechangeEvent); 3172 3173 #if ENABLE(MEDIA_SESSION) 3174 document().updateIsPlayingMedia(m_elementID); 3175 #else 3167 3176 document().updateIsPlayingMedia(); 3177 #endif 3168 3178 3169 3179 #if ENABLE(WIRELESS_PLAYBACK_TARGET) … … 4529 4539 pauseInternal(); 4530 4540 4541 #if ENABLE(MEDIA_SESSION) 4542 document().updateIsPlayingMedia(m_elementID); 4543 #else 4531 4544 document().updateIsPlayingMedia(); 4545 #endif 4532 4546 4533 4547 endProcessingMediaPlayerCallback(); … … 4789 4803 4790 4804 m_playing = playing; 4805 4806 #if ENABLE(MEDIA_SESSION) 4807 document().updateIsPlayingMedia(m_elementID); 4808 #else 4791 4809 document().updateIsPlayingMedia(); 4810 #endif 4792 4811 4793 4812 #if ENABLE(WIRELESS_PLAYBACK_TARGET) -
trunk/Source/WebCore/html/HTMLMediaElement.h
r187712 r188030 99 99 #endif 100 100 101 extern const uint64_t HTMLMediaElementInvalidID; 102 101 103 class HTMLMediaElement 102 104 : public HTMLElement -
trunk/Source/WebCore/page/ChromeClient.h
r187713 r188030 421 421 virtual bool shouldUseTiledBackingForFrameView(const FrameView*) const { return false; } 422 422 423 virtual void isPlayingMediaDidChange(MediaProducer::MediaStateFlags ) { }423 virtual void isPlayingMediaDidChange(MediaProducer::MediaStateFlags, uint64_t) { } 424 424 425 425 #if ENABLE(MEDIA_SESSION) -
trunk/Source/WebCore/page/MediaProducer.h
r186361 r188030 39 39 ExternalDeviceAutoPlayCandidate = 1 << 4, 40 40 DidPlayToEnd = 1 << 5, 41 IsSourceElementPlaying = 1 << 6, 41 42 }; 42 43 typedef unsigned MediaStateFlags; -
trunk/Source/WebCore/page/Page.cpp
r187790 r188030 1184 1184 } 1185 1185 1186 void Page::updateIsPlayingMedia( )1186 void Page::updateIsPlayingMedia(uint64_t sourceElementID) 1187 1187 { 1188 1188 MediaProducer::MediaStateFlags state = MediaProducer::IsNotPlaying; … … 1196 1196 m_mediaState = state; 1197 1197 1198 chrome().client().isPlayingMediaDidChange(state );1198 chrome().client().isPlayingMediaDidChange(state, sourceElementID); 1199 1199 } 1200 1200 … … 1225 1225 } 1226 1226 } 1227 1228 bool Page::isMediaElementPaused(uint64_t elementID)1229 {1230 if (HTMLMediaElement* element = HTMLMediaElement::elementWithID(elementID))1231 return element->paused();1232 1233 ASSERT_NOT_REACHED();1234 return true;1235 }1236 1227 #endif 1237 1228 -
trunk/Source/WebCore/page/Page.h
r187790 r188030 437 437 438 438 MediaProducer::MediaStateFlags mediaState() const { return m_mediaState; } 439 void updateIsPlayingMedia( );439 void updateIsPlayingMedia(uint64_t); 440 440 bool isMuted() const { return m_muted; } 441 441 WEBCORE_EXPORT void setMuted(bool); … … 443 443 #if ENABLE(MEDIA_SESSION) 444 444 WEBCORE_EXPORT void handleMediaEvent(MediaEventType); 445 WEBCORE_EXPORT bool isMediaElementPaused(uint64_t);446 445 #endif 447 446 -
trunk/Source/WebKit2/ChangeLog
r188011 r188030 1 2015-08-04 Matt Rajca <mrajca@apple.com> 2 3 Media Session: push paused state to the media session focus manager instead of polling 4 https://bugs.webkit.org/show_bug.cgi?id=147633 5 6 Reviewed by Simon Fraser. 7 8 * UIProcess/WebMediaSessionFocusManager.cpp: 9 (WebKit::WebMediaSessionFocusManager::isFocusedContentMediaElementPaused): Report whether the focused media 10 element is currently playing. The callback is no longer necessary and will be removed in a future patch in 11 favor of returning a value directly. 12 (WebKit::WebMediaSessionFocusManager::mediaElementIsPlayingDidChange): Keep track of whether the focused media 13 element is currently playing. 14 * UIProcess/WebMediaSessionFocusManager.h: 15 * UIProcess/WebPageProxy.cpp: 16 (WebKit::WebPageProxy::isPlayingMediaDidChange): If the focused media element begins/ends playing, keep track 17 of its playing state. 18 (WebKit::WebPageProxy::isMediaElementPaused): Deleted. We now push media playback state changes instead of 19 polling. 20 * UIProcess/WebPageProxy.h: isPlayingMediaDidChange is now passed the ID of the media element that triggered 21 the 'playing' state change. This can be used in conjunction with the IsSourcePlaying media flag to identify 22 whether the source element begin/ended playing. 23 * UIProcess/WebPageProxy.messages.in: Ditto. 24 * WebProcess/Plugins/PluginView.cpp: 25 (WebKit::PluginView::setPluginIsPlayingAudio): Since a media element did not trigger this, pass in 0 for the 26 source media element. 27 * WebProcess/WebCoreSupport/WebChromeClient.cpp: 28 (WebKit::WebChromeClient::isPlayingMediaDidChange): isPlayingMediaDidChange is now passed the ID of the media 29 element that triggered the 'playing' state change. 30 * WebProcess/WebCoreSupport/WebChromeClient.h: Ditto. 31 * WebProcess/WebPage/WebPage.cpp: 32 (WebKit::WebPage::isMediaElementPaused): Deleted. We now push media playback state changes instead of polling. 33 * WebProcess/WebPage/WebPage.h: Ditto. 34 * WebProcess/WebPage/WebPage.messages.in: Ditto. 35 1 36 2015-08-05 Tim Horton <timothy_horton@apple.com> 2 37 -
trunk/Source/WebKit2/UIProcess/WebMediaSessionFocusManager.cpp
r187917 r188030 63 63 return; 64 64 65 RefPtr<UnsignedCallback> callback = UnsignedCallback::create(callbackFunction); 66 WebPageProxy* proxy = m_focusedMediaElement->first; 67 uint64_t elementID = m_focusedMediaElement->second; 68 proxy->isMediaElementPaused(elementID, callback); 65 callbackFunction(!m_focusedMediaElementIsPlaying, CallbackBase::Error::None); 66 } 67 68 void WebMediaSessionFocusManager::mediaElementIsPlayingDidChange(WebPageProxy* proxy, uint64_t elementID, bool isPlaying) 69 { 70 if (m_focusedMediaElement) { 71 if (proxy == m_focusedMediaElement->first && elementID == m_focusedMediaElement->second) 72 m_focusedMediaElementIsPlaying = isPlaying; 73 } 69 74 } 70 75 -
trunk/Source/WebKit2/UIProcess/WebMediaSessionFocusManager.h
r187917 r188030 45 45 46 46 void isFocusedContentMediaElementPaused(std::function<void(bool, CallbackBase::Error)>); 47 void mediaElementIsPlayingDidChange(WebPageProxy*, uint64_t, bool); 47 48 48 49 void setFocusedMediaElement(WebPageProxy&, uint64_t); … … 60 61 61 62 std::unique_ptr<FocusedMediaElement> m_focusedMediaElement; 63 bool m_focusedMediaElementIsPlaying { false }; 62 64 }; 63 65 -
trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp
r188011 r188030 3883 3883 m_process->send(Messages::WebPage::HandleMediaEvent(eventType), m_pageID); 3884 3884 } 3885 3886 void WebPageProxy::isMediaElementPaused(uint64_t elementID, RefPtr<UnsignedCallback> callback)3887 {3888 if (!isValid()) {3889 callback->invalidate();3890 return;3891 }3892 3893 uint64_t callbackID = callback->callbackID();3894 m_callbacks.put(callback);3895 3896 m_process->send(Messages::WebPage::IsMediaElementPaused(elementID, callbackID), m_pageID);3897 }3898 3885 #endif 3899 3886 … … 5951 5938 } 5952 5939 5953 void WebPageProxy::isPlayingMediaDidChange(MediaProducer::MediaStateFlags state) 5954 { 5940 void WebPageProxy::isPlayingMediaDidChange(MediaProducer::MediaStateFlags state, uint64_t sourceElementID) 5941 { 5942 #if ENABLE(MEDIA_SESSION) 5943 WebMediaSessionFocusManager* focusManager = process().processPool().supplement<WebMediaSessionFocusManager>(); 5944 ASSERT(focusManager); 5945 focusManager->mediaElementIsPlayingDidChange(this, sourceElementID, state & MediaProducer::IsSourceElementPlaying); 5946 #endif 5947 5955 5948 if (state == m_mediaState) 5956 5949 return; -
trunk/Source/WebKit2/UIProcess/WebPageProxy.h
r188011 r188030 944 944 bool hasMediaSessionWithActiveMediaElements() const { return m_hasMediaSessionWithActiveMediaElements; } 945 945 void handleMediaEvent(WebCore::MediaEventType); 946 void isMediaElementPaused(uint64_t, RefPtr<UnsignedCallback>);947 946 #endif 948 947 … … 1026 1025 1027 1026 bool isPlayingAudio() const { return !!(m_mediaState & WebCore::MediaProducer::IsPlayingAudio); } 1028 void isPlayingMediaDidChange(WebCore::MediaProducer::MediaStateFlags );1027 void isPlayingMediaDidChange(WebCore::MediaProducer::MediaStateFlags, uint64_t); 1029 1028 1030 1029 #if ENABLE(MEDIA_SESSION) -
trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in
r188011 r188030 423 423 #endif 424 424 425 IsPlayingMediaDidChange(unsigned state )425 IsPlayingMediaDidChange(unsigned state, uint64_t sourceElementID) 426 426 427 427 #if ENABLE(MEDIA_SESSION) -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp
r187713 r188030 1058 1058 } 1059 1059 1060 void WebChromeClient::isPlayingMediaDidChange(WebCore::MediaProducer::MediaStateFlags state )1061 { 1062 m_page->send(Messages::WebPageProxy::IsPlayingMediaDidChange(state ));1060 void WebChromeClient::isPlayingMediaDidChange(WebCore::MediaProducer::MediaStateFlags state, uint64_t sourceElementID) 1061 { 1062 m_page->send(Messages::WebPageProxy::IsPlayingMediaDidChange(state, sourceElementID)); 1063 1063 } 1064 1064 -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h
r187713 r188030 292 292 virtual bool shouldUseTiledBackingForFrameView(const WebCore::FrameView*) const override; 293 293 294 virtual void isPlayingMediaDidChange(WebCore::MediaProducer::MediaStateFlags ) override;294 virtual void isPlayingMediaDidChange(WebCore::MediaProducer::MediaStateFlags, uint64_t) override; 295 295 virtual void setPageActivityState(WebCore::PageActivityState::Flags) override; 296 296 -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp
r188011 r188030 4077 4077 m_page->handleMediaEvent(static_cast<MediaEventType>(eventType)); 4078 4078 } 4079 4080 void WebPage::isMediaElementPaused(uint64_t elementID, uint64_t callbackID)4081 {4082 bool paused = m_page->isMediaElementPaused(elementID);4083 send(Messages::WebPageProxy::UnsignedCallback(paused, callbackID));4084 }4085 4079 #endif 4086 4080 -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h
r187795 r188030 751 751 #if ENABLE(MEDIA_SESSION) 752 752 void handleMediaEvent(uint32_t /* WebCore::MediaEventType */); 753 void isMediaElementPaused(uint64_t, uint64_t);754 753 #endif 755 754 -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in
r187790 r188030 317 317 #if ENABLE(MEDIA_SESSION) 318 318 HandleMediaEvent(uint32_t eventType) 319 IsMediaElementPaused(uint64_t elementID, uint64_t callbackID)320 319 #endif 321 320
Note: See TracChangeset
for help on using the changeset viewer.