Title: [203629] trunk
- Revision
- 203629
- Author
- wenson_hs...@apple.com
- Date
- 2016-07-22 17:47:32 -0700 (Fri, 22 Jul 2016)
Log Message
Media controls should be displayed for media in media documents
https://bugs.webkit.org/show_bug.cgi?id=160104
<rdar://problem/27438936>
Reviewed by Myles C. Maxfield.
Source/WebCore:
Make videos that would otherwise not have been large enough or have the right
aspect ratio cause media controls to appear. This is because media elements in
a media document are implied to be main content.
Added a new API test.
* html/MediaElementSession.cpp:
(WebCore::MediaElementSession::canControlControlsManager):
Tools:
Verifies that even a small video with audio in a media document gets media controls.
* TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm:
(TestWebKitAPI::TEST):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (203628 => 203629)
--- trunk/Source/WebCore/ChangeLog 2016-07-22 23:48:14 UTC (rev 203628)
+++ trunk/Source/WebCore/ChangeLog 2016-07-23 00:47:32 UTC (rev 203629)
@@ -1,3 +1,20 @@
+2016-07-22 Wenson Hsieh <wenson_hs...@apple.com>
+
+ Media controls should be displayed for media in media documents
+ https://bugs.webkit.org/show_bug.cgi?id=160104
+ <rdar://problem/27438936>
+
+ Reviewed by Myles C. Maxfield.
+
+ Make videos that would otherwise not have been large enough or have the right
+ aspect ratio cause media controls to appear. This is because media elements in
+ a media document are implied to be main content.
+
+ Added a new API test.
+
+ * html/MediaElementSession.cpp:
+ (WebCore::MediaElementSession::canControlControlsManager):
+
2016-07-22 Myles C. Maxfield <mmaxfi...@apple.com>
All dancers with bunny ears are female
Modified: trunk/Source/WebCore/html/MediaElementSession.cpp (203628 => 203629)
--- trunk/Source/WebCore/html/MediaElementSession.cpp 2016-07-22 23:48:14 UTC (rev 203628)
+++ trunk/Source/WebCore/html/MediaElementSession.cpp 2016-07-23 00:47:32 UTC (rev 203629)
@@ -254,6 +254,11 @@
return false;
}
+ if (m_element.document().isMediaDocument()) {
+ LOG(Media, "MediaElementSession::canControlControlsManager - returning TRUE: Is media document");
+ return true;
+ }
+
if (!m_element.hasVideo()) {
LOG(Media, "MediaElementSession::canControlControlsManager - returning FALSE: No video");
return false;
Modified: trunk/Tools/ChangeLog (203628 => 203629)
--- trunk/Tools/ChangeLog 2016-07-22 23:48:14 UTC (rev 203628)
+++ trunk/Tools/ChangeLog 2016-07-23 00:47:32 UTC (rev 203629)
@@ -1,3 +1,16 @@
+2016-07-22 Wenson Hsieh <wenson_hs...@apple.com>
+
+ Media controls should be displayed for media in media documents
+ https://bugs.webkit.org/show_bug.cgi?id=160104
+ <rdar://problem/27438936>
+
+ Reviewed by Myles C. Maxfield.
+
+ Verifies that even a small video with audio in a media document gets media controls.
+
+ * TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm:
+ (TestWebKitAPI::TEST):
+
2016-07-22 Michael Saboff <msab...@apple.com>
REGRESSION(203616): no FTL testing was inadvertently removed
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm (203628 => 203629)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm 2016-07-22 23:48:14 UTC (rev 203628)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm 2016-07-23 00:47:32 UTC (rev 203629)
@@ -235,6 +235,36 @@
TestWebKitAPI::Util::run(&receivedScriptMessage);
}
+TEST(VideoControlsManager, VideoControlsManagerSmallVideoInMediaDocument)
+{
+ RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+ configuration.get().mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone;
+ RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) configuration:configuration.get()]);
+
+ RetainPtr<NSWindow> window = adoptNS([[NSWindow alloc] initWithContentRect:[webView frame] styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]);
+ [[window contentView] addSubview:webView.get()];
+
+ __block bool finishedLoad = false;
+ dispatch_block_t handleFinishedLoad = ^()
+ {
+ finishedLoad = true;
+ };
+ OnLoadMessageHandler *handler = [[OnLoadMessageHandler alloc] initWithWKWebView:webView.get() handler:handleFinishedLoad];
+
+ NSString *_onloadScript_ = @"window._onload_ = function() { window.webkit.messageHandlers.onloadHandler.postMessage('loaded'); }";
+ WKUserScript *script = [[WKUserScript alloc] initWithSource:onloadScript injectionTime:WKUserScriptInjectionTimeAtDocumentStart forMainFrameOnly:NO];
+ [[configuration userContentController] addUserScript:script];
+ [[configuration userContentController] addScriptMessageHandler:handler name:@"onloadHandler"];
+
+ NSURL *urlOfVideo = [[NSBundle mainBundle] URLForResource:@"video-with-audio" withExtension:@"mp4" subdirectory:@"TestWebKitAPI.resources"];
+ [webView loadFileURL:urlOfVideo allowingReadAccessToURL:[urlOfVideo URLByDeletingLastPathComponent]];
+
+ TestWebKitAPI::Util::run(&finishedLoad);
+
+ // We expect the media controller to be present because this is a media document.
+ EXPECT_TRUE([webView _hasActiveVideoForControlsManager]);
+}
+
} // namespace TestWebKitAPI
#endif // WK_API_ENABLED && PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes