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_TextTrack_h
|
|
|
|
#define mozilla_dom_TextTrack_h
|
|
|
|
|
2014-04-01 10:13:50 +04:00
|
|
|
#include "mozilla/DOMEventTargetHelper.h"
|
2013-05-21 20:14:00 +04:00
|
|
|
#include "mozilla/dom/TextTrackBinding.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsCycleCollectionParticipant.h"
|
|
|
|
#include "nsString.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2014-01-27 22:10:06 +04:00
|
|
|
class TextTrackList;
|
2013-05-21 20:14:00 +04:00
|
|
|
class TextTrackCue;
|
|
|
|
class TextTrackCueList;
|
2014-02-27 23:07:39 +04:00
|
|
|
class HTMLTrackElement;
|
2013-05-21 20:14:00 +04:00
|
|
|
|
2014-02-27 21:47:23 +04:00
|
|
|
enum TextTrackSource {
|
|
|
|
Track,
|
|
|
|
AddTextTrack,
|
|
|
|
MediaResourceSpecific
|
|
|
|
};
|
|
|
|
|
2014-03-13 22:29:32 +04:00
|
|
|
// Constants for numeric readyState property values.
|
|
|
|
enum TextTrackReadyState {
|
|
|
|
NotLoaded = 0U,
|
|
|
|
Loading = 1U,
|
|
|
|
Loaded = 2U,
|
|
|
|
FailedToLoad = 3U
|
|
|
|
};
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class TextTrack final : public DOMEventTargetHelper
|
2013-05-21 20:14:00 +04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2014-04-01 10:13:50 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(TextTrack, DOMEventTargetHelper)
|
2013-05-21 20:14:00 +04:00
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
TextTrack(nsPIDOMWindowInner* aOwnerWindow,
|
2014-01-28 00:17:20 +04:00
|
|
|
TextTrackKind aKind,
|
|
|
|
const nsAString& aLabel,
|
2014-02-27 21:47:23 +04:00
|
|
|
const nsAString& aLanguage,
|
2014-03-13 21:18:06 +04:00
|
|
|
TextTrackMode aMode,
|
2014-03-13 22:41:21 +04:00
|
|
|
TextTrackReadyState aReadyState,
|
2014-02-27 21:47:23 +04:00
|
|
|
TextTrackSource aTextTrackSource);
|
2016-01-30 20:05:36 +03:00
|
|
|
TextTrack(nsPIDOMWindowInner* aOwnerWindow,
|
2014-01-28 00:17:20 +04:00
|
|
|
TextTrackList* aTextTrackList,
|
2013-05-21 20:14:00 +04:00
|
|
|
TextTrackKind aKind,
|
|
|
|
const nsAString& aLabel,
|
2014-02-27 21:47:23 +04:00
|
|
|
const nsAString& aLanguage,
|
2014-03-13 21:18:06 +04:00
|
|
|
TextTrackMode aMode,
|
2014-03-13 22:41:21 +04:00
|
|
|
TextTrackReadyState aReadyState,
|
2014-02-27 21:47:23 +04:00
|
|
|
TextTrackSource aTextTrackSource);
|
2013-05-21 20:14:00 +04:00
|
|
|
|
2013-06-15 00:10:36 +04:00
|
|
|
void SetDefaultSettings();
|
|
|
|
|
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
|
|
|
|
|
|
|
TextTrackKind Kind() const
|
|
|
|
{
|
|
|
|
return mKind;
|
|
|
|
}
|
2016-06-30 08:36:31 +03:00
|
|
|
void GetLabel(nsAString& aLabel) const;
|
|
|
|
void GetLanguage(nsAString& aLanguage) const;
|
2013-05-21 20:14:00 +04:00
|
|
|
void GetInBandMetadataTrackDispatchType(nsAString& aType) const
|
|
|
|
{
|
|
|
|
aType = mType;
|
|
|
|
}
|
2014-03-19 19:27:39 +04:00
|
|
|
void GetId(nsAString& aId) const;
|
2013-05-21 20:14:00 +04:00
|
|
|
|
|
|
|
TextTrackMode Mode() const
|
|
|
|
{
|
|
|
|
return mMode;
|
|
|
|
}
|
|
|
|
void SetMode(TextTrackMode aValue);
|
|
|
|
|
|
|
|
TextTrackCueList* GetCues() const
|
|
|
|
{
|
|
|
|
if (mMode == TextTrackMode::Disabled) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return mCueList;
|
|
|
|
}
|
|
|
|
|
2013-06-15 00:10:36 +04:00
|
|
|
TextTrackCueList* GetActiveCues();
|
2014-02-27 19:02:40 +04:00
|
|
|
void UpdateActiveCueList();
|
2015-10-18 08:24:48 +03:00
|
|
|
void GetActiveCueArray(nsTArray<RefPtr<TextTrackCue> >& aCues);
|
2013-05-21 20:14:00 +04:00
|
|
|
|
2014-03-13 22:29:32 +04:00
|
|
|
TextTrackReadyState ReadyState() const;
|
|
|
|
void SetReadyState(TextTrackReadyState aState);
|
2014-03-14 20:13:41 +04:00
|
|
|
void SetReadyState(uint32_t aReadyState);
|
2013-10-25 08:14:36 +04:00
|
|
|
|
2013-05-21 20:14:00 +04:00
|
|
|
void AddCue(TextTrackCue& aCue);
|
2013-06-28 21:31:43 +04:00
|
|
|
void RemoveCue(TextTrackCue& aCue, ErrorResult& aRv);
|
2013-06-15 00:10:36 +04:00
|
|
|
void SetDirty() { mDirty = true; }
|
2014-04-07 23:42:33 +04:00
|
|
|
void SetCuesDirty();
|
2013-05-21 20:14:00 +04:00
|
|
|
|
2014-01-27 22:10:06 +04:00
|
|
|
TextTrackList* GetTextTrackList();
|
|
|
|
void SetTextTrackList(TextTrackList* aTextTrackList);
|
|
|
|
|
2013-05-21 20:14:00 +04:00
|
|
|
IMPL_EVENT_HANDLER(cuechange)
|
|
|
|
|
2014-02-27 23:07:39 +04:00
|
|
|
HTMLTrackElement* GetTrackElement();
|
|
|
|
void SetTrackElement(HTMLTrackElement* aTrackElement);
|
|
|
|
|
2014-02-27 21:47:23 +04:00
|
|
|
TextTrackSource GetTextTrackSource() {
|
|
|
|
return mTextTrackSource;
|
|
|
|
}
|
|
|
|
|
2016-06-01 08:35:53 +03:00
|
|
|
void SetCuesInactive();
|
|
|
|
|
2016-06-08 11:53:30 +03:00
|
|
|
void NotifyCueUpdated(TextTrackCue *aCue);
|
|
|
|
|
2016-07-12 12:41:41 +03:00
|
|
|
void DispatchAsyncTrustedEvent(const nsString& aEventName);
|
|
|
|
|
2017-02-20 10:27:06 +03:00
|
|
|
bool IsLoaded();
|
|
|
|
|
2013-05-21 20:14:00 +04:00
|
|
|
private:
|
2014-07-09 01:23:16 +04:00
|
|
|
~TextTrack();
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<TextTrackList> mTextTrackList;
|
2013-05-21 20:14:00 +04:00
|
|
|
|
|
|
|
TextTrackKind mKind;
|
|
|
|
nsString mLabel;
|
|
|
|
nsString mLanguage;
|
|
|
|
nsString mType;
|
|
|
|
TextTrackMode mMode;
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<TextTrackCueList> mCueList;
|
|
|
|
RefPtr<TextTrackCueList> mActiveCueList;
|
|
|
|
RefPtr<HTMLTrackElement> mTrackElement;
|
2013-06-15 00:10:36 +04:00
|
|
|
|
|
|
|
uint32_t mCuePos;
|
2014-03-13 22:29:32 +04:00
|
|
|
TextTrackReadyState mReadyState;
|
2013-06-15 00:10:36 +04:00
|
|
|
bool mDirty;
|
2014-02-27 21:47:23 +04:00
|
|
|
|
|
|
|
// An enum that represents where the track was sourced from.
|
|
|
|
TextTrackSource mTextTrackSource;
|
2013-05-21 20:14:00 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_TextTrack_h
|