2013-05-21 09:14:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim:set ts=2 sw=2 et tw=78: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_TextTrack_h
|
|
|
|
#define mozilla_dom_TextTrack_h
|
|
|
|
|
|
|
|
#include "mozilla/dom/TextTrackBinding.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsCycleCollectionParticipant.h"
|
|
|
|
#include "nsDOMEventTargetHelper.h"
|
|
|
|
#include "nsString.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2014-01-27 10:10:06 -08:00
|
|
|
class TextTrackList;
|
2013-05-21 09:14:00 -07:00
|
|
|
class TextTrackCue;
|
|
|
|
class TextTrackCueList;
|
2013-09-13 16:44:33 -07:00
|
|
|
class TextTrackRegion;
|
|
|
|
class TextTrackRegionList;
|
2013-05-21 09:14:00 -07:00
|
|
|
|
|
|
|
class TextTrack MOZ_FINAL : public nsDOMEventTargetHelper
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2013-08-15 08:11:15 -07:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(TextTrack, nsDOMEventTargetHelper)
|
2013-05-21 09:14:00 -07:00
|
|
|
|
|
|
|
TextTrack(nsISupports* aParent);
|
|
|
|
TextTrack(nsISupports* aParent,
|
2014-01-27 12:17:20 -08:00
|
|
|
TextTrackKind aKind,
|
|
|
|
const nsAString& aLabel,
|
|
|
|
const nsAString& aLanguage);
|
2013-06-14 13:10:36 -07:00
|
|
|
TextTrack(nsISupports* aParent,
|
2014-01-27 12:17:20 -08:00
|
|
|
TextTrackList* aTextTrackList,
|
2013-05-21 09:14:00 -07:00
|
|
|
TextTrackKind aKind,
|
|
|
|
const nsAString& aLabel,
|
|
|
|
const nsAString& aLanguage);
|
|
|
|
|
2013-06-14 13:10:36 -07:00
|
|
|
void SetDefaultSettings();
|
|
|
|
|
2013-05-21 09:14:00 -07:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
nsISupports* GetParentObject() const
|
|
|
|
{
|
|
|
|
return mParent;
|
|
|
|
}
|
|
|
|
|
|
|
|
TextTrackKind Kind() const
|
|
|
|
{
|
|
|
|
return mKind;
|
|
|
|
}
|
|
|
|
void GetLabel(nsAString& aLabel) const
|
|
|
|
{
|
|
|
|
aLabel = mLabel;
|
|
|
|
}
|
|
|
|
void GetLanguage(nsAString& aLanguage) const
|
|
|
|
{
|
|
|
|
aLanguage = mLanguage;
|
|
|
|
}
|
|
|
|
void GetInBandMetadataTrackDispatchType(nsAString& aType) const
|
|
|
|
{
|
|
|
|
aType = mType;
|
|
|
|
}
|
2013-07-09 08:44:35 -07:00
|
|
|
void GetId(nsAString& aId) const
|
|
|
|
{
|
|
|
|
aId = mId;
|
|
|
|
}
|
2013-05-21 09:14:00 -07:00
|
|
|
|
|
|
|
TextTrackMode Mode() const
|
|
|
|
{
|
|
|
|
return mMode;
|
|
|
|
}
|
|
|
|
void SetMode(TextTrackMode aValue);
|
|
|
|
|
|
|
|
TextTrackCueList* GetCues() const
|
|
|
|
{
|
|
|
|
if (mMode == TextTrackMode::Disabled) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return mCueList;
|
|
|
|
}
|
|
|
|
|
2013-06-14 13:10:36 -07:00
|
|
|
TextTrackCueList* GetActiveCues();
|
2013-12-12 07:57:21 -08:00
|
|
|
void GetActiveCueArray(nsTArray<nsRefPtr<TextTrackCue> >& aCues);
|
2013-05-21 09:14:00 -07:00
|
|
|
|
2013-09-13 16:44:33 -07:00
|
|
|
TextTrackRegionList* GetRegions() const
|
|
|
|
{
|
|
|
|
if (mMode != TextTrackMode::Disabled) {
|
|
|
|
return mRegionList;
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2013-10-24 21:14:36 -07:00
|
|
|
uint16_t ReadyState() const;
|
|
|
|
void SetReadyState(uint16_t aState);
|
|
|
|
|
2013-09-13 16:44:33 -07:00
|
|
|
void AddRegion(TextTrackRegion& aRegion);
|
|
|
|
void RemoveRegion(const TextTrackRegion& aRegion, ErrorResult& aRv);
|
|
|
|
|
2013-05-21 09:14:00 -07:00
|
|
|
void AddCue(TextTrackCue& aCue);
|
2013-06-28 10:31:43 -07:00
|
|
|
void RemoveCue(TextTrackCue& aCue, ErrorResult& aRv);
|
2013-05-21 09:14:00 -07:00
|
|
|
void CueChanged(TextTrackCue& aCue);
|
2013-06-14 13:10:36 -07:00
|
|
|
void SetDirty() { mDirty = true; }
|
2013-05-21 09:14:00 -07:00
|
|
|
|
2014-01-27 10:10:06 -08:00
|
|
|
TextTrackList* GetTextTrackList();
|
|
|
|
void SetTextTrackList(TextTrackList* aTextTrackList);
|
|
|
|
|
2013-05-21 09:14:00 -07:00
|
|
|
IMPL_EVENT_HANDLER(cuechange)
|
|
|
|
|
|
|
|
private:
|
2013-12-12 07:57:21 -08:00
|
|
|
void UpdateActiveCueList();
|
|
|
|
|
2013-05-21 09:14:00 -07:00
|
|
|
nsCOMPtr<nsISupports> mParent;
|
2014-01-27 10:10:06 -08:00
|
|
|
nsRefPtr<TextTrackList> mTextTrackList;
|
2013-05-21 09:14:00 -07:00
|
|
|
|
|
|
|
TextTrackKind mKind;
|
|
|
|
nsString mLabel;
|
|
|
|
nsString mLanguage;
|
|
|
|
nsString mType;
|
2013-07-09 08:44:35 -07:00
|
|
|
nsString mId;
|
2013-05-21 09:14:00 -07:00
|
|
|
TextTrackMode mMode;
|
|
|
|
|
|
|
|
nsRefPtr<TextTrackCueList> mCueList;
|
|
|
|
nsRefPtr<TextTrackCueList> mActiveCueList;
|
2013-09-13 16:44:33 -07:00
|
|
|
nsRefPtr<TextTrackRegionList> mRegionList;
|
2013-06-14 13:10:36 -07:00
|
|
|
|
|
|
|
uint32_t mCuePos;
|
2013-10-24 21:14:36 -07:00
|
|
|
uint16_t mReadyState;
|
2013-06-14 13:10:36 -07:00
|
|
|
bool mDirty;
|
2013-05-21 09:14:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_TextTrack_h
|