Bug 882718 - triggerTimeMarchesOn. r=rillian

MozReview-Commit-ID: 2OOqr1Z6X9
This commit is contained in:
bechen
2016-05-25 16:11:28 +08:00
parent 6391e8e2b5
commit da72c8bd4c
4 changed files with 40 additions and 1 deletions

View File

@@ -172,6 +172,7 @@ TextTrackManager::AddCues(TextTrack* aTextTrack)
for (uint32_t i = 0; i < cueList->Length(); ++i) {
mNewCues->AddCue(*cueList->IndexedGetter(i, dummy));
}
DispatchTimeMarchesOn();
}
}
@@ -188,6 +189,15 @@ TextTrackManager::RemoveTextTrack(TextTrack* aTextTrack, bool aPendingListOnly)
}
mTextTracks->RemoveTextTrack(aTextTrack);
// Remove the cues in mNewCues belong to aTextTrack.
TextTrackCueList* removeCueList = aTextTrack->GetCues();
if (removeCueList) {
for (uint32_t i = 0; i < removeCueList->Length(); ++i) {
ErrorResult dummyRv;
mNewCues->RemoveCue(*((*removeCueList)[i]), dummyRv);
}
DispatchTimeMarchesOn();
}
}
void
@@ -235,6 +245,10 @@ TextTrackManager::UpdateCueDisplay()
} else if (overlay->Length() > 0) {
nsContentUtils::SetNodeTextContent(overlay, EmptyString(), true);
}
// Call TimeMarchesOn() directly instead DispatchTimeMarchesOn()
// because we had render the new cue, so we must run
// TimeMarchesOn immediately.
TimeMarchesOn();
}
void
@@ -243,6 +257,17 @@ TextTrackManager::AddCue(TextTrackCue& aCue)
if (mNewCues) {
mNewCues->AddCue(aCue);
}
DispatchTimeMarchesOn();
}
void
TextTrackManager::NotifyCueRemoved(TextTrackCue& aCue)
{
if (mNewCues) {
ErrorResult dummyRv;
mNewCues->RemoveCue(aCue, dummyRv);
}
DispatchTimeMarchesOn();
}
void
@@ -507,6 +532,10 @@ TextTrackManager::TimeMarchesOn()
}
nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(parentObject);
if (mMediaElement && !(mMediaElement->GetPlayedOrSeeked())) {
return;
}
// Step 3.
double currentPlaybackTime = mMediaElement->CurrentTime();
bool hasNormalPlayback = !mHasSeeked;
@@ -521,6 +550,7 @@ TextTrackManager::TimeMarchesOn()
for (uint32_t index = 0; index < mTextTracks->Length(); ++index) {
TextTrack* ttrack = mTextTracks->IndexedGetter(index, dummy);
if (ttrack && dummy) {
// TODO: call GetCueListByTimeInterval on mNewCues?
TextTrackCueList* activeCueList = ttrack->GetActiveCues();
if (activeCueList) {
for (uint32_t i = 0; i < activeCueList->Length(); ++i) {