Title: [204989] trunk
Revision
204989
Author
[email protected]
Date
2016-08-25 15:01:07 -0700 (Thu, 25 Aug 2016)

Log Message

Dragging against the end of the inline media scrubber causes the media scrubber to hide
https://bugs.webkit.org/show_bug.cgi?id=161207

Reviewed by Eric Carlson.

Source/WebCore:

Previously, we would re-enable behavior restrictions when firing an ended event. However, if the ended event is
caused by the user seeking to the end of the video, the media controls would be taken away from under the user.
To prevent this, we don't add the relevant behavior restrictions upon media ended if media was seeking before
firing the event.

Tweaked an existing WebKit API test to cover this change.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::mediaPlayerTimeChanged):
(WebCore::HTMLMediaElement::addBehaviorRestrictionsOnEndIfNecessary):
* html/HTMLMediaElement.h:
* html/MediaElementSession.cpp:
(WebCore::MediaElementSession::canControlControlsManager):

Tools:

Tweaks an existing WebKit API test covering this behavior change. After some discussion, rather than hide media
controls in this case, we should actually continue showing them. This is because seeking due to user gestures
similar to "scrubbing" are indistinguishable from gestures that immediately seek to the end.

* TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm:
(TestWebKitAPI::TEST):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (204988 => 204989)


--- trunk/Source/WebCore/ChangeLog	2016-08-25 21:59:54 UTC (rev 204988)
+++ trunk/Source/WebCore/ChangeLog	2016-08-25 22:01:07 UTC (rev 204989)
@@ -1,3 +1,24 @@
+2016-08-25  Wenson Hsieh  <[email protected]>
+
+        Dragging against the end of the inline media scrubber causes the media scrubber to hide
+        https://bugs.webkit.org/show_bug.cgi?id=161207
+
+        Reviewed by Eric Carlson.
+
+        Previously, we would re-enable behavior restrictions when firing an ended event. However, if the ended event is
+        caused by the user seeking to the end of the video, the media controls would be taken away from under the user.
+        To prevent this, we don't add the relevant behavior restrictions upon media ended if media was seeking before
+        firing the event.
+
+        Tweaked an existing WebKit API test to cover this change.
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::mediaPlayerTimeChanged):
+        (WebCore::HTMLMediaElement::addBehaviorRestrictionsOnEndIfNecessary):
+        * html/HTMLMediaElement.h:
+        * html/MediaElementSession.cpp:
+        (WebCore::MediaElementSession::canControlControlsManager):
+
 2016-08-25  Andreas Kling  <[email protected]>
 
         REGRESSION: RELEASE_ASSERT in ResourceUsageThread::platformThreadBody when ASan is enabled

Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (204988 => 204989)


--- trunk/Source/WebCore/html/HTMLMediaElement.cpp	2016-08-25 21:59:54 UTC (rev 204988)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp	2016-08-25 22:01:07 UTC (rev 204989)
@@ -4365,6 +4365,7 @@
     beginProcessingMediaPlayerCallback();
 
     invalidateCachedTime();
+    bool wasSeeking = seeking();
 
     // 4.8.10.9 step 14 & 15.  Needed if no ReadyState change is associated with the seek.
     if (m_seeking && m_readyState >= HAVE_CURRENT_DATA && !m_player->seeking())
@@ -4402,7 +4403,8 @@
             if (!m_sentEndEvent) {
                 m_sentEndEvent = true;
                 scheduleEvent(eventNames().endedEvent);
-                m_mediaSession->addBehaviorRestriction(MediaElementSession::RequireUserGestureToControlControlsManager | MediaElementSession::RequirePlaybackToControlControlsManager);
+                if (!wasSeeking)
+                    addBehaviorRestrictionsOnEndIfNecessary();
             }
             // If the media element has a current media controller, then report the controller state
             // for the media element's current media controller.
@@ -4423,7 +4425,8 @@
             if (!m_sentEndEvent && m_player && m_player->ended()) {
                 m_sentEndEvent = true;
                 scheduleEvent(eventNames().endedEvent);
-                m_mediaSession->addBehaviorRestriction(MediaElementSession::RequireUserGestureToControlControlsManager | MediaElementSession::RequirePlaybackToControlControlsManager);
+                if (!wasSeeking)
+                    addBehaviorRestrictionsOnEndIfNecessary();
                 m_paused = true;
                 setPlaying(false);
             }
