Index: third_party/WebKit/Source/core/html/HTMLMediaElement.cpp |
diff --git a/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp b/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp |
index 5d9fc80c972c70e2d16df7f56ef108ce6aa25aa6..e400ec77f3eb4de6afd9ec8c4a2c5eea7be413dd 100644 |
--- a/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp |
+++ b/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp |
@@ -413,8 +413,9 @@ HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, Document& docum |
, m_seeking(false) |
, m_sentStalledEvent(false) |
, m_sentEndEvent(false) |
- , m_closedCaptionsVisible(false) |
, m_ignorePreloadNone(false) |
+ , m_textTracksVisible(false) |
+ , m_shouldPerformAutomaticTrackSelection(true) |
, m_tracksAreReady(true) |
, m_processingPreferenceChange(false) |
, m_remoteRoutesAvailable(false) |
@@ -1231,6 +1232,11 @@ void HTMLMediaElement::textTrackModeChanged(TextTrack* track) |
textTracks()->scheduleChangeEvent(); |
} |
+void HTMLMediaElement::disableAutomaticTextTrackSelection() |
+{ |
+ m_shouldPerformAutomaticTrackSelection = false; |
+} |
+ |
bool HTMLMediaElement::isSafeToLoadURL(const KURL& url, InvalidURLAction actionIfInvalid) |
{ |
if (!url.isValid()) { |
@@ -2587,10 +2593,13 @@ void HTMLMediaElement::honorUserPreferencesForAutomaticTextTrackSelection() |
if (!m_textTracks || !m_textTracks->length()) |
return; |
+ if (!m_shouldPerformAutomaticTrackSelection) |
+ return; |
+ |
AutomaticTrackSelection::Configuration configuration; |
if (m_processingPreferenceChange) |
configuration.disableCurrentlyEnabledTracks = true; |
- if (m_closedCaptionsVisible) |
+ if (m_textTracksVisible) |
configuration.forceEnableSubtitleOrCaptionTrack = true; |
Settings* settings = document().settings(); |
@@ -3260,9 +3269,9 @@ bool HTMLMediaElement::hasClosedCaptions() const |
return false; |
} |
-bool HTMLMediaElement::closedCaptionsVisible() const |
+bool HTMLMediaElement::textTracksVisible() const |
{ |
- return m_closedCaptionsVisible; |
+ return m_textTracksVisible; |
} |
static void assertShadowRootChildren(ShadowRoot& shadowRoot) |
@@ -3318,30 +3327,10 @@ void HTMLMediaElement::mediaControlsDidBecomeVisible() |
// When the user agent starts exposing a user interface for a video element, |
// the user agent should run the rules for updating the text track rendering |
// of each of the text tracks in the video element's list of text tracks ... |
- if (isHTMLVideoElement() && closedCaptionsVisible()) |
+ if (isHTMLVideoElement() && textTracksVisible()) |
ensureTextTrackContainer().updateDisplay(*this, TextTrackContainer::DidStartExposingControls); |
} |
-void HTMLMediaElement::setClosedCaptionsVisible(bool closedCaptionVisible) |
-{ |
- WTF_LOG(Media, "HTMLMediaElement::setClosedCaptionsVisible(%p, %s)", this, boolString(closedCaptionVisible)); |
- |
- if (!hasClosedCaptions()) |
- return; |
- |
- m_closedCaptionsVisible = closedCaptionVisible; |
- |
- markCaptionAndSubtitleTracksAsUnconfigured(); |
- m_processingPreferenceChange = true; |
- honorUserPreferencesForAutomaticTextTrackSelection(); |
- m_processingPreferenceChange = false; |
- |
- // As track visibility changed while m_processingPreferenceChange was set, |
- // there was no call to updateTextTrackDisplay(). This call is not in the |
- // spec, see the note in configureTextTrackDisplay(). |
- updateTextTrackDisplay(); |
-} |
- |
void HTMLMediaElement::setTextTrackKindUserPreferenceForAllMediaElements(Document* document) |
{ |
auto it = documentToElementSetMap().find(document); |
@@ -3360,13 +3349,13 @@ void HTMLMediaElement::automaticTrackSelectionForUpdatedUserPreference() |
markCaptionAndSubtitleTracksAsUnconfigured(); |
m_processingPreferenceChange = true; |
- m_closedCaptionsVisible = false; |
+ m_textTracksVisible = false; |
honorUserPreferencesForAutomaticTextTrackSelection(); |
m_processingPreferenceChange = false; |
// If a track is set to 'showing' post performing automatic track selection, |
- // set closed captions state to visible to update the CC button and display the track. |
- m_closedCaptionsVisible = m_textTracks->hasShowingTracks(); |
+ // set text tracks state to visible to update the CC button and display the track. |
+ m_textTracksVisible = m_textTracks->hasShowingTracks(); |
updateTextTrackDisplay(); |
} |
@@ -3491,7 +3480,7 @@ void HTMLMediaElement::configureTextTrackDisplay() |
return; |
bool haveVisibleTextTrack = m_textTracks->hasShowingTracks(); |
- m_closedCaptionsVisible = haveVisibleTextTrack; |
+ m_textTracksVisible = haveVisibleTextTrack; |
if (!haveVisibleTextTrack && !mediaControls()) |
return; |