Changeset 204989 in webkit


Ignore:
Timestamp:
Aug 25, 2016, 3:01:07 PM (9 years ago)
Author:
Wenson Hsieh
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):

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r204987 r204989  
     12016-08-25  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Dragging against the end of the inline media scrubber causes the media scrubber to hide
     4        https://bugs.webkit.org/show_bug.cgi?id=161207
     5
     6        Reviewed by Eric Carlson.
     7
     8        Previously, we would re-enable behavior restrictions when firing an ended event. However, if the ended event is
     9        caused by the user seeking to the end of the video, the media controls would be taken away from under the user.
     10        To prevent this, we don't add the relevant behavior restrictions upon media ended if media was seeking before
     11        firing the event.
     12
     13        Tweaked an existing WebKit API test to cover this change.
     14
     15        * html/HTMLMediaElement.cpp:
     16        (WebCore::HTMLMediaElement::mediaPlayerTimeChanged):
     17        (WebCore::HTMLMediaElement::addBehaviorRestrictionsOnEndIfNecessary):
     18        * html/HTMLMediaElement.h:
     19        * html/MediaElementSession.cpp:
     20        (WebCore::MediaElementSession::canControlControlsManager):
     21
    1222016-08-25  Andreas Kling  <akling@apple.com>
    223
  • trunk/Source/WebCore/html/HTMLMediaElement.cpp

    r204702 r204989  
    43664366
    43674367    invalidateCachedTime();
     4368    bool wasSeeking = seeking();
    43684369
    43694370    // 4.8.10.9 step 14 & 15.  Needed if no ReadyState change is associated with the seek.
     
    44034404                m_sentEndEvent = true;
    44044405                scheduleEvent(eventNames().endedEvent);
    4405                 m_mediaSession->addBehaviorRestriction(MediaElementSession::RequireUserGestureToControlControlsManager | MediaElementSession::RequirePlaybackToControlControlsManager);
     4406                if (!wasSeeking)
     4407                    addBehaviorRestrictionsOnEndIfNecessary();
    44064408            }
    44074409            // If the media element has a current media controller, then report the controller state
     
    44244426                m_sentEndEvent = true;
    44254427                scheduleEvent(eventNames().endedEvent);
    4426                 m_mediaSession->addBehaviorRestriction(MediaElementSession::RequireUserGestureToControlControlsManager | MediaElementSession::RequirePlaybackToControlControlsManager);
     4428                if (!wasSeeking)
     4429                    addBehaviorRestrictionsOnEndIfNecessary();
    44274430                m_paused = true;
    44284431                setPlaying(false);
     
    44354438    updatePlayState(UpdateState::Asynchronously);
    44364439    endProcessingMediaPlayerCallback();
     4440}
     4441
     4442void HTMLMediaElement::addBehaviorRestrictionsOnEndIfNecessary()
     4443{
     4444    if (isFullscreen())
     4445        return;
     4446
     4447    m_mediaSession->addBehaviorRestriction(MediaElementSession::RequirePlaybackToControlControlsManager | MediaElementSession::RequireUserGestureToControlControlsManager);
    44374448}
    44384449
  • trunk/Source/WebCore/html/HTMLMediaElement.h

    r204717 r204989  
    795795    void setControllerJSProperty(const char*, JSC::JSValue);
    796796
     797    void addBehaviorRestrictionsOnEndIfNecessary();
     798
    797799    Timer m_pendingActionTimer;
    798800    Timer m_progressEventTimer;
  • trunk/Source/WebCore/html/MediaElementSession.cpp

    r204394 r204989  
    225225    }
    226226
    227     if (m_element.ended()) {
    228         LOG(Media, "MediaElementSession::canControlControlsManager - returning FALSE: Ended");
    229         return false;
    230     }
    231 
    232227    if (m_element.document().activeDOMObjectsAreSuspended()) {
    233228        LOG(Media, "MediaElementSession::canControlControlsManager - returning FALSE: activeDOMObjectsAreSuspended()");
  • trunk/Tools/ChangeLog

    r204971 r204989  
     12016-08-25  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Dragging against the end of the inline media scrubber causes the media scrubber to hide
     4        https://bugs.webkit.org/show_bug.cgi?id=161207
     5
     6        Reviewed by Eric Carlson.
     7
     8        Tweaks an existing WebKit API test covering this behavior change. After some discussion, rather than hide media
     9        controls in this case, we should actually continue showing them. This is because seeking due to user gestures
     10        similar to "scrubbing" are indistinguishable from gestures that immediately seek to the end.
     11
     12        * TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm:
     13        (TestWebKitAPI::TEST):
     14
    1152016-08-25  Daniel Bates  <dabates@apple.com>
    216
  • trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm

    r203928 r204989  
    300300}
    301301
    302 TEST(VideoControlsManager, VideoControlsManagerLargeAutoplayingVideoHidesControlsAfterSeekingToEnd)
     302TEST(VideoControlsManager, VideoControlsManagerLargeAutoplayingVideoAfterSeekingToEnd)
    303303{
    304304    RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
     
    316316    [[configuration userContentController] addScriptMessageHandler:onloadHandler.get() name:@"onloadHandler"];
    317317
    318     // Since the video has ended, the expectation is NO.
    319     [handler setExpectedToHaveControlsManager:NO];
     318    // We expect there to be media controls, since this is a user gestured seek to the end.
     319    // This is akin to seeking to the end by scrubbing in the controls.
     320    [handler setExpectedToHaveControlsManager:YES];
    320321    NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"large-video-hides-controls-after-seek-to-end" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];
    321322    [webView loadRequest:request];
Note: See TracChangeset for help on using the changeset viewer.