Bug 1449132 [wpt PR 10194] - [css-grid] Fix resolution of percentage paddings and...
[gecko.git] / dom / media / TextTrack.h
blobc8d84f4d53fa4d15ecf66cfb3a8aed8116b585c6
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"
12 #include "nsCOMPtr.h"
13 #include "nsCycleCollectionParticipant.h"
14 #include "nsString.h"
16 namespace mozilla {
17 namespace dom {
19 class TextTrackList;
20 class TextTrackCue;
21 class TextTrackCueList;
22 class HTMLTrackElement;
24 enum TextTrackSource {
25 Track,
26 AddTextTrack,
27 MediaResourceSpecific
30 // Constants for numeric readyState property values.
31 enum TextTrackReadyState {
32 NotLoaded = 0U,
33 Loading = 1U,
34 Loaded = 2U,
35 FailedToLoad = 3U
38 class TextTrack final : public DOMEventTargetHelper
40 public:
41 NS_DECL_ISUPPORTS_INHERITED
42 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(TextTrack, DOMEventTargetHelper)
44 TextTrack(nsPIDOMWindowInner* aOwnerWindow,
45 TextTrackKind aKind,
46 const nsAString& aLabel,
47 const nsAString& aLanguage,
48 TextTrackMode aMode,
49 TextTrackReadyState aReadyState,
50 TextTrackSource aTextTrackSource);
51 TextTrack(nsPIDOMWindowInner* aOwnerWindow,
52 TextTrackList* aTextTrackList,
53 TextTrackKind aKind,
54 const nsAString& aLabel,
55 const nsAString& aLanguage,
56 TextTrackMode aMode,
57 TextTrackReadyState aReadyState,
58 TextTrackSource aTextTrackSource);
60 void SetDefaultSettings();
62 JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
64 TextTrackKind Kind() const
66 return mKind;
68 void GetLabel(nsAString& aLabel) const;
69 void GetLanguage(nsAString& aLanguage) const;
70 void GetInBandMetadataTrackDispatchType(nsAString& aType) const
72 aType = mType;
74 void GetId(nsAString& aId) const;
76 TextTrackMode Mode() const
78 return mMode;
80 void SetMode(TextTrackMode aValue);
82 TextTrackCueList* GetCues() const
84 if (mMode == TextTrackMode::Disabled) {
85 return nullptr;
87 return mCueList;
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; }
101 void SetCuesDirty();
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);
121 bool IsLoaded();
123 private:
124 ~TextTrack();
126 RefPtr<TextTrackList> mTextTrackList;
128 TextTrackKind mKind;
129 nsString mLabel;
130 nsString mLanguage;
131 nsString mType;
132 TextTrackMode mMode;
134 RefPtr<TextTrackCueList> mCueList;
135 RefPtr<TextTrackCueList> mActiveCueList;
136 RefPtr<HTMLTrackElement> mTrackElement;
138 uint32_t mCuePos;
139 TextTrackReadyState mReadyState;
140 bool mDirty;
142 // An enum that represents where the track was sourced from.
143 TextTrackSource mTextTrackSource;
146 } // namespace dom
147 } // namespace mozilla
149 #endif // mozilla_dom_TextTrack_h