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

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

Issue 1082533002: Support text track selection in video controls (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 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
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 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 , m_playingRemotely(false) 356 , m_playingRemotely(false)
357 #if ENABLE(OILPAN) 357 #if ENABLE(OILPAN)
358 , m_isFinalizing(false) 358 , m_isFinalizing(false)
359 , m_closeMediaSourceWhenFinalizing(false) 359 , m_closeMediaSourceWhenFinalizing(false)
360 #endif 360 #endif
361 , m_initialPlayWithoutUserGestures(false) 361 , m_initialPlayWithoutUserGestures(false)
362 , m_autoplayMediaCounted(false) 362 , m_autoplayMediaCounted(false)
363 , m_audioTracks(AudioTrackList::create(*this)) 363 , m_audioTracks(AudioTrackList::create(*this))
364 , m_videoTracks(VideoTrackList::create(*this)) 364 , m_videoTracks(VideoTrackList::create(*this))
365 , m_textTracks(nullptr) 365 , m_textTracks(nullptr)
366 , m_selectedTextTrack(nullptr)
366 #if ENABLE(WEB_AUDIO) 367 #if ENABLE(WEB_AUDIO)
367 , m_audioSourceNode(nullptr) 368 , m_audioSourceNode(nullptr)
368 #endif 369 #endif
369 { 370 {
370 ASSERT(RuntimeEnabledFeatures::mediaEnabled()); 371 ASSERT(RuntimeEnabledFeatures::mediaEnabled());
371 372
372 WTF_LOG(Media, "HTMLMediaElement::HTMLMediaElement(%p)", this); 373 WTF_LOG(Media, "HTMLMediaElement::HTMLMediaElement(%p)", this);
373 374
374 if (document.settings() && document.settings()->mediaPlaybackRequiresUserGes ture()) 375 if (document.settings() && document.settings()->mediaPlaybackRequiresUserGes ture())
375 m_userGestureRequiredForPlay = true; 376 m_userGestureRequiredForPlay = true;
(...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after
1160 // Mark this track as "configured" so configureTextTracks won't change the m ode again. 1161 // Mark this track as "configured" so configureTextTracks won't change the m ode again.
1161 if (track->trackType() == TextTrack::TrackElement) 1162 if (track->trackType() == TextTrack::TrackElement)
1162 track->setHasBeenConfigured(true); 1163 track->setHasBeenConfigured(true);
1163 1164
1164 configureTextTrackDisplay(AssumeVisibleChange); 1165 configureTextTrackDisplay(AssumeVisibleChange);
1165 1166
1166 ASSERT(textTracks()->contains(track)); 1167 ASSERT(textTracks()->contains(track));
1167 textTracks()->scheduleChangeEvent(); 1168 textTracks()->scheduleChangeEvent();
1168 } 1169 }
1169 1170
1171 void HTMLMediaElement::showTextTrackAtIndex(unsigned index)
fs 2015/04/14 12:34:56 Any reason - m_selectedTextTrack excepted - to hav
srivats 2015/04/16 23:37:19 No. I moved this method to MediaControlElements an
1172 {
1173 TextTrackList* trackList = textTracks();
1174 if (!trackList || !trackList->length())
1175 return;
1176
1177 for (unsigned i = 0; i < trackList->length(); ++i) {
1178 TextTrack* track = trackList->item(i);
1179 track->setMode(TextTrack::disabledKeyword());
fs 2015/04/14 12:34:56 This ought to be more selective. I.e. only do this
srivats 2015/04/16 23:37:19 By rendered tracks, are you referring to tracks wi
fs 2015/04/17 11:54:46 No, I mean tracks that are either kind=subtitles o
srivats 2015/04/21 01:48:55 Done.
1180 }
1181
1182 if (index < trackList->length()) {
1183 m_selectedTextTrack = trackList->item(index);
fs 2015/04/14 12:34:56 It feels a bit like this is only used to avoid run
srivats 2015/04/16 23:37:19 Done.
1184 m_selectedTextTrack->setMode(TextTrack::showingKeyword());
1185 }
1186 }
1187
1170 bool HTMLMediaElement::isSafeToLoadURL(const KURL& url, InvalidURLAction actionI fInvalid) 1188 bool HTMLMediaElement::isSafeToLoadURL(const KURL& url, InvalidURLAction actionI fInvalid)
1171 { 1189 {
1172 if (!url.isValid()) { 1190 if (!url.isValid()) {
1173 WTF_LOG(Media, "HTMLMediaElement::isSafeToLoadURL(%p, %s) -> FALSE becau se url is invalid", this, urlForLoggingMedia(url).utf8().data()); 1191 WTF_LOG(Media, "HTMLMediaElement::isSafeToLoadURL(%p, %s) -> FALSE becau se url is invalid", this, urlForLoggingMedia(url).utf8().data());
1174 return false; 1192 return false;
1175 } 1193 }
1176 1194
1177 LocalFrame* frame = document().frame(); 1195 LocalFrame* frame = document().frame();
1178 if (!frame || !document().securityOrigin()->canDisplay(url)) { 1196 if (!frame || !document().securityOrigin()->canDisplay(url)) {
1179 if (actionIfInvalid == Complain) 1197 if (actionIfInvalid == Complain)
(...skipping 1294 matching lines...) Expand 10 before | Expand all | Expand 10 after
2474 size_t index = m_textTracksWhenResourceSelectionBegan.find(textTrack.get()); 2492 size_t index = m_textTracksWhenResourceSelectionBegan.find(textTrack.get());
2475 if (index != kNotFound) 2493 if (index != kNotFound)
2476 m_textTracksWhenResourceSelectionBegan.remove(index); 2494 m_textTracksWhenResourceSelectionBegan.remove(index);
2477 } 2495 }
2478 2496
2479 void HTMLMediaElement::honorUserPreferencesForAutomaticTextTrackSelection() 2497 void HTMLMediaElement::honorUserPreferencesForAutomaticTextTrackSelection()
2480 { 2498 {
2481 if (!m_textTracks || !m_textTracks->length()) 2499 if (!m_textTracks || !m_textTracks->length())
2482 return; 2500 return;
2483 2501
2502 // If the user has selected a track to display, don't perform automatic sele ction
2503 if (m_selectedTextTrack) {
2504 m_selectedTextTrack->setMode(TextTrack::showingKeyword());
2505 return;
2506 }
2507
2484 AutomaticTrackSelection::Configuration configuration; 2508 AutomaticTrackSelection::Configuration configuration;
2485 if (m_processingPreferenceChange) 2509 if (m_processingPreferenceChange)
2486 configuration.disableCurrentlyEnabledTracks = true; 2510 configuration.disableCurrentlyEnabledTracks = true;
2487 if (m_closedCaptionsVisible) 2511 if (m_closedCaptionsVisible)
2488 configuration.forceEnableSubtitleOrCaptionTrack = true; 2512 configuration.forceEnableSubtitleOrCaptionTrack = true;
2489 2513
2490 AutomaticTrackSelection trackSelection(configuration); 2514 AutomaticTrackSelection trackSelection(configuration);
2491 trackSelection.perform(*m_textTracks); 2515 trackSelection.perform(*m_textTracks);
2492 2516
2493 textTracksChanged(); 2517 textTracksChanged();
(...skipping 1179 matching lines...) Expand 10 before | Expand all | Expand 10 after
3673 3697
3674 #if ENABLE(WEB_AUDIO) 3698 #if ENABLE(WEB_AUDIO)
3675 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) 3699 void HTMLMediaElement::clearWeakMembers(Visitor* visitor)
3676 { 3700 {
3677 if (!visitor->isHeapObjectAlive(m_audioSourceNode) && audioSourceProvider()) 3701 if (!visitor->isHeapObjectAlive(m_audioSourceNode) && audioSourceProvider())
3678 audioSourceProvider()->setClient(nullptr); 3702 audioSourceProvider()->setClient(nullptr);
3679 } 3703 }
3680 #endif 3704 #endif
3681 3705
3682 } 3706 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698