Changeset 206490 in webkit


Ignore:
Timestamp:
Sep 27, 2016, 6:39:15 PM (9 years ago)
Author:
bshafiei@apple.com
Message:

Merge r206454. rdar://problem/28484193

Location:
branches/safari-602.2.14.0-branch/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-602.2.14.0-branch/Source/WebCore/ChangeLog

    r206489 r206490  
     12016-09-27  Babak Shafiei  <bshafiei@apple.com>
     2
     3        Merge r206454. rdar://problem/28484193
     4
     5    2016-09-27  Wenson Hsieh  <wenson_hsieh@apple.com>
     6
     7            Related videos on YouTube (and YouTube playlists) cause media controls to disappear
     8            https://bugs.webkit.org/show_bug.cgi?id=162621
     9            <rdar://problem/28484193>
     10
     11            Reviewed by Jer Noble.
     12
     13            Tweaks the main content media heuristic for better Now Playing behavior on YouTube by making the following
     14            changes:
     15            - Remove the strict requirement for audio to be actively playing for the session to be able to show
     16              controls for the purpose of Now Playing, making it the same as our policy for the controls manager.
     17            - Make playback requirement restrictions apply only for the controls manager. Videos that do not
     18              autoplay will still have the correct behavior with respect to Now Playing, since we will bail in the
     19              hasEverNotifiedAboutPlaying() check.
     20            - Only consider the main content heuristic as preventing media controls from showing up for the purposes
     21              of the controls manager. Now Playing should instead account for this by preferring elements large
     22              enough for main content after collecting all of the candidate sessions.
     23
     24            * html/HTMLMediaElement.cpp:
     25            (WebCore::mediaElementSessionInfoForSession):
     26            (WebCore::preferMediaControlsForCandidateSessionOverOtherCandidateSession):
     27            (WebCore::HTMLMediaElement::updatePlayState):
     28            * html/MediaElementSession.cpp:
     29            (WebCore::MediaElementSession::canShowControlsManager):
     30            * platform/audio/mac/MediaSessionManagerMac.mm:
     31            (WebCore::MediaSessionManagerMac::sessionWillBeginPlayback):
     32
    1332016-09-27  Babak Shafiei  <bshafiei@apple.com>
    234
  • branches/safari-602.2.14.0-branch/Source/WebCore/html/HTMLMediaElement.cpp

    r206487 r206490  
    351351struct MediaElementSessionInfo {
    352352    const MediaElementSession* session;
     353    MediaElementSession::PlaybackControlsPurpose purpose;
    353354
    354355    double timeOfLastUserInteraction;
     
    364365    return {
    365366        &session,
     367        purpose,
    366368        session.mostRecentUserInteractionTime(),
    367369        session.canShowControlsManager(purpose),
     
    374376static bool preferMediaControlsForCandidateSessionOverOtherCandidateSession(const MediaElementSessionInfo& session, const MediaElementSessionInfo& otherSession)
    375377{
    376     // Prioritize visible media over offscreen media.
    377     if (session.isVisibleInViewportOrFullscreen != otherSession.isVisibleInViewportOrFullscreen)
     378    MediaElementSession::PlaybackControlsPurpose purpose = session.purpose;
     379    ASSERT(purpose == otherSession.purpose);
     380
     381    // For the controls manager, prioritize visible media over offscreen media.
     382    if (purpose == MediaElementSession::PlaybackControlsPurpose::ControlsManager && session.isVisibleInViewportOrFullscreen != otherSession.isVisibleInViewportOrFullscreen)
    378383        return session.isVisibleInViewportOrFullscreen;
     384
     385    // For Now Playing, prioritize elements that would normally satisfy main content.
     386    if (purpose == MediaElementSession::PlaybackControlsPurpose::NowPlaying && session.isLargeEnoughForMainContent != otherSession.isLargeEnoughForMainContent)
     387        return session.isLargeEnoughForMainContent;
    379388
    380389    // As a tiebreaker, prioritize elements that the user recently interacted with.
     
    50865095    updateMediaController();
    50875096    updateRenderer();
     5097
     5098    m_hasEverHadAudio |= hasAudio();
     5099    m_hasEverHadVideo |= hasVideo();
    50885100}
    50895101
  • branches/safari-602.2.14.0-branch/Source/WebCore/html/MediaElementSession.cpp

    r206489 r206490  
    234234    }
    235235
    236     bool meetsAudioTrackRequirements = m_element.hasAudio() || (purpose == PlaybackControlsPurpose::ControlsManager && m_element.hasEverHadAudio());
    237     if (!meetsAudioTrackRequirements) {
     236    if (!m_element.hasAudio() && !m_element.hasEverHadAudio()) {
    238237        LOG(Media, "MediaElementSession::canShowControlsManager - returning FALSE: No audio");
    239238        return false;
     
    260259    }
    261260
    262     if (hasBehaviorRestriction(RequirePlaybackToControlControlsManager) && !m_element.isPlaying()) {
     261    if (purpose == PlaybackControlsPurpose::ControlsManager && hasBehaviorRestriction(RequirePlaybackToControlControlsManager) && !m_element.isPlaying()) {
    263262        LOG(Media, "MediaElementSession::canShowControlsManager - returning FALSE: Needs to be playing");
    264263        return false;
     
    275274    }
    276275
    277     if (m_element.isVideo()) {
     276    // Only allow the main content heuristic to forbid videos from showing up if our purpose is the controls manager.
     277    if (purpose == PlaybackControlsPurpose::ControlsManager && m_element.isVideo()) {
    278278        if (!m_element.renderer()) {
    279279            LOG(Media, "MediaElementSession::canShowControlsManager - returning FALSE: No renderer");
     
    281281        }
    282282
    283         if (purpose == PlaybackControlsPurpose::ControlsManager && !m_element.hasVideo() && !m_element.hasEverHadVideo()) {
     283        if (!m_element.hasVideo() && !m_element.hasEverHadVideo()) {
    284284            LOG(Media, "MediaElementSession::canShowControlsManager - returning FALSE: No video");
    285285            return false;
     
    290290            return true;
    291291        }
     292    }
     293
     294    if (purpose == PlaybackControlsPurpose::NowPlaying) {
     295        LOG(Media, "MediaElementSession::canShowControlsManager - returning TRUE: Potentially plays audio");
     296        return true;
    292297    }
    293298
  • branches/safari-602.2.14.0-branch/Source/WebCore/platform/audio/mac/MediaSessionManagerMac.mm

    r206487 r206490  
    8282
    8383    LOG(Media, "MediaSessionManagerMac::sessionWillBeginPlayback");
    84     updateNowPlayingInfo();
     84    scheduleUpdateNowPlayingInfo();
    8585    return true;
    8686}
Note: See TracChangeset for help on using the changeset viewer.