Add heuristic for "main content" videos which override user gesture requirements
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 10 Mar 2016 00:22:12 +0000 (00:22 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 10 Mar 2016 00:22:12 +0000 (00:22 +0000)
commit9d8c2a4ee4b549457392e914e903c5b6cc8800d5
treea0a351e8b9c8d9b4cf3033f7e3f97ebc43f7f95d
parent505661a07302f9a59ce2c88dd7f2686770c0d4a2
Add heuristic for "main content" videos which override user gesture requirements
https://bugs.webkit.org/show_bug.cgi?id=155224

Reviewed by Eric Carlson.

Source/WebCore:

Tests: media/video-main-content-allow-then-deny.html
       media/video-main-content-allow.html
       media/video-main-content-deny-display-none.html
       media/video-main-content-deny-not-in-dom.html
       media/video-main-content-deny-not-visible.html
       media/video-main-content-deny-obscured.html
       media/video-main-content-deny-too-small.html

Add a new behavior "restriction" to MediaElementSession that allows media elements
to optionally overriding their own user gesture requirements if the session determines
that the media element is the page's "main content".

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::didAttachRenderers):
(WebCore::HTMLMediaElement::updateShouldPlay):
* html/HTMLMediaElement.h:
* html/MediaElementSession.cpp:
(WebCore::restrictionName):
(WebCore::MediaElementSession::MediaElementSession):
(WebCore::MediaElementSession::addBehaviorRestriction):
(WebCore::MediaElementSession::playbackPermitted):
(WebCore::MediaElementSession::dataLoadingPermitted):
(WebCore::isMainContent):
(WebCore::MediaElementSession::mainContentCheckTimerFired):
(WebCore::MediaElementSession::updateIsMainContent):
* html/MediaElementSession.h:
* testing/Internals.cpp:
(WebCore::Internals::setMediaElementRestrictions):

LayoutTests:

* media/video-main-content-allow-expected.txt: Added.
* media/video-main-content-allow-then-deny-expected.txt: Added.
* media/video-main-content-allow-then-deny.html: Added.
* media/video-main-content-allow.html: Added.
* media/video-main-content-deny-display-none-expected.txt: Added.
* media/video-main-content-deny-display-none.html: Added.
* media/video-main-content-deny-not-in-dom-expected.txt: Added.
* media/video-main-content-deny-not-in-dom.html: Added.
* media/video-main-content-deny-not-visible-expected.txt: Added.
* media/video-main-content-deny-not-visible.html: Added.
* media/video-main-content-deny-obscured-expected.txt: Added.
* media/video-main-content-deny-obscured.html: Added.
* media/video-main-content-deny-too-small-expected.txt: Added.
* media/video-main-content-deny-too-small.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@197898 268f45cc-cd09-0410-ab3c-d52691b4dbfc
21 files changed:
LayoutTests/ChangeLog
LayoutTests/media/video-main-content-allow-expected.txt [new file with mode: 0644]
LayoutTests/media/video-main-content-allow-then-deny-expected.txt [new file with mode: 0644]
LayoutTests/media/video-main-content-allow-then-deny.html [new file with mode: 0644]
LayoutTests/media/video-main-content-allow.html [new file with mode: 0644]
LayoutTests/media/video-main-content-deny-display-none-expected.txt [new file with mode: 0644]
LayoutTests/media/video-main-content-deny-display-none.html [new file with mode: 0644]
LayoutTests/media/video-main-content-deny-not-in-dom-expected.txt [new file with mode: 0644]
LayoutTests/media/video-main-content-deny-not-in-dom.html [new file with mode: 0644]
LayoutTests/media/video-main-content-deny-not-visible-expected.txt [new file with mode: 0644]
LayoutTests/media/video-main-content-deny-not-visible.html [new file with mode: 0644]
LayoutTests/media/video-main-content-deny-obscured-expected.txt [new file with mode: 0644]
LayoutTests/media/video-main-content-deny-obscured.html [new file with mode: 0644]
LayoutTests/media/video-main-content-deny-too-small-expected.txt [new file with mode: 0644]
LayoutTests/media/video-main-content-deny-too-small.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLMediaElement.h
Source/WebCore/html/MediaElementSession.cpp
Source/WebCore/html/MediaElementSession.h
Source/WebCore/testing/Internals.cpp