2013-05-21 09:14:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim:set ts=2 sw=2 et tw=78: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_TextTrackCueList_h
|
|
|
|
#define mozilla_dom_TextTrackCueList_h
|
|
|
|
|
2013-09-05 13:25:17 -07:00
|
|
|
#include "nsTArray.h"
|
2013-05-21 09:14:00 -07:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsCycleCollectionParticipant.h"
|
|
|
|
#include "nsWrapperCache.h"
|
2013-06-28 10:31:43 -07:00
|
|
|
#include "mozilla/ErrorResult.h"
|
2013-05-21 09:14:00 -07:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
class TextTrackCue;
|
|
|
|
|
|
|
|
class TextTrackCueList MOZ_FINAL : public nsISupports
|
|
|
|
, public nsWrapperCache
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(TextTrackCueList)
|
|
|
|
|
|
|
|
// TextTrackCueList WebIDL
|
2014-08-31 20:50:23 -07:00
|
|
|
explicit TextTrackCueList(nsISupports* aParent);
|
2013-05-21 09:14:00 -07:00
|
|
|
|
2014-04-08 15:27:18 -07:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
|
2013-05-21 09:14:00 -07:00
|
|
|
|
|
|
|
nsISupports* GetParentObject() const
|
|
|
|
{
|
|
|
|
return mParent;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t Length() const
|
|
|
|
{
|
|
|
|
return mList.Length();
|
|
|
|
}
|
|
|
|
|
|
|
|
TextTrackCue* IndexedGetter(uint32_t aIndex, bool& aFound);
|
2013-06-14 13:10:36 -07:00
|
|
|
TextTrackCue* operator[](uint32_t aIndex);
|
2013-05-21 09:14:00 -07:00
|
|
|
TextTrackCue* GetCueById(const nsAString& aId);
|
|
|
|
|
2013-06-18 10:52:10 -07:00
|
|
|
// Adds a cue to mList by performing an insertion sort on mList.
|
|
|
|
// We expect most files to already be sorted, so an insertion sort starting
|
|
|
|
// from the end of the current array should be more efficient than a general
|
|
|
|
// sort step after all cues are loaded.
|
2013-06-14 12:08:17 -07:00
|
|
|
void AddCue(TextTrackCue& aCue);
|
|
|
|
void RemoveCue(TextTrackCue& aCue, ErrorResult& aRv);
|
2013-06-14 13:10:36 -07:00
|
|
|
void RemoveCueAt(uint32_t aIndex);
|
|
|
|
void RemoveAll();
|
2013-12-12 07:57:21 -08:00
|
|
|
void GetArray(nsTArray<nsRefPtr<TextTrackCue> >& aCues);
|
2013-05-21 09:14:00 -07:00
|
|
|
|
|
|
|
private:
|
2014-06-24 09:36:43 -07:00
|
|
|
~TextTrackCueList();
|
|
|
|
|
2013-05-21 09:14:00 -07:00
|
|
|
nsCOMPtr<nsISupports> mParent;
|
|
|
|
|
2013-06-18 10:52:10 -07:00
|
|
|
// A sorted list of TextTrackCues sorted by earliest start time. If the start
|
|
|
|
// times are equal then it will be sorted by end time, earliest first.
|
2013-05-21 09:14:00 -07:00
|
|
|
nsTArray< nsRefPtr<TextTrackCue> > mList;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_TextTrackCueList_h
|