Bug 1325001 - TextTrackList::GetShowingCues should return cues whose kind is Subtitles or Captions. r=rillian
We should only render the Subtitles/Captions cue on the screen. In addition, rename the activeCues to showingCues.
Because the meaning of "active" and "showing" are different. Showing means we can see the cue on the screen, active means the current playback time touches the cue.
MozReview-Commit-ID: 1BfHhxFXBDP
--- a/dom/html/TextTrackManager.cpp
+++ b/dom/html/TextTrackManager.cpp
@@ -271,28 +271,28 @@ TextTrackManager::UpdateCueDisplay()
}
nsCOMPtr<nsIContent> overlay = videoFrame->GetCaptionOverlay();
nsCOMPtr<nsIContent> controls = videoFrame->GetVideoControls();
if (!overlay) {
return;
}
- nsTArray<RefPtr<TextTrackCue> > activeCues;
- mTextTracks->GetShowingCues(activeCues);
+ nsTArray<RefPtr<TextTrackCue> > showingCues;
+ mTextTracks->GetShowingCues(showingCues);
- if (activeCues.Length() > 0) {
+ if (showingCues.Length() > 0) {
WEBVTT_LOG("UpdateCueDisplay ProcessCues");
- WEBVTT_LOGV("UpdateCueDisplay activeCues.Length() %" PRIuSIZE, activeCues.Length());
+ WEBVTT_LOGV("UpdateCueDisplay showingCues.Length() %" PRIuSIZE, showingCues.Length());
RefPtr<nsVariantCC> jsCues = new nsVariantCC();
jsCues->SetAsArray(nsIDataType::VTYPE_INTERFACE,
&NS_GET_IID(nsIDOMEventTarget),
- activeCues.Length(),
- static_cast<void*>(activeCues.Elements()));
+ showingCues.Length(),
+ static_cast<void*>(showingCues.Elements()));
nsPIDOMWindowInner* window = mMediaElement->OwnerDoc()->GetInnerWindow();
if (window) {
sParserWrapper->ProcessCues(window, jsCues, overlay, controls);
}
} else if (overlay->Length() > 0) {
WEBVTT_LOG("UpdateCueDisplay EmptyString");
nsContentUtils::SetNodeTextContent(overlay, EmptyString(), true);
}
--- a/dom/media/TextTrackList.cpp
+++ b/dom/media/TextTrackList.cpp
@@ -38,19 +38,22 @@ TextTrackList::TextTrackList(nsPIDOMWind
TextTrackList::~TextTrackList()
{
}
void
TextTrackList::GetShowingCues(nsTArray<RefPtr<TextTrackCue> >& aCues)
{
+ // Only Subtitles and Captions can show on the screen.
nsTArray< RefPtr<TextTrackCue> > cues;
for (uint32_t i = 0; i < Length(); i++) {
- if (mTextTracks[i]->Mode() == TextTrackMode::Showing) {
+ if (mTextTracks[i]->Mode() == TextTrackMode::Showing &&
+ (mTextTracks[i]->Kind() == TextTrackKind::Subtitles ||
+ mTextTracks[i]->Kind() == TextTrackKind::Captions)) {
mTextTracks[i]->GetActiveCueArray(cues);
aCues.AppendElements(cues);
}
}
}
JSObject*
TextTrackList::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)