Bug 1941046 - Part 4: Send a callback request for impression and clicks of MARS Top...
[gecko.git] / dom / media / webvtt / TextTrackList.h
blob712e3ae9c4f3da8b3624e8e438a9f41a5241be9c
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_TextTrackList_h
8 #define mozilla_dom_TextTrackList_h
10 #include "mozilla/DOMEventTargetHelper.h"
11 #include "mozilla/dom/TextTrack.h"
12 #include "nsCycleCollectionParticipant.h"
14 namespace mozilla::dom {
16 class Event;
17 class HTMLMediaElement;
18 class TextTrackManager;
19 class CompareTextTracks;
20 class TrackEvent;
21 class TrackEventRunner;
23 class TextTrackList final : public DOMEventTargetHelper {
24 public:
25 NS_DECL_ISUPPORTS_INHERITED
26 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(TextTrackList, DOMEventTargetHelper)
28 explicit TextTrackList(nsPIDOMWindowInner* aOwnerWindow);
29 TextTrackList(nsPIDOMWindowInner* aOwnerWindow,
30 TextTrackManager* aTextTrackManager);
32 JSObject* WrapObject(JSContext* aCx,
33 JS::Handle<JSObject*> aGivenProto) override;
35 uint32_t Length() const { return mTextTracks.Length(); }
37 // Get all the current active cues.
38 void GetShowingCues(nsTArray<RefPtr<TextTrackCue>>& aCues);
40 TextTrack* IndexedGetter(uint32_t aIndex, bool& aFound);
41 TextTrack* operator[](uint32_t aIndex);
43 already_AddRefed<TextTrack> AddTextTrack(
44 TextTrackKind aKind, const nsAString& aLabel, const nsAString& aLanguage,
45 TextTrackMode aMode, TextTrackReadyState aReadyState,
46 TextTrackSource aTextTrackSource, const CompareTextTracks& aCompareTT);
47 TextTrack* GetTrackById(const nsAString& aId);
49 void AddTextTrack(TextTrack* aTextTrack, const CompareTextTracks& aCompareTT);
51 void RemoveTextTrack(TextTrack* aTrack);
53 HTMLMediaElement* GetMediaElement();
54 void SetTextTrackManager(TextTrackManager* aTextTrackManager);
56 nsresult DispatchTrackEvent(Event* aEvent);
57 void CreateAndDispatchChangeEvent();
58 void SetCuesInactive();
60 bool AreTextTracksLoaded();
61 nsTArray<RefPtr<TextTrack>>& GetTextTrackArray();
63 IMPL_EVENT_HANDLER(change)
64 IMPL_EVENT_HANDLER(addtrack)
65 IMPL_EVENT_HANDLER(removetrack)
67 private:
68 ~TextTrackList();
70 nsTArray<RefPtr<TextTrack>> mTextTracks;
71 RefPtr<TextTrackManager> mTextTrackManager;
73 void CreateAndDispatchTrackEventRunner(TextTrack* aTrack,
74 const nsAString& aEventName);
77 } // namespace mozilla::dom
79 #endif // mozilla_dom_TextTrackList_h