Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Side by Side Diff: Source/core/html/HTMLMediaElement.cpp

Issue 882993002: Implement automatic text track selection for 'metadata' tracks (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 2906 matching lines...) Expand 10 before | Expand all | Expand 10 after
2917 RefPtrWillBeRawPtr<TextTrack> textTrack = currentlyEnabledTracks[i]; 2917 RefPtrWillBeRawPtr<TextTrack> textTrack = currentlyEnabledTracks[i];
2918 if (textTrack != trackToEnable) 2918 if (textTrack != trackToEnable)
2919 textTrack->setMode(TextTrack::disabledKeyword()); 2919 textTrack->setMode(TextTrack::disabledKeyword());
2920 } 2920 }
2921 } 2921 }
2922 2922
2923 if (trackToEnable) 2923 if (trackToEnable)
2924 trackToEnable->setMode(TextTrack::showingKeyword()); 2924 trackToEnable->setMode(TextTrack::showingKeyword());
2925 } 2925 }
2926 2926
2927 void HTMLMediaElement::configureMetadataTextTrackGroup(const TrackGroup& group)
2928 {
2929 ASSERT(group.tracks.size());
2930
2931 // https://html.spec.whatwg.org/multipage/embedded-content.html#honor-user-p references-for-automatic-text-track-selection
2932
2933 // 4. If there are any text tracks in the media element's list of text
2934 // tracks whose text track kind is metadata that correspond to track
2935 // elements with a default attribute set whose text track mode is set to
2936 // disabled, then set the text track mode of all such tracks to hidden
2937 for (auto& textTrack : group.tracks) {
2938 if (textTrack->mode() != TextTrack::disabledKeyword())
2939 continue;
2940 if (!textTrack->isDefault())
2941 continue;
2942 textTrack->setMode(TextTrack::hiddenKeyword());
2943 }
2944 }
2945
2927 void HTMLMediaElement::configureTextTracks() 2946 void HTMLMediaElement::configureTextTracks()
2928 { 2947 {
2929 TrackGroup captionAndSubtitleTracks(TrackGroup::CaptionsAndSubtitles); 2948 TrackGroup captionAndSubtitleTracks(TrackGroup::CaptionsAndSubtitles);
2930 TrackGroup descriptionTracks(TrackGroup::Description); 2949 TrackGroup descriptionTracks(TrackGroup::Description);
2931 TrackGroup chapterTracks(TrackGroup::Chapter); 2950 TrackGroup chapterTracks(TrackGroup::Chapter);
2932 TrackGroup metadataTracks(TrackGroup::Metadata); 2951 TrackGroup metadataTracks(TrackGroup::Metadata);
2933 TrackGroup otherTracks(TrackGroup::Other); 2952 TrackGroup otherTracks(TrackGroup::Other);
2934 2953
2935 if (!m_textTracks) 2954 if (!m_textTracks)
2936 return; 2955 return;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
2972 currentGroup->tracks.append(textTrack); 2991 currentGroup->tracks.append(textTrack);
2973 } 2992 }
2974 2993
2975 if (captionAndSubtitleTracks.tracks.size()) 2994 if (captionAndSubtitleTracks.tracks.size())
2976 configureTextTrackGroup(captionAndSubtitleTracks); 2995 configureTextTrackGroup(captionAndSubtitleTracks);
2977 if (descriptionTracks.tracks.size()) 2996 if (descriptionTracks.tracks.size())
2978 configureTextTrackGroup(descriptionTracks); 2997 configureTextTrackGroup(descriptionTracks);
2979 if (chapterTracks.tracks.size()) 2998 if (chapterTracks.tracks.size())
2980 configureTextTrackGroup(chapterTracks); 2999 configureTextTrackGroup(chapterTracks);
2981 if (metadataTracks.tracks.size()) 3000 if (metadataTracks.tracks.size())
2982 configureTextTrackGroup(metadataTracks); 3001 configureMetadataTextTrackGroup(metadataTracks);
2983 if (otherTracks.tracks.size()) 3002 if (otherTracks.tracks.size())
2984 configureTextTrackGroup(otherTracks); 3003 configureTextTrackGroup(otherTracks);
philipj_slow 2015/01/29 10:34:52 This looks like it's not per spec if you want to r
fs 2015/01/29 12:05:51 Yes, I noticed this as well, and I wondered what t
2985 3004
2986 textTracksChanged(); 3005 textTracksChanged();
2987 } 3006 }
2988 3007
2989 bool HTMLMediaElement::havePotentialSourceChild() 3008 bool HTMLMediaElement::havePotentialSourceChild()
2990 { 3009 {
2991 // Stash the current <source> node and next nodes so we can restore them aft er checking 3010 // Stash the current <source> node and next nodes so we can restore them aft er checking
2992 // to see there is another potential. 3011 // to see there is another potential.
2993 RefPtrWillBeRawPtr<HTMLSourceElement> currentSourceNode = m_currentSourceNod e; 3012 RefPtrWillBeRawPtr<HTMLSourceElement> currentSourceNode = m_currentSourceNod e;
2994 RefPtrWillBeRawPtr<Node> nextNode = m_nextChildNodeToConsider; 3013 RefPtrWillBeRawPtr<Node> nextNode = m_nextChildNodeToConsider;
(...skipping 1102 matching lines...) Expand 10 before | Expand all | Expand 10 after
4097 4116
4098 #if ENABLE(WEB_AUDIO) 4117 #if ENABLE(WEB_AUDIO)
4099 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) 4118 void HTMLMediaElement::clearWeakMembers(Visitor* visitor)
4100 { 4119 {
4101 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider()) 4120 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider())
4102 audioSourceProvider()->setClient(nullptr); 4121 audioSourceProvider()->setClient(nullptr);
4103 } 4122 }
4104 #endif 4123 #endif
4105 4124
4106 } 4125 }
OLDNEW
« LayoutTests/media/track/track-selection-metadata.html ('K') | « Source/core/html/HTMLMediaElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698