⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 262456 in webkit


Ignore:
Timestamp:
Jun 2, 2020, 3:26:02 PM (6 years ago)
Author:
Peng Liu
Message:

Stressing webkitSetPresentationMode leads to wrong inline video dimensions
https://bugs.webkit.org/show_bug.cgi?id=202425

Reviewed by Eric Carlson.

Source/WebCore:

Make the HTMLVideoElement::setFullscreenMode() robust under stress tests
by ignoring a request when the video element is not ready yet.

Manually tested.

  • dom/Element.h:

(WebCore::Element::didStopBeingFullscreenElement):
Add a callback to indicate that the element has exited fullscreen.

  • dom/FullscreenManager.cpp:

(WebCore::FullscreenManager::didExitFullscreen):
Call Element::didStopBeingFullscreenElement() when the element has exited fullscreen.

  • html/HTMLMediaElement.cpp:

(WebCore::HTMLMediaElement::enterFullscreen):

  • html/HTMLMediaElement.h:
  • html/HTMLVideoElement.cpp:

(WebCore::HTMLVideoElement::webkitDisplayingFullscreen):
This function will return true when a video element is in the process to exit
fullscreen/picture-in-picture until it has completed the process. Therefore, a page
can safely request the video element to enter fullscreen/picture-in-picture when
this function returns false.

(WebCore::HTMLVideoElement::setFullscreenMode):
(WebCore::HTMLVideoElement::didBecomeFullscreenElement):
(WebCore::HTMLVideoElement::didStopBeingFullscreenElement):
(WebCore::HTMLVideoElement::didEnterFullscreen): Deleted.
(WebCore::HTMLVideoElement::didExitFullscreen): Deleted.

  • html/HTMLVideoElement.h:

Add a flag m_isChangingPresentationMode. webkitSetPresentationMode() will only
change the presentation mode when the flag is false.

Source/WebKit:

  • WebProcess/cocoa/VideoFullscreenManager.mm:

(WebKit::VideoFullscreenManager::didEnterFullscreen):
(WebKit::VideoFullscreenManager::didCleanupFullscreen):

Source/WebKitLegacy/mac:

Move DumpRenderTree's implementation of the mock video presentation mode from WebView
to WebChromeClient and call videoElement.didStopBeingFullscreenElement() when a video
element exits fullscreen.

  • WebCoreSupport/WebChromeClient.h:
  • WebCoreSupport/WebChromeClient.mm:

(WebChromeClient::setMockVideoPresentationModeEnabled):
(WebChromeClient::enterVideoFullscreenForVideoElement):
(WebChromeClient::exitVideoFullscreenForVideoElement):
(WebChromeClient::exitVideoFullscreenToModeWithoutAnimation):

  • WebView/WebView.mm:

(-[WebView _enterVideoFullscreenForVideoElement:mode:]):
(-[WebView _exitVideoFullscreen]):
(-[WebView _setMockVideoPresentationModeEnabled:]): Deleted.

  • WebView/WebViewData.h:
  • WebView/WebViewInternal.h:

Tools:

  • TestWebKitAPI/Tests/WebKitCocoa/WKWebViewCloseAllMediaPresentations.mm:

(TEST):

LayoutTests:

Enable the mock video presentation mode in WebKitTestRunner and
only request a video element to enter/exit fullscreen/picture-in-picture when
the element is ready to do so (by checking the attribute webkitDisplayingFullscreen).

  • media/modern-media-controls/placard-support/placard-support-pip-expected.txt:
  • media/modern-media-controls/placard-support/placard-support-pip.html:
  • media/presentationmodechanged-fired-once-expected.txt:
  • media/presentationmodechanged-fired-once.html:
  • media/video-presentation-mode-expected.txt:
  • media/video-presentation-mode.html:
