Diff
Modified: trunk/LayoutTests/ChangeLog (263706 => 263707)
--- trunk/LayoutTests/ChangeLog 2020-06-29 23:31:45 UTC (rev 263706)
+++ trunk/LayoutTests/ChangeLog 2020-06-29 23:32:18 UTC (rev 263707)
@@ -1,3 +1,13 @@
+2020-06-29 Peng Liu <peng.l...@apple.com>
+
+ Video spills over PiP screen a little when using Picture in Picture
+ https://bugs.webkit.org/show_bug.cgi?id=213658
+
+ Reviewed by Eric Carlson.
+
+ * media/picture-in-picture/picture-in-picture-window-aspect-ratio-expected.txt: Added.
+ * media/picture-in-picture/picture-in-picture-window-aspect-ratio.html: Added.
+
2020-06-29 Karl Rackler <rack...@apple.com>
Remove expectation for svg/W3C-SVG-1.1/fonts-elem-01-t.svg and svg/W3C-SVG-1.1/fonts-elem-02-t.svg and svg/W3C-SVG-1.1/fonts-elem-03-b.svg and svg/W3C-SVG-1.1/fonts-elem-07-b.svg as they are passing.
Added: trunk/LayoutTests/media/picture-in-picture/picture-in-picture-window-aspect-ratio-expected.txt (0 => 263707)
--- trunk/LayoutTests/media/picture-in-picture/picture-in-picture-window-aspect-ratio-expected.txt (rev 0)
+++ trunk/LayoutTests/media/picture-in-picture/picture-in-picture-window-aspect-ratio-expected.txt 2020-06-29 23:32:18 UTC (rev 263707)
@@ -0,0 +1,9 @@
+Tests that a pip window has the same aspect ratio as the video content.
+
+RUN(internals.settings.setAllowsPictureInPictureMediaPlayback(true))
+RUN(internals.setMockVideoPresentationModeEnabled(true))
+RUN(video.src = "" "../content/test"))
+EVENT(canplaythrough)
+EXPECTED (Math.abs(pipWindow.height / pipWindow.width - 240 / 320) < '0.01') OK
+END OF TEST
+
Added: trunk/LayoutTests/media/picture-in-picture/picture-in-picture-window-aspect-ratio.html (0 => 263707)
--- trunk/LayoutTests/media/picture-in-picture/picture-in-picture-window-aspect-ratio.html (rev 0)
+++ trunk/LayoutTests/media/picture-in-picture/picture-in-picture-window-aspect-ratio.html 2020-06-29 23:32:18 UTC (rev 263707)
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <script src=""
+ <script src=""
+ <script>
+ window.addEventListener('load', async event => {
+ if (!window.internals) {
+ failTest('This test requires window.internals.');
+ return;
+ }
+
+ findMediaElement();
+
+ run('internals.settings.setAllowsPictureInPictureMediaPlayback(true)');
+ run('internals.setMockVideoPresentationModeEnabled(true)');
+
+ run('video.src = "" "../content/test")');
+ await waitFor(video, 'canplaythrough');
+
+ runWithKeyDown(() => {
+ video.requestPictureInPicture()
+ .then(pipWindow => {
+ window.pipWindow = pipWindow;
+ // Compare floating point numbers with the precision 0.01
+ testExpected('Math.abs(pipWindow.height / pipWindow.width - 240 / 320)', 0.01, '<');
+
+ document.exitPictureInPicture().then(endTest).catch(() => {
+ failTest('Failed to exit the Picture-in-Picture mode.');
+ });
+ })
+ .catch(error => {
+ failTest("Failed to enter the Picture-in-Picture mode.");
+ });
+ });
+ });
+ </script>
+</head>
+<body>
+ <div>Tests that a pip window has the same aspect ratio as the video content.</div>
+ <video controls width="2" height="2"></video>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (263706 => 263707)
--- trunk/Source/WebCore/ChangeLog 2020-06-29 23:31:45 UTC (rev 263706)
+++ trunk/Source/WebCore/ChangeLog 2020-06-29 23:32:18 UTC (rev 263707)
@@ -1,3 +1,22 @@
+2020-06-29 Peng Liu <peng.l...@apple.com>
+
+ Video spills over PiP screen a little when using Picture in Picture
+ https://bugs.webkit.org/show_bug.cgi?id=213658
+
+ Reviewed by Eric Carlson.
+
+ We need to provide video content dimensions instead of video element sizes to
+ AVPlayerController to make sure that the Picture-in-Picture window will have
+ the correct aspect ratio.
+
+ Test: media/picture-in-picture/picture-in-picture-window-aspect-ratio.html
+
+ * platform/ios/VideoFullscreenInterfaceAVKit.h:
+ * platform/ios/VideoFullscreenInterfaceAVKit.mm:
+ (VideoFullscreenInterfaceAVKit::setupFullscreen):
+ * platform/ios/WebVideoFullscreenControllerAVKit.mm:
+ (VideoFullscreenControllerContext::setUpFullscreen):
+
2020-06-29 Tetsuharu Ohzeki <tetsuharu.ohz...@gmail.com>
Remove ENABLE_STREAMS_API compilation flag
Modified: trunk/Source/WebCore/platform/ios/VideoFullscreenInterfaceAVKit.h (263706 => 263707)
--- trunk/Source/WebCore/platform/ios/VideoFullscreenInterfaceAVKit.h 2020-06-29 23:31:45 UTC (rev 263706)
+++ trunk/Source/WebCore/platform/ios/VideoFullscreenInterfaceAVKit.h 2020-06-29 23:32:18 UTC (rev 263707)
@@ -79,7 +79,7 @@
// PlaybackSessionModelClient
WEBCORE_EXPORT void externalPlaybackChanged(bool enabled, PlaybackSessionModel::ExternalPlaybackTargetType, const String& localizedDeviceName) final;
- WEBCORE_EXPORT void setupFullscreen(UIView&, const IntRect& initialRect, UIView *, HTMLMediaElementEnums::VideoFullscreenMode, bool allowsPictureInPicturePlayback, bool standby);
+ WEBCORE_EXPORT void setupFullscreen(UIView& videoView, const IntRect& initialRect, const FloatSize& videoDimensions, UIView* parentView, HTMLMediaElementEnums::VideoFullscreenMode, bool allowsPictureInPicturePlayback, bool standby);
WEBCORE_EXPORT void enterFullscreen();
WEBCORE_EXPORT void exitFullscreen(const IntRect& finalRect);
WEBCORE_EXPORT void cleanupFullscreen();
Modified: trunk/Source/WebCore/platform/ios/VideoFullscreenInterfaceAVKit.mm (263706 => 263707)
--- trunk/Source/WebCore/platform/ios/VideoFullscreenInterfaceAVKit.mm 2020-06-29 23:31:45 UTC (rev 263706)
+++ trunk/Source/WebCore/platform/ios/VideoFullscreenInterfaceAVKit.mm 2020-06-29 23:32:18 UTC (rev 263707)
@@ -889,7 +889,7 @@
LOG(Fullscreen, "VideoFullscreenInterfaceAVKit::applicationDidBecomeActive(%p)", this);
}
-void VideoFullscreenInterfaceAVKit::setupFullscreen(UIView& videoView, const IntRect& initialRect, UIView* parentView, HTMLMediaElementEnums::VideoFullscreenMode mode, bool allowsPictureInPicturePlayback, bool standby)
+void VideoFullscreenInterfaceAVKit::setupFullscreen(UIView& videoView, const IntRect& initialRect, const FloatSize& videoDimensions, UIView* parentView, HTMLMediaElementEnums::VideoFullscreenMode mode, bool allowsPictureInPicturePlayback, bool standby)
{
ASSERT(standby || mode != HTMLMediaElementEnums::VideoFullscreenModeNone);
LOG(Fullscreen, "VideoFullscreenInterfaceAVKit::setupFullscreen(%p)", this);
@@ -896,7 +896,7 @@
[playerController() setHasEnabledVideo:true];
[playerController() setHasVideo:true];
- [playerController() setContentDimensions:initialRect.size()];
+ [playerController() setContentDimensions:videoDimensions];
m_allowsPictureInPicturePlayback = allowsPictureInPicturePlayback;
m_videoView = &videoView;
Modified: trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm (263706 => 263707)
--- trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm 2020-06-29 23:31:45 UTC (rev 263706)
+++ trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm 2020-06-29 23:32:18 UTC (rev 263707)
@@ -981,7 +981,9 @@
FloatRect videoLayerFrame = FloatRect(FloatPoint(), videoElementClientRect.size());
m_fullscreenModel->setVideoLayerFrame(videoLayerFrame);
- dispatch_async(dispatch_get_main_queue(), [protectedThis = makeRefPtr(this), this, videoElementClientRect, viewRef, mode, allowsPictureInPicture] {
+ FloatSize videoDimensions = { (float)videoElement.videoWidth(), (float)videoElement.videoHeight() };
+
+ dispatch_async(dispatch_get_main_queue(), [protectedThis = makeRefPtr(this), this, videoElementClientRect, videoDimensions, viewRef, mode, allowsPictureInPicture] {
ASSERT(isUIThread());
WebThreadLock();
@@ -993,7 +995,7 @@
m_videoFullscreenView = adoptNS([PAL::allocUIViewInstance() init]);
- m_interface->setupFullscreen(*m_videoFullscreenView.get(), videoElementClientRect, viewRef.get(), mode, allowsPictureInPicture, false);
+ m_interface->setupFullscreen(*m_videoFullscreenView.get(), videoElementClientRect, videoDimensions, viewRef.get(), mode, allowsPictureInPicture, false);
});
}
Modified: trunk/Source/WebKit/ChangeLog (263706 => 263707)
--- trunk/Source/WebKit/ChangeLog 2020-06-29 23:31:45 UTC (rev 263706)
+++ trunk/Source/WebKit/ChangeLog 2020-06-29 23:32:18 UTC (rev 263707)
@@ -1,3 +1,21 @@
+2020-06-29 Peng Liu <peng.l...@apple.com>
+
+ Video spills over PiP screen a little when using Picture in Picture
+ https://bugs.webkit.org/show_bug.cgi?id=213658
+
+ Reviewed by Eric Carlson.
+
+ Add the video content dimensions to the IPC message VideoFullscreenManagerProxy::SetupFullscreenWithID.
+
+ * UIProcess/Cocoa/VideoFullscreenManagerProxy.h:
+ * UIProcess/Cocoa/VideoFullscreenManagerProxy.messages.in:
+ * UIProcess/Cocoa/VideoFullscreenManagerProxy.mm:
+ (WebKit::VideoFullscreenManagerProxy::setupFullscreenWithID):
+ (WebKit::VideoFullscreenManagerProxy::setVideoDimensions):
+ (WebKit::VideoFullscreenManagerProxy::enterFullscreen):
+ * WebProcess/cocoa/VideoFullscreenManager.mm:
+ (WebKit::VideoFullscreenManager::enterVideoFullscreenForVideoElement):
+
2020-06-29 Chris Dumez <cdu...@apple.com>
Unreviewed, reverting r262004.
Modified: trunk/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.h (263706 => 263707)
--- trunk/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.h 2020-06-29 23:31:45 UTC (rev 263706)
+++ trunk/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.h 2020-06-29 23:32:18 UTC (rev 263707)
@@ -55,6 +55,9 @@
namespace WebKit {
+constexpr size_t DefaultMockPictureInPictureWindowWidth = 100;
+constexpr size_t DefaultMockPictureInPictureWindowHeight = 100;
+
class WebPageProxy;
class PlaybackSessionManagerProxy;
class PlaybackSessionModelContext;
@@ -160,7 +163,7 @@
void hasVideoInPictureInPictureDidChange(bool);
// Messages from VideoFullscreenManager
- void setupFullscreenWithID(PlaybackSessionContextIdentifier, WebKit::LayerHostingContextID videoLayerID, const WebCore::IntRect& initialRect, float hostingScaleFactor, WebCore::HTMLMediaElementEnums::VideoFullscreenMode, bool allowsPictureInPicture, bool standby);
+ void setupFullscreenWithID(PlaybackSessionContextIdentifier, WebKit::LayerHostingContextID videoLayerID, const WebCore::IntRect& initialRect, const WebCore::FloatSize& videoDimensions, float hostingScaleFactor, WebCore::HTMLMediaElementEnums::VideoFullscreenMode, bool allowsPictureInPicture, bool standby);
void setInlineRect(PlaybackSessionContextIdentifier, const WebCore::IntRect& inlineRect, bool visible);
void setHasVideoContentLayer(PlaybackSessionContextIdentifier, bool value);
void setHasVideo(PlaybackSessionContextIdentifier, bool);
@@ -188,6 +191,7 @@
void fullscreenMayReturnToInline(PlaybackSessionContextIdentifier);
bool m_mockVideoPresentationModeEnabled { false };
+ WebCore::FloatSize m_mockPictureInPictureWindowSize { DefaultMockPictureInPictureWindowWidth, DefaultMockPictureInPictureWindowHeight };
WebPageProxy* m_page;
Ref<PlaybackSessionManagerProxy> m_playbackSessionManagerProxy;
Modified: trunk/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.messages.in (263706 => 263707)
--- trunk/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.messages.in 2020-06-29 23:31:45 UTC (rev 263706)
+++ trunk/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.messages.in 2020-06-29 23:32:18 UTC (rev 263707)
@@ -24,7 +24,7 @@
messages -> VideoFullscreenManagerProxy {
SetHasVideo(WebKit::PlaybackSessionContextIdentifier contextId, bool hasVideo)
SetVideoDimensions(WebKit::PlaybackSessionContextIdentifier contextId, WebCore::FloatSize videoDimensions)
- SetupFullscreenWithID(WebKit::PlaybackSessionContextIdentifier contextId, WebKit::LayerHostingContextID videoLayerID, WebCore::IntRect initialRect, float hostingScaleFactor, WebCore::HTMLMediaElementEnums::VideoFullscreenMode videoFullscreenMode, bool allowsPictureInPicture, bool standby)
+ SetupFullscreenWithID(WebKit::PlaybackSessionContextIdentifier contextId, WebKit::LayerHostingContextID videoLayerID, WebCore::IntRect initialRect, WebCore::FloatSize videoDimensions, float hostingScaleFactor, WebCore::HTMLMediaElementEnums::VideoFullscreenMode videoFullscreenMode, bool allowsPictureInPicture, bool standby)
EnterFullscreen(WebKit::PlaybackSessionContextIdentifier contextId)
ExitFullscreen(WebKit::PlaybackSessionContextIdentifier contextId, WebCore::IntRect finalRect)
SetInlineRect(WebKit::PlaybackSessionContextIdentifier contextId, WebCore::IntRect inlineRect, bool visible)
Modified: trunk/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.mm (263706 => 263707)
--- trunk/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.mm 2020-06-29 23:31:45 UTC (rev 263706)
+++ trunk/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.mm 2020-06-29 23:32:18 UTC (rev 263707)
@@ -506,7 +506,7 @@
#pragma mark Messages from VideoFullscreenManager
-void VideoFullscreenManagerProxy::setupFullscreenWithID(PlaybackSessionContextIdentifier contextId, WebKit::LayerHostingContextID videoLayerID, const WebCore::IntRect& initialRect, float hostingDeviceScaleFactor, HTMLMediaElementEnums::VideoFullscreenMode videoFullscreenMode, bool allowsPictureInPicture, bool standby)
+void VideoFullscreenManagerProxy::setupFullscreenWithID(PlaybackSessionContextIdentifier contextId, WebKit::LayerHostingContextID videoLayerID, const WebCore::IntRect& initialRect, const WebCore::FloatSize& videoDimensions, float hostingDeviceScaleFactor, HTMLMediaElementEnums::VideoFullscreenMode videoFullscreenMode, bool allowsPictureInPicture, bool standby)
{
MESSAGE_CHECK(videoLayerID);
@@ -514,6 +514,8 @@
addClientForContext(contextId);
if (m_mockVideoPresentationModeEnabled) {
+ if (!videoDimensions.isEmpty())
+ m_mockPictureInPictureWindowSize.setHeight(DefaultMockPictureInPictureWindowWidth / videoDimensions.aspectRatio());
#if PLATFORM(IOS_FAMILY)
requestVideoContentLayer(contextId);
#else
@@ -540,8 +542,9 @@
#if PLATFORM(IOS_FAMILY)
auto* rootNode = downcast<RemoteLayerTreeDrawingAreaProxy>(*m_page->drawingArea()).remoteLayerTreeHost().rootNode();
UIView *parentView = rootNode ? rootNode->uiView() : nil;
- interface->setupFullscreen(*model->layerHostView(), initialRect, parentView, videoFullscreenMode, allowsPictureInPicture, standby);
+ interface->setupFullscreen(*model->layerHostView(), initialRect, videoDimensions, parentView, videoFullscreenMode, allowsPictureInPicture, standby);
#else
+ UNUSED_PARAM(videoDimensions);
IntRect initialWindowRect;
m_page->rootViewToWindow(initialRect, initialWindowRect);
interface->setupFullscreen(*model->layerHostView(), initialWindowRect, m_page->platformWindow(), videoFullscreenMode, allowsPictureInPicture);
@@ -559,11 +562,19 @@
void VideoFullscreenManagerProxy::setVideoDimensions(PlaybackSessionContextIdentifier contextId, const FloatSize& videoDimensions)
{
- if (m_mockVideoPresentationModeEnabled)
+ auto* interface = findInterface(contextId);
+ if (!interface)
return;
- if (auto* interface = findInterface(contextId))
- interface->videoDimensionsChanged(videoDimensions);
+ if (m_mockVideoPresentationModeEnabled) {
+ if (videoDimensions.isEmpty())
+ return;
+
+ m_mockPictureInPictureWindowSize.setHeight(DefaultMockPictureInPictureWindowWidth / videoDimensions.aspectRatio());
+ return;
+ }
+
+ interface->videoDimensionsChanged(videoDimensions);
}
void VideoFullscreenManagerProxy::enterFullscreen(PlaybackSessionContextIdentifier contextId)
@@ -570,7 +581,7 @@
{
if (m_mockVideoPresentationModeEnabled) {
didEnterFullscreen(contextId);
- setVideoLayerFrame(contextId, {0, 0, 200, 150});
+ setVideoLayerFrame(contextId, {0, 0, m_mockPictureInPictureWindowSize.width(), m_mockPictureInPictureWindowSize.height()});
return;
}
Modified: trunk/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm (263706 => 263707)
--- trunk/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm 2020-06-29 23:31:45 UTC (rev 263706)
+++ trunk/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm 2020-06-29 23:32:18 UTC (rev 263707)
@@ -285,7 +285,7 @@
interface->layerHostingContext()->setRootLayer(videoLayer.get());
}
- m_page->send(Messages::VideoFullscreenManagerProxy::SetupFullscreenWithID(contextId, interface->layerHostingContext()->contextID(), videoRect, m_page->deviceScaleFactor(), interface->fullscreenMode(), allowsPictureInPicture, standby));
+ m_page->send(Messages::VideoFullscreenManagerProxy::SetupFullscreenWithID(contextId, interface->layerHostingContext()->contextID(), videoRect, FloatSize(videoElement.videoWidth(), videoElement.videoHeight()), m_page->deviceScaleFactor(), interface->fullscreenMode(), allowsPictureInPicture, standby));
}
void VideoFullscreenManager::exitVideoFullscreenForVideoElement(WebCore::HTMLVideoElement& videoElement)