зеркало из https://github.com/mozilla/gecko-dev.git
Bug 865407 - Part 3: Add TextTrackList::GetAllActiveCues(). r=rillian
This commit is contained in:
Родитель
3df1b3361b
Коммит
4ca6ff109d
|
@ -142,11 +142,11 @@ TextTrack::RemoveRegion(const TextTrackRegion& aRegion, ErrorResult& aRv)
|
|||
mRegionList->RemoveTextTrackRegion(aRegion);
|
||||
}
|
||||
|
||||
TextTrackCueList*
|
||||
TextTrack::GetActiveCues()
|
||||
void
|
||||
TextTrack::UpdateActiveCueList()
|
||||
{
|
||||
if (mMode == TextTrackMode::Disabled || !mMediaElement) {
|
||||
return nullptr;
|
||||
return;
|
||||
}
|
||||
|
||||
// If we are dirty, i.e. an event happened that may cause the sorted mCueList
|
||||
|
@ -176,9 +176,21 @@ TextTrack::GetActiveCues()
|
|||
mActiveCueList->AddCue(*(*mCueList)[mCuePos]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TextTrackCueList*
|
||||
TextTrack::GetActiveCues() {
|
||||
UpdateActiveCueList();
|
||||
return mActiveCueList;
|
||||
}
|
||||
|
||||
void
|
||||
TextTrack::GetActiveCueArray(nsTArray<nsRefPtr<TextTrackCue> >& aCues)
|
||||
{
|
||||
UpdateActiveCueList();
|
||||
mActiveCueList->GetArray(aCues);
|
||||
}
|
||||
|
||||
uint16_t
|
||||
TextTrack::ReadyState() const
|
||||
{
|
||||
|
|
|
@ -83,6 +83,7 @@ public:
|
|||
}
|
||||
|
||||
TextTrackCueList* GetActiveCues();
|
||||
void GetActiveCueArray(nsTArray<nsRefPtr<TextTrackCue> >& aCues);
|
||||
|
||||
TextTrackRegionList* GetRegions() const
|
||||
{
|
||||
|
@ -109,6 +110,8 @@ public:
|
|||
IMPL_EVENT_HANDLER(cuechange)
|
||||
|
||||
private:
|
||||
void UpdateActiveCueList();
|
||||
|
||||
nsCOMPtr<nsISupports> mParent;
|
||||
nsRefPtr<HTMLMediaElement> mMediaElement;
|
||||
|
||||
|
|
|
@ -116,5 +116,12 @@ TextTrackCueList::RemoveAll()
|
|||
mList.Clear();
|
||||
}
|
||||
|
||||
void
|
||||
TextTrackCueList::GetArray(nsTArray<nsRefPtr<TextTrackCue> >& aCues)
|
||||
{
|
||||
aCues = nsTArray<nsRefPtr<TextTrackCue> >(mList);
|
||||
}
|
||||
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -56,6 +56,7 @@ public:
|
|||
void RemoveCue(TextTrackCue& aCue, ErrorResult& aRv);
|
||||
void RemoveCueAt(uint32_t aIndex);
|
||||
void RemoveAll();
|
||||
void GetArray(nsTArray<nsRefPtr<TextTrackCue> >& aCues);
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsISupports> mParent;
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "mozilla/dom/TextTrackListBinding.h"
|
||||
#include "mozilla/dom/TrackEvent.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "mozilla/dom/TextTrackCue.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
@ -35,6 +36,18 @@ TextTrackList::Update(double aTime)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
TextTrackList::GetAllActiveCues(nsTArray<nsRefPtr<TextTrackCue> >& aCues)
|
||||
{
|
||||
nsTArray< nsRefPtr<TextTrackCue> > cues;
|
||||
for (uint32_t i = 0; i < Length(); i++) {
|
||||
if (mTextTracks[i]->Mode() != TextTrackMode::Disabled) {
|
||||
mTextTracks[i]->GetActiveCueArray(cues);
|
||||
aCues.AppendElements(cues);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
JSObject*
|
||||
TextTrackList::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
|
||||
{
|
||||
|
|
|
@ -41,6 +41,9 @@ public:
|
|||
// Time is in seconds.
|
||||
void Update(double aTime);
|
||||
|
||||
// Get all the current active cues.
|
||||
void GetAllActiveCues(nsTArray<nsRefPtr<TextTrackCue> >& aCues);
|
||||
|
||||
TextTrack* IndexedGetter(uint32_t aIndex, bool& aFound);
|
||||
|
||||
already_AddRefed<TextTrack> AddTextTrack(HTMLMediaElement* aMediaElement,
|
||||
|
|
Загрузка…
Ссылка в новой задаче