Diff
Modified: branches/safari-602-branch/Source/WebCore/ChangeLog (205798 => 205799)
--- branches/safari-602-branch/Source/WebCore/ChangeLog 2016-09-12 07:53:52 UTC (rev 205798)
+++ branches/safari-602-branch/Source/WebCore/ChangeLog 2016-09-12 07:53:56 UTC (rev 205799)
@@ -1,5 +1,36 @@
2016-09-12 Babak Shafiei <[email protected]>
+ Merge r205784. rdar://problem/28230123
+
+ 2016-09-10 Wenson Hsieh <[email protected]>
+
+ Apple.com keynote does not display media controls
+ https://bugs.webkit.org/show_bug.cgi?id=161833
+ <rdar://problem/28230123>
+
+ Reviewed by Tim Horton.
+
+ Tweaks the main content check so that we can distinguish between main content for the purposes of determining
+ autoplay policy vs. main content for the purposes of showing media controls. Namely, we make the latter less
+ restrictive than the former in terms of the maximum aspect ratio a video can have to be considered the right
+ size for main content.
+
+ New unit test in TestWebKitAPI.
+
+ * html/HTMLMediaElement.cpp:
+ (WebCore::mediaElementSessionInfoForSession):
+ * html/MediaElementSession.cpp:
+ (WebCore::MediaElementSession::canShowControlsManager):
+ (WebCore::MediaElementSession::isLargeEnoughForMainContent):
+ (WebCore::MediaElementSession::wantsToObserveViewportVisibilityForMediaControls):
+ (WebCore::isMainContentForPurposesOfAutoplay):
+ (WebCore::isElementLargeEnoughForMainContent):
+ (WebCore::MediaElementSession::updateIsMainContent):
+ (WebCore::isMainContent): Deleted.
+ * html/MediaElementSession.h:
+
+2016-09-12 Babak Shafiei <[email protected]>
+
Merge r205765. rdar://problem/28033492
2016-09-09 Tim Horton <[email protected]>
Modified: branches/safari-602-branch/Source/WebCore/html/HTMLMediaElement.cpp (205798 => 205799)
--- branches/safari-602-branch/Source/WebCore/html/HTMLMediaElement.cpp 2016-09-12 07:53:52 UTC (rev 205798)
+++ branches/safari-602-branch/Source/WebCore/html/HTMLMediaElement.cpp 2016-09-12 07:53:56 UTC (rev 205799)
@@ -364,7 +364,7 @@
session.mostRecentUserInteractionTime(),
session.canShowControlsManager(),
element.isFullscreen() || element.isVisibleInViewport(),
- session.isLargeEnoughForMainContent(),
+ session.isLargeEnoughForMainContent(MediaSessionMainContentPurpose::MediaControls),
element.isPlaying() && element.hasAudio() && !element.muted()
};
}
Modified: branches/safari-602-branch/Source/WebCore/html/MediaElementSession.cpp (205798 => 205799)
--- branches/safari-602-branch/Source/WebCore/html/MediaElementSession.cpp 2016-09-12 07:53:52 UTC (rev 205798)
+++ branches/safari-602-branch/Source/WebCore/html/MediaElementSession.cpp 2016-09-12 07:53:56 UTC (rev 205799)
@@ -59,8 +59,7 @@
static const double elementMainContentCheckInterval = .250;
-static bool isMainContent(const HTMLMediaElement&);
-static bool isElementLargeEnoughForMainContent(const HTMLMediaElement&);
+static bool isElementLargeEnoughForMainContent(const HTMLMediaElement&, MediaSessionMainContentPurpose);
#if !LOG_DISABLED
static String restrictionName(MediaElementSession::BehaviorRestrictions restriction)
@@ -274,7 +273,7 @@
return false;
}
- if (isLargeEnoughForMainContent()) {
+ if (isLargeEnoughForMainContent(MediaSessionMainContentPurpose::MediaControls)) {
LOG(Media, "MediaElementSession::canShowControlsManager - returning TRUE: Is main content");
return true;
}
@@ -284,9 +283,9 @@
return false;
}
-bool MediaElementSession::isLargeEnoughForMainContent() const
+bool MediaElementSession::isLargeEnoughForMainContent(MediaSessionMainContentPurpose purpose) const
{
- return isElementLargeEnoughForMainContent(m_element);
+ return isElementLargeEnoughForMainContent(m_element, purpose);
}
double MediaElementSession::mostRecentUserInteractionTime() const
@@ -296,7 +295,7 @@
bool MediaElementSession::wantsToObserveViewportVisibilityForMediaControls() const
{
- return isLargeEnoughForMainContent();
+ return isLargeEnoughForMainContent(MediaSessionMainContentPurpose::MediaControls);
}
bool MediaElementSession::wantsToObserveViewportVisibilityForAutoplay() const
@@ -582,7 +581,7 @@
}
#endif
-static bool isMainContent(const HTMLMediaElement& element)
+static bool isMainContentForPurposesOfAutoplay(const HTMLMediaElement& element)
{
if (!element.hasAudio() || !element.hasVideo())
return false;
@@ -592,7 +591,7 @@
if (!renderer)
return false;
- if (!isElementLargeEnoughForMainContent(element))
+ if (!isElementLargeEnoughForMainContent(element, MediaSessionMainContentPurpose::Autoplay))
return false;
// Elements which are hidden by style, or have been scrolled out of view, cannot be main content.
@@ -652,10 +651,10 @@
return maxVisibleClientWidth * maxVisibleClientHeight > minimumPercentageOfMainFrameAreaForMainContent * mainFrameView.visibleWidth() * mainFrameView.visibleHeight();
}
-static bool isElementLargeEnoughForMainContent(const HTMLMediaElement& element)
+static bool isElementLargeEnoughForMainContent(const HTMLMediaElement& element, MediaSessionMainContentPurpose purpose)
{
static const double elementMainContentAreaMinimum = 400 * 300;
- static const double maximumAspectRatio = 1.8; // Slightly larger than 16:9.
+ static const double maximumAspectRatio = purpose == MediaSessionMainContentPurpose::MediaControls ? 3 : 1.8;
static const double minimumAspectRatio = .5; // Slightly smaller than 9:16.
// Elements which have not yet been laid out, or which are not yet in the DOM, cannot be main content.
@@ -688,7 +687,7 @@
bool MediaElementSession::updateIsMainContent() const
{
bool wasMainContent = m_isMainContent;
- m_isMainContent = isMainContent(m_element);
+ m_isMainContent = isMainContentForPurposesOfAutoplay(m_element);
if (m_isMainContent != wasMainContent)
m_element.updateShouldPlay();
Modified: branches/safari-602-branch/Source/WebCore/html/MediaElementSession.h (205798 => 205799)
--- branches/safari-602-branch/Source/WebCore/html/MediaElementSession.h 2016-09-12 07:53:52 UTC (rev 205798)
+++ branches/safari-602-branch/Source/WebCore/html/MediaElementSession.h 2016-09-12 07:53:56 UTC (rev 205799)
@@ -35,6 +35,11 @@
namespace WebCore {
+enum class MediaSessionMainContentPurpose {
+ MediaControls,
+ Autoplay
+};
+
class Document;
class HTMLMediaElement;
class SourceBuffer;
@@ -114,7 +119,7 @@
bool wantsToObserveViewportVisibilityForMediaControls() const;
bool wantsToObserveViewportVisibilityForAutoplay() const;
bool canShowControlsManager() const;
- bool isLargeEnoughForMainContent() const;
+ bool isLargeEnoughForMainContent(MediaSessionMainContentPurpose) const;
double mostRecentUserInteractionTime() const;
private:
Modified: branches/safari-602-branch/Tools/ChangeLog (205798 => 205799)
--- branches/safari-602-branch/Tools/ChangeLog 2016-09-12 07:53:52 UTC (rev 205798)
+++ branches/safari-602-branch/Tools/ChangeLog 2016-09-12 07:53:56 UTC (rev 205799)
@@ -1,5 +1,24 @@
2016-09-12 Babak Shafiei <[email protected]>
+ Merge r205784. rdar://problem/28230123
+
+ 2016-09-10 Wenson Hsieh <[email protected]>
+
+ Apple.com keynote does not display media controls
+ https://bugs.webkit.org/show_bug.cgi?id=161833
+ <rdar://problem/28230123>
+
+ Reviewed by Tim Horton.
+
+ New unit test verifying that wide videos (~2 aspect ratio) still get media controls.
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm:
+ (TestWebKitAPI::TEST):
+ * TestWebKitAPI/Tests/WebKit2Cocoa/wide-autoplaying-video-with-audio.html: Added.
+
+2016-09-12 Babak Shafiei <[email protected]>
+
Merge r205783. rdar://problem/28229756
2016-09-09 Tim Horton <[email protected]>
Modified: branches/safari-602-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (205798 => 205799)
--- branches/safari-602-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2016-09-12 07:53:52 UTC (rev 205798)
+++ branches/safari-602-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2016-09-12 07:53:56 UTC (rev 205799)
@@ -55,6 +55,7 @@
2DD7D3AF178227B30026E1E3 /* lots-of-text-vertical-lr.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2DD7D3AE178227AC0026E1E3 /* lots-of-text-vertical-lr.html */; };
2DE71AFE1D49C0BD00904094 /* AnimatedResize.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2DE71AFD1D49C0BD00904094 /* AnimatedResize.mm */; };
2DE71B001D49C3ED00904094 /* blinking-div.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2DE71AFF1D49C2F000904094 /* blinking-div.html */; };
+ 2E131C181D83A98A001BA36C /* wide-autoplaying-video-with-audio.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2E131C171D83A97E001BA36C /* wide-autoplaying-video-with-audio.html */; };
2E14A5291D3FE96B0010F35B /* autoplaying-video-with-audio.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2E14A5281D3FE8B80010F35B /* autoplaying-video-with-audio.html */; };
2E1B7B001D41ABA7007558B4 /* large-video-seek-after-ending.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2E1B7AFF1D41A95F007558B4 /* large-video-seek-after-ending.html */; };
2E1B7B021D41B1B9007558B4 /* large-video-hides-controls-after-seek-to-end.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2E1B7B011D41B1B3007558B4 /* large-video-hides-controls-after-seek-to-end.html */; };
@@ -570,6 +571,7 @@
7AE9E5091AE5AE8B00CF874B /* test.pdf in Copy Resources */,
7A1458FC1AD5C07000E06772 /* mouse-button-listener.html in Copy Resources */,
7C486BA11AA12567003F6F9B /* bundle-file.html in Copy Resources */,
+ 2E131C181D83A98A001BA36C /* wide-autoplaying-video-with-audio.html in Copy Resources */,
2E54F40D1D7BC84200921ADF /* large-video-mutes-onplaying.html in Copy Resources */,
2E691AF31D79E75E00129407 /* large-video-playing-scroll-away.html in Copy Resources */,
2E691AF11D79E51A00129407 /* large-videos-autoplaying-scroll-to-video.html in Copy Resources */,
@@ -732,6 +734,7 @@
2DD7D3AE178227AC0026E1E3 /* lots-of-text-vertical-lr.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "lots-of-text-vertical-lr.html"; sourceTree = "<group>"; };
2DE71AFD1D49C0BD00904094 /* AnimatedResize.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AnimatedResize.mm; sourceTree = "<group>"; };
2DE71AFF1D49C2F000904094 /* blinking-div.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "blinking-div.html"; sourceTree = "<group>"; };
+ 2E131C171D83A97E001BA36C /* wide-autoplaying-video-with-audio.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "wide-autoplaying-video-with-audio.html"; sourceTree = "<group>"; };
2E14A5281D3FE8B80010F35B /* autoplaying-video-with-audio.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "autoplaying-video-with-audio.html"; sourceTree = "<group>"; };
2E1B7AFF1D41A95F007558B4 /* large-video-seek-after-ending.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "large-video-seek-after-ending.html"; sourceTree = "<group>"; };
2E1B7B011D41B1B3007558B4 /* large-video-hides-controls-after-seek-to-end.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "large-video-hides-controls-after-seek-to-end.html"; sourceTree = "<group>"; };
@@ -1390,6 +1393,7 @@
2E1DFDF01D42E14400714A00 /* large-video-seek-to-beginning-and-play-after-ending.html */,
2E1B7B011D41B1B3007558B4 /* large-video-hides-controls-after-seek-to-end.html */,
2E1DFDEE1D42A6EB00714A00 /* large-videos-with-audio-autoplay.html */,
+ 2E131C171D83A97E001BA36C /* wide-autoplaying-video-with-audio.html */,
2E54F40C1D7BC83900921ADF /* large-video-mutes-onplaying.html */,
2E691AF21D79E75400129407 /* large-video-playing-scroll-away.html */,
2E691AF01D79E51400129407 /* large-videos-autoplaying-scroll-to-video.html */,
Modified: branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm (205798 => 205799)
--- branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm 2016-09-12 07:53:52 UTC (rev 205798)
+++ branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm 2016-09-12 07:53:56 UTC (rev 205799)
@@ -411,6 +411,14 @@
[webView expectControlsManager:NO afterReceivingMessage:@"playing"];
}
+TEST(VideoControlsManager, VideoControlsManagerWideMediumSizedVideoInWideMainFrame)
+{
+ RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 1600, 800));
+
+ [webView loadTestPageNamed:@"wide-autoplaying-video-with-audio"];
+ [webView expectControlsManager:YES afterReceivingMessage:@"playing"];
+}
+
TEST(VideoControlsManager, VideoControlsManagerFullSizeVideoInWideMainFrame)
{
RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 1600, 800));
Added: branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/wide-autoplaying-video-with-audio.html (0 => 205799)
--- branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/wide-autoplaying-video-with-audio.html (rev 0)
+++ branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/wide-autoplaying-video-with-audio.html 2016-09-12 07:53:56 UTC (rev 205799)
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <style>
+ video {
+ width: 800px;
+ height: 400px;
+ }
+ </style>
+ <script>
+ function finishTest() {
+ setTimeout(function() {
+ try {
+ window.webkit.messageHandlers.playingHandler.postMessage("playing");
+ } catch(e) { }
+ }, 0);
+ }
+ </script>
+</head>
+<body>
+ <video autoplay src="" webkit-playsinline _onplaying_=finishTest()></video>
+</body>
+</html>