Location:
trunk
Files:
24 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r262438 r262456  
     12020-06-02  Peng Liu  <peng.liu6@apple.com>
     2
     3        Stressing webkitSetPresentationMode leads to wrong inline video dimensions
     4        https://bugs.webkit.org/show_bug.cgi?id=202425
     5
     6        Reviewed by Eric Carlson.
     7
     8        Enable the mock video presentation mode in WebKitTestRunner and
     9        only request a video element to enter/exit fullscreen/picture-in-picture when
     10        the element is ready to do so (by checking the attribute webkitDisplayingFullscreen).
     11
     12        * media/modern-media-controls/placard-support/placard-support-pip-expected.txt:
     13        * media/modern-media-controls/placard-support/placard-support-pip.html:
     14        * media/presentationmodechanged-fired-once-expected.txt:
     15        * media/presentationmodechanged-fired-once.html:
     16        * media/video-presentation-mode-expected.txt:
     17        * media/video-presentation-mode.html:
     18
    1192020-06-02  Simon Fraser  <simon.fraser@apple.com>
    220
  • trunk/LayoutTests/media/modern-media-controls/placard-support/placard-support-pip-expected.txt

    r218241 r262456  
    44
    55
     6PASS media.webkitDisplayingFullscreen became true
    67PASS mediaController.controls.placard is mediaController.controls.pipPlacard
    78PASS mediaController.controls.children.includes(mediaController.controls.pipPlacard) is true
     9PASS media.webkitDisplayingFullscreen became false
    810PASS mediaController.controls.placard is null
    911PASS mediaController.controls.children.includes(mediaController.controls.pipPlacard) is false
  • trunk/LayoutTests/media/modern-media-controls/placard-support/placard-support-pip.html

    r218725 r262456  
    2626description("Testing the <code>PlacardSupport</code> behavior when entering picture-in-picture.");
    2727
    28 if (window.internals)
     28if (window.internals) {
    2929    window.internals.settings.setAllowsPictureInPictureMediaPlayback(true);
     30    window.internals.setMockVideoPresentationModeEnabled(true);
     31}
    3032
    3133const container = document.querySelector("div#host");
     
    3739
    3840button.addEventListener("click", togglePiP);
    39 
    4041media.addEventListener("webkitpresentationmodechanged", () => {
    4142    if (media.webkitPresentationMode == "picture-in-picture") {
    42         shouldBe("mediaController.controls.placard", "mediaController.controls.pipPlacard");
    43         shouldBeTrue("mediaController.controls.children.includes(mediaController.controls.pipPlacard)");
    44         togglePiP();
     43        shouldBecomeEqual("media.webkitDisplayingFullscreen", "true", () => {
     44            shouldBe("mediaController.controls.placard", "mediaController.controls.pipPlacard");
     45            shouldBeTrue("mediaController.controls.children.includes(mediaController.controls.pipPlacard)");
     46            togglePiP();
     47        });
    4548    } else {
    46         shouldBeNull("mediaController.controls.placard");
    47         shouldBeFalse("mediaController.controls.children.includes(mediaController.controls.pipPlacard)");
    48         container.remove();
    49         media.remove();
    50         button.remove();
    51         finishJSTest();
     49        shouldBecomeEqual("media.webkitDisplayingFullscreen", "false", () => {
     50            shouldBeNull("mediaController.controls.placard");
     51            shouldBeFalse("mediaController.controls.children.includes(mediaController.controls.pipPlacard)");
     52            container.remove();
     53            media.remove();
     54            button.remove();
     55            finishJSTest();
     56        });
    5257    }
    5358});
  • trunk/LayoutTests/media/presentationmodechanged-fired-once-expected.txt

    r249141 r262456  
    11This tests that the "webkitpresentationmodechanged" event is fired only once when the browser switches back to inline from the picture-in-picture mode.
    22
    3 RUN(internals.settings.setAllowsPictureInPictureMediaPlayback(true))
    43RUN(video.src = findMediaFile("video", "content/test"))
    54EVENT(canplaythrough)
     
    76RUN(video.webkitSetPresentationMode("picture-in-picture"))
    87EVENT(webkitpresentationmodechanged)
     8EXPECTED (video.webkitDisplayingFullscreen == 'true') OK
    99EXPECTED (video.webkitPresentationMode == 'picture-in-picture') OK
    1010RUN(video.webkitSetPresentationMode("inline"))
  • trunk/LayoutTests/media/presentationmodechanged-fired-once.html

    r249141 r262456  
    99        function go()
    1010        {
     11            if (window.internals) {
     12                internals.settings.setAllowsPictureInPictureMediaPlayback(true);
     13                internals.setMockVideoPresentationModeEnabled(true);
     14            }
     15
    1116            findMediaElement();
    12             run('internals.settings.setAllowsPictureInPictureMediaPlayback(true)');
    1317            run('video.src = findMediaFile("video", "content/test")');
    1418            waitForEventOnce('canplaythrough', canPlayThrough);
     
    2226        }
    2327
    24         function presentationModeChanged1()
     28        async function presentationModeChanged1()
    2529        {
     30            await testExpectedEventually('video.webkitDisplayingFullscreen', true);
    2631            testExpected("video.webkitPresentationMode", "picture-in-picture");
    2732            runWithKeyDown('video.webkitSetPresentationMode("inline")');
  • trunk/LayoutTests/media/video-presentation-mode-expected.txt

    r261203 r262456  
    1010RUN(video.webkitSetPresentationMode('fullscreen'))
    1111EVENT(webkitpresentationmodechanged)
     12EXPECTED (video.webkitDisplayingFullscreen == 'true') OK
    1213
    1314** Entered fullscreen
     
    1718RUN(video.webkitSetPresentationMode('picture-in-picture'))
    1819EVENT(webkitpresentationmodechanged)
     20EXPECTED (video.webkitDisplayingFullscreen == 'true') OK
    1921
    2022** Entered picture-in-picture
     
    2426RUN(video.webkitSetPresentationMode('inline'))
    2527EVENT(webkitpresentationmodechanged)
     28EXPECTED (video.webkitDisplayingFullscreen == 'false') OK
    2629
    2730** Returned to inline
  • trunk/LayoutTests/media/video-presentation-mode.html

    r261203 r262456  
    22<html>
    33    <head>
    4             <script src=media-file.js></script>
    5             <script src=video-test.js></script>
    6             <script>
     4        <script src=media-file.js></script>
     5        <script src=video-test.js></script>
     6        <script>
    77            function start()
    88            {
    9                     if (window.internals) {
    10                     window.internals.settings.setAllowsPictureInPictureMediaPlayback(true);
    11                     window.internals.setMockVideoPresentationModeEnabled(true);
     9                if (window.internals) {
     10                    internals.settings.setAllowsPictureInPictureMediaPlayback(true);
     11                    internals.setMockVideoPresentationModeEnabled(true);
    1212                }
    13        
    14                     video = document.getElementsByTagName('video')[0];
    15                     waitForEventOnce("canplaythrough", canplaythrough);
    16                     video.src = findMediaFile("video", "content/test");
    1713
    18                     consoleWrite("");
     14                video = document.getElementsByTagName('video')[0];
     15                waitForEventOnce("canplaythrough", canplaythrough);
     16                video.src = findMediaFile("video", "content/test");
     17
     18                consoleWrite("");
    1919            }
    20        
    21                 function canplaythrough()
    22                 {
    23                     testExpected("video.webkitSupportsFullscreen", true);
    24                     testExpected("video.webkitDisplayingFullscreen", false);
    25        
    26                     consoleWrite("<br>** Try to enter fullscreen");
    27                     runWithKeyDown("video.webkitSetPresentationMode('fullscreen')");
    28                     waitForEventOnce('webkitpresentationmodechanged', presentationModeChanged1);
    29                 }
    30        
    31                 function presentationModeChanged1()
    32                 {
    33                     consoleWrite("<br>** Entered fullscreen");
    34                     testExpected("video.webkitPresentationMode", "fullscreen");
    35                     consoleWrite("<br>** Try to enter picture-in-picture");
    36                     waitForEventOnce('webkitpresentationmodechanged', presentationModeChanged2);
    37                     runWithKeyDown("video.webkitSetPresentationMode('picture-in-picture')");
    38                 }
    39        
    40                 function presentationModeChanged2()
    41                 {
    42                     consoleWrite("<br>** Entered picture-in-picture");
    43                     testExpected("video.webkitPresentationMode", "picture-in-picture");
    44                     consoleWrite("<br>** Try to return to inline");
    45                     waitForEventOnce('webkitpresentationmodechanged', testCompleted);
    46                     runWithKeyDown("video.webkitSetPresentationMode('inline')");
    47                 }
    48        
    49                 function testCompleted()
    50                 {
    51                     consoleWrite("<br>** Returned to inline");
    52                     testExpected("video.webkitPresentationMode", "inline");
    53                     consoleWrite("<br>** Test Completed");
    54                     endTest();
    55                 }
    56             </script>
    57         </head>
    58        
    59         <body onload="start()">
    60             <video controls playsinline></video>
    61             <p>Test the video presentation mode (video fullscreen and picture-in-picture) API.</p>
    62         </body>
     20
     21            async function canplaythrough()
     22            {
     23                testExpected("video.webkitSupportsFullscreen", true);
     24                await testExpectedEventually('video.webkitDisplayingFullscreen', false);
     25
     26                consoleWrite("<br>** Try to enter fullscreen");
     27                runWithKeyDown("video.webkitSetPresentationMode('fullscreen')");
     28                waitForEventOnce('webkitpresentationmodechanged', presentationModeChanged1);
     29            }
     30
     31            async function presentationModeChanged1()
     32            {
     33                await testExpectedEventually('video.webkitDisplayingFullscreen', true);
     34                consoleWrite("<br>** Entered fullscreen");
     35                testExpected("video.webkitPresentationMode", "fullscreen");
     36                consoleWrite("<br>** Try to enter picture-in-picture");
     37                waitForEventOnce('webkitpresentationmodechanged', presentationModeChanged2);
     38                runWithKeyDown("video.webkitSetPresentationMode('picture-in-picture')");
     39            }
     40
     41            async function presentationModeChanged2()
     42            {
     43                await testExpectedEventually('video.webkitDisplayingFullscreen', true);
     44                consoleWrite("<br>** Entered picture-in-picture");
     45                testExpected("video.webkitPresentationMode", "picture-in-picture");
     46                consoleWrite("<br>** Try to return to inline");
     47                waitForEventOnce('webkitpresentationmodechanged', testCompleted);
     48                runWithKeyDown("video.webkitSetPresentationMode('inline')");
     49            }
     50
     51            async function testCompleted()
     52            {
     53                await testExpectedEventually('video.webkitDisplayingFullscreen', false);
     54                consoleWrite("<br>** Returned to inline");
     55                testExpected("video.webkitPresentationMode", "inline");
     56                consoleWrite("<br>** Test Completed");
     57                endTest();
     58            }
     59        </script>
     60    </head>
     61
     62    <body onload="start()">
     63        <video controls playsinline></video>
     64        <p>Test the video presentation mode (video fullscreen and picture-in-picture) API.</p>
     65    </body>
    6366</html>
  • trunk/Source/WebCore/ChangeLog

    r262437 r262456  
     12020-06-02  Peng Liu  <peng.liu6@apple.com>
     2
     3        Stressing webkitSetPresentationMode leads to wrong inline video dimensions
     4        https://bugs.webkit.org/show_bug.cgi?id=202425
     5
     6        Reviewed by Eric Carlson.
     7
     8        Make the HTMLVideoElement::setFullscreenMode() robust under stress tests
     9        by ignoring a request when the video element is not ready yet.
     10
     11        Manually tested.
     12
     13        * dom/Element.h:
     14        (WebCore::Element::didStopBeingFullscreenElement):
     15        Add a callback to indicate that the element has exited fullscreen.
     16        * dom/FullscreenManager.cpp:
     17        (WebCore::FullscreenManager::didExitFullscreen):
     18        Call Element::didStopBeingFullscreenElement() when the element has exited fullscreen.
     19
     20        * html/HTMLMediaElement.cpp:
     21        (WebCore::HTMLMediaElement::enterFullscreen):
     22        * html/HTMLMediaElement.h:
     23
     24        * html/HTMLVideoElement.cpp:
     25        (WebCore::HTMLVideoElement::webkitDisplayingFullscreen):
     26        This function will return true when a video element is in the process to exit
     27        fullscreen/picture-in-picture until it has completed the process. Therefore, a page
     28        can safely request the video element to enter fullscreen/picture-in-picture when
     29        this function returns false.
     30
     31        (WebCore::HTMLVideoElement::setFullscreenMode):
     32        (WebCore::HTMLVideoElement::didBecomeFullscreenElement):
     33        (WebCore::HTMLVideoElement::didStopBeingFullscreenElement):
     34        (WebCore::HTMLVideoElement::didEnterFullscreen): Deleted.
     35        (WebCore::HTMLVideoElement::didExitFullscreen): Deleted.
     36        * html/HTMLVideoElement.h:
     37        Add a flag m_isChangingPresentationMode. webkitSetPresentationMode() will only
     38        change the presentation mode when the flag is false.
     39
    1402020-06-01  Simon Fraser  <simon.fraser@apple.com>
    241
  • trunk/Source/WebCore/dom/Element.h

    r262154 r262456  
    424424    virtual void didBecomeFullscreenElement() { }
    425425    virtual void willStopBeingFullscreenElement() { }
     426    virtual void didStopBeingFullscreenElement() { }
    426427
    427428    bool isFinishedParsingChildren() const { return isParsingChildrenFinished(); }
  • trunk/Source/WebCore/dom/FullscreenManager.cpp

    r257644 r262456  
    422422        return;
    423423    fullscreenElement->setContainsFullScreenElementOnAncestorsCrossingFrameBoundaries(false);
     424    m_fullscreenElement->didStopBeingFullscreenElement();
    424425
    425426    m_areKeysEnabledInFullscreen = false;
  • trunk/Source/WebCore/html/HTMLMediaElement.cpp

    r261899 r262456  
    59935993        return;
    59945994
     5995    if (m_waitingToEnterFullscreen)
     5996        return;
     5997
    59955998#if ENABLE(FULLSCREEN_API) && ENABLE(VIDEO_USES_ELEMENT_FULLSCREEN)
    59965999    if (document().settings().fullScreenEnabled() && mode == VideoFullscreenModeStandard) {
  • trunk/Source/WebCore/html/HTMLMediaElement.h

    r262038 r262456  
    562562    bool isSuspended() const final;
    563563
    564     WEBCORE_EXPORT void didBecomeFullscreenElement() final;
     564    WEBCORE_EXPORT void didBecomeFullscreenElement() override;
    565565    WEBCORE_EXPORT void willExitFullscreen();
    566566
  • trunk/Source/WebCore/html/HTMLVideoElement.cpp

    r262038 r262456  
    349349bool HTMLVideoElement::webkitDisplayingFullscreen()
    350350{
    351     return isFullscreen() && !waitingToEnterFullscreen();
     351    // This function starts to return true after the video element has entered
     352    // fullscreen/picture-in-picture until it has exited fullscreen/picture-in-picture
     353    return (isFullscreen() && !waitingToEnterFullscreen()) || (!isFullscreen() && m_isChangingPresentationMode);
    352354}
    353355
     
    468470    INFO_LOG(LOGIDENTIFIER, ", mode = ", mode);
    469471
     472    if (m_isChangingPresentationMode)
     473        return;
     474
    470475    if (mode == VideoFullscreenModeNone) {
    471476        if (isFullscreen()) {
    472477            if (toPresentationMode(fullscreenMode()) == VideoPresentationMode::PictureInPicture)
    473478                m_isEnteringOrExitingPictureInPicture = true;
     479
     480            m_isChangingPresentationMode = true;
    474481            exitFullscreen();
    475482        }
     
    484491        m_isEnteringOrExitingPictureInPicture = true;
    485492
    486     enterFullscreen(mode);
     493    if (mode != fullscreenMode()) {
     494        m_isChangingPresentationMode = true;
     495        enterFullscreen(mode);
     496    }
    487497}
    488498
     
    505515}
    506516
    507 void HTMLVideoElement::didEnterFullscreen()
    508 {
     517void HTMLVideoElement::didBecomeFullscreenElement()
     518{
     519    m_isChangingPresentationMode = false;
    509520    if (m_isEnteringOrExitingPictureInPicture)
    510521        m_isWaitingForPictureInPictureWindowFrame = true;
    511 }
    512 
    513 void HTMLVideoElement::didExitFullscreen()
    514 {
     522
     523    HTMLMediaElement::didBecomeFullscreenElement();
     524}
     525
     526void HTMLVideoElement::didStopBeingFullscreenElement()
     527{
     528    m_isChangingPresentationMode = false;
    515529    if (m_isEnteringOrExitingPictureInPicture) {
    516530        m_isEnteringOrExitingPictureInPicture = false;
  • trunk/Source/WebCore/html/HTMLVideoElement.h

    r262038 r262456  
    9090    void fullscreenModeChanged(VideoFullscreenMode) final;
    9191
    92     WEBCORE_EXPORT void didEnterFullscreen();
    93     WEBCORE_EXPORT void didExitFullscreen();
     92    WEBCORE_EXPORT void didBecomeFullscreenElement() final;
     93    WEBCORE_EXPORT void didStopBeingFullscreenElement() final;
    9494    void setVideoFullscreenFrame(FloatRect) final;
    9595
     
    135135    unsigned m_lastReportedVideoHeight { 0 };
    136136
     137    bool m_isChangingPresentationMode { false };
    137138    bool m_isEnteringOrExitingPictureInPicture { false };
    138139    bool m_isWaitingForPictureInPictureWindowFrame { false };
  • trunk/Source/WebKit/ChangeLog

    r262455 r262456  
     12020-06-02  Peng Liu  <peng.liu6@apple.com>
     2
     3        Stressing webkitSetPresentationMode leads to wrong inline video dimensions
     4        https://bugs.webkit.org/show_bug.cgi?id=202425
     5
     6        Reviewed by Eric Carlson.
     7
     8        * WebProcess/cocoa/VideoFullscreenManager.mm:
     9        (WebKit::VideoFullscreenManager::didEnterFullscreen):
     10        (WebKit::VideoFullscreenManager::didCleanupFullscreen):
     11
    1122020-06-02  Kate Cheney  <katherine_cheney@apple.com>
    213
  • trunk/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm

    r262038 r262456  
    442442        return;
    443443
    444     videoElement->didEnterFullscreen();
    445 
    446444    dispatch_async(dispatch_get_main_queue(), [protectedThis = makeRefPtr(this), videoElement] {
    447445        videoElement->didBecomeFullscreenElement();
     
    509507    RefPtr<HTMLVideoElement> videoElement = model->videoElement();
    510508    if (videoElement)
    511         videoElement->didExitFullscreen();
     509        videoElement->didStopBeingFullscreenElement();
    512510
    513511    interface->setFullscreenMode(HTMLMediaElementEnums::VideoFullscreenModeNone);
  • trunk/Source/WebKitLegacy/mac/ChangeLog

    r262395 r262456  
     12020-06-02  Peng Liu  <peng.liu6@apple.com>
     2
     3        Stressing webkitSetPresentationMode leads to wrong inline video dimensions
     4        https://bugs.webkit.org/show_bug.cgi?id=202425
     5
     6        Reviewed by Eric Carlson.
     7
     8        Move DumpRenderTree's implementation of the mock video presentation mode from WebView
     9        to WebChromeClient and call videoElement.didStopBeingFullscreenElement() when a video
     10        element exits fullscreen.
     11
     12        * WebCoreSupport/WebChromeClient.h:
     13        * WebCoreSupport/WebChromeClient.mm:
     14        (WebChromeClient::setMockVideoPresentationModeEnabled):
     15        (WebChromeClient::enterVideoFullscreenForVideoElement):
     16        (WebChromeClient::exitVideoFullscreenForVideoElement):
     17        (WebChromeClient::exitVideoFullscreenToModeWithoutAnimation):
     18        * WebView/WebView.mm:
     19        (-[WebView _enterVideoFullscreenForVideoElement:mode:]):
     20        (-[WebView _exitVideoFullscreen]):
     21        (-[WebView _setMockVideoPresentationModeEnabled:]): Deleted.
     22        * WebView/WebViewData.h:
     23        * WebView/WebViewInternal.h:
     24
    1252020-06-01  David Kilzer  <ddkilzer@apple.com>
    226
  • trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.h

    r261203 r262456  
    237237    String signedPublicKeyAndChallengeString(unsigned keySizeIndex, const String& challengeString, const URL&) const final;
    238238
     239    bool m_mockVideoPresentationModeEnabled { false };
    239240    WebView *m_webView;
    240241};
  • trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.mm

    r261203 r262456  
    7373#import <WebCore/HTMLNames.h>
    7474#import <WebCore/HTMLPlugInImageElement.h>
     75#import <WebCore/HTMLVideoElement.h>
    7576#import <WebCore/HitTestResult.h>
    7677#import <WebCore/Icon.h>
     
    970971void WebChromeClient::setMockVideoPresentationModeEnabled(bool enabled)
    971972{
    972     [m_webView _setMockVideoPresentationModeEnabled:enabled];
     973    m_mockVideoPresentationModeEnabled = enabled;
    973974}
    974975
     
    978979    ASSERT(mode != HTMLMediaElementEnums::VideoFullscreenModeNone);
    979980    BEGIN_BLOCK_OBJC_EXCEPTIONS;
    980     [m_webView _enterVideoFullscreenForVideoElement:&videoElement mode:mode];
     981    if (m_mockVideoPresentationModeEnabled)
     982        videoElement.didBecomeFullscreenElement();
     983    else
     984        [m_webView _enterVideoFullscreenForVideoElement:&videoElement mode:mode];
    981985    END_BLOCK_OBJC_EXCEPTIONS;
    982986}
    983987
    984 void WebChromeClient::exitVideoFullscreenForVideoElement(WebCore::HTMLVideoElement&)
     988void WebChromeClient::exitVideoFullscreenForVideoElement(WebCore::HTMLVideoElement& videoElement)
    985989{
    986990    BEGIN_BLOCK_OBJC_EXCEPTIONS;
    987     [m_webView _exitVideoFullscreen];
     991    if (m_mockVideoPresentationModeEnabled)
     992        videoElement.didStopBeingFullscreenElement();
     993    else
     994        [m_webView _exitVideoFullscreen];
    988995    END_BLOCK_OBJC_EXCEPTIONS;   
    989996}
     
    992999{
    9931000    BEGIN_BLOCK_OBJC_EXCEPTIONS;
    994     [m_webView _exitVideoFullscreen];
     1001    if (m_mockVideoPresentationModeEnabled)
     1002        videoElement.didStopBeingFullscreenElement();
     1003    else
     1004        [m_webView _exitVideoFullscreen];
    9951005    END_BLOCK_OBJC_EXCEPTIONS;
    9961006}
  • trunk/Source/WebKitLegacy/mac/WebView/WebView.mm

    r262395 r262456  
    92909290#if ENABLE(VIDEO_PRESENTATION_MODE)
    92919291
    9292 - (void)_setMockVideoPresentationModeEnabled:(BOOL)enabled
    9293 {
    9294     _private->mockVideoPresentationModeEnabled = enabled;
    9295 }
    9296 
    92979292- (void)_enterVideoFullscreenForVideoElement:(NakedPtr<WebCore::HTMLVideoElement>)videoElement mode:(WebCore::HTMLMediaElementEnums::VideoFullscreenMode)mode
    92989293{
    9299     if (_private->mockVideoPresentationModeEnabled) {
    9300         videoElement->didBecomeFullscreenElement();
    9301         return;
    9302     }
    9303 
    93049294    if (_private->fullscreenController) {
    93059295        if ([_private->fullscreenController videoElement] == videoElement) {
     
    93309320- (void)_exitVideoFullscreen
    93319321{
    9332     if (_private->mockVideoPresentationModeEnabled)
    9333         return;
    9334 
    93359322    if (!_private->fullscreenController && _private->fullscreenControllersExiting.isEmpty())
    93369323        return;
  • trunk/Source/WebKitLegacy/mac/WebView/WebViewData.h

    r262272 r262456  
    324324#endif
    325325
    326 #if ENABLE(VIDEO_PRESENTATION_MODE)
    327     BOOL mockVideoPresentationModeEnabled;
    328 #endif
    329 
    330326#if PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)
    331327    RefPtr<WebCore::PlaybackSessionModelMediaElement> playbackSessionModel;
  • trunk/Source/WebKitLegacy/mac/WebView/WebViewInternal.h

    r261981 r262456  
    271271#if ENABLE(VIDEO) && defined(__cplusplus)
    272272#if ENABLE(VIDEO_PRESENTATION_MODE)
    273 - (void)_setMockVideoPresentationModeEnabled:(BOOL)enabled;
    274273- (void)_enterVideoFullscreenForVideoElement:(NakedPtr<WebCore::HTMLVideoElement>)videoElement mode:(WebCore::HTMLMediaElementEnums::VideoFullscreenMode)mode;
    275274- (void)_exitVideoFullscreen;
  • trunk/Tools/ChangeLog

    r262432 r262456  
     12020-06-02  Peng Liu  <peng.liu6@apple.com>
     2
     3        Stressing webkitSetPresentationMode leads to wrong inline video dimensions
     4        https://bugs.webkit.org/show_bug.cgi?id=202425
     5
     6        Reviewed by Eric Carlson.
     7
     8        * TestWebKitAPI/Tests/WebKitCocoa/WKWebViewCloseAllMediaPresentations.mm:
     9        (TEST):
     10
    1112020-06-02  Youenn Fablet  <youenn@apple.com>
    212
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewCloseAllMediaPresentations.mm

    r256528 r262456  
    3939
    4040    [webView synchronouslyLoadHTMLString:@"<video src=video-with-audio.mp4 webkit-playsinline></video>"];
     41
     42    [webView objectByEvaluatingJavaScriptWithUserGesture:@"document.querySelector('video').webkitSetPresentationMode('picture-in-picture')"];
     43
     44    do {
     45        id result = [webView objectByEvaluatingJavaScript:@"document.querySelector('video').webkitDisplayingFullscreen"];
     46        if ([result boolValue])
     47            break;
     48
     49        TestWebKitAPI::Util::sleep(0.5);
     50    } while (true);
     51
    4152    [webView objectByEvaluatingJavaScript:@"document.querySelector('video').addEventListener('webkitpresentationmodechanged', event => { window.webkit.messageHandlers.testHandler.postMessage('presentationmodechanged'); });"];
    4253
    4354    __block bool presentationModeChanged = false;
    44     [webView performAfterReceivingMessage:@"presentationmodechanged" action:^{ presentationModeChanged = true; }];
    45 
    46     [webView objectByEvaluatingJavaScriptWithUserGesture:@"document.querySelector('video').webkitSetPresentationMode('picture-in-picture')"];
    47 
    48     TestWebKitAPI::Util::run(&presentationModeChanged);
    49 
    50     presentationModeChanged = false;
    5155    [webView performAfterReceivingMessage:@"presentationmodechanged" action:^{ presentationModeChanged = true; }];
    5256
Note: See TracChangeset for help on using the changeset viewer.