mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 03:45:46 +00:00
Bug 882665 - Part b: Add list of pending text tracks to TextTrackManager. r=rillian, khuey
This commit is contained in:
parent
bccdc26ea8
commit
2d494bdb0f
@ -532,9 +532,9 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void RemoveTextTrack(TextTrack* aTextTrack) {
|
||||
void RemoveTextTrack(TextTrack* aTextTrack, bool aPendingListOnly = false) {
|
||||
if (mTextTrackManager) {
|
||||
mTextTrackManager->RemoveTextTrack(aTextTrack);
|
||||
mTextTrackManager->RemoveTextTrack(aTextTrack, aPendingListOnly);
|
||||
}
|
||||
}
|
||||
|
||||
@ -862,6 +862,11 @@ protected:
|
||||
// Update the audio channel playing state
|
||||
virtual void UpdateAudioChannelPlayingState();
|
||||
|
||||
// Adds to the element's list of pending text tracks each text track
|
||||
// in the element's list of text tracks whose text track mode is not disabled
|
||||
// and whose text track readiness state is loading.
|
||||
void PopulatePendingTextTrackList();
|
||||
|
||||
// The current decoder. Load() has been called on this decoder.
|
||||
// At most one of mDecoder and mSrcStream can be non-null.
|
||||
nsRefPtr<MediaDecoder> mDecoder;
|
||||
|
@ -3920,5 +3920,13 @@ HTMLMediaElement::AddTextTrack(TextTrackKind aKind,
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
HTMLMediaElement::PopulatePendingTextTrackList()
|
||||
{
|
||||
if (mTextTrackManager) {
|
||||
mTextTrackManager->PopulatePendingList();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
@ -12,7 +12,7 @@
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_1(TextTrackManager, mTextTracks)
|
||||
NS_IMPL_CYCLE_COLLECTION_2(TextTrackManager, mTextTracks, mPendingTextTracks)
|
||||
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(TextTrackManager, AddRef)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(TextTrackManager, Release)
|
||||
|
||||
@ -21,6 +21,8 @@ TextTrackManager::TextTrackManager(HTMLMediaElement *aMediaElement)
|
||||
{
|
||||
MOZ_COUNT_CTOR(TextTrackManager);
|
||||
mTextTracks = new TextTrackList(mMediaElement->OwnerDoc()->GetParentObject());
|
||||
mPendingTextTracks =
|
||||
new TextTrackList(mMediaElement->OwnerDoc()->GetParentObject());
|
||||
}
|
||||
|
||||
TextTrackManager::~TextTrackManager()
|
||||
@ -51,8 +53,13 @@ TextTrackManager::AddTextTrack(TextTrack* aTextTrack)
|
||||
}
|
||||
|
||||
void
|
||||
TextTrackManager::RemoveTextTrack(TextTrack* aTextTrack)
|
||||
TextTrackManager::RemoveTextTrack(TextTrack* aTextTrack, bool aPendingListOnly)
|
||||
{
|
||||
mPendingTextTracks->RemoveTextTrack(aTextTrack);
|
||||
if (aPendingListOnly) {
|
||||
return;
|
||||
}
|
||||
|
||||
mTextTracks->RemoveTextTrack(aTextTrack);
|
||||
}
|
||||
|
||||
@ -68,5 +75,19 @@ TextTrackManager::Update(double aTime)
|
||||
mTextTracks->Update(aTime);
|
||||
}
|
||||
|
||||
void
|
||||
TextTrackManager::PopulatePendingList()
|
||||
{
|
||||
uint32_t len = mTextTracks->Length();
|
||||
bool dummy;
|
||||
for (uint32_t index = 0; index < len; ++index) {
|
||||
TextTrack* ttrack = mTextTracks->IndexedGetter(index, dummy);
|
||||
if (ttrack && ttrack->Mode() != TextTrackMode::Disabled &&
|
||||
ttrack->ReadyState() == HTMLTrackElement::LOADING) {
|
||||
mPendingTextTracks->AddTextTrack(ttrack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
@ -30,13 +30,15 @@ public:
|
||||
const nsAString& aLabel,
|
||||
const nsAString& aLanguage);
|
||||
void AddTextTrack(TextTrack* aTextTrack);
|
||||
void RemoveTextTrack(TextTrack* aTextTrack);
|
||||
void RemoveTextTrack(TextTrack* aTextTrack, bool aPendingListOnly);
|
||||
void DidSeek();
|
||||
|
||||
// Update the display of cues on the video as per the current play back time
|
||||
// of aTime.
|
||||
void Update(double aTime);
|
||||
|
||||
void PopulatePendingList();
|
||||
|
||||
private:
|
||||
// The HTMLMediaElement that this TextTrackManager manages the TextTracks of.
|
||||
// This is a weak reference as the life time of TextTrackManager is dependent
|
||||
@ -45,6 +47,8 @@ private:
|
||||
HTMLMediaElement* mMediaElement;
|
||||
// List of the TextTrackManager's owning HTMLMediaElement's TextTracks.
|
||||
nsRefPtr<TextTrackList> mTextTracks;
|
||||
// List of text track objects awaiting loading.
|
||||
nsRefPtr<TextTrackList> mPendingTextTracks;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
@ -182,6 +182,10 @@ void
|
||||
TextTrack::SetReadyState(uint16_t aState)
|
||||
{
|
||||
mReadyState = aState;
|
||||
if (mReadyState == HTMLTrackElement::LOADED ||
|
||||
mReadyState == HTMLTrackElement::ERROR) {
|
||||
mMediaElement->RemoveTextTrack(this, true);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
|
Loading…
Reference in New Issue
Block a user