Diff
Modified: branches/safari-602.1.32-branch/LayoutTests/ChangeLog (201000 => 201001)
--- branches/safari-602.1.32-branch/LayoutTests/ChangeLog 2016-05-17 06:36:52 UTC (rev 201000)
+++ branches/safari-602.1.32-branch/LayoutTests/ChangeLog 2016-05-17 08:46:49 UTC (rev 201001)
@@ -1,3 +1,19 @@
+2016-05-17 Babak Shafiei <[email protected]>
+
+ Merge r200778. rdar://problem/25840861
+
+ 2016-05-12 Eric Carlson <[email protected]>
+
+ Adjust "main content" video heuristic
+ https://bugs.webkit.org/show_bug.cgi?id=157532
+
+ Reviewed by Darin Adler.
+
+ * media/video-main-content-allow.html:
+ * media/video-main-content-autoplay-expected.txt: Added.
+ * media/video-main-content-autoplay.html: Added.
+ * media/video-main-content-deny-too-small.html:
+
2016-05-09 Simon Fraser <[email protected]>
Remove testRunner.setTextAutosizingEnabled and migrate the one test that uses it
Modified: branches/safari-602.1.32-branch/LayoutTests/media/video-main-content-allow.html (201000 => 201001)
--- branches/safari-602.1.32-branch/LayoutTests/media/video-main-content-allow.html 2016-05-17 06:36:52 UTC (rev 201000)
+++ branches/safari-602.1.32-branch/LayoutTests/media/video-main-content-allow.html 2016-05-17 08:46:49 UTC (rev 201001)
@@ -22,8 +22,8 @@
</script>
<style>
video {
- width: 600px;
- height: 400px;
+ width: 270px;
+ height: 480px;
}
</style>
</head>
Added: branches/safari-602.1.32-branch/LayoutTests/media/video-main-content-autoplay-expected.txt (0 => 201001)
--- branches/safari-602.1.32-branch/LayoutTests/media/video-main-content-autoplay-expected.txt (rev 0)
+++ branches/safari-602.1.32-branch/LayoutTests/media/video-main-content-autoplay-expected.txt 2016-05-17 08:46:49 UTC (rev 201001)
@@ -0,0 +1,13 @@
+RUN(smallVideo.setAttribute('controls','controls'))
+RUN(smallVideo.setAttribute('autoplay','autoplay'))
+RUN(smallVideo.setAttribute('id','small'))
+RUN(document.body.appendChild(smallVideo))
+
+RUN(largeVideo.setAttribute('controls','controls'))
+RUN(largeVideo.setAttribute('autoplay','autoplay'))
+RUN(largeVideo.setAttribute('id','large'))
+RUN(document.body.appendChild(largeVideo))
+
+Large video auto-played, small video did not. OK
+END OF TEST
+
Added: branches/safari-602.1.32-branch/LayoutTests/media/video-main-content-autoplay.html (0 => 201001)
--- branches/safari-602.1.32-branch/LayoutTests/media/video-main-content-autoplay.html (rev 0)
+++ branches/safari-602.1.32-branch/LayoutTests/media/video-main-content-autoplay.html 2016-05-17 08:46:49 UTC (rev 201001)
@@ -0,0 +1,75 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>video-main-content-size-check</title>
+ <script src=""
+ <script src=""
+ <script>
+ var smallVideo;
+ var largeVideo;
+ var counter = 0;
+
+ function maybeEndTest()
+ {
+ if (++counter < 2)
+ return;
+
+ logResult(true, 'Large video auto-played, small video did not.');
+ endTest();
+ }
+
+ function playing(event)
+ {
+ if (event.target == smallVideo)
+ failTest('Small video should not autoplay.');
+ else
+ maybeEndTest();
+ }
+
+ function canPlayThrough(event)
+ {
+ if (event.target == smallVideo)
+ setTimeout(maybeEndTest, 100);
+ }
+
+ function go()
+ {
+ smallVideo = document.createElement('video');
+ internals.setMediaElementRestrictions(smallVideo, "RequireUserGestureForVideoRateChange,OverrideUserGestureRequirementForMainContent");
+ run("smallVideo.setAttribute('controls','controls')");
+ run("smallVideo.setAttribute('autoplay','autoplay')");
+ run("smallVideo.setAttribute('id','small')");
+ smallVideo.addEventListener('canplaythrough', canPlayThrough, true);
+ smallVideo.addEventListener('playing', playing, true);
+ run("document.body.appendChild(smallVideo)");
+
+ consoleWrite("");
+ largeVideo = document.createElement('video');
+ internals.setMediaElementRestrictions(largeVideo, "RequireUserGestureForVideoRateChange,OverrideUserGestureRequirementForMainContent");
+ run("largeVideo.setAttribute('controls','controls')");
+ run("largeVideo.setAttribute('autoplay','autoplay')");
+ run("largeVideo.setAttribute('id','large')");
+ largeVideo.addEventListener('canplaythrough', canPlayThrough, true);
+ largeVideo.addEventListener('playing', playing, true);
+ run("document.body.appendChild(largeVideo)");
+
+ consoleWrite("");
+ smallVideo.src = "" 'content/test');
+ largeVideo.src = "" 'content/test');
+ }
+
+ </script>
+ <style>
+ #large {
+ width: 270px;
+ height: 480px;
+ }
+ #small {
+ width: 400;
+ height: 240;
+ }
+ </style>
+ </head>
+ <body _onload_="go()">
+ </body>
+</html>
\ No newline at end of file
Modified: branches/safari-602.1.32-branch/LayoutTests/media/video-main-content-deny-too-small.html (201000 => 201001)
--- branches/safari-602.1.32-branch/LayoutTests/media/video-main-content-deny-too-small.html 2016-05-17 06:36:52 UTC (rev 201000)
+++ branches/safari-602.1.32-branch/LayoutTests/media/video-main-content-deny-too-small.html 2016-05-17 08:46:49 UTC (rev 201001)
@@ -7,6 +7,7 @@
<script>
function go() {
video = document.createElement('video');
+ video.controls = ""
run('internals.setMediaElementRestrictions(video, "RequireUserGestureForVideoRateChange,OverrideUserGestureRequirementForMainContent")');
document.body.appendChild(video);
@@ -27,8 +28,8 @@
</script>
<style>
video {
- width: 200px;
- height: 100px;
+ width: 400px;
+ height: 299px;
}
</style>
</head>
Modified: branches/safari-602.1.32-branch/Source/WebCore/ChangeLog (201000 => 201001)
--- branches/safari-602.1.32-branch/Source/WebCore/ChangeLog 2016-05-17 06:36:52 UTC (rev 201000)
+++ branches/safari-602.1.32-branch/Source/WebCore/ChangeLog 2016-05-17 08:46:49 UTC (rev 201001)
@@ -1,3 +1,24 @@
+2016-05-17 Babak Shafiei <[email protected]>
+
+ Merge r200778. rdar://problem/25840861
+
+ 2016-05-12 Eric Carlson <[email protected]>
+
+ Adjust "main content" video heuristic
+ https://bugs.webkit.org/show_bug.cgi?id=157532
+ <rdar://problem/25840861>
+
+ Reviewed by Darin Adler.
+
+ Test: media/video-main-content-autoplay.html, plus existing tests updated.
+
+ * html/MediaElementSession.cpp:
+ (WebCore::MediaElementSession::canControlControlsManager): Use isElementLargeEnoughForMainContent.
+ (WebCore::isMainContent): Ditto.
+ (WebCore::isElementLargeEnoughForMainContent): Check video area and aspect ratio.
+ (WebCore::MediaElementSession::mainContentCheckTimerFired): Call result.setToNonUserAgentShadowAncestor
+ so it doesn't hit test the video controls in the shadow DOM.
+
2016-05-16 Dean Jackson <[email protected]>
Disable some features on safari-602.1.32-branch.
Modified: branches/safari-602.1.32-branch/Source/WebCore/html/MediaElementSession.cpp (201000 => 201001)
--- branches/safari-602.1.32-branch/Source/WebCore/html/MediaElementSession.cpp 2016-05-17 06:36:52 UTC (rev 201000)
+++ branches/safari-602.1.32-branch/Source/WebCore/html/MediaElementSession.cpp 2016-05-17 08:46:49 UTC (rev 201001)
@@ -54,11 +54,10 @@
namespace WebCore {
-static const int elementMainContentMinimumWidth = 400;
-static const int elementMainContentMinimumHeight = 300;
static const double elementMainContentCheckInterval = .250;
static bool isMainContent(const HTMLMediaElement&);
+static bool isElementLargeEnoughForMainContent(const HTMLMediaElement&);
#if !LOG_DISABLED
static String restrictionName(MediaElementSession::BehaviorRestrictions restriction)
@@ -224,8 +223,8 @@
if (!renderer)
return false;
- if (element.hasVideo() && renderer->clientWidth() >= elementMainContentMinimumWidth && renderer->clientHeight() >= elementMainContentMinimumHeight)
- return true;
+ if (isElementLargeEnoughForMainContent(element))
+ return true;
if (ScriptController::processingUserGestureForMedia())
return true;
@@ -506,8 +505,7 @@
if (!renderer)
return false;
- if (renderer->clientWidth() < elementMainContentMinimumWidth
- || renderer->clientHeight() < elementMainContentMinimumHeight)
+ if (!isElementLargeEnoughForMainContent(element))
return false;
// Elements which are hidden by style, or have been scrolled out of view, cannot be main content.
@@ -535,6 +533,7 @@
// Elements which are obscured by other elements cannot be main content.
mainRenderView.hitTest(request, result);
+ result.setToNonUserAgentShadowAncestor();
Element* hitElement = result.innerElement();
if (hitElement != &element)
return false;
@@ -542,6 +541,24 @@
return true;
}
+static bool isElementLargeEnoughForMainContent(const HTMLMediaElement& element)
+{
+ static const double elementMainContentAreaMinimum = 400 * 300;
+ static const double maximumAspectRatio = 1.8; // Slightly larger than 16:9.
+ static const double minimumAspectRatio = .5; // Slightly smaller than 16:9.
+
+ // Elements which have not yet been laid out, or which are not yet in the DOM, cannot be main content.
+ RenderBox* renderer = downcast<RenderBox>(element.renderer());
+ if (!renderer)
+ return false;
+
+ double width = renderer->clientWidth();
+ double height = renderer->clientHeight();
+ double area = width * height;
+ double aspectRatio = width / height;
+ return area >= elementMainContentAreaMinimum && aspectRatio >= minimumAspectRatio && aspectRatio <= maximumAspectRatio;
+}
+
void MediaElementSession::mainContentCheckTimerFired()
{
if (!hasBehaviorRestriction(OverrideUserGestureRequirementForMainContent))