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

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 comment 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)
3289 element->automaticTrackSelectionForUpdatedUserPreference();
3290 }
3291
3292 void HTMLMediaElement::automaticTrackSelectionForUpdatedUserPreference()
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,
3301 // set closed captions state to visible to update the CC button and display the track.
3302 for (unsigned i = 0; i < m_textTracks->length(); ++i) {
fs 2015/06/23 09:23:58 We have this same loop in configureTextTrackDispla
srivats 2015/06/24 01:40:19 Done.
3303 RefPtrWillBeRawPtr<TextTrack> textTrack = m_textTracks->item(i);
3304 if (textTrack->mode() == TextTrack::showingKeyword())
3305 m_closedCaptionsVisible = true;
3306 }
3307
3308 updateTextTrackDisplay();
3309 }
3310
3281 void HTMLMediaElement::markCaptionAndSubtitleTracksAsUnconfigured() 3311 void HTMLMediaElement::markCaptionAndSubtitleTracksAsUnconfigured()
3282 { 3312 {
3283 if (!m_textTracks) 3313 if (!m_textTracks)
3284 return; 3314 return;
3285 3315
3286 // Mark all tracks as not "configured" so that 3316 // Mark all tracks as not "configured" so that
3287 // honorUserPreferencesForAutomaticTextTrackSelection() will reconsider 3317 // honorUserPreferencesForAutomaticTextTrackSelection() will reconsider
3288 // which tracks to display in light of new user preferences (e.g. default 3318 // 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 3319 // 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 3320 // non-default tracks should be displayed based on language preferences if
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
3680 3710
3681 #if ENABLE(WEB_AUDIO) 3711 #if ENABLE(WEB_AUDIO)
3682 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) 3712 void HTMLMediaElement::clearWeakMembers(Visitor* visitor)
3683 { 3713 {
3684 if (!Heap::isHeapObjectAlive(m_audioSourceNode) && audioSourceProvider()) 3714 if (!Heap::isHeapObjectAlive(m_audioSourceNode) && audioSourceProvider())
3685 audioSourceProvider()->setClient(nullptr); 3715 audioSourceProvider()->setClient(nullptr);
3686 } 3716 }
3687 #endif 3717 #endif
3688 3718
3689 } 3719 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698