1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/media/TextTrackList.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,80 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* vim:set ts=2 sw=2 et tw=78: */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#ifndef mozilla_dom_TextTrackList_h 1.11 +#define mozilla_dom_TextTrackList_h 1.12 + 1.13 +#include "mozilla/DOMEventTargetHelper.h" 1.14 +#include "mozilla/dom/TextTrack.h" 1.15 +#include "nsCycleCollectionParticipant.h" 1.16 + 1.17 +namespace mozilla { 1.18 +namespace dom { 1.19 + 1.20 +class HTMLMediaElement; 1.21 +class TextTrackManager; 1.22 +class CompareTextTracks; 1.23 +class TrackEvent; 1.24 +class TrackEventRunner; 1.25 + 1.26 +class TextTrackList MOZ_FINAL : public DOMEventTargetHelper 1.27 +{ 1.28 +public: 1.29 + NS_DECL_ISUPPORTS_INHERITED 1.30 + NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(TextTrackList, DOMEventTargetHelper) 1.31 + 1.32 + TextTrackList(nsPIDOMWindow* aOwnerWindow); 1.33 + TextTrackList(nsPIDOMWindow* aOwnerWindow, TextTrackManager* aTextTrackManager); 1.34 + 1.35 + virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE; 1.36 + 1.37 + uint32_t Length() const 1.38 + { 1.39 + return mTextTracks.Length(); 1.40 + } 1.41 + 1.42 + // Get all the current active cues. 1.43 + void UpdateAndGetShowingCues(nsTArray<nsRefPtr<TextTrackCue> >& aCues); 1.44 + 1.45 + TextTrack* IndexedGetter(uint32_t aIndex, bool& aFound); 1.46 + TextTrack* operator[](uint32_t aIndex); 1.47 + 1.48 + already_AddRefed<TextTrack> AddTextTrack(TextTrackKind aKind, 1.49 + const nsAString& aLabel, 1.50 + const nsAString& aLanguage, 1.51 + TextTrackMode aMode, 1.52 + TextTrackReadyState aReadyState, 1.53 + TextTrackSource aTextTrackSource, 1.54 + const CompareTextTracks& aCompareTT); 1.55 + TextTrack* GetTrackById(const nsAString& aId); 1.56 + 1.57 + void AddTextTrack(TextTrack* aTextTrack, const CompareTextTracks& aCompareTT); 1.58 + 1.59 + void RemoveTextTrack(TextTrack* aTrack); 1.60 + void DidSeek(); 1.61 + 1.62 + HTMLMediaElement* GetMediaElement(); 1.63 + void SetTextTrackManager(TextTrackManager* aTextTrackManager); 1.64 + 1.65 + nsresult DispatchTrackEvent(nsIDOMEvent* aEvent); 1.66 + void CreateAndDispatchChangeEvent(); 1.67 + 1.68 + IMPL_EVENT_HANDLER(change) 1.69 + IMPL_EVENT_HANDLER(addtrack) 1.70 + IMPL_EVENT_HANDLER(removetrack) 1.71 + 1.72 +private: 1.73 + nsTArray< nsRefPtr<TextTrack> > mTextTracks; 1.74 + nsRefPtr<TextTrackManager> mTextTrackManager; 1.75 + 1.76 + void CreateAndDispatchTrackEventRunner(TextTrack* aTrack, 1.77 + const nsAString& aEventName); 1.78 +}; 1.79 + 1.80 +} // namespace dom 1.81 +} // namespace mozilla 1.82 + 1.83 +#endif // mozilla_dom_TextTrackList_h