Bug 882717 - Invoke TimeMarchesOn when the startTime/endTime/pauseOnExit be changed of TextTrackCue. r=rillian

MozReview-Commit-ID: 7Xol9x83lLx

--HG--
extra : transplant_source : %DD%5C%E9%5C%98Y4%7B%AE%24%E1%7C%9F%F8%60C%85%0D%D5W
This commit is contained in:
bechen 2016-06-08 16:53:30 +08:00
parent 73b62156c7
commit 5f7ef9b5d7
8 changed files with 52 additions and 1 deletions

View File

@ -706,6 +706,11 @@ public:
mTextTrackManager->NotifyCueRemoved(aCue);
}
}
void NotifyCueUpdated(TextTrackCue *aCue) {
if (mTextTrackManager) {
mTextTrackManager->NotifyCueUpdated(aCue);
}
}
/**
* A public wrapper for FinishDecoderSetup()

View File

@ -712,5 +712,12 @@ TextTrackManager::TimeMarchesOn()
UpdateCueDisplay();
}
void
TextTrackManager::NotifyCueUpdated(TextTrackCue *aCue)
{
// TODO: Add/Reorder the cue to mNewCues if we have some optimization?
DispatchTimeMarchesOn();
}
} // namespace dom
} // namespace mozilla

View File

@ -98,6 +98,8 @@ public:
mShutdown = true;
}
void NotifyCueUpdated(TextTrackCue *aCue);
private:
/**
* Converts the TextTrackCue's cuetext into a tree of DOM objects
@ -112,7 +114,7 @@ private:
RefPtr<TextTrackList> mPendingTextTracks;
// List of newly introduced Text Track cues.
// Contain all cues for a MediaElement.
// Contain all cues for a MediaElement. Not sorted.
RefPtr<TextTrackCueList> mNewCues;
// The active cues for the last TimeMarchesOn iteration.
RefPtr<TextTrackCueList> mLastActiveCues;

View File

@ -117,6 +117,9 @@ TextTrack::SetMode(TextTrackMode aValue)
if (mTextTrackList) {
mTextTrackList->CreateAndDispatchChangeEvent();
}
// Ensure the TimeMarchesOn is called in case that the mCueList
// is empty.
NotifyCueUpdated(nullptr);
}
}
@ -284,5 +287,18 @@ TextTrack::SetCuesInactive()
mCueList->SetCuesInactive();
}
void
TextTrack::NotifyCueUpdated(TextTrackCue *aCue)
{
mCueList->NotifyCueUpdated(aCue);
if (mTextTrackList) {
HTMLMediaElement* mediaElement = mTextTrackList->GetMediaElement();
if (mediaElement) {
mediaElement->NotifyCueUpdated(aCue);
}
}
SetDirty();
}
} // namespace dom
} // namespace mozilla

View File

@ -120,6 +120,8 @@ public:
void SetCuesInactive();
void NotifyCueUpdated(TextTrackCue *aCue);
private:
~TextTrack();

View File

@ -84,6 +84,7 @@ public:
mStartTime = aStartTime;
mReset = true;
NotifyCueUpdated(this);
}
double EndTime() const
@ -99,6 +100,7 @@ public:
mEndTime = aEndTime;
mReset = true;
NotifyCueUpdated(this);
}
bool PauseOnExit()
@ -113,6 +115,7 @@ public:
}
mPauseOnExit = aPauseOnExit;
NotifyCueUpdated(nullptr);
}
TextTrackRegion* GetRegion();
@ -339,6 +342,12 @@ public:
private:
~TextTrackCue();
void NotifyCueUpdated(TextTrackCue* aCue)
{
if (mTrack) {
mTrack->NotifyCueUpdated(aCue);
}
}
void SetDefaultCueSettings();
nsresult StashDocument();

View File

@ -152,5 +152,14 @@ TextTrackCueList::GetCueListByTimeInterval(media::Interval<double>& aInterval)
return output.forget();
}
void
TextTrackCueList::NotifyCueUpdated(TextTrackCue *aCue)
{
if (aCue) {
mList.RemoveElement(aCue);
mList.InsertElementSorted(aCue, CompareCuesByTime());
}
}
} // namespace dom
} // namespace mozilla

View File

@ -60,6 +60,7 @@ public:
already_AddRefed<TextTrackCueList>
GetCueListByTimeInterval(media::Interval<double>& aInterval);
void NotifyCueUpdated(TextTrackCue *aCue);
private:
~TextTrackCueList();