content/media/TextTrackCueList.h

Fri, 16 Jan 2015 04:50:19 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 04:50:19 +0100
branch
TOR_BUG_9701
changeset 13
44a2da4a2ab2
permissions
-rw-r--r--

Replace accessor implementation with direct member state manipulation, by
request https://trac.torproject.org/projects/tor/ticket/9701#comment:32

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* vim:set ts=2 sw=2 et tw=78: */
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #ifndef mozilla_dom_TextTrackCueList_h
michael@0 8 #define mozilla_dom_TextTrackCueList_h
michael@0 9
michael@0 10 #include "nsTArray.h"
michael@0 11 #include "nsCOMPtr.h"
michael@0 12 #include "nsCycleCollectionParticipant.h"
michael@0 13 #include "nsWrapperCache.h"
michael@0 14 #include "mozilla/ErrorResult.h"
michael@0 15
michael@0 16 namespace mozilla {
michael@0 17 namespace dom {
michael@0 18
michael@0 19 class TextTrackCue;
michael@0 20
michael@0 21 class TextTrackCueList MOZ_FINAL : public nsISupports
michael@0 22 , public nsWrapperCache
michael@0 23 {
michael@0 24 public:
michael@0 25 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
michael@0 26 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(TextTrackCueList)
michael@0 27
michael@0 28 // TextTrackCueList WebIDL
michael@0 29 TextTrackCueList(nsISupports* aParent);
michael@0 30
michael@0 31 virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
michael@0 32
michael@0 33 nsISupports* GetParentObject() const
michael@0 34 {
michael@0 35 return mParent;
michael@0 36 }
michael@0 37
michael@0 38 uint32_t Length() const
michael@0 39 {
michael@0 40 return mList.Length();
michael@0 41 }
michael@0 42
michael@0 43 TextTrackCue* IndexedGetter(uint32_t aIndex, bool& aFound);
michael@0 44 TextTrackCue* operator[](uint32_t aIndex);
michael@0 45 TextTrackCue* GetCueById(const nsAString& aId);
michael@0 46
michael@0 47 // Adds a cue to mList by performing an insertion sort on mList.
michael@0 48 // We expect most files to already be sorted, so an insertion sort starting
michael@0 49 // from the end of the current array should be more efficient than a general
michael@0 50 // sort step after all cues are loaded.
michael@0 51 void AddCue(TextTrackCue& aCue);
michael@0 52 void RemoveCue(TextTrackCue& aCue, ErrorResult& aRv);
michael@0 53 void RemoveCueAt(uint32_t aIndex);
michael@0 54 void RemoveAll();
michael@0 55 void GetArray(nsTArray<nsRefPtr<TextTrackCue> >& aCues);
michael@0 56
michael@0 57 private:
michael@0 58 nsCOMPtr<nsISupports> mParent;
michael@0 59
michael@0 60 // A sorted list of TextTrackCues sorted by earliest start time. If the start
michael@0 61 // times are equal then it will be sorted by end time, earliest first.
michael@0 62 nsTArray< nsRefPtr<TextTrackCue> > mList;
michael@0 63 };
michael@0 64
michael@0 65 } // namespace dom
michael@0 66 } // namespace mozilla
michael@0 67
michael@0 68 #endif // mozilla_dom_TextTrackCueList_h

mercurial