Bug 983293 - Part 4: Pass ReadyState variables to AddTextTrack methods and TextTrack ctors. r=cpearce

This makes it more clear what part of the code is triggering the ReadyState
to be what it is. I.E. Tracks added through the HTMLMediaElement::AddTextTrack
method should have a ReadyState of "Loaded" and so it's more clear for
function to specify that. Vice versa for TrackElements which add TextTracks
with a default ReadyState of "None".
This commit is contained in:
Rick Eyre 2014-03-13 14:41:21 -04:00
parent fffd5328cf
commit 4b465b49a2
8 changed files with 19 additions and 6 deletions

View File

@ -3951,6 +3951,7 @@ HTMLMediaElement::AddTextTrack(TextTrackKind aKind,
if (mTextTrackManager) {
return mTextTrackManager->AddTextTrack(aKind, aLabel, aLanguage,
TextTrackMode::Hidden,
TextTrackReadyState::Loaded,
TextTrackSource::AddTextTrack);
}
return nullptr;

View File

@ -154,7 +154,9 @@ HTMLTrackElement::CreateTextTrack()
}
mTrack = new TextTrack(OwnerDoc()->GetParentObject(), kind, label, srcLang,
TextTrackMode::Disabled, TextTrackSource::Track);
TextTrackMode::Disabled,
TextTrackReadyState::NotLoaded,
TextTrackSource::Track);
mTrack->SetTrackElement(this);
if (mMediaParent) {

View File

@ -113,15 +113,15 @@ already_AddRefed<TextTrack>
TextTrackManager::AddTextTrack(TextTrackKind aKind, const nsAString& aLabel,
const nsAString& aLanguage,
TextTrackMode aMode,
TextTrackReadyState aReadyState,
TextTrackSource aTextTrackSource)
{
if (!mMediaElement) {
return nullptr;
}
nsRefPtr<TextTrack> ttrack =
mTextTracks->AddTextTrack(aKind, aLabel, aLanguage, aMode, aTextTrackSource,
CompareTextTracks(mMediaElement));
ttrack->SetReadyState(TextTrackReadyState::Loaded);
mTextTracks->AddTextTrack(aKind, aLabel, aLanguage, aMode, aReadyState,
aTextTrackSource, CompareTextTracks(mMediaElement));
AddCues(ttrack);
return ttrack.forget();
}

View File

@ -47,6 +47,7 @@ public:
const nsAString& aLabel,
const nsAString& aLanguage,
TextTrackMode aMode,
TextTrackReadyState aReadyState,
TextTrackSource aTextTrackSource);
void AddTextTrack(TextTrack* aTextTrack);
void RemoveTextTrack(TextTrack* aTextTrack, bool aPendingListOnly);

View File

@ -34,6 +34,7 @@ TextTrack::TextTrack(nsISupports* aParent,
const nsAString& aLabel,
const nsAString& aLanguage,
TextTrackMode aMode,
TextTrackReadyState aReadyState,
TextTrackSource aTextTrackSource)
: mParent(aParent)
, mTextTrackSource(aTextTrackSource)
@ -43,6 +44,7 @@ TextTrack::TextTrack(nsISupports* aParent,
mLabel = aLabel;
mLanguage = aLanguage;
mMode = aMode;
mReadyState = aReadyState;
SetIsDOMBinding();
}
@ -52,6 +54,7 @@ TextTrack::TextTrack(nsISupports* aParent,
const nsAString& aLabel,
const nsAString& aLanguage,
TextTrackMode aMode,
TextTrackReadyState aReadyState,
TextTrackSource aTextTrackSource)
: mParent(aParent)
, mTextTrackList(aTextTrackList)
@ -62,6 +65,7 @@ TextTrack::TextTrack(nsISupports* aParent,
mLabel = aLabel;
mLanguage = aLanguage;
mMode = aMode;
mReadyState = aReadyState;
SetIsDOMBinding();
}

View File

@ -47,6 +47,7 @@ public:
const nsAString& aLabel,
const nsAString& aLanguage,
TextTrackMode aMode,
TextTrackReadyState aReadyState,
TextTrackSource aTextTrackSource);
TextTrack(nsISupports* aParent,
TextTrackList* aTextTrackList,
@ -54,6 +55,7 @@ public:
const nsAString& aLabel,
const nsAString& aLanguage,
TextTrackMode aMode,
TextTrackReadyState aReadyState,
TextTrackSource aTextTrackSource);
void SetDefaultSettings();

View File

@ -66,11 +66,13 @@ TextTrackList::AddTextTrack(TextTrackKind aKind,
const nsAString& aLabel,
const nsAString& aLanguage,
TextTrackMode aMode,
TextTrackReadyState aReadyState,
TextTrackSource aTextTrackSource,
const CompareTextTracks& aCompareTT)
{
nsRefPtr<TextTrack> track = new TextTrack(mGlobal, this, aKind, aLabel, aLanguage,
aMode, aTextTrackSource);
nsRefPtr<TextTrack> track = new TextTrack(mGlobal, this, aKind, aLabel,
aLanguage, aMode, aReadyState,
aTextTrackSource);
AddTextTrack(track, aCompareTT);
return track.forget();
}

View File

@ -51,6 +51,7 @@ public:
const nsAString& aLabel,
const nsAString& aLanguage,
TextTrackMode aMode,
TextTrackReadyState aReadyState,
TextTrackSource aTextTrackSource,
const CompareTextTracks& aCompareTT);
TextTrack* GetTrackById(const nsAString& aId);