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

Side by Side 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. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « LayoutTests/platform/chromium/TestExpectations ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2937 matching lines...) Expand 10 before | Expand all | Expand 10 after
2948 // Let the text track mode be showing by default. 2948 // Let the text track mode be showing by default.
2949 defaultTrack = textTrack; 2949 defaultTrack = textTrack;
2950 } 2950 }
2951 } 2951 }
2952 2952
2953 if (!trackToEnable && defaultTrack) 2953 if (!trackToEnable && defaultTrack)
2954 trackToEnable = defaultTrack; 2954 trackToEnable = defaultTrack;
2955 2955
2956 // If no track matches the user's preferred language and non was marked 'def ault', enable the first track 2956 // If no track matches the user's preferred language and non was marked 'def ault', enable the first track
2957 // because the user has explicitly stated a preference for this kind of trac k. 2957 // because the user has explicitly stated a preference for this kind of trac k.
2958 if (!trackToEnable && fallbackTrack) 2958 if (!trackToEnable) {
2959 trackToEnable = fallbackTrack; 2959 if (fallbackTrack)
2960 trackToEnable = fallbackTrack;
2961 else if (group.kind == TrackGroup::CaptionsAndSubtitles && m_closedCapti onsVisible)
2962 trackToEnable = group.tracks[0];
2963 }
2960 2964
2961 if (currentlyEnabledTracks.size()) { 2965 if (currentlyEnabledTracks.size()) {
2962 for (size_t i = 0; i < currentlyEnabledTracks.size(); ++i) { 2966 for (size_t i = 0; i < currentlyEnabledTracks.size(); ++i) {
2963 RefPtr<TextTrack> textTrack = currentlyEnabledTracks[i]; 2967 RefPtr<TextTrack> textTrack = currentlyEnabledTracks[i];
2964 if (textTrack != trackToEnable) 2968 if (textTrack != trackToEnable)
2965 textTrack->setMode(TextTrack::disabledKeyword()); 2969 textTrack->setMode(TextTrack::disabledKeyword());
2966 } 2970 }
2967 } 2971 }
2968 2972
2969 if (trackToEnable) 2973 if (trackToEnable)
2970 trackToEnable->setMode(TextTrack::showingKeyword()); 2974 trackToEnable->setMode(TextTrack::showingKeyword());
2971
2972 m_processingPreferenceChange = false;
2973 } 2975 }
2974 2976
2975 void HTMLMediaElement::setSelectedTextTrack(TextTrack* trackToSelect) 2977 void HTMLMediaElement::setSelectedTextTrack(TextTrack* trackToSelect)
2976 { 2978 {
2977 TextTrackList* trackList = textTracks(); 2979 TextTrackList* trackList = textTracks();
2978 if (!trackList || !trackList->length()) 2980 if (!trackList || !trackList->length())
2979 return; 2981 return;
2980 if (trackToSelect && !trackList->contains(trackToSelect)) 2982 if (trackToSelect && !trackList->contains(trackToSelect))
2981 return; 2983 return;
2982 2984
(...skipping 957 matching lines...) Expand 10 before | Expand all | Expand 10 after
3940 bool HTMLMediaElement::closedCaptionsVisible() const 3942 bool HTMLMediaElement::closedCaptionsVisible() const
3941 { 3943 {
3942 return m_closedCaptionsVisible; 3944 return m_closedCaptionsVisible;
3943 } 3945 }
3944 3946
3945 #if ENABLE(VIDEO_TRACK) 3947 #if ENABLE(VIDEO_TRACK)
3946 void HTMLMediaElement::updateTextTrackDisplay() 3948 void HTMLMediaElement::updateTextTrackDisplay()
3947 { 3949 {
3948 if (!hasMediaControls() && !createMediaControls()) 3950 if (!hasMediaControls() && !createMediaControls())
3949 return; 3951 return;
3950 3952
3951 mediaControls()->updateTextTrackDisplay(); 3953 mediaControls()->updateTextTrackDisplay();
3952 } 3954 }
3953 #endif 3955 #endif
3954 3956
3955 void HTMLMediaElement::setClosedCaptionsVisible(bool closedCaptionVisible) 3957 void HTMLMediaElement::setClosedCaptionsVisible(bool closedCaptionVisible)
3956 { 3958 {
3957 LOG(Media, "HTMLMediaElement::setClosedCaptionsVisible(%s)", boolString(clos edCaptionVisible)); 3959 LOG(Media, "HTMLMediaElement::setClosedCaptionsVisible(%s)", boolString(clos edCaptionVisible));
3958 3960
3959 if (!m_player || !hasClosedCaptions()) 3961 if (!m_player || !hasClosedCaptions())
3960 return; 3962 return;
3961 3963
3962 m_closedCaptionsVisible = closedCaptionVisible; 3964 m_closedCaptionsVisible = closedCaptionVisible;
3963 m_player->setClosedCaptionsVisible(closedCaptionVisible); 3965 m_player->setClosedCaptionsVisible(closedCaptionVisible);
3964 3966
3965 #if ENABLE(VIDEO_TRACK) 3967 #if ENABLE(VIDEO_TRACK)
3966 if (RuntimeEnabledFeatures::webkitVideoTrackEnabled()) { 3968 if (RuntimeEnabledFeatures::webkitVideoTrackEnabled()) {
3967 m_processingPreferenceChange = true; 3969 m_processingPreferenceChange = true;
3968 markCaptionAndSubtitleTracksAsUnconfigured(); 3970 markCaptionAndSubtitleTracksAsUnconfigured();
3971 m_processingPreferenceChange = false;
3972
3973 // 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-
3974 // display has been enable due to not passing the criteria according to
3975 // user preferences or language, enable the first track that can be rend ered.
3976 if (closedCaptionsVisible && !m_haveVisibleTextTrack)
abarth-chromium 2013/04/18 05:36:39 Multiline if statements require { } even if they c
3977 for (size_t i = 0; i < m_textTracks->length(); ++i) {
3978 RefPtr<TextTrack> track = m_textTracks->item(i);
abarth-chromium 2013/04/18 05:36:39 Why RefPtr rather than just TextTrack* ?
3979 if (track->kind() == TextTrack::captionsKeyword() ||
3980 track->kind() == TextTrack::subtitlesKeyword()) {
3981 track->setMode(TextTrack::showingKeyword());
3982 break;
3983 }
3984 }
3985
3969 updateTextTrackDisplay(); 3986 updateTextTrackDisplay();
3970 } 3987 }
3971 #else 3988 #else
3972 if (hasMediaControls()) 3989 if (hasMediaControls())
3973 mediaControls()->changedClosedCaptionsVisibility(); 3990 mediaControls()->changedClosedCaptionsVisibility();
3974 #endif 3991 #endif
3975 } 3992 }
3976 3993
3977 void HTMLMediaElement::setWebkitClosedCaptionsVisible(bool visible) 3994 void HTMLMediaElement::setWebkitClosedCaptionsVisible(bool visible)
3978 { 3995 {
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
4115 if (!hasMediaControls() && !createMediaControls()) 4132 if (!hasMediaControls() && !createMediaControls())
4116 return; 4133 return;
4117 4134
4118 mediaControls()->show(); 4135 mediaControls()->show();
4119 } 4136 }
4120 4137
4121 #if ENABLE(VIDEO_TRACK) 4138 #if ENABLE(VIDEO_TRACK)
4122 void HTMLMediaElement::configureTextTrackDisplay() 4139 void HTMLMediaElement::configureTextTrackDisplay()
4123 { 4140 {
4124 ASSERT(m_textTracks); 4141 ASSERT(m_textTracks);
4142 LOG(Media, "HTMLMediaElement::configureTextTrackDisplay");
4125 4143
4126 if (m_processingPreferenceChange) 4144 if (m_processingPreferenceChange)
4127 return; 4145 return;
4128 4146
4129 bool haveVisibleTextTrack = false; 4147 bool haveVisibleTextTrack = false;
4130 for (unsigned i = 0; i < m_textTracks->length(); ++i) { 4148 for (unsigned i = 0; i < m_textTracks->length(); ++i) {
4131 if (m_textTracks->item(i)->mode() == TextTrack::showingKeyword()) { 4149 if (m_textTracks->item(i)->mode() == TextTrack::showingKeyword()) {
4132 haveVisibleTextTrack = true; 4150 haveVisibleTextTrack = true;
4133 break; 4151 break;
4134 } 4152 }
(...skipping 30 matching lines...) Expand all
4165 { 4183 {
4166 if (!m_textTracks) 4184 if (!m_textTracks)
4167 return; 4185 return;
4168 4186
4169 // Mark all tracks as not "configured" so that configureTextTracks() 4187 // Mark all tracks as not "configured" so that configureTextTracks()
4170 // will reconsider which tracks to display in light of new user preferences 4188 // will reconsider which tracks to display in light of new user preferences
4171 // (e.g. default tracks should not be displayed if the user has turned off 4189 // (e.g. default tracks should not be displayed if the user has turned off
4172 // captions and non-default tracks should be displayed based on language 4190 // captions and non-default tracks should be displayed based on language
4173 // preferences if the user has turned captions on). 4191 // preferences if the user has turned captions on).
4174 for (unsigned i = 0; i < m_textTracks->length(); ++i) { 4192 for (unsigned i = 0; i < m_textTracks->length(); ++i) {
4175
4176 RefPtr<TextTrack> textTrack = m_textTracks->item(i); 4193 RefPtr<TextTrack> textTrack = m_textTracks->item(i);
4177 String kind = textTrack->kind(); 4194 String kind = textTrack->kind();
4178 4195
4179 if (kind == TextTrack::subtitlesKeyword() || kind == TextTrack::captions Keyword()) 4196 if (kind == TextTrack::subtitlesKeyword() || kind == TextTrack::captions Keyword())
4180 textTrack->setHasBeenConfigured(false); 4197 textTrack->setHasBeenConfigured(false);
4181 } 4198 }
4182 configureTextTracks(); 4199 configureTextTracks();
4183 } 4200 }
4184 4201
4185 #endif 4202 #endif
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
4536 info.addMember(m_mediaController, "mediaController"); 4553 info.addMember(m_mediaController, "mediaController");
4537 4554
4538 #if ENABLE(WEB_AUDIO) 4555 #if ENABLE(WEB_AUDIO)
4539 info.addMember(m_audioSourceNode, "audioSourceNode"); 4556 info.addMember(m_audioSourceNode, "audioSourceNode");
4540 #endif 4557 #endif
4541 4558
4542 } 4559 }
4543 4560
4544 } 4561 }
4545 #endif 4562 #endif
OLDNEW
« no previous file with comments | « LayoutTests/platform/chromium/TestExpectations ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698