Changeset 263707 in webkit


Ignore:
Timestamp:
Jun 29, 2020 4:32:18 PM (4 years ago)
Author:
Peng Liu
Message:

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.

Source/WebCore:

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):

Source/WebKit:

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):

LayoutTests:

  • 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.
Location:
trunk
Files:
2 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r263706 r263707  
     12020-06-29  Peng Liu  <peng.liu6@apple.com>
     2
     3        Video spills over PiP screen a little when using Picture in Picture
     4        https://bugs.webkit.org/show_bug.cgi?id=213658
     5
     6        Reviewed by Eric Carlson.
     7
     8        * media/picture-in-picture/picture-in-picture-window-aspect-ratio-expected.txt: Added.
     9        * media/picture-in-picture/picture-in-picture-window-aspect-ratio.html: Added.
     10
    1112020-06-29  Karl Rackler  <rackler@apple.com>
    212
  • trunk/Source/WebCore/ChangeLog

    r263700 r263707  
     12020-06-29  Peng Liu  <peng.liu6@apple.com>
     2
     3        Video spills over PiP screen a little when using Picture in Picture
     4        https://bugs.webkit.org/show_bug.cgi?id=213658
     5
     6        Reviewed by Eric Carlson.
     7
     8        We need to provide video content dimensions instead of video element sizes to
     9        AVPlayerController to make sure that the Picture-in-Picture window will have
     10        the correct aspect ratio.
     11
     12        Test: media/picture-in-picture/picture-in-picture-window-aspect-ratio.html
     13
     14        * platform/ios/VideoFullscreenInterfaceAVKit.h:
     15        * platform/ios/VideoFullscreenInterfaceAVKit.mm:
     16        (VideoFullscreenInterfaceAVKit::setupFullscreen):
     17        * platform/ios/WebVideoFullscreenControllerAVKit.mm:
     18        (VideoFullscreenControllerContext::setUpFullscreen):
     19
    1202020-06-29  Tetsuharu Ohzeki  <tetsuharu.ohzeki@gmail.com>
    221
  • trunk/Source/WebCore/platform/ios/VideoFullscreenInterfaceAVKit.h

    r262185 r263707  
    8080    WEBCORE_EXPORT void externalPlaybackChanged(bool enabled, PlaybackSessionModel::ExternalPlaybackTargetType, const String& localizedDeviceName) final;
    8181
    82     WEBCORE_EXPORT void setupFullscreen(UIView&, const IntRect& initialRect, UIView *, HTMLMediaElementEnums::VideoFullscreenMode, bool allowsPictureInPicturePlayback, bool standby);
     82    WEBCORE_EXPORT void setupFullscreen(UIView& videoView, const IntRect& initialRect, const FloatSize& videoDimensions, UIView* parentView, HTMLMediaElementEnums::VideoFullscreenMode, bool allowsPictureInPicturePlayback, bool standby);
    8383    WEBCORE_EXPORT void enterFullscreen();
    8484    WEBCORE_EXPORT void exitFullscreen(const IntRect& finalRect);
  • trunk/Source/WebCore/platform/ios/VideoFullscreenInterfaceAVKit.mm

    r263500 r263707  
    890890}
    891891
    892 void VideoFullscreenInterfaceAVKit::setupFullscreen(UIView& videoView, const IntRect& initialRect, UIView* parentView, HTMLMediaElementEnums::VideoFullscreenMode mode, bool allowsPictureInPicturePlayback, bool standby)
     892void VideoFullscreenInterfaceAVKit::setupFullscreen(UIView& videoView, const IntRect& initialRect, const FloatSize& videoDimensions, UIView* parentView, HTMLMediaElementEnums::VideoFullscreenMode mode, bool allowsPictureInPicturePlayback, bool standby)
    893893{
    894894    ASSERT(standby || mode != HTMLMediaElementEnums::VideoFullscreenModeNone);
     
    897897    [playerController() setHasEnabledVideo:true];
    898898    [playerController() setHasVideo:true];
    899     [playerController() setContentDimensions:initialRect.size()];
     899    [playerController() setContentDimensions:videoDimensions];
    900900
    901901    m_allowsPictureInPicturePlayback = allowsPictureInPicturePlayback;
  • trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm

    r260486 r263707  
    982982    m_fullscreenModel->setVideoLayerFrame(videoLayerFrame);
    983983
    984     dispatch_async(dispatch_get_main_queue(), [protectedThis = makeRefPtr(this), this, videoElementClientRect, viewRef, mode, allowsPictureInPicture] {
     984    FloatSize videoDimensions = { (float)videoElement.videoWidth(), (float)videoElement.videoHeight() };
     985
     986    dispatch_async(dispatch_get_main_queue(), [protectedThis = makeRefPtr(this), this, videoElementClientRect, videoDimensions, viewRef, mode, allowsPictureInPicture] {
    985987        ASSERT(isUIThread());
    986988        WebThreadLock();
     
    994996        m_videoFullscreenView = adoptNS([PAL::allocUIViewInstance() init]);
    995997
    996         m_interface->setupFullscreen(*m_videoFullscreenView.get(), videoElementClientRect, viewRef.get(), mode, allowsPictureInPicture, false);
     998        m_interface->setupFullscreen(*m_videoFullscreenView.get(), videoElementClientRect, videoDimensions, viewRef.get(), mode, allowsPictureInPicture, false);
    997999    });
    9981000}
  • trunk/Source/WebKit/ChangeLog

    r263705 r263707  
     12020-06-29  Peng Liu  <peng.liu6@apple.com>
     2
     3        Video spills over PiP screen a little when using Picture in Picture
     4        https://bugs.webkit.org/show_bug.cgi?id=213658
     5
     6        Reviewed by Eric Carlson.
     7
     8        Add the video content dimensions to the IPC message VideoFullscreenManagerProxy::SetupFullscreenWithID.
     9
     10        * UIProcess/Cocoa/VideoFullscreenManagerProxy.h:
     11        * UIProcess/Cocoa/VideoFullscreenManagerProxy.messages.in:
     12        * UIProcess/Cocoa/VideoFullscreenManagerProxy.mm:
     13        (WebKit::VideoFullscreenManagerProxy::setupFullscreenWithID):
     14        (WebKit::VideoFullscreenManagerProxy::setVideoDimensions):
     15        (WebKit::VideoFullscreenManagerProxy::enterFullscreen):
     16        * WebProcess/cocoa/VideoFullscreenManager.mm:
     17        (WebKit::VideoFullscreenManager::enterVideoFullscreenForVideoElement):
     18
    1192020-06-29  Chris Dumez  <cdumez@apple.com>
    220
  • trunk/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.h

    r263490 r263707  
    5656namespace WebKit {
    5757
     58constexpr size_t DefaultMockPictureInPictureWindowWidth = 100;
     59constexpr size_t DefaultMockPictureInPictureWindowHeight = 100;
     60
    5861class WebPageProxy;
    5962class PlaybackSessionManagerProxy;
     
    161164
    162165    // Messages from VideoFullscreenManager
    163     void setupFullscreenWithID(PlaybackSessionContextIdentifier, WebKit::LayerHostingContextID videoLayerID, const WebCore::IntRect& initialRect, float hostingScaleFactor, WebCore::HTMLMediaElementEnums::VideoFullscreenMode, bool allowsPictureInPicture, bool standby);
     166    void setupFullscreenWithID(PlaybackSessionContextIdentifier, WebKit::LayerHostingContextID videoLayerID, const WebCore::IntRect& initialRect, const WebCore::FloatSize& videoDimensions, float hostingScaleFactor, WebCore::HTMLMediaElementEnums::VideoFullscreenMode, bool allowsPictureInPicture, bool standby);
    164167    void setInlineRect(PlaybackSessionContextIdentifier, const WebCore::IntRect& inlineRect, bool visible);
    165168    void setHasVideoContentLayer(PlaybackSessionContextIdentifier, bool value);
     
    189192
    190193    bool m_mockVideoPresentationModeEnabled { false };
     194    WebCore::FloatSize m_mockPictureInPictureWindowSize { DefaultMockPictureInPictureWindowWidth, DefaultMockPictureInPictureWindowHeight };
    191195
    192196    WebPageProxy* m_page;
  • trunk/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.messages.in

    r263490 r263707  
    2525    SetHasVideo(WebKit::PlaybackSessionContextIdentifier contextId, bool hasVideo)
    2626    SetVideoDimensions(WebKit::PlaybackSessionContextIdentifier contextId, WebCore::FloatSize videoDimensions)
    27     SetupFullscreenWithID(WebKit::PlaybackSessionContextIdentifier contextId, WebKit::LayerHostingContextID videoLayerID, WebCore::IntRect initialRect, float hostingScaleFactor, WebCore::HTMLMediaElementEnums::VideoFullscreenMode videoFullscreenMode, bool allowsPictureInPicture, bool standby)
     27    SetupFullscreenWithID(WebKit::PlaybackSessionContextIdentifier contextId, WebKit::LayerHostingContextID videoLayerID, WebCore::IntRect initialRect, WebCore::FloatSize videoDimensions, float hostingScaleFactor, WebCore::HTMLMediaElementEnums::VideoFullscreenMode videoFullscreenMode, bool allowsPictureInPicture, bool standby)
    2828    EnterFullscreen(WebKit::PlaybackSessionContextIdentifier contextId)
    2929    ExitFullscreen(WebKit::PlaybackSessionContextIdentifier contextId, WebCore::IntRect finalRect)
  • trunk/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.mm

    r263490 r263707  
    507507#pragma mark Messages from VideoFullscreenManager
    508508
    509 void VideoFullscreenManagerProxy::setupFullscreenWithID(PlaybackSessionContextIdentifier contextId, WebKit::LayerHostingContextID videoLayerID, const WebCore::IntRect& initialRect, float hostingDeviceScaleFactor, HTMLMediaElementEnums::VideoFullscreenMode videoFullscreenMode, bool allowsPictureInPicture, bool standby)
     509void VideoFullscreenManagerProxy::setupFullscreenWithID(PlaybackSessionContextIdentifier contextId, WebKit::LayerHostingContextID videoLayerID, const WebCore::IntRect& initialRect, const WebCore::FloatSize& videoDimensions, float hostingDeviceScaleFactor, HTMLMediaElementEnums::VideoFullscreenMode videoFullscreenMode, bool allowsPictureInPicture, bool standby)
    510510{
    511511    MESSAGE_CHECK(videoLayerID);
     
    515515
    516516    if (m_mockVideoPresentationModeEnabled) {
     517        if (!videoDimensions.isEmpty())
     518            m_mockPictureInPictureWindowSize.setHeight(DefaultMockPictureInPictureWindowWidth /  videoDimensions.aspectRatio());
    517519#if PLATFORM(IOS_FAMILY)
    518520        requestVideoContentLayer(contextId);
     
    541543    auto* rootNode = downcast<RemoteLayerTreeDrawingAreaProxy>(*m_page->drawingArea()).remoteLayerTreeHost().rootNode();
    542544    UIView *parentView = rootNode ? rootNode->uiView() : nil;
    543     interface->setupFullscreen(*model->layerHostView(), initialRect, parentView, videoFullscreenMode, allowsPictureInPicture, standby);
    544 #else
     545    interface->setupFullscreen(*model->layerHostView(), initialRect, videoDimensions, parentView, videoFullscreenMode, allowsPictureInPicture, standby);
     546#else
     547    UNUSED_PARAM(videoDimensions);
    545548    IntRect initialWindowRect;
    546549    m_page->rootViewToWindow(initialRect, initialWindowRect);
     
    560563void VideoFullscreenManagerProxy::setVideoDimensions(PlaybackSessionContextIdentifier contextId, const FloatSize& videoDimensions)
    561564{
    562     if (m_mockVideoPresentationModeEnabled)
    563         return;
    564 
    565     if (auto* interface = findInterface(contextId))
    566         interface->videoDimensionsChanged(videoDimensions);
     565    auto* interface = findInterface(contextId);
     566    if (!interface)
     567        return;
     568
     569    if (m_mockVideoPresentationModeEnabled) {
     570        if (videoDimensions.isEmpty())
     571            return;
     572
     573        m_mockPictureInPictureWindowSize.setHeight(DefaultMockPictureInPictureWindowWidth / videoDimensions.aspectRatio());
     574        return;
     575    }
     576
     577    interface->videoDimensionsChanged(videoDimensions);
    567578}
    568579
     
    571582    if (m_mockVideoPresentationModeEnabled) {
    572583        didEnterFullscreen(contextId);
    573         setVideoLayerFrame(contextId, {0, 0, 200, 150});
     584        setVideoLayerFrame(contextId, {0, 0, m_mockPictureInPictureWindowSize.width(), m_mockPictureInPictureWindowSize.height()});
    574585        return;
    575586    }
  • trunk/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm

    r263476 r263707  
    286286    }
    287287
    288     m_page->send(Messages::VideoFullscreenManagerProxy::SetupFullscreenWithID(contextId, interface->layerHostingContext()->contextID(), videoRect, m_page->deviceScaleFactor(), interface->fullscreenMode(), allowsPictureInPicture, standby));
     288    m_page->send(Messages::VideoFullscreenManagerProxy::SetupFullscreenWithID(contextId, interface->layerHostingContext()->contextID(), videoRect, FloatSize(videoElement.videoWidth(), videoElement.videoHeight()), m_page->deviceScaleFactor(), interface->fullscreenMode(), allowsPictureInPicture, standby));
    289289}
    290290
Note: See TracChangeset for help on using the changeset viewer.