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/dom/TextTrack.h"
11 #include "nsCycleCollectionParticipant.h"
12 #include "nsDOMEventTargetHelper.h"
18 class TrackEventRunner
;
20 class TextTrackList MOZ_FINAL
: public nsDOMEventTargetHelper
23 NS_DECL_ISUPPORTS_INHERITED
24 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(TextTrackList
, nsDOMEventTargetHelper
)
26 TextTrackList(nsISupports
* aGlobal
);
28 virtual JSObject
* WrapObject(JSContext
* aCx
,
29 JS::Handle
<JSObject
*> aScope
) MOZ_OVERRIDE
;
31 nsISupports
* GetParentObject() const
36 uint32_t Length() const
38 return mTextTracks
.Length();
41 // Time is in seconds.
42 void Update(double aTime
);
44 TextTrack
* IndexedGetter(uint32_t aIndex
, bool& aFound
);
46 already_AddRefed
<TextTrack
> AddTextTrack(HTMLMediaElement
* aMediaElement
,
48 const nsAString
& aLabel
,
49 const nsAString
& aLanguage
);
50 TextTrack
* GetTrackById(const nsAString
& aId
);
52 void AddTextTrack(TextTrack
* aTextTrack
) {
53 mTextTracks
.AppendElement(aTextTrack
);
56 void RemoveTextTrack(TextTrack
* aTrack
);
59 nsresult
DispatchTrackEvent(TrackEvent
* aEvent
);
61 IMPL_EVENT_HANDLER(addtrack
)
62 IMPL_EVENT_HANDLER(removetrack
)
65 nsCOMPtr
<nsISupports
> mGlobal
;
66 nsTArray
< nsRefPtr
<TextTrack
> > mTextTracks
;
68 void CreateAndDispatchTrackEventRunner(TextTrack
* aTrack
,
69 const nsAString
& aEventName
);
73 } // namespace mozilla
75 #endif // mozilla_dom_TextTrackList_h