Title: [212314] trunk
Revision
212314
Author
[email protected]
Date
2017-02-14 11:34:09 -0800 (Tue, 14 Feb 2017)

Log Message

When playing inline after fullscreen, set a flag instead of adding attribute plays inline, and use in requiresFullscreenForVideoPlayback.
https://bugs.webkit.org/show_bug.cgi?id=167815
rdar://problem/27685077

Patch by Jeremy Jones <[email protected]> on 2017-02-14
Reviewed by Jer Noble.

Source/WebCore:

Test: media/media-fullscreen-loop-inline.html

When video is allowed to play inline after fullscreen. Looped video causes play state to update, which can send video back to fullscreen when
allowsInline is false. This change will set a new flag when allowsInlineMediaPlaybackAfterFullscreen allows inline playback that can be tested
in requiresFullscreenForVideoPlayback to prevent sending video back into fullscreen when video loops.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::enterFullscreen):
(WebCore::HTMLMediaElement::exitFullscreen):
* html/HTMLMediaElement.h:
(WebCore::HTMLMediaElement::isTemporarilyAllowingInlinePlaybackAfterFullscreen): Added.
* html/MediaElementSession.cpp:
(WebCore::MediaElementSession::requiresFullscreenForVideoPlayback):

LayoutTests:

Add a new test that tests inline after fullscreen behavior of looping video.

* media/media-fullscreen-loop-inline-expected.txt: Added.
* media/media-fullscreen-loop-inline.html: Added.
* platform/mac-wk2/TestExpectations: Skipped on webkit2.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (212313 => 212314)


--- trunk/LayoutTests/ChangeLog	2017-02-14 19:24:34 UTC (rev 212313)
+++ trunk/LayoutTests/ChangeLog	2017-02-14 19:34:09 UTC (rev 212314)
@@ -1,3 +1,17 @@
+2017-02-14  Jeremy Jones  <[email protected]>
+
+        When playing inline after fullscreen, set a flag instead of adding attribute plays inline, and use in requiresFullscreenForVideoPlayback.
+        https://bugs.webkit.org/show_bug.cgi?id=167815
+        rdar://problem/27685077
+
+        Reviewed by Jer Noble.
+
+        Add a new test that tests inline after fullscreen behavior of looping video.
+
+        * media/media-fullscreen-loop-inline-expected.txt: Added.
+        * media/media-fullscreen-loop-inline.html: Added.
+        * platform/mac-wk2/TestExpectations: Skipped on webkit2.
+
 2017-02-14  Ryan Haddad  <[email protected]>
 
         Rebaseline media/modern-media-controls/airplay-button/airplay-button-on.html for ios-simulator.

Added: trunk/LayoutTests/media/media-fullscreen-loop-inline-expected.txt (0 => 212314)


--- trunk/LayoutTests/media/media-fullscreen-loop-inline-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/media/media-fullscreen-loop-inline-expected.txt	2017-02-14 19:34:09 UTC (rev 212314)
@@ -0,0 +1,20 @@
+
+RUN(internals.settings.setAllowsInlineMediaPlayback(false))
+RUN(internals.settings.setAllowsInlineMediaPlaybackAfterFullscreen(true))
+RUN(internals.settings.setFullScreenEnabled(false))
+RUN(internals.setMediaElementRestrictions(video, "NoRestrictions"))
+RUN(video.loop = true)
+RUN(video.src = "" "content/test"))
+RUN(video.play())
+EVENT(webkitbeginfullscreen)
+RUN(video.currentTime = 5)
+RUN(video.webkitExitFullscreen())
+EVENT(webkitendfullscreen)
+EXPECTED (video.paused == 'false') OK
+RUN(video._ontimeupdate_ = timeupdate)
+RUN(video._ontimeupdate_ = null)
+Looped
+EXPECTED (video.playsInline == 'false') OK
+EXPECTED (video.paused == 'false') OK
+END OF TEST
+

Added: trunk/LayoutTests/media/media-fullscreen-loop-inline.html (0 => 212314)


--- trunk/LayoutTests/media/media-fullscreen-loop-inline.html	                        (rev 0)
+++ trunk/LayoutTests/media/media-fullscreen-loop-inline.html	2017-02-14 19:34:09 UTC (rev 212314)
@@ -0,0 +1,57 @@
+<!DOCTYPE html><!-- webkit-test-runner [ enableModernMediaControls=false ] -->
+<html>
+<head>
+    <title>media-fullscreen-return-to-inline</title>
+
+    <script src=""
+    <script src=""
+
+    <script>
+    function go()
+    {
+        findMediaElement();
+        run('internals.settings.setAllowsInlineMediaPlayback(false)');
+        run('internals.settings.setAllowsInlineMediaPlaybackAfterFullscreen(true)');
+        run('internals.settings.setFullScreenEnabled(false)');
+        run('internals.setMediaElementRestrictions(video, "NoRestrictions")');
+        run('video.loop = true');
+        run('video.src = "" "content/test")');
+        waitForEventOnce('webkitbeginfullscreen', beginfullscreen);
+        run('video.play()');
+    }
+
+    function beginfullscreen()
+    {
+        run('video.currentTime = 5');
+        run('video.webkitExitFullscreen()');
+        waitForEventOnce('webkitendfullscreen', endfullscreen);
+    }
+
+    function endfullscreen()
+    {
+        testExpected('video.paused', false);
+        run('video._ontimeupdate_ = timeupdate');
+        waitForEventAndFail('webkitbeginfullscreen');
+    }
+
+    function timeupdate()
+    {
+        if (video.currentTime == 0) {
+            run('video._ontimeupdate_ = null');
+            consoleWrite("Looped");
+            testExpected('video.playsInline', false);
+            setTimeout(function loopCompleted() {
+               testExpected('video.paused', false);
+               endTest();
+            }, 0);
+        }
+    }
+
+    </script>
+
+</head>
+
+<body _onload_="go()">
+    <video controls></video>
+</body>
+</html>

