1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:set ts=2 sw=2 et tw=78: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_TextTrack_h
8 #define mozilla_dom_TextTrack_h
10 #include "mozilla/DOMEventTargetHelper.h"
11 #include "mozilla/dom/TextTrackBinding.h"
13 #include "nsCycleCollectionParticipant.h"
21 class TextTrackCueList
;
22 class HTMLTrackElement
;
24 enum TextTrackSource
{
30 // Constants for numeric readyState property values.
31 enum TextTrackReadyState
{
38 class TextTrack final
: public DOMEventTargetHelper
41 NS_DECL_ISUPPORTS_INHERITED
42 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(TextTrack
, DOMEventTargetHelper
)
44 TextTrack(nsPIDOMWindowInner
* aOwnerWindow
,
46 const nsAString
& aLabel
,
47 const nsAString
& aLanguage
,
49 TextTrackReadyState aReadyState
,
50 TextTrackSource aTextTrackSource
);
51 TextTrack(nsPIDOMWindowInner
* aOwnerWindow
,
52 TextTrackList
* aTextTrackList
,
54 const nsAString
& aLabel
,
55 const nsAString
& aLanguage
,
57 TextTrackReadyState aReadyState
,
58 TextTrackSource aTextTrackSource
);
60 void SetDefaultSettings();
62 JSObject
* WrapObject(JSContext
* aCx
, JS::Handle
<JSObject
*> aGivenProto
) override
;
64 TextTrackKind
Kind() const
68 void GetLabel(nsAString
& aLabel
) const;
69 void GetLanguage(nsAString
& aLanguage
) const;
70 void GetInBandMetadataTrackDispatchType(nsAString
& aType
) const
74 void GetId(nsAString
& aId
) const;
76 TextTrackMode
Mode() const
80 void SetMode(TextTrackMode aValue
);
82 TextTrackCueList
* GetCues() const
84 if (mMode
== TextTrackMode::Disabled
) {
90 TextTrackCueList
* GetActiveCues();
91 void UpdateActiveCueList();
92 void GetActiveCueArray(nsTArray
<RefPtr
<TextTrackCue
> >& aCues
);
94 TextTrackReadyState
ReadyState() const;
95 void SetReadyState(TextTrackReadyState aState
);
96 void SetReadyState(uint32_t aReadyState
);
98 void AddCue(TextTrackCue
& aCue
);
99 void RemoveCue(TextTrackCue
& aCue
, ErrorResult
& aRv
);
100 void SetDirty() { mDirty
= true; }
103 TextTrackList
* GetTextTrackList();
104 void SetTextTrackList(TextTrackList
* aTextTrackList
);
106 IMPL_EVENT_HANDLER(cuechange
)
108 HTMLTrackElement
* GetTrackElement();
109 void SetTrackElement(HTMLTrackElement
* aTrackElement
);
111 TextTrackSource
GetTextTrackSource() {
112 return mTextTrackSource
;
115 void SetCuesInactive();
117 void NotifyCueUpdated(TextTrackCue
*aCue
);
119 void DispatchAsyncTrustedEvent(const nsString
& aEventName
);
126 RefPtr
<TextTrackList
> mTextTrackList
;
134 RefPtr
<TextTrackCueList
> mCueList
;
135 RefPtr
<TextTrackCueList
> mActiveCueList
;
136 RefPtr
<HTMLTrackElement
> mTrackElement
;
139 TextTrackReadyState mReadyState
;
142 // An enum that represents where the track was sourced from.
143 TextTrackSource mTextTrackSource
;
147 } // namespace mozilla
149 #endif // mozilla_dom_TextTrack_h