Backout a74bd5095902, Bug 959405 - Please update the Buri Moz-central, 1.3, 1.2 with...
[gecko.git] / content / media / TextTrackCueList.h
blob645c596064895906d31a1be7df7022673b9e4526
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_TextTrackCueList_h
8 #define mozilla_dom_TextTrackCueList_h
10 #include "nsTArray.h"
11 #include "nsCOMPtr.h"
12 #include "nsCycleCollectionParticipant.h"
13 #include "nsWrapperCache.h"
14 #include "mozilla/ErrorResult.h"
16 namespace mozilla {
17 namespace dom {
19 class TextTrackCue;
21 class TextTrackCueList MOZ_FINAL : public nsISupports
22 , public nsWrapperCache
24 public:
25 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
26 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(TextTrackCueList)
28 // TextTrackCueList WebIDL
29 TextTrackCueList(nsISupports* aParent);
31 virtual JSObject* WrapObject(JSContext* aCx,
32 JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
34 nsISupports* GetParentObject() const
36 return mParent;
39 uint32_t Length() const
41 return mList.Length();
44 // Time is in seconds.
45 void Update(double aTime);
47 TextTrackCue* IndexedGetter(uint32_t aIndex, bool& aFound);
48 TextTrackCue* operator[](uint32_t aIndex);
49 TextTrackCue* GetCueById(const nsAString& aId);
51 // Adds a cue to mList by performing an insertion sort on mList.
52 // We expect most files to already be sorted, so an insertion sort starting
53 // from the end of the current array should be more efficient than a general
54 // sort step after all cues are loaded.
55 void AddCue(TextTrackCue& aCue);
56 void RemoveCue(TextTrackCue& aCue, ErrorResult& aRv);
57 void RemoveCueAt(uint32_t aIndex);
58 void RemoveAll();
60 private:
61 nsCOMPtr<nsISupports> mParent;
63 // A sorted list of TextTrackCues sorted by earliest start time. If the start
64 // times are equal then it will be sorted by end time, earliest first.
65 nsTArray< nsRefPtr<TextTrackCue> > mList;
68 } // namespace dom
69 } // namespace mozilla
71 #endif // mozilla_dom_TextTrackCueList_h