Modified: trunk/LayoutTests/platform/mac-wk2/TestExpectations (212313 => 212314)


--- trunk/LayoutTests/platform/mac-wk2/TestExpectations	2017-02-14 19:24:34 UTC (rev 212313)
+++ trunk/LayoutTests/platform/mac-wk2/TestExpectations	2017-02-14 19:34:09 UTC (rev 212314)
@@ -321,6 +321,9 @@
 
 webkit.org/b/156077 inspector/heap/getRemoteObject.html [ Pass Failure ]
 
+# Video fullscreen is not implemented for mac wk2 in webkittestrunner
+media/media-fullscreen-loop-inline.html [ Skip ]
+
 ### END OF (1) Classified failures with bug reports
 ########################################
 

Modified: trunk/Source/WebCore/ChangeLog (212313 => 212314)


--- trunk/Source/WebCore/ChangeLog	2017-02-14 19:24:34 UTC (rev 212313)
+++ trunk/Source/WebCore/ChangeLog	2017-02-14 19:34:09 UTC (rev 212314)
@@ -1,3 +1,25 @@
+2017-02-14  Jeremy Jones  <[email protected]>
+
+        When playing inline after fullscreen, set a flag instead of adding attribute plays inline, and use in requiresFullscreenForVideoPlayback.
+        https://bugs.webkit.org/show_bug.cgi?id=167815
+        rdar://problem/27685077
+
+        Reviewed by Jer Noble.
+
+        Test: media/media-fullscreen-loop-inline.html
+
+        When video is allowed to play inline after fullscreen. Looped video causes play state to update, which can send video back to fullscreen when
+        allowsInline is false. This change will set a new flag when allowsInlineMediaPlaybackAfterFullscreen allows inline playback that can be tested
+        in requiresFullscreenForVideoPlayback to prevent sending video back into fullscreen when video loops.
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::enterFullscreen):
+        (WebCore::HTMLMediaElement::exitFullscreen):
+        * html/HTMLMediaElement.h:
+        (WebCore::HTMLMediaElement::isTemporarilyAllowingInlinePlaybackAfterFullscreen): Added.
+        * html/MediaElementSession.cpp:
+        (WebCore::MediaElementSession::requiresFullscreenForVideoPlayback):
+
 2017-02-14  Jer Noble  <[email protected]>
 
         Video elements with MediaSource objects set by srcObject are not cleared when srcObject is set to null

Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (212313 => 212314)


--- trunk/Source/WebCore/html/HTMLMediaElement.cpp	2017-02-14 19:24:34 UTC (rev 212313)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp	2017-02-14 19:34:09 UTC (rev 212314)
@@ -5452,6 +5452,8 @@
     if (m_videoFullscreenMode == mode)
         return;
 
+    m_temporarilyAllowingInlinePlaybackAfterFullscreen = false;
+
 #if ENABLE(FULLSCREEN_API)
     if (document().settings().fullScreenEnabled()) {
         if (mode == VideoFullscreenModeStandard) {
@@ -5515,9 +5517,9 @@
         if (!document().settings().allowsInlineMediaPlaybackAfterFullscreen() || isVideoTooSmallForInlinePlayback())
             pauseInternal();
         else {
-            // Allow inline playback, but set 'playsinline' so pausing and starting again (e.g. when scrubbing) won't go back to fullscreen.
+            // Allow inline playback, but set a flag so pausing and starting again (e.g. when scrubbing or looping) won't go back to fullscreen.
             // Also set the controls attribute so the user will be able to control playback.
-            setBooleanAttribute(HTMLNames::playsinlineAttr, true);
+            m_temporarilyAllowingInlinePlaybackAfterFullscreen = true;
             setControls(true);
         }
     }

Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (212313 => 212314)


--- trunk/Source/WebCore/html/HTMLMediaElement.h	2017-02-14 19:24:34 UTC (rev 212313)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h	2017-02-14 19:34:09 UTC (rev 212314)
@@ -493,6 +493,8 @@
 
     double playbackStartedTime() const { return m_playbackStartedTime; }
 
+    bool isTemporarilyAllowingInlinePlaybackAfterFullscreen() const {return m_temporarilyAllowingInlinePlaybackAfterFullscreen; }
+
 protected:
     HTMLMediaElement(const QualifiedName&, Document&, bool createdByParser);
     virtual ~HTMLMediaElement();
@@ -891,6 +893,8 @@
     bool m_preparedForInline;
     std::function<void()> m_preparedForInlineCompletionHandler;
 
+    bool m_temporarilyAllowingInlinePlaybackAfterFullscreen { false };
+
 #if PLATFORM(IOS) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
     RetainPtr<PlatformLayer> m_videoFullscreenLayer;
     FloatRect m_videoFullscreenFrame;

Modified: trunk/Source/WebCore/html/MediaElementSession.cpp (212313 => 212314)


--- trunk/Source/WebCore/html/MediaElementSession.cpp	2017-02-14 19:24:34 UTC (rev 212313)
+++ trunk/Source/WebCore/html/MediaElementSession.cpp	2017-02-14 19:34:09 UTC (rev 212314)
@@ -540,6 +540,9 @@
     if (is<HTMLAudioElement>(element))
         return false;
 
+    if (element.isTemporarilyAllowingInlinePlaybackAfterFullscreen())
+        return false;
+
     if (!element.document().settings().allowsInlineMediaPlayback())
         return true;
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to