Chromium Code Reviews

Unified Diff: Source/WebCore/html/HTMLMediaElement.cpp

Issue 14056005: Added code to enable the first caption track if the user has requested captions and one such track … (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
« no previous file with comments | « LayoutTests/platform/chromium/TestExpectations ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/WebCore/html/HTMLMediaElement.cpp
diff --git a/Source/WebCore/html/HTMLMediaElement.cpp b/Source/WebCore/html/HTMLMediaElement.cpp
index 81fadb354dbfc4e7fab5cdc53a7289e049f21845..f51cc34f7f88a6623a9d991bb6a9334ced9a02fd 100644
--- a/Source/WebCore/html/HTMLMediaElement.cpp
+++ b/Source/WebCore/html/HTMLMediaElement.cpp
@@ -2955,8 +2955,12 @@ void HTMLMediaElement::configureTextTrackGroup(const TrackGroup& group)
// If no track matches the user's preferred language and non was marked 'default', enable the first track
// because the user has explicitly stated a preference for this kind of track.
- if (!trackToEnable && fallbackTrack)
- trackToEnable = fallbackTrack;
+ if (!trackToEnable) {
+ if (fallbackTrack)
+ trackToEnable = fallbackTrack;
+ else if (group.kind == TrackGroup::CaptionsAndSubtitles && m_closedCaptionsVisible)
+ trackToEnable = group.tracks[0];
+ }
if (currentlyEnabledTracks.size()) {
for (size_t i = 0; i < currentlyEnabledTracks.size(); ++i) {
@@ -2968,8 +2972,6 @@ void HTMLMediaElement::configureTextTrackGroup(const TrackGroup& group)
if (trackToEnable)
trackToEnable->setMode(TextTrack::showingKeyword());
-
- m_processingPreferenceChange = false;
}
void HTMLMediaElement::setSelectedTextTrack(TextTrack* trackToSelect)
@@ -3947,7 +3949,7 @@ void HTMLMediaElement::updateTextTrackDisplay()
{
if (!hasMediaControls() && !createMediaControls())
return;
-
+
mediaControls()->updateTextTrackDisplay();
}
#endif
@@ -3966,6 +3968,21 @@ void HTMLMediaElement::setClosedCaptionsVisible(bool closedCaptionVisible)
if (RuntimeEnabledFeatures::webkitVideoTrackEnabled()) {
m_processingPreferenceChange = true;
markCaptionAndSubtitleTracksAsUnconfigured();
+ m_processingPreferenceChange = false;
+
+ // If the user has enabled captions and no track that is available for
vcarbune.chromium 2013/04/20 00:30:12 I have removed this part, as it was merely a work-
+ // display has been enable due to not passing the criteria according to
+ // user preferences or language, enable the first track that can be rendered.
+ if (closedCaptionsVisible && !m_haveVisibleTextTrack)
abarth-chromium 2013/04/18 05:36:39 Multiline if statements require { } even if they c
+ for (size_t i = 0; i < m_textTracks->length(); ++i) {
+ RefPtr<TextTrack> track = m_textTracks->item(i);
abarth-chromium 2013/04/18 05:36:39 Why RefPtr rather than just TextTrack* ?
+ if (track->kind() == TextTrack::captionsKeyword() ||
+ track->kind() == TextTrack::subtitlesKeyword()) {
+ track->setMode(TextTrack::showingKeyword());
+ break;
+ }
+ }
+
updateTextTrackDisplay();
}
#else
@@ -4122,6 +4139,7 @@ void HTMLMediaElement::configureMediaControls()
void HTMLMediaElement::configureTextTrackDisplay()
{
ASSERT(m_textTracks);
+ LOG(Media, "HTMLMediaElement::configureTextTrackDisplay");
if (m_processingPreferenceChange)
return;
@@ -4172,7 +4190,6 @@ void HTMLMediaElement::markCaptionAndSubtitleTracksAsUnconfigured()
// captions and non-default tracks should be displayed based on language
// preferences if the user has turned captions on).
for (unsigned i = 0; i < m_textTracks->length(); ++i) {
-
RefPtr<TextTrack> textTrack = m_textTracks->item(i);
String kind = textTrack->kind();
« no previous file with comments | « LayoutTests/platform/chromium/TestExpectations ('k') | no next file » | no next file with comments »

Powered by Google App Engine