Bug 1548923 - part2 : reset cues' active flag when media element's ready state becomes 'HAVE_NOTHING' r=jya

According to the spec [1], whenever the media element's readyState is changed back to `HAVE_NOTHING`, we have to reset all cues' active flag and update cue display in order to hide them.

[1] https://html.spec.whatwg.org/multipage/media.html#text-track-cue-active-flag

Differential Revision: https://phabricator.services.mozilla.com/D30110

--HG--
extra : moz-landing-system : lando
This commit is contained in:
alwu 2019-05-08 17:46:39 +00:00
Родитель 70e585dd96
Коммит dfb849b238
3 изменённых файлов: 17 добавлений и 5 удалений

Просмотреть файл

@ -1875,10 +1875,6 @@ void HTMLMediaElement::AbortExistingLoads() {
mIsRunningSelectResource = false;
if (mTextTrackManager) {
mTextTrackManager->NotifyReset();
}
mEventDeliveryPaused = false;
mPendingEvents.Clear();
mCurrentLoadPlayTime.Reset();
@ -5521,6 +5517,13 @@ void HTMLMediaElement::ChangeReadyState(nsMediaReadyState aState) {
DDLOG(DDLogCategory::Property, "ready_state", gReadyStateToString[aState]);
// https://html.spec.whatwg.org/multipage/media.html#text-track-cue-active-flag
// The user agent must synchronously unset cues' active flag whenever the
// media element's readyState is changed back to HAVE_NOTHING.
if (mReadyState == HAVE_NOTHING && mTextTrackManager) {
mTextTrackManager->NotifyReset();
}
if (mNetworkState == NETWORK_EMPTY) {
return;
}

Просмотреть файл

@ -824,8 +824,14 @@ void TextTrackManager::NotifyCueUpdated(TextTrackCue* aCue) {
}
void TextTrackManager::NotifyReset() {
// https://html.spec.whatwg.org/multipage/media.html#text-track-cue-active-flag
// This will unset all cues' active flag and update the cue display.
WEBVTT_LOG("NotifyReset");
mLastTimeMarchesOnCalled = media::TimeUnit::Zero();
for (uint32_t idx = 0; idx < mTextTracks->Length(); ++idx) {
(*mTextTracks)[idx]->SetCuesInactive();
}
UpdateCueDisplay();
}
void TextTrackManager::ReportTelemetryForTrack(TextTrack* aTextTrack) const {

Просмотреть файл

@ -222,7 +222,10 @@ void TextTrack::SetTrackElement(HTMLTrackElement* aTrackElement) {
mTrackElement = aTrackElement;
}
void TextTrack::SetCuesInactive() { mCueList->SetCuesInactive(); }
void TextTrack::SetCuesInactive() {
WEBVTT_LOG("SetCuesInactive");
mCueList->SetCuesInactive();
}
void TextTrack::NotifyCueUpdated(TextTrackCue* aCue) {
WEBVTT_LOG("NotifyCueUpdated, cue=%p", aCue);