|
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 MOZ_FINAL : public DOMEventTargetHelper |
|
24 { |
|
25 public: |
|
26 NS_DECL_ISUPPORTS_INHERITED |
|
27 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(TextTrackList, DOMEventTargetHelper) |
|
28 |
|
29 TextTrackList(nsPIDOMWindow* aOwnerWindow); |
|
30 TextTrackList(nsPIDOMWindow* aOwnerWindow, TextTrackManager* aTextTrackManager); |
|
31 |
|
32 virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE; |
|
33 |
|
34 uint32_t Length() const |
|
35 { |
|
36 return mTextTracks.Length(); |
|
37 } |
|
38 |
|
39 // Get all the current active cues. |
|
40 void UpdateAndGetShowingCues(nsTArray<nsRefPtr<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 |
|
65 IMPL_EVENT_HANDLER(change) |
|
66 IMPL_EVENT_HANDLER(addtrack) |
|
67 IMPL_EVENT_HANDLER(removetrack) |
|
68 |
|
69 private: |
|
70 nsTArray< nsRefPtr<TextTrack> > mTextTracks; |
|
71 nsRefPtr<TextTrackManager> mTextTrackManager; |
|
72 |
|
73 void CreateAndDispatchTrackEventRunner(TextTrack* aTrack, |
|
74 const nsAString& aEventName); |
|
75 }; |
|
76 |
|
77 } // namespace dom |
|
78 } // namespace mozilla |
|
79 |
|
80 #endif // mozilla_dom_TextTrackList_h |