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

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

Issue 1118613002: Hook up Android closed captions 'enabled' setting to Blink (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Addressed comments from fs Created 5 years, 6 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 2484 matching lines...) Expand 10 before | Expand all | Expand 10 after
2495 { 2495 {
2496 if (!m_textTracks || !m_textTracks->length()) 2496 if (!m_textTracks || !m_textTracks->length())
2497 return; 2497 return;
2498 2498
2499 AutomaticTrackSelection::Configuration configuration; 2499 AutomaticTrackSelection::Configuration configuration;
2500 if (m_processingPreferenceChange) 2500 if (m_processingPreferenceChange)
2501 configuration.disableCurrentlyEnabledTracks = true; 2501 configuration.disableCurrentlyEnabledTracks = true;
2502 if (m_closedCaptionsVisible) 2502 if (m_closedCaptionsVisible)
2503 configuration.forceEnableSubtitleOrCaptionTrack = true; 2503 configuration.forceEnableSubtitleOrCaptionTrack = true;
2504 2504
2505 Settings* settings = document().settings();
2506 if (settings)
2507 configuration.textTrackKindUserPreference = settings->textTrackKindUserP reference();
2508
2505 AutomaticTrackSelection trackSelection(configuration); 2509 AutomaticTrackSelection trackSelection(configuration);
2506 trackSelection.perform(*m_textTracks); 2510 trackSelection.perform(*m_textTracks);
2507 2511
2508 textTracksChanged(); 2512 textTracksChanged();
2509 } 2513 }
2510 2514
2511 bool HTMLMediaElement::havePotentialSourceChild() 2515 bool HTMLMediaElement::havePotentialSourceChild()
2512 { 2516 {
2513 // Stash the current <source> node and next nodes so we can restore them aft er checking 2517 // Stash the current <source> node and next nodes so we can restore them aft er checking
2514 // to see there is another potential. 2518 // to see there is another potential.
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after
3271 m_processingPreferenceChange = true; 3275 m_processingPreferenceChange = true;
3272 honorUserPreferencesForAutomaticTextTrackSelection(); 3276 honorUserPreferencesForAutomaticTextTrackSelection();
3273 m_processingPreferenceChange = false; 3277 m_processingPreferenceChange = false;
3274 3278
3275 // As track visibility changed while m_processingPreferenceChange was set, 3279 // As track visibility changed while m_processingPreferenceChange was set,
3276 // there was no call to updateTextTrackDisplay(). This call is not in the 3280 // there was no call to updateTextTrackDisplay(). This call is not in the
3277 // spec, see the note in configureTextTrackDisplay(). 3281 // spec, see the note in configureTextTrackDisplay().
3278 updateTextTrackDisplay(); 3282 updateTextTrackDisplay();
3279 } 3283 }
3280 3284
3285 void HTMLMediaElement::setTextTrackKindUserPreferenceForAllMediaElements(Documen t* document)
3286 {
3287 WeakMediaElementSet elements = documentToElementSetMap().get(document);
3288 for (const auto& element: elements)
fs 2015/06/24 08:59:07 Nit: space around ':'
srivats 2015/07/02 01:41:21 Done.
3289 element->automaticTrackSelectionForUpdatedUserPreference();
3290 }
3291
3292 void HTMLMediaElement::automaticTrackSelectionForUpdatedUserPreference()
philipj_slow 2015/06/24 09:54:20 Is it really necessary to act on the changed user
srivats 2015/07/02 01:41:21 It does seem a little buggy to not have the platfo
philipj_slow 2015/07/09 15:20:49 Do native video players take the setting into acco
srivats 2015/07/09 21:25:37 I know that WebKit's native video player reacts to
philipj_slow 2015/07/09 22:36:26 OK, fair enough.
3293 {
3294 markCaptionAndSubtitleTracksAsUnconfigured();
3295 m_processingPreferenceChange = true;
3296 m_closedCaptionsVisible = false;
3297 honorUserPreferencesForAutomaticTextTrackSelection();
3298 m_processingPreferenceChange = false;
3299
3300 // If a track is set to showing post performing automatic track selection,
fs 2015/06/24 08:59:07 Nit: showing -> 'showing'
srivats 2015/07/02 01:41:20 Done.
3301 // set closed captions state to visible to update the CC button and display the track.
3302 m_closedCaptionsVisible = m_textTracks->hasShowingTracks();
3303 updateTextTrackDisplay();
3304 }
3305
3281 void HTMLMediaElement::markCaptionAndSubtitleTracksAsUnconfigured() 3306 void HTMLMediaElement::markCaptionAndSubtitleTracksAsUnconfigured()
3282 { 3307 {
3283 if (!m_textTracks) 3308 if (!m_textTracks)
3284 return; 3309 return;
3285 3310
3286 // Mark all tracks as not "configured" so that 3311 // Mark all tracks as not "configured" so that
3287 // honorUserPreferencesForAutomaticTextTrackSelection() will reconsider 3312 // honorUserPreferencesForAutomaticTextTrackSelection() will reconsider
3288 // which tracks to display in light of new user preferences (e.g. default 3313 // which tracks to display in light of new user preferences (e.g. default
3289 // tracks should not be displayed if the user has turned off captions and 3314 // tracks should not be displayed if the user has turned off captions and
3290 // non-default tracks should be displayed based on language preferences if 3315 // non-default tracks should be displayed based on language preferences if
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
3390 } 3415 }
3391 3416
3392 void HTMLMediaElement::configureTextTrackDisplay(VisibilityChangeAssumption assu mption) 3417 void HTMLMediaElement::configureTextTrackDisplay(VisibilityChangeAssumption assu mption)
3393 { 3418 {
3394 ASSERT(m_textTracks); 3419 ASSERT(m_textTracks);
3395 WTF_LOG(Media, "HTMLMediaElement::configureTextTrackDisplay(%p)", this); 3420 WTF_LOG(Media, "HTMLMediaElement::configureTextTrackDisplay(%p)", this);
3396 3421
3397 if (m_processingPreferenceChange) 3422 if (m_processingPreferenceChange)
3398 return; 3423 return;
3399 3424
3400 bool haveVisibleTextTrack = false; 3425 bool haveVisibleTextTrack = m_textTracks->hasShowingTracks();
3401 for (unsigned i = 0; i < m_textTracks->length(); ++i) {
3402 if (m_textTracks->item(i)->mode() == TextTrack::showingKeyword()) {
3403 haveVisibleTextTrack = true;
3404 break;
3405 }
3406 }
3407 3426
3408 if (assumption == AssumeNoVisibleChange 3427 if (assumption == AssumeNoVisibleChange
3409 && m_haveVisibleTextTrack == haveVisibleTextTrack) { 3428 && m_haveVisibleTextTrack == haveVisibleTextTrack) {
3410 cueTimeline().updateActiveCues(currentTime()); 3429 cueTimeline().updateActiveCues(currentTime());
3411 return; 3430 return;
3412 } 3431 }
3413 m_haveVisibleTextTrack = haveVisibleTextTrack; 3432 m_haveVisibleTextTrack = haveVisibleTextTrack;
3414 m_closedCaptionsVisible = m_haveVisibleTextTrack; 3433 m_closedCaptionsVisible = m_haveVisibleTextTrack;
3415 3434
3416 if (!m_haveVisibleTextTrack && !mediaControls()) 3435 if (!m_haveVisibleTextTrack && !mediaControls())
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
3680 3699
3681 #if ENABLE(WEB_AUDIO) 3700 #if ENABLE(WEB_AUDIO)
3682 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) 3701 void HTMLMediaElement::clearWeakMembers(Visitor* visitor)
3683 { 3702 {
3684 if (!Heap::isHeapObjectAlive(m_audioSourceNode) && audioSourceProvider()) 3703 if (!Heap::isHeapObjectAlive(m_audioSourceNode) && audioSourceProvider())
3685 audioSourceProvider()->setClient(nullptr); 3704 audioSourceProvider()->setClient(nullptr);
3686 } 3705 }
3687 #endif 3706 #endif
3688 3707
3689 } 3708 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698