@@ -4436,6 +4439,14 @@
     endProcessingMediaPlayerCallback();
 }
 
+void HTMLMediaElement::addBehaviorRestrictionsOnEndIfNecessary()
+{
+    if (isFullscreen())
+        return;
+
+    m_mediaSession->addBehaviorRestriction(MediaElementSession::RequirePlaybackToControlControlsManager | MediaElementSession::RequireUserGestureToControlControlsManager);
+}
+
 void HTMLMediaElement::mediaPlayerVolumeChanged(MediaPlayer*)
 {
     LOG(Media, "HTMLMediaElement::mediaPlayerVolumeChanged(%p)", this);

Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (204988 => 204989)


--- trunk/Source/WebCore/html/HTMLMediaElement.h	2016-08-25 21:59:54 UTC (rev 204988)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h	2016-08-25 22:01:07 UTC (rev 204989)
@@ -794,6 +794,8 @@
     void updateUsesLTRUserInterfaceLayoutDirectionJSProperty();
     void setControllerJSProperty(const char*, JSC::JSValue);
 
+    void addBehaviorRestrictionsOnEndIfNecessary();
+
     Timer m_pendingActionTimer;
     Timer m_progressEventTimer;
     Timer m_playbackProgressTimer;

Modified: trunk/Source/WebCore/html/MediaElementSession.cpp (204988 => 204989)


--- trunk/Source/WebCore/html/MediaElementSession.cpp	2016-08-25 21:59:54 UTC (rev 204988)
+++ trunk/Source/WebCore/html/MediaElementSession.cpp	2016-08-25 22:01:07 UTC (rev 204989)
@@ -224,11 +224,6 @@
         return false;
     }
 
-    if (m_element.ended()) {
-        LOG(Media, "MediaElementSession::canControlControlsManager - returning FALSE: Ended");
-        return false;
-    }
-
     if (m_element.document().activeDOMObjectsAreSuspended()) {
         LOG(Media, "MediaElementSession::canControlControlsManager - returning FALSE: activeDOMObjectsAreSuspended()");
         return false;

Modified: trunk/Tools/ChangeLog (204988 => 204989)


--- trunk/Tools/ChangeLog	2016-08-25 21:59:54 UTC (rev 204988)
+++ trunk/Tools/ChangeLog	2016-08-25 22:01:07 UTC (rev 204989)
@@ -1,3 +1,17 @@
+2016-08-25  Wenson Hsieh  <[email protected]>
+
+        Dragging against the end of the inline media scrubber causes the media scrubber to hide
+        https://bugs.webkit.org/show_bug.cgi?id=161207
+
+        Reviewed by Eric Carlson.
+
+        Tweaks an existing WebKit API test covering this behavior change. After some discussion, rather than hide media
+        controls in this case, we should actually continue showing them. This is because seeking due to user gestures
+        similar to "scrubbing" are indistinguishable from gestures that immediately seek to the end.
+
+        * TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm:
+        (TestWebKitAPI::TEST):
+
 2016-08-25  Daniel Bates  <[email protected]>
 
         Watch more things.

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm (204988 => 204989)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm	2016-08-25 21:59:54 UTC (rev 204988)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm	2016-08-25 22:01:07 UTC (rev 204989)
@@ -299,7 +299,7 @@
     TestWebKitAPI::Util::run(&receivedScriptMessage);
 }
 
-TEST(VideoControlsManager, VideoControlsManagerLargeAutoplayingVideoHidesControlsAfterSeekingToEnd)
+TEST(VideoControlsManager, VideoControlsManagerLargeAutoplayingVideoAfterSeekingToEnd)
 {
     RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
     configuration.get().mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone;
@@ -315,8 +315,9 @@
     }]);
     [[configuration userContentController] addScriptMessageHandler:onloadHandler.get() name:@"onloadHandler"];
 
-    // Since the video has ended, the expectation is NO.
-    [handler setExpectedToHaveControlsManager:NO];
+    // We expect there to be media controls, since this is a user gestured seek to the end.
+    // This is akin to seeking to the end by scrubbing in the controls.
+    [handler setExpectedToHaveControlsManager:YES];
     NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"large-video-hides-controls-after-seek-to-end" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];
     [webView loadRequest:request];
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to