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

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: Updated automatic track selection logic 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 2470 matching lines...) Expand 10 before | Expand all | Expand 10 after
2481 { 2481 {
2482 if (!m_textTracks || !m_textTracks->length()) 2482 if (!m_textTracks || !m_textTracks->length())
2483 return; 2483 return;
2484 2484
2485 AutomaticTrackSelection::Configuration configuration; 2485 AutomaticTrackSelection::Configuration configuration;
2486 if (m_processingPreferenceChange) 2486 if (m_processingPreferenceChange)
2487 configuration.disableCurrentlyEnabledTracks = true; 2487 configuration.disableCurrentlyEnabledTracks = true;
2488 if (m_closedCaptionsVisible) 2488 if (m_closedCaptionsVisible)
2489 configuration.forceEnableSubtitleOrCaptionTrack = true; 2489 configuration.forceEnableSubtitleOrCaptionTrack = true;
2490 2490
2491 Settings* settings = document().settings();
2492 if (settings)
2493 configuration.textTrackKindUserPreference = settings->textTrackKindUserP reference();
2494
2491 AutomaticTrackSelection trackSelection(configuration); 2495 AutomaticTrackSelection trackSelection(configuration);
2492 trackSelection.perform(*m_textTracks); 2496 trackSelection.perform(*m_textTracks);
2493 2497
2494 textTracksChanged(); 2498 textTracksChanged();
2495 } 2499 }
2496 2500
2497 bool HTMLMediaElement::havePotentialSourceChild() 2501 bool HTMLMediaElement::havePotentialSourceChild()
2498 { 2502 {
2499 // Stash the current <source> node and next nodes so we can restore them aft er checking 2503 // Stash the current <source> node and next nodes so we can restore them aft er checking
2500 // to see there is another potential. 2504 // to see there is another potential.
(...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after
3251 m_processingPreferenceChange = true; 3255 m_processingPreferenceChange = true;
3252 honorUserPreferencesForAutomaticTextTrackSelection(); 3256 honorUserPreferencesForAutomaticTextTrackSelection();
3253 m_processingPreferenceChange = false; 3257 m_processingPreferenceChange = false;
3254 3258
3255 // As track visibility changed while m_processingPreferenceChange was set, 3259 // As track visibility changed while m_processingPreferenceChange was set,
3256 // there was no call to updateTextTrackDisplay(). This call is not in the 3260 // there was no call to updateTextTrackDisplay(). This call is not in the
3257 // spec, see the note in configureTextTrackDisplay(). 3261 // spec, see the note in configureTextTrackDisplay().
3258 updateTextTrackDisplay(); 3262 updateTextTrackDisplay();
3259 } 3263 }
3260 3264
3265 void HTMLMediaElement::setTextTrackKindUserPreferenceForAllMediaElements(Documen t* document)
3266 {
3267 WeakMediaElementSet elements = documentToElementSetMap().get(document);
3268 for (const auto& element: elements)
3269 element->automaticTrackSelectionForUpdatedUserPreference();
3270 }
3271
3272 void HTMLMediaElement::automaticTrackSelectionForUpdatedUserPreference()
3273 {
3274 markCaptionAndSubtitleTracksAsUnconfigured();
3275 m_processingPreferenceChange = true;
3276 m_closedCaptionsVisible = false;
3277 honorUserPreferencesForAutomaticTextTrackSelection();
3278 m_processingPreferenceChange = false;
3279
3280 // If a track is set to showing post performing automatic track selection,
3281 // set closed captions state to visible to update the CC button and display the track.
3282 for (unsigned i = 0; i < m_textTracks->length(); ++i) {
3283 RefPtrWillBeRawPtr<TextTrack> textTrack = m_textTracks->item(i);
3284 if (textTrack->mode() == TextTrack::showingKeyword())
3285 m_closedCaptionsVisible = true;
3286 }
3287
3288 updateTextTrackDisplay();
3289 }
3290
3261 void HTMLMediaElement::markCaptionAndSubtitleTracksAsUnconfigured() 3291 void HTMLMediaElement::markCaptionAndSubtitleTracksAsUnconfigured()
3262 { 3292 {
3263 if (!m_textTracks) 3293 if (!m_textTracks)
3264 return; 3294 return;
3265 3295
3266 // Mark all tracks as not "configured" so that 3296 // Mark all tracks as not "configured" so that
3267 // honorUserPreferencesForAutomaticTextTrackSelection() will reconsider 3297 // honorUserPreferencesForAutomaticTextTrackSelection() will reconsider
3268 // which tracks to display in light of new user preferences (e.g. default 3298 // which tracks to display in light of new user preferences (e.g. default
3269 // tracks should not be displayed if the user has turned off captions and 3299 // tracks should not be displayed if the user has turned off captions and
3270 // non-default tracks should be displayed based on language preferences if 3300 // non-default tracks should be displayed based on language preferences if
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
3660 3690
3661 #if ENABLE(WEB_AUDIO) 3691 #if ENABLE(WEB_AUDIO)
3662 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) 3692 void HTMLMediaElement::clearWeakMembers(Visitor* visitor)
3663 { 3693 {
3664 if (!visitor->isHeapObjectAlive(m_audioSourceNode) && audioSourceProvider()) 3694 if (!visitor->isHeapObjectAlive(m_audioSourceNode) && audioSourceProvider())
3665 audioSourceProvider()->setClient(nullptr); 3695 audioSourceProvider()->setClient(nullptr);
3666 } 3696 }
3667 #endif 3697 #endif
3668 3698
3669 } 3699 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698