Line data Source code
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/. */
6 :
7 : #ifndef mozilla_dom_TextTrackList_h
8 : #define mozilla_dom_TextTrackList_h
9 :
10 : #include "mozilla/DOMEventTargetHelper.h"
11 : #include "mozilla/dom/TextTrack.h"
12 : #include "nsCycleCollectionParticipant.h"
13 :
14 : namespace mozilla {
15 : namespace dom {
16 :
17 : class HTMLMediaElement;
18 : class TextTrackManager;
19 : class CompareTextTracks;
20 : class TrackEvent;
21 : class TrackEventRunner;
22 :
23 : class TextTrackList final : public DOMEventTargetHelper
24 : {
25 : public:
26 : NS_DECL_ISUPPORTS_INHERITED
27 0 : NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(TextTrackList, DOMEventTargetHelper)
28 :
29 : explicit TextTrackList(nsPIDOMWindowInner* aOwnerWindow);
30 : TextTrackList(nsPIDOMWindowInner* aOwnerWindow, TextTrackManager* aTextTrackManager);
31 :
32 : JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
33 :
34 0 : uint32_t Length() const
35 : {
36 0 : return mTextTracks.Length();
37 : }
38 :
39 : // Get all the current active cues.
40 : void GetShowingCues(nsTArray<RefPtr<TextTrackCue> >& aCues);
41 :
42 : TextTrack* IndexedGetter(uint32_t aIndex, bool& aFound);
43 : TextTrack* operator[](uint32_t aIndex);
44 :
45 : already_AddRefed<TextTrack> AddTextTrack(TextTrackKind aKind,
46 : const nsAString& aLabel,
47 : const nsAString& aLanguage,
48 : TextTrackMode aMode,
49 : TextTrackReadyState aReadyState,
50 : TextTrackSource aTextTrackSource,
51 : const CompareTextTracks& aCompareTT);
52 : TextTrack* GetTrackById(const nsAString& aId);
53 :
54 : void AddTextTrack(TextTrack* aTextTrack, const CompareTextTracks& aCompareTT);
55 :
56 : void RemoveTextTrack(TextTrack* aTrack);
57 : void DidSeek();
58 :
59 : HTMLMediaElement* GetMediaElement();
60 : void SetTextTrackManager(TextTrackManager* aTextTrackManager);
61 :
62 : nsresult DispatchTrackEvent(nsIDOMEvent* aEvent);
63 : void CreateAndDispatchChangeEvent();
64 : void SetCuesInactive();
65 :
66 : bool AreTextTracksLoaded();
67 : nsTArray<RefPtr<TextTrack>>& GetTextTrackArray();
68 :
69 0 : IMPL_EVENT_HANDLER(change)
70 0 : IMPL_EVENT_HANDLER(addtrack)
71 0 : IMPL_EVENT_HANDLER(removetrack)
72 :
73 : bool mPendingTextTrackChange = false;
74 :
75 : private:
76 : ~TextTrackList();
77 :
78 : nsTArray< RefPtr<TextTrack> > mTextTracks;
79 : RefPtr<TextTrackManager> mTextTrackManager;
80 :
81 : void CreateAndDispatchTrackEventRunner(TextTrack* aTrack,
82 : const nsAString& aEventName);
83 : };
84 :
85 : } // namespace dom
86 : } // namespace mozilla
87 :
88 : #endif // mozilla_dom_TextTrackList_h
|