content/media/TextTrackCueList.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/media/TextTrackCueList.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,68 @@
     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_TextTrackCueList_h
    1.11 +#define mozilla_dom_TextTrackCueList_h
    1.12 +
    1.13 +#include "nsTArray.h"
    1.14 +#include "nsCOMPtr.h"
    1.15 +#include "nsCycleCollectionParticipant.h"
    1.16 +#include "nsWrapperCache.h"
    1.17 +#include "mozilla/ErrorResult.h"
    1.18 +
    1.19 +namespace mozilla {
    1.20 +namespace dom {
    1.21 +
    1.22 +class TextTrackCue;
    1.23 +
    1.24 +class TextTrackCueList MOZ_FINAL : public nsISupports
    1.25 +                                 , public nsWrapperCache
    1.26 +{
    1.27 +public:
    1.28 +  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
    1.29 +  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(TextTrackCueList)
    1.30 +
    1.31 +  // TextTrackCueList WebIDL
    1.32 +  TextTrackCueList(nsISupports* aParent);
    1.33 +
    1.34 +  virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
    1.35 +
    1.36 +  nsISupports* GetParentObject() const
    1.37 +  {
    1.38 +    return mParent;
    1.39 +  }
    1.40 +
    1.41 +  uint32_t Length() const
    1.42 +  {
    1.43 +    return mList.Length();
    1.44 +  }
    1.45 +
    1.46 +  TextTrackCue* IndexedGetter(uint32_t aIndex, bool& aFound);
    1.47 +  TextTrackCue* operator[](uint32_t aIndex);
    1.48 +  TextTrackCue* GetCueById(const nsAString& aId);
    1.49 +
    1.50 +  // Adds a cue to mList by performing an insertion sort on mList.
    1.51 +  // We expect most files to already be sorted, so an insertion sort starting
    1.52 +  // from the end of the current array should be more efficient than a general
    1.53 +  // sort step after all cues are loaded.
    1.54 +  void AddCue(TextTrackCue& aCue);
    1.55 +  void RemoveCue(TextTrackCue& aCue, ErrorResult& aRv);
    1.56 +  void RemoveCueAt(uint32_t aIndex);
    1.57 +  void RemoveAll();
    1.58 +  void GetArray(nsTArray<nsRefPtr<TextTrackCue> >& aCues);
    1.59 +
    1.60 +private:
    1.61 +  nsCOMPtr<nsISupports> mParent;
    1.62 +
    1.63 +  // A sorted list of TextTrackCues sorted by earliest start time. If the start
    1.64 +  // times are equal then it will be sorted by end time, earliest first.
    1.65 +  nsTArray< nsRefPtr<TextTrackCue> > mList;
    1.66 +};
    1.67 +
    1.68 +} // namespace dom
    1.69 +} // namespace mozilla
    1.70 +
    1.71 +#endif // mozilla_dom_TextTrackCueList_h

mercurial