mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 1281999 - Update the display when we remove an active cue by changing the texttrackmode to disabled. r=rillian
MozReview-Commit-ID: GeF5Icd9jLu --HG-- extra : transplant_source : %D40%3Ed%07%F1%17%5B%9FG%EC%C5%80%C3f%EDJ%22%7Bd
This commit is contained in:
parent
0334d84e82
commit
a54b4b6946
@ -224,6 +224,8 @@ TextTrackManager::DidSeek()
|
||||
void
|
||||
TextTrackManager::UpdateCueDisplay()
|
||||
{
|
||||
mUpdateCueDisplayDispatched = false;
|
||||
|
||||
if (!mMediaElement || !mTextTracks) {
|
||||
return;
|
||||
}
|
||||
@ -241,7 +243,7 @@ TextTrackManager::UpdateCueDisplay()
|
||||
}
|
||||
|
||||
nsTArray<RefPtr<TextTrackCue> > activeCues;
|
||||
mTextTracks->UpdateAndGetShowingCues(activeCues);
|
||||
mTextTracks->GetShowingCues(activeCues);
|
||||
|
||||
if (activeCues.Length() > 0) {
|
||||
RefPtr<nsVariantCC> jsCues = new nsVariantCC();
|
||||
@ -250,7 +252,6 @@ TextTrackManager::UpdateCueDisplay()
|
||||
&NS_GET_IID(nsIDOMEventTarget),
|
||||
activeCues.Length(),
|
||||
static_cast<void*>(activeCues.Elements()));
|
||||
|
||||
nsPIDOMWindowInner* window = mMediaElement->OwnerDoc()->GetInnerWindow();
|
||||
if (window) {
|
||||
sParserWrapper->ProcessCues(window, jsCues, overlay, controls);
|
||||
@ -277,6 +278,10 @@ TextTrackManager::NotifyCueRemoved(TextTrackCue& aCue)
|
||||
mNewCues->RemoveCue(aCue);
|
||||
}
|
||||
DispatchTimeMarchesOn();
|
||||
if (aCue.GetActive()) {
|
||||
// We remove an active cue, need to update the display.
|
||||
DispatchUpdateCueDisplay();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@ -523,6 +528,16 @@ private:
|
||||
nsTArray<RefPtr<TextTrack>> mTextTracks;
|
||||
};
|
||||
|
||||
void
|
||||
TextTrackManager::DispatchUpdateCueDisplay()
|
||||
{
|
||||
if (!mUpdateCueDisplayDispatched && !mShutdown &&
|
||||
(mMediaElement->GetHasUserInteraction() || mMediaElement->IsCurrentlyPlaying())) {
|
||||
NS_DispatchToMainThread(NewRunnableMethod(this, &TextTrackManager::UpdateCueDisplay));
|
||||
mUpdateCueDisplayDispatched = true;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
TextTrackManager::DispatchTimeMarchesOn()
|
||||
{
|
||||
|
@ -92,6 +92,7 @@ public:
|
||||
|
||||
void DispatchTimeMarchesOn();
|
||||
void TimeMarchesOn();
|
||||
void DispatchUpdateCueDisplay();
|
||||
|
||||
void NotifyShutdown()
|
||||
{
|
||||
@ -128,6 +129,7 @@ private:
|
||||
double mLastTimeMarchesOnCalled;
|
||||
|
||||
bool mTimeMarchesOnDispatched;
|
||||
bool mUpdateCueDisplayDispatched;
|
||||
|
||||
static StaticRefPtr<nsIWebVTTParserWrapper> sParserWrapper;
|
||||
|
||||
|
@ -93,7 +93,6 @@ TextTrack::SetMode(TextTrackMode aValue)
|
||||
if (mMode != aValue) {
|
||||
mMode = aValue;
|
||||
if (aValue == TextTrackMode::Disabled) {
|
||||
SetCuesInactive();
|
||||
// Remove all the cues in MediaElement.
|
||||
if (mTextTrackList) {
|
||||
HTMLMediaElement* mediaElement = mTextTrackList->GetMediaElement();
|
||||
@ -103,6 +102,7 @@ TextTrack::SetMode(TextTrackMode aValue)
|
||||
}
|
||||
}
|
||||
}
|
||||
SetCuesInactive();
|
||||
} else {
|
||||
// Add all the cues into MediaElement.
|
||||
if (mTextTrackList) {
|
||||
|
@ -40,19 +40,11 @@ TextTrackList::~TextTrackList()
|
||||
}
|
||||
|
||||
void
|
||||
TextTrackList::UpdateAndGetShowingCues(nsTArray<RefPtr<TextTrackCue> >& aCues)
|
||||
TextTrackList::GetShowingCues(nsTArray<RefPtr<TextTrackCue> >& aCues)
|
||||
{
|
||||
nsTArray< RefPtr<TextTrackCue> > cues;
|
||||
for (uint32_t i = 0; i < Length(); i++) {
|
||||
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.
|
||||
if (mTextTracks[i]->Mode() == TextTrackMode::Showing) {
|
||||
mTextTracks[i]->GetActiveCueArray(cues);
|
||||
aCues.AppendElements(cues);
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ public:
|
||||
}
|
||||
|
||||
// Get all the current active cues.
|
||||
void UpdateAndGetShowingCues(nsTArray<RefPtr<TextTrackCue> >& aCues);
|
||||
void GetShowingCues(nsTArray<RefPtr<TextTrackCue> >& aCues);
|
||||
|
||||
TextTrack* IndexedGetter(uint32_t aIndex, bool& aFound);
|
||||
TextTrack* operator[](uint32_t aIndex);
|
||||
|
Loading…
Reference in New Issue
Block a user