Bug 977299 - Don't display subtitles if their mode is 'hidden'. r=rillian

I've renamed TextTrackList::GetAllActiveCues to
UpdateAndGetShowingCues to make it a bit more clear what
this function is doing.
This commit is contained in:
Rick Eyre 2014-02-27 10:02:40 -05:00
parent 8178319bae
commit e528d12f52
4 changed files with 13 additions and 6 deletions

View File

@ -193,7 +193,7 @@ TextTrackManager::UpdateCueDisplay()
}
nsTArray<nsRefPtr<TextTrackCue> > activeCues;
mTextTracks->GetAllActiveCues(activeCues);
mTextTracks->UpdateAndGetShowingCues(activeCues);
if (activeCues.Length() > 0) {
nsCOMPtr<nsIWritableVariant> jsCues =

View File

@ -104,6 +104,7 @@ public:
}
TextTrackCueList* GetActiveCues();
void UpdateActiveCueList();
void GetActiveCueArray(nsTArray<nsRefPtr<TextTrackCue> >& aCues);
TextTrackReadyState ReadyState() const;
@ -126,8 +127,6 @@ public:
}
private:
void UpdateActiveCueList();
nsCOMPtr<nsISupports> mParent;
nsRefPtr<TextTrackList> mTextTrackList;

View File

@ -37,11 +37,19 @@ TextTrackList::TextTrackList(nsISupports* aGlobal, TextTrackManager* aTextTrackM
}
void
TextTrackList::GetAllActiveCues(nsTArray<nsRefPtr<TextTrackCue> >& aCues)
TextTrackList::UpdateAndGetShowingCues(nsTArray<nsRefPtr<TextTrackCue> >& aCues)
{
nsTArray< nsRefPtr<TextTrackCue> > cues;
for (uint32_t i = 0; i < Length(); i++) {
if (mTextTracks[i]->Mode() != TextTrackMode::Disabled) {
TextTrackMode mode = mTextTracks[i]->Mode();
// If the mode is hidden then we just need to update the active cue list,
// we don't need to show it on the video.
if (mode == TextTrackMode::Hidden) {
mTextTracks[i]->UpdateActiveCueList();
} else if (mode == TextTrackMode::Showing) {
// If the mode is showing then we need to update the cue list and show it
// on the video. GetActiveCueArray() calls UpdateActiveCueList() so we
// don't need to call it explicitly.
mTextTracks[i]->GetActiveCueArray(cues);
aCues.AppendElements(cues);
}

View File

@ -43,7 +43,7 @@ public:
}
// Get all the current active cues.
void GetAllActiveCues(nsTArray<nsRefPtr<TextTrackCue> >& aCues);
void UpdateAndGetShowingCues(nsTArray<nsRefPtr<TextTrackCue> >& aCues);
TextTrack* IndexedGetter(uint32_t aIndex, bool& aFound);
TextTrack* operator[](uint32_t aIndex);