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

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 lgtm comment and rebased Created 5 years, 5 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
« no previous file with comments | « Source/core/html/HTMLMediaElement.h ('k') | Source/core/html/track/AutomaticTrackSelection.h » ('j') | 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 2472 matching lines...) Expand 10 before | Expand all | Expand 10 after
2483 { 2483 {
2484 if (!m_textTracks || !m_textTracks->length()) 2484 if (!m_textTracks || !m_textTracks->length())
2485 return; 2485 return;
2486 2486
2487 AutomaticTrackSelection::Configuration configuration; 2487 AutomaticTrackSelection::Configuration configuration;
2488 if (m_processingPreferenceChange) 2488 if (m_processingPreferenceChange)
2489 configuration.disableCurrentlyEnabledTracks = true; 2489 configuration.disableCurrentlyEnabledTracks = true;
2490 if (m_closedCaptionsVisible) 2490 if (m_closedCaptionsVisible)
2491 configuration.forceEnableSubtitleOrCaptionTrack = true; 2491 configuration.forceEnableSubtitleOrCaptionTrack = true;
2492 2492
2493 Settings* settings = document().settings();
2494 if (settings)
2495 configuration.textTrackKindUserPreference = settings->textTrackKindUserP reference();
2496
2493 AutomaticTrackSelection trackSelection(configuration); 2497 AutomaticTrackSelection trackSelection(configuration);
2494 trackSelection.perform(*m_textTracks); 2498 trackSelection.perform(*m_textTracks);
2495 2499
2496 textTracksChanged(); 2500 textTracksChanged();
2497 } 2501 }
2498 2502
2499 bool HTMLMediaElement::havePotentialSourceChild() 2503 bool HTMLMediaElement::havePotentialSourceChild()
2500 { 2504 {
2501 // Stash the current <source> node and next nodes so we can restore them aft er checking 2505 // Stash the current <source> node and next nodes so we can restore them aft er checking
2502 // to see there is another potential. 2506 // to see there is another potential.
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after
3259 m_processingPreferenceChange = true; 3263 m_processingPreferenceChange = true;
3260 honorUserPreferencesForAutomaticTextTrackSelection(); 3264 honorUserPreferencesForAutomaticTextTrackSelection();
3261 m_processingPreferenceChange = false; 3265 m_processingPreferenceChange = false;
3262 3266
3263 // As track visibility changed while m_processingPreferenceChange was set, 3267 // As track visibility changed while m_processingPreferenceChange was set,
3264 // there was no call to updateTextTrackDisplay(). This call is not in the 3268 // there was no call to updateTextTrackDisplay(). This call is not in the
3265 // spec, see the note in configureTextTrackDisplay(). 3269 // spec, see the note in configureTextTrackDisplay().
3266 updateTextTrackDisplay(); 3270 updateTextTrackDisplay();
3267 } 3271 }
3268 3272
3273 void HTMLMediaElement::setTextTrackKindUserPreferenceForAllMediaElements(Documen t* document)
3274 {
3275 WeakMediaElementSet elements = documentToElementSetMap().get(document);
3276 for (const auto& element : elements)
3277 element->automaticTrackSelectionForUpdatedUserPreference();
3278 }
3279
3280 void HTMLMediaElement::automaticTrackSelectionForUpdatedUserPreference()
3281 {
3282 markCaptionAndSubtitleTracksAsUnconfigured();
3283 m_processingPreferenceChange = true;
3284 m_closedCaptionsVisible = false;
3285 honorUserPreferencesForAutomaticTextTrackSelection();
3286 m_processingPreferenceChange = false;
3287
3288 // If a track is set to 'showing' post performing automatic track selection,
3289 // set closed captions state to visible to update the CC button and display the track.
3290 m_closedCaptionsVisible = m_textTracks->hasShowingTracks();
3291 updateTextTrackDisplay();
3292 }
3293
3269 void HTMLMediaElement::markCaptionAndSubtitleTracksAsUnconfigured() 3294 void HTMLMediaElement::markCaptionAndSubtitleTracksAsUnconfigured()
3270 { 3295 {
3271 if (!m_textTracks) 3296 if (!m_textTracks)
3272 return; 3297 return;
3273 3298
3274 // Mark all tracks as not "configured" so that 3299 // Mark all tracks as not "configured" so that
3275 // honorUserPreferencesForAutomaticTextTrackSelection() will reconsider 3300 // honorUserPreferencesForAutomaticTextTrackSelection() will reconsider
3276 // which tracks to display in light of new user preferences (e.g. default 3301 // which tracks to display in light of new user preferences (e.g. default
3277 // tracks should not be displayed if the user has turned off captions and 3302 // tracks should not be displayed if the user has turned off captions and
3278 // non-default tracks should be displayed based on language preferences if 3303 // non-default tracks should be displayed based on language preferences if
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
3378 } 3403 }
3379 3404
3380 void HTMLMediaElement::configureTextTrackDisplay(VisibilityChangeAssumption assu mption) 3405 void HTMLMediaElement::configureTextTrackDisplay(VisibilityChangeAssumption assu mption)
3381 { 3406 {
3382 ASSERT(m_textTracks); 3407 ASSERT(m_textTracks);
3383 WTF_LOG(Media, "HTMLMediaElement::configureTextTrackDisplay(%p)", this); 3408 WTF_LOG(Media, "HTMLMediaElement::configureTextTrackDisplay(%p)", this);
3384 3409
3385 if (m_processingPreferenceChange) 3410 if (m_processingPreferenceChange)
3386 return; 3411 return;
3387 3412
3388 bool haveVisibleTextTrack = false; 3413 bool haveVisibleTextTrack = m_textTracks->hasShowingTracks();
3389 for (unsigned i = 0; i < m_textTracks->length(); ++i) {
3390 if (m_textTracks->item(i)->mode() == TextTrack::showingKeyword()) {
3391 haveVisibleTextTrack = true;
3392 break;
3393 }
3394 }
3395 3414
3396 if (assumption == AssumeNoVisibleChange 3415 if (assumption == AssumeNoVisibleChange
3397 && m_haveVisibleTextTrack == haveVisibleTextTrack) { 3416 && m_haveVisibleTextTrack == haveVisibleTextTrack) {
3398 cueTimeline().updateActiveCues(currentTime()); 3417 cueTimeline().updateActiveCues(currentTime());
3399 return; 3418 return;
3400 } 3419 }
3401 m_haveVisibleTextTrack = haveVisibleTextTrack; 3420 m_haveVisibleTextTrack = haveVisibleTextTrack;
3402 m_closedCaptionsVisible = m_haveVisibleTextTrack; 3421 m_closedCaptionsVisible = m_haveVisibleTextTrack;
3403 3422
3404 if (!m_haveVisibleTextTrack && !mediaControls()) 3423 if (!m_haveVisibleTextTrack && !mediaControls())
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
3668 3687
3669 #if ENABLE(WEB_AUDIO) 3688 #if ENABLE(WEB_AUDIO)
3670 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) 3689 void HTMLMediaElement::clearWeakMembers(Visitor* visitor)
3671 { 3690 {
3672 if (!Heap::isHeapObjectAlive(m_audioSourceNode) && audioSourceProvider()) 3691 if (!Heap::isHeapObjectAlive(m_audioSourceNode) && audioSourceProvider())
3673 audioSourceProvider()->setClient(nullptr); 3692 audioSourceProvider()->setClient(nullptr);
3674 } 3693 }
3675 #endif 3694 #endif
3676 3695
3677 } 3696 }
OLDNEW
« no previous file with comments | « Source/core/html/HTMLMediaElement.h ('k') | Source/core/html/track/AutomaticTrackSelection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698