Bug 983293 - Part 3: Rename the READY_STATE enum to TextTrackReadyState. r=cpearce

- This allows us to pass around ReadyState values. It also makes the type
explicit which will save us from potentially shooting ourselves in
the foot.
- I also renamed 'READY_STATE_NONE' and 'READY_STATE_ERROR' to
'NotLoaded' and 'FailedToLoad' respectively in the enum. This is to
avoid some name collision errors we were having. It also makes it more
clear where in the spec this is as these names are the spec's names
for the TextTrack enum.
This commit is contained in:
Rick Eyre 2014-03-13 14:29:32 -04:00
Родитель 5b8f62b638
Коммит ac80b91953
5 изменённых файлов: 22 добавлений и 21 удалений

Просмотреть файл

@ -317,7 +317,7 @@ uint16_t
HTMLTrackElement::ReadyState() const
{
if (!mTrack) {
return TextTrack::READY_STATE_NONE;
return TextTrackReadyState::NotLoaded;
}
return mTrack->ReadyState();

Просмотреть файл

@ -121,7 +121,7 @@ TextTrackManager::AddTextTrack(TextTrackKind aKind, const nsAString& aLabel,
nsRefPtr<TextTrack> ttrack =
mTextTracks->AddTextTrack(aKind, aLabel, aLanguage, aMode, aTextTrackSource,
CompareTextTracks(mMediaElement));
ttrack->SetReadyState(TextTrack::READY_STATE_LOADED);
ttrack->SetReadyState(TextTrackReadyState::Loaded);
AddCues(ttrack);
return ttrack.forget();
}
@ -218,7 +218,7 @@ TextTrackManager::PopulatePendingList()
for (uint32_t index = 0; index < len; ++index) {
TextTrack* ttrack = mTextTracks->IndexedGetter(index, dummy);
if (ttrack && ttrack->Mode() != TextTrackMode::Disabled &&
ttrack->ReadyState() == TextTrack::READY_STATE_LOADING) {
ttrack->ReadyState() == TextTrackReadyState::Loading) {
mPendingTextTracks->AddTextTrack(ttrack,
CompareTextTracks(mMediaElement));
}

Просмотреть файл

@ -74,7 +74,7 @@ TextTrack::SetDefaultSettings()
mActiveCueList = new TextTrackCueList(mParent);
mCuePos = 0;
mDirty = false;
mReadyState = TextTrack::READY_STATE_NONE;
mReadyState = TextTrackReadyState::NotLoaded;
}
JSObject*
@ -179,14 +179,14 @@ TextTrack::GetActiveCueArray(nsTArray<nsRefPtr<TextTrackCue> >& aCues)
}
}
uint16_t
TextTrackReadyState
TextTrack::ReadyState() const
{
return mReadyState;
}
void
TextTrack::SetReadyState(uint16_t aState)
TextTrack::SetReadyState(TextTrackReadyState aState)
{
mReadyState = aState;
@ -195,8 +195,8 @@ TextTrack::SetReadyState(uint16_t aState)
}
HTMLMediaElement* mediaElement = mTextTrackList->GetMediaElement();
if (mediaElement && (mReadyState == TextTrack::READY_STATE_LOADED ||
mReadyState == TextTrack::READY_STATE_ERROR)) {
if (mediaElement && (mReadyState == TextTrackReadyState::Loaded||
mReadyState == TextTrackReadyState::FailedToLoad)) {
mediaElement->RemoveTextTrack(this, true);
}
}

Просмотреть файл

@ -28,6 +28,14 @@ enum TextTrackSource {
MediaResourceSpecific
};
// Constants for numeric readyState property values.
enum TextTrackReadyState {
NotLoaded = 0U,
Loading = 1U,
Loaded = 2U,
FailedToLoad = 3U
};
class TextTrack MOZ_FINAL : public nsDOMEventTargetHelper
{
public:
@ -96,15 +104,8 @@ public:
TextTrackCueList* GetActiveCues();
void GetActiveCueArray(nsTArray<nsRefPtr<TextTrackCue> >& aCues);
// Constants for numeric readyState property values.
enum {
READY_STATE_NONE = 0U,
READY_STATE_LOADING = 1U,
READY_STATE_LOADED = 2U,
READY_STATE_ERROR = 3U
};
uint16_t ReadyState() const;
void SetReadyState(uint16_t aState);
TextTrackReadyState ReadyState() const;
void SetReadyState(TextTrackReadyState aState);
void AddCue(TextTrackCue& aCue);
void RemoveCue(TextTrackCue& aCue, ErrorResult& aRv);
@ -141,7 +142,7 @@ private:
nsRefPtr<HTMLTrackElement> mTrackElement;
uint32_t mCuePos;
uint16_t mReadyState;
TextTrackReadyState mReadyState;
bool mDirty;
// An enum that represents where the track was sourced from.

Просмотреть файл

@ -78,7 +78,7 @@ WebVTTListener::LoadResource()
rv = mParserWrapper->Watch(this);
NS_ENSURE_SUCCESS(rv, rv);
mElement->mTrack->SetReadyState(TextTrack::READY_STATE_LOADING);
mElement->mTrack->SetReadyState(TextTrackReadyState::Loading);
return NS_OK;
}
@ -106,9 +106,9 @@ WebVTTListener::OnStopRequest(nsIRequest* aRequest,
nsISupports* aContext,
nsresult aStatus)
{
if (mElement->ReadyState() != TextTrack::READY_STATE_ERROR) {
if (mElement->ReadyState() != TextTrackReadyState::FailedToLoad) {
TextTrack* track = mElement->Track();
track->SetReadyState(TextTrack::READY_STATE_LOADED);
track->SetReadyState(TextTrackReadyState::Loaded);
}
// Attempt to parse any final data the parser might still have.
mParserWrapper->Flush();