[WebKitLegacy] Media playback pauses on scroll
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Jan 2019 22:23:15 +0000 (22:23 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Jan 2019 22:23:15 +0000 (22:23 +0000)
commit471485775cebe1fdb0c2c6ebe1588c18a8251d4a
tree56e65b610cf8180e75c44a6c4f43cfea75be94db
parent349379dce9fed6aa458b030acf302df5867b7752
[WebKitLegacy] Media playback pauses on scroll
https://bugs.webkit.org/show_bug.cgi?id=192829

Reviewed by Eric Carlson.

Source/WebCore:

New API tests:
    WebKitLegacy.ScrollingDoesNotPauseMedia
    WKWebView.StopAllMediaPlayback
    WKWebView.SuspendResumeAllMediaPlayback

Do not use suspendActiveDOMObjects(ReasonForSuspension::PageWillBeSuspended) to pause
video. Roll back the changes to HTMLMediaElement, and introduce a new set of Page calls
suspendAllMediaPlayback() & resumeAllMediaPlayback() which replaces the removed bahavior.

* dom/Document.cpp:
(WebCore::Document::~Document):
(WebCore::Document::stopAllMediaPlayback):
(WebCore::Document::suspendAllMediaPlayback):
(WebCore::Document::resumeAllMediaPlayback):
* dom/Document.h:
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::HTMLMediaElement):
(WebCore::HTMLMediaElement::parseAttribute):
(WebCore::HTMLMediaElement::didFinishInsertingNode):
(WebCore::HTMLMediaElement::setSrcObject):
(WebCore::HTMLMediaElement::updateActiveTextTrackCues):
(WebCore::HTMLMediaElement::suspend):
(WebCore::HTMLMediaElement::resume):
(WebCore::HTMLMediaElement::webkitCurrentPlaybackTargetIsWireless const):
* html/HTMLMediaElement.h:
(WebCore::HTMLMediaElement::webkitCurrentPlaybackTargetIsWireless const): Deleted.
* html/MediaElementSession.cpp:
(WebCore::MediaElementSession::playbackPermitted const):
* page/Page.cpp:
(WebCore::Page::stopAllMediaPlayback):
(WebCore::Page::suspendAllMediaPlayback):
(WebCore::Page::resumeAllMediaPlayback):
* page/Page.h:
(WebCore::Page::mediaPlaybackIsSuspended):
* platform/audio/PlatformMediaSession.h:
* platform/audio/PlatformMediaSessionManager.cpp:
(WebCore::PlatformMediaSessionManager::suspendAllMediaPlaybackForDocument):
(WebCore::PlatformMediaSessionManager::resumeAllMediaPlaybackForDocument):
* platform/audio/PlatformMediaSessionManager.h:

Source/WebKit:

Add a new WebPage, WebPageProxy, & WKWebView SPI to stop, suspend, and resume all
existing media playback in the page.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _stopAllMediaPlayback]):
(-[WKWebView _suspendAllMediaPlayback]):
(-[WKWebView _resumeAllMediaPlayback]):
* UIProcess/API/Cocoa/WKWebViewPrivate.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::stopAllMediaPlayback):
(WebKit::WebPageProxy::suspendAllMediaPlayback):
(WebKit::WebPageProxy::resumeAllMediaPlayback):
* UIProcess/WebPageProxy.h:
* UIProcess/ios/fullscreen/WKFullScreenViewController.mm:
(-[WKFullScreenViewController _showPhishingAlert]):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::stopAllMediaPlayback):
(WebKit::WebPage::suspendAllMediaPlayback):
(WebKit::WebPage::resumeAllMediaPlayback):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:

Tools:

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKitCocoa/StopSuspendResumeAllMedia.mm: Added.
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/WebKitLegacy/ios/ScrollingDoesNotPauseMedia.mm: Added.
(-[ScrollingDoesNotPauseMediaDelegate webViewDidFinishLoad:]):
(-[ScrollingDoesNotPauseMediaDelegate uiWebView:didCommitLoadForFrame:]):
(-[ScrollingDoesNotPauseMediaDelegate handleEvent:]):
(TestWebKitAPI::TEST):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239640 268f45cc-cd09-0410-ab3c-d52691b4dbfc
24 files changed:
Source/WebCore/ChangeLog
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLMediaElement.h
Source/WebCore/html/MediaElementSession.cpp
Source/WebCore/page/Page.cpp
Source/WebCore/page/Page.h
Source/WebCore/platform/audio/PlatformMediaSession.h
Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp
Source/WebCore/platform/audio/PlatformMediaSessionManager.h
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h
Source/WebKit/UIProcess/WebPageProxy.cpp
Source/WebKit/UIProcess/WebPageProxy.h
Source/WebKit/UIProcess/ios/fullscreen/WKFullScreenViewController.mm
Source/WebKit/WebProcess/WebPage/WebPage.cpp
Source/WebKit/WebProcess/WebPage/WebPage.h
Source/WebKit/WebProcess/WebPage/WebPage.messages.in
Tools/ChangeLog
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WebKitCocoa/StopSuspendResumeAllMedia.mm [new file with mode: 0644]
Tools/TestWebKitAPI/Tests/WebKitLegacy/ios/ScrollingDoesNotPauseMedia.mm [new file with mode: 0644]