| Differences between
and this patch
- a/Source/WebCore/ChangeLog +19 lines
Lines 1-3 a/Source/WebCore/ChangeLog_sec1
1
2020-08-19  Peng Liu  <peng.liu6@apple.com>
2
3
        A PiP window is closed when the video element is removed from DOM
4
        https://bugs.webkit.org/show_bug.cgi?id=215594
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        Test: media/remove-video-element-in-pip-from-document.html
9
10
        * html/HTMLMediaElement.cpp:
11
        (WebCore::HTMLMediaElement::pauseAfterDetachedTask):
12
        When a video is playing in the picture-in-picture mode, do not pause it or exit the
13
        picture-in-picture mode when detaching the video element from the DOM.
14
        (WebCore::HTMLMediaElement::mediaPlayerRenderingCanBeAccelerated):
15
        Always return true when the video is playing in the picture-in-picture mode.
16
        * rendering/RenderVideo.cpp:
17
        (WebCore::RenderVideo::willBeDestroyed):
18
        Don't hide the player when destroying the renderer of an inline video.
19
1
2020-08-17  David Kilzer  <ddkilzer@apple.com>
20
2020-08-17  David Kilzer  <ddkilzer@apple.com>
2
21
3
        Clean up DragApplicationFlags after switch to OptionSet<>
22
        Clean up DragApplicationFlags after switch to OptionSet<>
- a/Source/WebCore/html/HTMLMediaElement.cpp -2 / +5 lines
Lines 835-843 void HTMLMediaElement::pauseAfterDetachedTask() a/Source/WebCore/html/HTMLMediaElement.cpp_sec1
835
    if (m_inActiveDocument)
835
    if (m_inActiveDocument)
836
        return;
836
        return;
837
837
838
    if (m_networkState > NETWORK_EMPTY)
838
    if (m_videoFullscreenMode != VideoFullscreenModePictureInPicture && m_networkState > NETWORK_EMPTY)
839
        pause();
839
        pause();
840
    if (m_videoFullscreenMode != VideoFullscreenModeNone)
840
    if (m_videoFullscreenMode == VideoFullscreenModeStandard)
841
        exitFullscreen();
841
        exitFullscreen();
842
842
843
    if (!m_player)
843
    if (!m_player)
Lines 4926-4931 void HTMLMediaElement::mediaPlayerSizeChanged() a/Source/WebCore/html/HTMLMediaElement.cpp_sec2
4926
4926
4927
bool HTMLMediaElement::mediaPlayerRenderingCanBeAccelerated()
4927
bool HTMLMediaElement::mediaPlayerRenderingCanBeAccelerated()
4928
{
4928
{
4929
    if (m_videoFullscreenMode == VideoFullscreenModePictureInPicture)
4930
        return true;
4931
4929
    auto* renderer = this->renderer();
4932
    auto* renderer = this->renderer();
4930
    return is<RenderVideo>(renderer)
4933
    return is<RenderVideo>(renderer)
4931
        && downcast<RenderVideo>(*renderer).view().compositor().canAccelerateVideoRendering(downcast<RenderVideo>(*renderer));
4934
        && downcast<RenderVideo>(*renderer).view().compositor().canAccelerateVideoRendering(downcast<RenderVideo>(*renderer));
- a/Source/WebCore/rendering/RenderVideo.cpp -1 / +8 lines
Lines 65-72 RenderVideo::~RenderVideo() a/Source/WebCore/rendering/RenderVideo.cpp_sec1
65
void RenderVideo::willBeDestroyed()
65
void RenderVideo::willBeDestroyed()
66
{
66
{
67
    visibleInViewportStateChanged();
67
    visibleInViewportStateChanged();
68
    if (auto player = videoElement().player())
68
69
#if ENABLE(VIDEO_PRESENTATION_MODE)
70
    auto player = videoElement().player();
71
    if (player && videoElement().webkitPresentationMode() != HTMLVideoElement::VideoPresentationMode::PictureInPicture)
69
        player->setVisible(false);
72
        player->setVisible(false);
73
#else
74
    if (player = videoElement().player())
75
        player->setVisible(false);
76
#endif
70
77
71
    RenderMedia::willBeDestroyed();
78
    RenderMedia::willBeDestroyed();
72
}
79
}
- a/LayoutTests/ChangeLog +10 lines
Lines 1-3 a/LayoutTests/ChangeLog_sec1
1
2020-08-19  Peng Liu  <peng.liu6@apple.com>
2
3
        A PiP window is closed when the video element is removed from DOM
4
        https://bugs.webkit.org/show_bug.cgi?id=215594
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        * media/remove-video-element-in-pip-from-document-expected.txt: Added.
9
        * media/remove-video-element-in-pip-from-document.html: Added.
10
1
2020-08-17  Hector Lopez  <hector_i_lopez@apple.com>
11
2020-08-17  Hector Lopez  <hector_i_lopez@apple.com>
2
12
3
        [ macOS ] media/modern-media-controls/volume-up-support/volume-up-support.html is a flaky timeout
13
        [ macOS ] media/modern-media-controls/volume-up-support/volume-up-support.html is a flaky timeout
- a/LayoutTests/media/remove-video-element-in-pip-from-document-expected.txt +10 lines
Line 0 a/LayoutTests/media/remove-video-element-in-pip-from-document-expected.txt_sec1
1
Test that removing a video element from the DOM while the video is in the picture-in-picture mode does not close the PiP window.
2
3
RUN(internals.settings.setAllowsPictureInPictureMediaPlayback(true))
4
RUN(internals.setMockVideoPresentationModeEnabled(true))
5
EVENT(canplaythrough)
6
EVENT(enterpictureinpicture)
7
EXPECTED (pipWindow.width > '0') OK
8
EXPECTED (pipWindow.height > '0') OK
9
END OF TEST
10
- a/LayoutTests/media/remove-video-element-in-pip-from-document.html +45 lines
Line 0 a/LayoutTests/media/remove-video-element-in-pip-from-document.html_sec1
1
<!DOCTYPE html>
2
<html>
3
<head>
4
    <script src="video-test.js"></script>
5
    <script src="media-file.js"></script>
6
    <script>
7
        window.addEventListener('load', async event => {
8
            if (!window.internals) {
9
                failTest('This test requires window.internals.');
10
                return;
11
            }
12
13
            consoleWrite('');
14
            run('internals.settings.setAllowsPictureInPictureMediaPlayback(true)');
15
            run('internals.setMockVideoPresentationModeEnabled(true)');
16
17
            findMediaElement();
18
            video.src = findMediaFile("video", "content/test");
19
20
            await waitFor(video, 'canplaythrough');
21
22
            runWithKeyDown(() => {
23
                video.webkitSetPresentationMode('picture-in-picture');
24
            });
25
26
            waitForEventOnce('enterpictureinpicture', event => {
27
                window.pipWindow = event.pictureInPictureWindow;
28
                testExpected('pipWindow.width', 0, '>');
29
                testExpected('pipWindow.height', 0, '>');
30
31
                setTimeout(endTest, 4000);
32
                waitForEvent('webkitpresentationmodechanged', () => {
33
                    failTest('PiP window is closed!');
34
                });
35
36
                document.body.removeChild(video);
37
            });
38
        });
39
    </script>
40
</head>
41
<body>
42
    <div>Test that removing a video element from the DOM while the video is in the picture-in-picture mode does not close the PiP window.</div>
43
    <video controls playsinline></video>
44
</body>
45
</html>

Return to Bug 215594