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

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: zqzhang review comments 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 6b69c4faa0ae04a0225bd0b591543354fb823ee0..b1af849b88f7553f8e7fed9572344661776fb82a 100644
--- a/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
@@ -1241,9 +1241,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();
+ }
}
}
@@ -1692,11 +1697,8 @@ void HTMLMediaElement::setReadyState(ReadyState state) {
shouldUpdateDisplayState = true;
}
- if (shouldUpdateDisplayState) {
+ if (shouldUpdateDisplayState)
updateDisplayState();
- if (mediaControls())
- mediaControls()->refreshClosedCaptionsButtonVisibility();
- }
updatePlayState();
cueTimeline().updateActiveCues(currentTime());
@@ -2597,7 +2599,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) {
@@ -2611,24 +2613,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() {
@@ -2638,7 +2623,6 @@ void HTMLMediaElement::forgetResourceSpecificTracks() {
if (m_textTracks) {
TrackDisplayUpdateScope scope(this->cueTimeline());
m_textTracks->removeAllInbandTracks();
- textTracksChanged();
}
m_audioTracks->removeAll();
@@ -2671,7 +2655,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.
@@ -2703,7 +2687,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.
@@ -2729,7 +2713,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)
@@ -2756,8 +2740,6 @@ void HTMLMediaElement::honorUserPreferencesForAutomaticTextTrackSelection() {
AutomaticTrackSelection trackSelection(configuration);
trackSelection.perform(*m_textTracks);
-
- textTracksChanged();
}
bool HTMLMediaElement::havePotentialSourceChild() {
@@ -3420,12 +3402,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;
}
@@ -3632,9 +3616,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