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

Unified Diff: third_party/WebKit/Source/core/html/HTMLMediaElement.cpp

Issue 2539023002: Media Controls: Use events to update controls for closed captions. (Closed)
Patch Set: ready for review Created 4 years 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 side-by-side diff with in-line comments
Download patch
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 d45eab3cdcce8973ee9007b6d9073df3a715311d..8b7d73e1d8e28f045d1557b753eed4af7122d018 100644
--- a/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
@@ -1313,9 +1313,14 @@ void HTMLMediaElement::textTrackReadyStateChanged(TextTrack* track) {
// clicking the captions button. In this case, a check whether all the
// resources have failed loading should be done in order to hide the CC
// button.
+ // TODO(mlamouri): when an HTMLTrackElement fails to load, it is not
+ // propagated to the TextTrack object in a web exposed fashion. We have to
+ // keep relying on a custom glue to the controls while this is taken care
+ // of on the web side. See https://crbug.com/669977
if (mediaControls() &&
- track->getReadinessState() == TextTrack::FailedToLoad)
- mediaControls()->refreshClosedCaptionsButtonVisibility();
+ track->getReadinessState() == TextTrack::FailedToLoad) {
+ mediaControls()->onTrackElementFailedToLoad();
+ }
}
}
@@ -1768,11 +1773,8 @@ void HTMLMediaElement::setReadyState(ReadyState state) {
shouldUpdateDisplayState = true;
}
- if (shouldUpdateDisplayState) {
+ if (shouldUpdateDisplayState)
updateDisplayState();
- if (mediaControls())
- mediaControls()->refreshClosedCaptionsButtonVisibility();
- }
updatePlayState();
cueTimeline().updateActiveCues(currentTime());
@@ -2695,7 +2697,7 @@ void HTMLMediaElement::addTextTrack(WebInbandTextTrack* webTrack) {
// cancelable, and that uses the TrackEvent interface, with the track
// attribute initialized to the text track's TextTrack object, at the media
// element's textTracks attribute's TextTrackList object.
- addTextTrack(textTrack);
+ textTracks()->append(textTrack);
}
void HTMLMediaElement::removeTextTrack(WebInbandTextTrack* webTrack) {
@@ -2709,24 +2711,7 @@ void HTMLMediaElement::removeTextTrack(WebInbandTextTrack* webTrack) {
if (!textTrack)
return;
- removeTextTrack(textTrack);
-}
-
-void HTMLMediaElement::textTracksChanged() {
- if (mediaControls())
- mediaControls()->refreshClosedCaptionsButtonVisibility();
-}
-
-void HTMLMediaElement::addTextTrack(TextTrack* track) {
- textTracks()->append(track);
-
- textTracksChanged();
-}
-
-void HTMLMediaElement::removeTextTrack(TextTrack* track) {
- m_textTracks->remove(track);
-
- textTracksChanged();
+ m_textTracks->remove(textTrack);
}
void HTMLMediaElement::forgetResourceSpecificTracks() {
@@ -2736,7 +2721,6 @@ void HTMLMediaElement::forgetResourceSpecificTracks() {
if (m_textTracks) {
TrackDisplayUpdateScope scope(this->cueTimeline());
m_textTracks->removeAllInbandTracks();
- textTracksChanged();
}
m_audioTracks->removeAll();
@@ -2769,7 +2753,7 @@ TextTrack* HTMLMediaElement::addTextTrack(const AtomicString& kind,
// interface, with the track attribute initialised to the new text
// track's TextTrack object, at the media element's textTracks
// attribute's TextTrackList object.
- addTextTrack(textTrack);
+ textTracks()->append(textTrack);
// Note: Due to side effects when changing track parameters, we have to
// first append the track to the text track list.
@@ -2801,7 +2785,7 @@ void HTMLMediaElement::didAddTrackElement(HTMLTrackElement* trackElement) {
if (!textTrack)
return;
- addTextTrack(textTrack);
+ textTracks()->append(textTrack);
// Do not schedule the track loading until parsing finishes so we don't start
// before all tracks in the markup have been added.
@@ -2827,7 +2811,7 @@ void HTMLMediaElement::didRemoveTrackElement(HTMLTrackElement* trackElement) {
// When a track element's parent element changes and the old parent was a
// media element, then the user agent must remove the track element's
// corresponding text track from the media element's list of text tracks.
- removeTextTrack(textTrack);
+ m_textTracks->remove(textTrack);
size_t index = m_textTracksWhenResourceSelectionBegan.find(textTrack);
if (index != kNotFound)
@@ -2854,8 +2838,6 @@ void HTMLMediaElement::honorUserPreferencesForAutomaticTextTrackSelection() {
AutomaticTrackSelection trackSelection(configuration);
trackSelection.perform(*m_textTracks);
-
- textTracksChanged();
}
bool HTMLMediaElement::havePotentialSourceChild() {
@@ -3520,12 +3502,14 @@ WebLayer* HTMLMediaElement::platformLayer() const {
}
bool HTMLMediaElement::hasClosedCaptions() const {
- if (m_textTracks) {
- for (unsigned i = 0; i < m_textTracks->length(); ++i) {
- if (m_textTracks->anonymousIndexedGetter(i)->canBeRendered())
- return true;
- }
+ if (!m_textTracks)
+ return false;
+
+ for (unsigned i = 0; i < m_textTracks->length(); ++i) {
+ if (m_textTracks->anonymousIndexedGetter(i)->canBeRendered())
+ return true;
}
+
return false;
}
@@ -3732,9 +3716,6 @@ void HTMLMediaElement::configureTextTrackDisplay() {
if (!haveVisibleTextTrack && !mediaControls())
return;
- if (mediaControls())
- mediaControls()->changedClosedCaptionsVisibility();
-
cueTimeline().updateActiveCues(currentTime());
// Note: The "time marches on" algorithm (updateActiveCues) runs the "rules

Powered by Google App Engine
This is Rietveld 408576698