2013-05-21 20:14:00 +04: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-06 00:25:17 +04:00
|
|
|
#include "nsTArray.h"
|
2013-05-21 20:14:00 +04:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsCycleCollectionParticipant.h"
|
|
|
|
#include "nsWrapperCache.h"
|
2013-06-28 21:31:43 +04:00
|
|
|
#include "mozilla/ErrorResult.h"
|
2013-05-21 20:14:00 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
class TextTrackCue;
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class TextTrackCueList final : public nsISupports, public nsWrapperCache {
|
2013-05-21 20:14:00 +04:00
|
|
|
public:
|
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(TextTrackCueList)
|
|
|
|
|
|
|
|
// TextTrackCueList WebIDL
|
2014-09-01 07:50:23 +04:00
|
|
|
explicit TextTrackCueList(nsISupports* aParent);
|
2013-05-21 20:14:00 +04:00
|
|
|
|
2016-01-18 06:50:29 +03:00
|
|
|
JSObject* WrapObject(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) override;
|
2013-05-21 20:14:00 +04:00
|
|
|
|
|
|
|
nsISupports* GetParentObject() const { return mParent; }
|
|
|
|
|
|
|
|
uint32_t Length() const { return mList.Length(); }
|
|
|
|
|
2016-07-11 05:51:08 +03:00
|
|
|
bool IsEmpty() const { return mList.Length() == 0; }
|
|
|
|
|
2013-05-21 20:14:00 +04:00
|
|
|
TextTrackCue* IndexedGetter(uint32_t aIndex, bool& aFound);
|
2013-06-15 00:10:36 +04:00
|
|
|
TextTrackCue* operator[](uint32_t aIndex);
|
2013-05-21 20:14:00 +04:00
|
|
|
TextTrackCue* GetCueById(const nsAString& aId);
|
2016-06-01 08:35:56 +03:00
|
|
|
TextTrackCueList& operator=(const TextTrackCueList& aOther);
|
2013-06-18 21:52:10 +04: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 23:08:17 +04:00
|
|
|
void AddCue(TextTrackCue& aCue);
|
2016-06-01 10:13:43 +03:00
|
|
|
void RemoveCue(TextTrackCue& aCue);
|
2013-06-14 23:08:17 +04:00
|
|
|
void RemoveCue(TextTrackCue& aCue, ErrorResult& aRv);
|
2013-06-15 00:10:36 +04:00
|
|
|
void RemoveCueAt(uint32_t aIndex);
|
|
|
|
void RemoveAll();
|
2015-10-18 08:24:48 +03:00
|
|
|
void GetArray(nsTArray<RefPtr<TextTrackCue>>& aCues);
|
2013-05-21 20:14:00 +04:00
|
|
|
|
2016-06-01 08:35:53 +03:00
|
|
|
void SetCuesInactive();
|
|
|
|
|
2016-06-08 11:53:30 +03:00
|
|
|
void NotifyCueUpdated(TextTrackCue* aCue);
|
2016-06-17 12:20:24 +03:00
|
|
|
bool IsCueExist(TextTrackCue* aCue);
|
2017-06-13 04:52:27 +03:00
|
|
|
nsTArray<RefPtr<TextTrackCue>>& GetCuesArray();
|
2016-06-01 08:35:54 +03:00
|
|
|
|
2013-05-21 20:14:00 +04:00
|
|
|
private:
|
2014-06-24 20:36:43 +04:00
|
|
|
~TextTrackCueList();
|
|
|
|
|
2013-05-21 20:14:00 +04:00
|
|
|
nsCOMPtr<nsISupports> mParent;
|
|
|
|
|
2013-06-18 21:52:10 +04: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.
|
2015-10-18 08:24:48 +03:00
|
|
|
nsTArray<RefPtr<TextTrackCue>> mList;
|
2013-05-21 20:14:00 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_TextTrackCueList_h
|