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

     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
    23 {
    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) MOZ_OVERRIDE;
    33   nsISupports* GetParentObject() const
    34   {
    35     return mParent;
    36   }
    38   uint32_t Length() const
    39   {
    40     return mList.Length();
    41   }
    43   TextTrackCue* IndexedGetter(uint32_t aIndex, bool& aFound);
    44   TextTrackCue* operator[](uint32_t aIndex);
    45   TextTrackCue* GetCueById(const nsAString& aId);
    47   // Adds a cue to mList by performing an insertion sort on mList.
    48   // We expect most files to already be sorted, so an insertion sort starting
    49   // from the end of the current array should be more efficient than a general
    50   // sort step after all cues are loaded.
    51   void AddCue(TextTrackCue& aCue);
    52   void RemoveCue(TextTrackCue& aCue, ErrorResult& aRv);
    53   void RemoveCueAt(uint32_t aIndex);
    54   void RemoveAll();
    55   void GetArray(nsTArray<nsRefPtr<TextTrackCue> >& aCues);
    57 private:
    58   nsCOMPtr<nsISupports> mParent;
    60   // A sorted list of TextTrackCues sorted by earliest start time. If the start
    61   // times are equal then it will be sorted by end time, earliest first.
    62   nsTArray< nsRefPtr<TextTrackCue> > mList;
    63 };
    65 } // namespace dom
    66 } // namespace mozilla
    68 #endif // mozilla_dom_TextTrackCueList_h

mercurial