2015-05-03 12:32:37 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2013-05-21 09:14:00 -07:00
|
|
|
/* 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/Element.h"
|
|
|
|
#include "mozilla/dom/HTMLMediaElement.h"
|
|
|
|
#include "mozilla/dom/HTMLTrackElement.h"
|
|
|
|
#include "mozilla/dom/HTMLTrackElementBinding.h"
|
|
|
|
#include "mozilla/dom/HTMLUnknownElement.h"
|
2014-09-21 09:36:25 -07:00
|
|
|
#include "nsIContentPolicy.h"
|
|
|
|
#include "mozilla/LoadInfo.h"
|
2013-09-19 08:26:00 -07:00
|
|
|
#include "WebVTTListener.h"
|
2013-05-21 09:14:00 -07:00
|
|
|
#include "nsAttrValueInlines.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsContentPolicyUtils.h"
|
|
|
|
#include "nsContentUtils.h"
|
|
|
|
#include "nsCycleCollectionParticipant.h"
|
|
|
|
#include "nsGenericHTMLElement.h"
|
|
|
|
#include "nsGkAtoms.h"
|
|
|
|
#include "nsIAsyncVerifyRedirectCallback.h"
|
|
|
|
#include "nsICachingChannel.h"
|
|
|
|
#include "nsIChannelEventSink.h"
|
|
|
|
#include "nsIContentPolicy.h"
|
|
|
|
#include "nsIContentSecurityPolicy.h"
|
|
|
|
#include "nsIDocument.h"
|
|
|
|
#include "nsIDOMEventTarget.h"
|
|
|
|
#include "nsIDOMHTMLMediaElement.h"
|
|
|
|
#include "nsIHttpChannel.h"
|
|
|
|
#include "nsIInterfaceRequestor.h"
|
|
|
|
#include "nsILoadGroup.h"
|
|
|
|
#include "nsIObserver.h"
|
|
|
|
#include "nsIStreamListener.h"
|
|
|
|
#include "nsISupportsImpl.h"
|
|
|
|
#include "nsMappedAttributes.h"
|
|
|
|
#include "nsNetUtil.h"
|
|
|
|
#include "nsRuleData.h"
|
|
|
|
#include "nsStyleConsts.h"
|
|
|
|
#include "nsThreadUtils.h"
|
|
|
|
#include "nsVideoFrame.h"
|
|
|
|
|
|
|
|
static PRLogModuleInfo* gTrackElementLog;
|
2015-05-21 13:22:04 -07:00
|
|
|
#define LOG(type, msg) MOZ_LOG(gTrackElementLog, type, msg)
|
2013-05-21 09:14:00 -07:00
|
|
|
|
|
|
|
// Replace the usual NS_IMPL_NS_NEW_HTML_ELEMENT(Track) so
|
|
|
|
// we can return an UnknownElement instead when pref'd off.
|
|
|
|
nsGenericHTMLElement*
|
2014-06-19 19:01:40 -07:00
|
|
|
NS_NewHTMLTrackElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
|
2013-05-21 09:14:00 -07:00
|
|
|
mozilla::dom::FromParser aFromParser)
|
|
|
|
{
|
|
|
|
if (!mozilla::dom::HTMLTrackElement::IsWebVTTEnabled()) {
|
2013-06-26 07:59:46 -07:00
|
|
|
return new mozilla::dom::HTMLUnknownElement(aNodeInfo);
|
2013-05-21 09:14:00 -07:00
|
|
|
}
|
|
|
|
|
2013-06-26 07:59:46 -07:00
|
|
|
return new mozilla::dom::HTMLTrackElement(aNodeInfo);
|
2013-05-21 09:14:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2014-02-21 19:06:48 -08:00
|
|
|
// Map html attribute string values to TextTrackKind enums.
|
|
|
|
static MOZ_CONSTEXPR nsAttrValue::EnumTable kKindTable[] = {
|
|
|
|
{ "subtitles", static_cast<int16_t>(TextTrackKind::Subtitles) },
|
|
|
|
{ "captions", static_cast<int16_t>(TextTrackKind::Captions) },
|
|
|
|
{ "descriptions", static_cast<int16_t>(TextTrackKind::Descriptions) },
|
|
|
|
{ "chapters", static_cast<int16_t>(TextTrackKind::Chapters) },
|
|
|
|
{ "metadata", static_cast<int16_t>(TextTrackKind::Metadata) },
|
|
|
|
{ 0 }
|
|
|
|
};
|
|
|
|
|
2013-07-04 11:16:05 -07:00
|
|
|
// The default value for kKindTable is "subtitles"
|
2013-11-22 11:45:50 -08:00
|
|
|
static MOZ_CONSTEXPR const char* kKindTableDefaultString = kKindTable->tag;
|
2013-07-04 11:16:05 -07:00
|
|
|
|
2013-05-21 09:14:00 -07:00
|
|
|
/** HTMLTrackElement */
|
2014-06-19 19:01:40 -07:00
|
|
|
HTMLTrackElement::HTMLTrackElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
|
2013-05-21 09:14:00 -07:00
|
|
|
: nsGenericHTMLElement(aNodeInfo)
|
|
|
|
{
|
|
|
|
if (!gTrackElementLog) {
|
|
|
|
gTrackElementLog = PR_NewLogModule("nsTrackElement");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
HTMLTrackElement::~HTMLTrackElement()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMPL_ELEMENT_CLONE(HTMLTrackElement)
|
|
|
|
|
|
|
|
NS_IMPL_ADDREF_INHERITED(HTMLTrackElement, Element)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(HTMLTrackElement, Element)
|
|
|
|
|
2014-04-25 09:49:00 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_INHERITED(HTMLTrackElement, nsGenericHTMLElement,
|
2014-06-18 13:10:24 -07:00
|
|
|
mTrack, mMediaParent, mListener)
|
2013-05-21 09:14:00 -07:00
|
|
|
|
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(HTMLTrackElement)
|
2013-08-07 13:23:08 -07:00
|
|
|
NS_INTERFACE_MAP_END_INHERITING(nsGenericHTMLElement)
|
2013-05-21 09:14:00 -07:00
|
|
|
|
2013-07-04 11:16:05 -07:00
|
|
|
void
|
|
|
|
HTMLTrackElement::GetKind(DOMString& aKind) const
|
|
|
|
{
|
|
|
|
GetEnumAttr(nsGkAtoms::kind, kKindTableDefaultString, aKind);
|
|
|
|
}
|
|
|
|
|
2013-06-10 08:30:00 -07:00
|
|
|
void
|
|
|
|
HTMLTrackElement::OnChannelRedirect(nsIChannel* aChannel,
|
|
|
|
nsIChannel* aNewChannel,
|
|
|
|
uint32_t aFlags)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aChannel == mChannel, "Channels should match!");
|
|
|
|
mChannel = aNewChannel;
|
|
|
|
}
|
|
|
|
|
2013-05-21 09:14:00 -07:00
|
|
|
JSObject*
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 07:13:33 -07:00
|
|
|
HTMLTrackElement::WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
2013-05-21 09:14:00 -07:00
|
|
|
{
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 07:13:33 -07:00
|
|
|
return HTMLTrackElementBinding::Wrap(aCx, this, aGivenProto);
|
2013-05-21 09:14:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
HTMLTrackElement::IsWebVTTEnabled()
|
|
|
|
{
|
2013-06-12 22:12:26 -07:00
|
|
|
// Our callee does not use its arguments.
|
2015-05-13 14:07:34 -07:00
|
|
|
return HTMLTrackElementBinding::ConstructorEnabled(nullptr, nullptr);
|
2013-05-21 09:14:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
TextTrack*
|
2014-04-07 10:58:38 -07:00
|
|
|
HTMLTrackElement::GetTrack()
|
2013-05-21 09:14:00 -07:00
|
|
|
{
|
|
|
|
if (!mTrack) {
|
2014-01-27 12:17:20 -08:00
|
|
|
CreateTextTrack();
|
2013-05-21 09:14:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return mTrack;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
HTMLTrackElement::CreateTextTrack()
|
|
|
|
{
|
2013-05-23 19:57:00 -07:00
|
|
|
nsString label, srcLang;
|
2013-05-21 09:14:00 -07:00
|
|
|
GetSrclang(srcLang);
|
|
|
|
GetLabel(label);
|
|
|
|
|
2013-07-04 11:16:05 -07:00
|
|
|
TextTrackKind kind;
|
|
|
|
if (const nsAttrValue* value = GetParsedAttr(nsGkAtoms::kind)) {
|
|
|
|
kind = static_cast<TextTrackKind>(value->GetEnumValue());
|
|
|
|
} else {
|
|
|
|
kind = TextTrackKind::Subtitles;
|
2013-05-21 09:14:00 -07:00
|
|
|
}
|
|
|
|
|
2015-01-12 03:07:38 -08:00
|
|
|
nsISupports* parentObject =
|
|
|
|
OwnerDoc()->GetParentObject();
|
2014-04-07 10:58:38 -07:00
|
|
|
|
2015-01-12 03:07:38 -08:00
|
|
|
NS_ENSURE_TRUE_VOID(parentObject);
|
2014-04-07 10:58:38 -07:00
|
|
|
|
2015-01-12 03:07:38 -08:00
|
|
|
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(parentObject);
|
2014-04-07 10:58:38 -07:00
|
|
|
mTrack = new TextTrack(window, kind, label, srcLang,
|
2014-03-13 11:41:21 -07:00
|
|
|
TextTrackMode::Disabled,
|
|
|
|
TextTrackReadyState::NotLoaded,
|
|
|
|
TextTrackSource::Track);
|
2014-02-27 11:07:39 -08:00
|
|
|
mTrack->SetTrackElement(this);
|
2013-05-21 09:14:00 -07:00
|
|
|
|
2013-07-04 11:16:05 -07:00
|
|
|
if (mMediaParent) {
|
|
|
|
mMediaParent->AddTextTrack(mTrack);
|
|
|
|
}
|
2013-05-21 09:14:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
HTMLTrackElement::ParseAttribute(int32_t aNamespaceID,
|
|
|
|
nsIAtom* aAttribute,
|
|
|
|
const nsAString& aValue,
|
|
|
|
nsAttrValue& aResult)
|
|
|
|
{
|
|
|
|
if (aNamespaceID == kNameSpaceID_None && aAttribute == nsGkAtoms::kind) {
|
|
|
|
// Case-insensitive lookup, with the first element as the default.
|
|
|
|
return aResult.ParseEnumValue(aValue, kKindTable, false, kKindTable);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Otherwise call the generic implementation.
|
|
|
|
return nsGenericHTMLElement::ParseAttribute(aNamespaceID,
|
|
|
|
aAttribute,
|
|
|
|
aValue,
|
|
|
|
aResult);
|
|
|
|
}
|
|
|
|
|
2013-06-10 08:30:00 -07:00
|
|
|
void
|
|
|
|
HTMLTrackElement::LoadResource()
|
|
|
|
{
|
|
|
|
// Find our 'src' url
|
|
|
|
nsAutoString src;
|
|
|
|
if (!GetAttr(kNameSpaceID_None, nsGkAtoms::src, src)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIURI> uri;
|
|
|
|
nsresult rv = NewURIFromString(src, getter_AddRefs(uri));
|
|
|
|
NS_ENSURE_TRUE_VOID(NS_SUCCEEDED(rv));
|
2015-06-01 14:31:01 -07:00
|
|
|
LOG(LogLevel::Info, ("%p Trying to load from src=%s", this,
|
2013-06-10 08:30:00 -07:00
|
|
|
NS_ConvertUTF16toUTF8(src).get()));
|
|
|
|
|
|
|
|
if (mChannel) {
|
|
|
|
mChannel->Cancel(NS_BINDING_ABORTED);
|
|
|
|
mChannel = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
rv = nsContentUtils::GetSecurityManager()->
|
|
|
|
CheckLoadURIWithPrincipal(NodePrincipal(), uri,
|
|
|
|
nsIScriptSecurityManager::STANDARD);
|
|
|
|
NS_ENSURE_TRUE_VOID(NS_SUCCEEDED(rv));
|
|
|
|
|
|
|
|
int16_t shouldLoad = nsIContentPolicy::ACCEPT;
|
|
|
|
rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_MEDIA,
|
|
|
|
uri,
|
|
|
|
NodePrincipal(),
|
2013-08-07 13:23:08 -07:00
|
|
|
static_cast<Element*>(this),
|
2013-06-10 08:30:00 -07:00
|
|
|
NS_LITERAL_CSTRING("text/vtt"), // mime type
|
|
|
|
nullptr, // extra
|
|
|
|
&shouldLoad,
|
|
|
|
nsContentUtils::GetContentPolicy(),
|
|
|
|
nsContentUtils::GetSecurityManager());
|
|
|
|
NS_ENSURE_TRUE_VOID(NS_SUCCEEDED(rv));
|
|
|
|
if (NS_CP_REJECTED(shouldLoad)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-07-02 10:10:00 -07:00
|
|
|
// We may already have a TextTrack at this point if GetTrack() has already
|
|
|
|
// been called. This happens, for instance, if script tries to get the
|
|
|
|
// TextTrack before its mTrackElement has been bound to the DOM tree.
|
|
|
|
if (!mTrack) {
|
|
|
|
CreateTextTrack();
|
|
|
|
}
|
2013-06-10 08:30:00 -07:00
|
|
|
|
|
|
|
nsCOMPtr<nsIChannel> channel;
|
|
|
|
nsCOMPtr<nsILoadGroup> loadGroup = OwnerDoc()->GetDocumentLoadGroup();
|
|
|
|
rv = NS_NewChannel(getter_AddRefs(channel),
|
|
|
|
uri,
|
2014-09-21 09:36:25 -07:00
|
|
|
static_cast<Element*>(this),
|
|
|
|
nsILoadInfo::SEC_NORMAL,
|
|
|
|
nsIContentPolicy::TYPE_MEDIA,
|
|
|
|
loadGroup);
|
|
|
|
|
2013-06-10 08:30:00 -07:00
|
|
|
NS_ENSURE_TRUE_VOID(NS_SUCCEEDED(rv));
|
|
|
|
|
2013-09-19 08:26:00 -07:00
|
|
|
mListener = new WebVTTListener(this);
|
|
|
|
rv = mListener->LoadResource();
|
2013-06-10 08:30:00 -07:00
|
|
|
NS_ENSURE_TRUE_VOID(NS_SUCCEEDED(rv));
|
2013-09-19 08:26:00 -07:00
|
|
|
channel->SetNotificationCallbacks(mListener);
|
2013-06-10 08:30:00 -07:00
|
|
|
|
2015-06-01 14:31:01 -07:00
|
|
|
LOG(LogLevel::Debug, ("opening webvtt channel"));
|
2013-09-19 08:26:00 -07:00
|
|
|
rv = channel->AsyncOpen(mListener, nullptr);
|
2013-06-10 08:30:00 -07:00
|
|
|
NS_ENSURE_TRUE_VOID(NS_SUCCEEDED(rv));
|
|
|
|
|
|
|
|
mChannel = channel;
|
|
|
|
}
|
|
|
|
|
2013-05-21 09:14:00 -07:00
|
|
|
nsresult
|
|
|
|
HTMLTrackElement::BindToTree(nsIDocument* aDocument,
|
|
|
|
nsIContent* aParent,
|
|
|
|
nsIContent* aBindingParent,
|
|
|
|
bool aCompileEventHandlers)
|
|
|
|
{
|
|
|
|
nsresult rv = nsGenericHTMLElement::BindToTree(aDocument,
|
|
|
|
aParent,
|
|
|
|
aBindingParent,
|
|
|
|
aCompileEventHandlers);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
if (!aDocument) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-06-01 14:31:01 -07:00
|
|
|
LOG(LogLevel::Debug, ("Track Element bound to tree."));
|
2013-05-21 09:14:00 -07:00
|
|
|
if (!aParent || !aParent->IsNodeOfType(nsINode::eMEDIA)) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Store our parent so we can look up its frame for display.
|
|
|
|
if (!mMediaParent) {
|
|
|
|
mMediaParent = static_cast<HTMLMediaElement*>(aParent);
|
|
|
|
|
|
|
|
HTMLMediaElement* media = static_cast<HTMLMediaElement*>(aParent);
|
|
|
|
// TODO: separate notification for 'alternate' tracks?
|
|
|
|
media->NotifyAddedSource();
|
2015-06-01 14:31:01 -07:00
|
|
|
LOG(LogLevel::Debug, ("Track element sent notification to parent."));
|
2013-05-21 09:14:00 -07:00
|
|
|
|
2013-06-27 18:05:03 -07:00
|
|
|
mMediaParent->RunInStableState(
|
2013-06-10 08:30:00 -07:00
|
|
|
NS_NewRunnableMethod(this, &HTMLTrackElement::LoadResource));
|
2013-05-21 09:14:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
HTMLTrackElement::UnbindFromTree(bool aDeep, bool aNullParent)
|
|
|
|
{
|
2013-06-24 08:35:58 -07:00
|
|
|
if (mMediaParent) {
|
|
|
|
// mTrack can be null if HTMLTrackElement::LoadResource has never been
|
|
|
|
// called.
|
|
|
|
if (mTrack) {
|
|
|
|
mMediaParent->RemoveTextTrack(mTrack);
|
|
|
|
}
|
|
|
|
if (aNullParent) {
|
|
|
|
mMediaParent = nullptr;
|
|
|
|
}
|
2013-05-21 09:14:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsGenericHTMLElement::UnbindFromTree(aDeep, aNullParent);
|
|
|
|
}
|
|
|
|
|
2013-10-24 21:14:36 -07:00
|
|
|
uint16_t
|
|
|
|
HTMLTrackElement::ReadyState() const
|
|
|
|
{
|
|
|
|
if (!mTrack) {
|
2014-03-13 11:29:32 -07:00
|
|
|
return TextTrackReadyState::NotLoaded;
|
2013-10-24 21:14:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return mTrack->ReadyState();
|
|
|
|
}
|
|
|
|
|
2014-03-14 09:13:41 -07:00
|
|
|
void
|
|
|
|
HTMLTrackElement::SetReadyState(uint16_t aReadyState)
|
|
|
|
{
|
|
|
|
if (mTrack) {
|
|
|
|
switch (aReadyState) {
|
|
|
|
case TextTrackReadyState::Loaded:
|
2014-07-07 07:49:00 -07:00
|
|
|
DispatchTrackRunnable(NS_LITERAL_STRING("load"));
|
2014-03-14 09:13:41 -07:00
|
|
|
break;
|
|
|
|
case TextTrackReadyState::FailedToLoad:
|
|
|
|
DispatchTrackRunnable(NS_LITERAL_STRING("error"));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
mTrack->SetReadyState(aReadyState);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
HTMLTrackElement::DispatchTrackRunnable(const nsString& aEventName)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIRunnable> runnable =
|
|
|
|
NS_NewRunnableMethodWithArg
|
|
|
|
<const nsString>(this,
|
|
|
|
&HTMLTrackElement::DispatchTrustedEvent,
|
|
|
|
aEventName);
|
|
|
|
NS_DispatchToMainThread(runnable);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
HTMLTrackElement::DispatchTrustedEvent(const nsAString& aName)
|
|
|
|
{
|
|
|
|
nsIDocument* doc = OwnerDoc();
|
|
|
|
if (!doc) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
nsContentUtils::DispatchTrustedEvent(doc, static_cast<nsIContent*>(this),
|
|
|
|
aName, false, false);
|
|
|
|
}
|
|
|
|
|
2014-06-18 13:10:24 -07:00
|
|
|
void
|
|
|
|
HTMLTrackElement::DropChannel()
|
|
|
|
{
|
|
|
|
mChannel = nullptr;
|
|
|
|
}
|
|
|
|
|
2013-05-21 09:14:00 -07:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|