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/. */
|
|
|
|
|
|
|
|
#include "mozilla/dom/TextTrack.h"
|
|
|
|
#include "mozilla/dom/TextTrackBinding.h"
|
2013-09-06 00:25:17 +04:00
|
|
|
#include "mozilla/dom/TextTrackCueList.h"
|
2013-09-14 03:44:33 +04:00
|
|
|
#include "mozilla/dom/TextTrackRegion.h"
|
|
|
|
#include "mozilla/dom/TextTrackRegionList.h"
|
2013-05-21 20:14:00 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2013-09-14 03:44:33 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_INHERITED_4(TextTrack,
|
2013-08-15 19:11:15 +04:00
|
|
|
nsDOMEventTargetHelper,
|
|
|
|
mParent,
|
|
|
|
mCueList,
|
2013-09-14 03:44:33 +04:00
|
|
|
mActiveCueList,
|
|
|
|
mRegionList)
|
2013-05-21 20:14:00 +04:00
|
|
|
|
|
|
|
NS_IMPL_ADDREF_INHERITED(TextTrack, nsDOMEventTargetHelper)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(TextTrack, nsDOMEventTargetHelper)
|
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(TextTrack)
|
|
|
|
NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetHelper)
|
|
|
|
|
|
|
|
TextTrack::TextTrack(nsISupports* aParent,
|
|
|
|
TextTrackKind aKind,
|
|
|
|
const nsAString& aLabel,
|
|
|
|
const nsAString& aLanguage)
|
|
|
|
: mParent(aParent)
|
|
|
|
, mKind(aKind)
|
|
|
|
, mLabel(aLabel)
|
|
|
|
, mLanguage(aLanguage)
|
|
|
|
, mMode(TextTrackMode::Hidden)
|
|
|
|
, mCueList(new TextTrackCueList(aParent))
|
|
|
|
, mActiveCueList(new TextTrackCueList(aParent))
|
2013-09-14 03:44:33 +04:00
|
|
|
, mRegionList(new TextTrackRegionList(aParent))
|
2013-05-21 20:14:00 +04:00
|
|
|
{
|
|
|
|
SetIsDOMBinding();
|
|
|
|
}
|
|
|
|
|
|
|
|
TextTrack::TextTrack(nsISupports* aParent)
|
|
|
|
: mParent(aParent)
|
|
|
|
, mKind(TextTrackKind::Subtitles)
|
|
|
|
, mMode(TextTrackMode::Disabled)
|
|
|
|
, mCueList(new TextTrackCueList(aParent))
|
|
|
|
, mActiveCueList(new TextTrackCueList(aParent))
|
2013-09-14 03:44:33 +04:00
|
|
|
, mRegionList(new TextTrackRegionList(aParent))
|
2013-05-21 20:14:00 +04:00
|
|
|
{
|
|
|
|
SetIsDOMBinding();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-06-10 19:30:00 +04:00
|
|
|
TextTrack::Update(double aTime)
|
2013-05-21 20:14:00 +04:00
|
|
|
{
|
2013-06-10 19:30:00 +04:00
|
|
|
mCueList->Update(aTime);
|
2013-05-21 20:14:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
JSObject*
|
|
|
|
TextTrack::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
|
|
|
|
{
|
|
|
|
return TextTrackBinding::Wrap(aCx, aScope, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TextTrack::SetMode(TextTrackMode aValue)
|
|
|
|
{
|
|
|
|
mMode = aValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TextTrack::AddCue(TextTrackCue& aCue)
|
|
|
|
{
|
|
|
|
//XXX: If cue exists, remove. Bug 867823.
|
|
|
|
mCueList->AddCue(aCue);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TextTrack::RemoveCue(TextTrackCue& aCue)
|
|
|
|
{
|
|
|
|
//XXX: If cue does not exists throw NotFoundError. Bug 867823.
|
|
|
|
mCueList->RemoveCue(aCue);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TextTrack::CueChanged(TextTrackCue& aCue)
|
|
|
|
{
|
|
|
|
//XXX: Implement Cue changed. Bug 867823.
|
|
|
|
}
|
|
|
|
|
2013-09-14 03:44:33 +04:00
|
|
|
void
|
|
|
|
TextTrack::AddRegion(TextTrackRegion& aRegion)
|
|
|
|
{
|
|
|
|
TextTrackRegion* region = mRegionList->GetRegionById(aRegion.Id());
|
|
|
|
if (!region) {
|
|
|
|
mRegionList->AddTextTrackRegion(&aRegion);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
region->CopyValues(aRegion);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TextTrack::RemoveRegion(const TextTrackRegion& aRegion, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
if (!mRegionList->GetRegionById(aRegion.Id())) {
|
|
|
|
aRv.Throw(NS_ERROR_DOM_NOT_FOUND_ERR);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mRegionList->RemoveTextTrackRegion(aRegion);
|
|
|
|
}
|
|
|
|
|
2013-05-21 20:14:00 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|