tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

TextTrackList.h (2540B)


      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::dom {
     15 
     16 class Event;
     17 class HTMLMediaElement;
     18 class TextTrackManager;
     19 class CompareTextTracks;
     20 class TrackEvent;
     21 class TrackEventRunner;
     22 
     23 class TextTrackList final : public DOMEventTargetHelper {
     24 public:
     25  NS_DECL_ISUPPORTS_INHERITED
     26  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(TextTrackList, DOMEventTargetHelper)
     27 
     28  explicit TextTrackList(nsPIDOMWindowInner* aOwnerWindow);
     29  TextTrackList(nsPIDOMWindowInner* aOwnerWindow,
     30                TextTrackManager* aTextTrackManager);
     31 
     32  JSObject* WrapObject(JSContext* aCx,
     33                       JS::Handle<JSObject*> aGivenProto) override;
     34 
     35  uint32_t Length() const { return mTextTracks.Length(); }
     36 
     37  // Get all the current active cues.
     38  void GetShowingCues(nsTArray<RefPtr<TextTrackCue>>& aCues);
     39 
     40  TextTrack* IndexedGetter(uint32_t aIndex, bool& aFound);
     41  TextTrack* operator[](uint32_t aIndex);
     42 
     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);
     48 
     49  void AddTextTrack(TextTrack* aTextTrack, const CompareTextTracks& aCompareTT);
     50 
     51  void RemoveTextTrack(TextTrack* aTrack);
     52 
     53  HTMLMediaElement* GetMediaElement();
     54  void SetTextTrackManager(TextTrackManager* aTextTrackManager);
     55 
     56  nsresult DispatchTrackEvent(Event* aEvent);
     57  void CreateAndDispatchChangeEvent();
     58  void SetCuesInactive();
     59 
     60  bool AreTextTracksLoaded();
     61  nsTArray<RefPtr<TextTrack>>& GetTextTrackArray();
     62 
     63  IMPL_EVENT_HANDLER(change)
     64  IMPL_EVENT_HANDLER(addtrack)
     65  IMPL_EVENT_HANDLER(removetrack)
     66 
     67 private:
     68  ~TextTrackList();
     69 
     70  nsTArray<RefPtr<TextTrack>> mTextTracks;
     71  RefPtr<TextTrackManager> mTextTrackManager;
     72 
     73  void CreateAndDispatchTrackEventRunner(TextTrack* aTrack,
     74                                         const nsAString& aEventName);
     75 };
     76 
     77 }  // namespace mozilla::dom
     78 
     79 #endif  // mozilla_dom_TextTrackList_h