2015-05-03 22:32:37 +03: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 20:14:00 +04: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 20:36:25 +04:00
|
|
|
#include "nsIContentPolicy.h"
|
|
|
|
#include "mozilla/LoadInfo.h"
|
2013-09-19 19:26:00 +04:00
|
|
|
#include "WebVTTListener.h"
|
2013-05-21 20:14:00 +04: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 23:22:04 +03:00
|
|
|
#define LOG(type, msg) MOZ_LOG(gTrackElementLog, type, msg)
|
2013-05-21 20:14:00 +04: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-20 06:01:40 +04:00
|
|
|
NS_NewHTMLTrackElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
|
2013-05-21 20:14:00 +04:00
|
|
|
mozilla::dom::FromParser aFromParser)
|
|
|
|
{
|
|
|
|
if (!mozilla::dom::HTMLTrackElement::IsWebVTTEnabled()) {
|
2013-06-26 18:59:46 +04:00
|
|
|
return new mozilla::dom::HTMLUnknownElement(aNodeInfo);
|
2013-05-21 20:14:00 +04:00
|
|
|
}
|
|
|
|
|
2013-06-26 18:59:46 +04:00
|
|
|
return new mozilla::dom::HTMLTrackElement(aNodeInfo);
|
2013-05-21 20:14:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2014-02-22 07:06:48 +04: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 22:16:05 +04:00
|
|
|
// The default value for kKindTable is "subtitles"
|
2013-11-22 23:45:50 +04:00
|
|
|
static MOZ_CONSTEXPR const char* kKindTableDefaultString = kKindTable->tag;
|
2013-07-04 22:16:05 +04:00
|
|
|
|
2013-05-21 20:14:00 +04:00
|
|
|
/** HTMLTrackElement */
|
2014-06-20 06:01:40 +04:00
|
|
|
HTMLTrackElement::HTMLTrackElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
|
2013-05-21 20:14:00 +04: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 20:49:00 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_INHERITED(HTMLTrackElement, nsGenericHTMLElement,
|
2014-06-19 00:10:24 +04:00
|
|
|
mTrack, mMediaParent, mListener)
|
2013-05-21 20:14:00 +04:00
|
|
|
|
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(HTMLTrackElement)
|
2013-08-08 00:23:08 +04:00
|
|
|
NS_INTERFACE_MAP_END_INHERITING(nsGenericHTMLElement)
|
2013-05-21 20:14:00 +04:00
|
|
|
|
2013-07-04 22:16:05 +04:00
|
|
|
void
|
|
|
|
HTMLTrackElement::GetKind(DOMString& aKind) const
|
|
|
|
{
|
|
|
|
GetEnumAttr(nsGkAtoms::kind, kKindTableDefaultString, aKind);
|
|
|
|
}
|
|
|
|
|
2013-06-10 19:30:00 +04:00
|
|
|
void
|
|
|
|
HTMLTrackElement::OnChannelRedirect(nsIChannel* aChannel,
|
|
|
|
nsIChannel* aNewChannel,
|
|
|
|
uint32_t aFlags)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aChannel == mChannel, "Channels should match!");
|
|
|
|
mChannel = aNewChannel;
|
|
|
|
}
|
|
|
|
|
2013-05-21 20:14:00 +04: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 17:13:33 +03:00
|
|
|
HTMLTrackElement::WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
2013-05-21 20:14:00 +04: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 17:13:33 +03:00
|
|
|
return HTMLTrackElementBinding::Wrap(aCx, this, aGivenProto);
|
2013-05-21 20:14:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
HTMLTrackElement::IsWebVTTEnabled()
|
|
|
|
{
|
2013-06-13 09:12:26 +04:00
|
|
|
// Our callee does not use its arguments.
|
2015-05-14 00:07:34 +03:00
|
|
|
return HTMLTrackElementBinding::ConstructorEnabled(nullptr, nullptr);
|
2013-05-21 20:14:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
TextTrack*
|
2014-04-07 21:58:38 +04:00
|
|
|
HTMLTrackElement::GetTrack()
|
2013-05-21 20:14:00 +04:00
|
|
|
{
|
|
|
|
if (!mTrack) {
|
2014-01-28 00:17:20 +04:00
|
|
|
CreateTextTrack();
|
2013-05-21 20:14:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return mTrack;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
HTMLTrackElement::CreateTextTrack()
|
|
|
|
{
|
2013-05-24 06:57:00 +04:00
|
|
|
nsString label, srcLang;
|
2013-05-21 20:14:00 +04:00
|
|
|
GetSrclang(srcLang);
|
|
|
|
GetLabel(label);
|
|
|
|
|
2013-07-04 22:16:05 +04:00
|
|
|
TextTrackKind kind;
|
|
|
|
if (const nsAttrValue* value = GetParsedAttr(nsGkAtoms::kind)) {
|
|
|
|
kind = static_cast<TextTrackKind>(value->GetEnumValue());
|
|
|
|
} else {
|
|
|
|
kind = TextTrackKind::Subtitles;
|
2013-05-21 20:14:00 +04:00
|
|
|
}
|
|
|
|
|
2015-01-12 14:07:38 +03:00
|
|
|
nsISupports* parentObject =
|
|
|
|
OwnerDoc()->GetParentObject();
|
2014-04-07 21:58:38 +04:00
|
|
|
|
2015-01-12 14:07:38 +03:00
|
|
|
NS_ENSURE_TRUE_VOID(parentObject);
|
2014-04-07 21:58:38 +04:00
|
|
|
|
2015-01-12 14:07:38 +03:00
|
|
|
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(parentObject);
|
2014-04-07 21:58:38 +04:00
|
|
|
mTrack = new TextTrack(window, kind, label, srcLang,
|
2014-03-13 22:41:21 +04:00
|
|
|
TextTrackMode::Disabled,
|
|
|
|
TextTrackReadyState::NotLoaded,
|
|
|
|
TextTrackSource::Track);
|
2014-02-27 23:07:39 +04:00
|
|
|
mTrack->SetTrackElement(this);
|
2013-05-21 20:14:00 +04:00
|
|
|
|
2013-07-04 22:16:05 +04:00
|
|
|
if (mMediaParent) {
|
|
|
|
mMediaParent->AddTextTrack(mTrack);
|
|
|
|
}
|
2013-05-21 20:14:00 +04: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 19:30:00 +04: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-04 01:22:30 +03:00
|
|
|
LOG(PR_LOG_INFO, ("%p Trying to load from src=%s", this,
|
2013-06-10 19:30:00 +04: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-08 00:23:08 +04:00
|
|
|
static_cast<Element*>(this),
|
2013-06-10 19:30:00 +04: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 21:10:00 +04: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 19:30:00 +04:00
|
|
|
|
|
|
|
nsCOMPtr<nsIChannel> channel;
|
|
|
|
nsCOMPtr<nsILoadGroup> loadGroup = OwnerDoc()->GetDocumentLoadGroup();
|
|
|
|
rv = NS_NewChannel(getter_AddRefs(channel),
|
|
|
|
uri,
|
2014-09-21 20:36:25 +04:00
|
|
|
static_cast<Element*>(this),
|
|
|
|
nsILoadInfo::SEC_NORMAL,
|
|
|
|
nsIContentPolicy::TYPE_MEDIA,
|
|
|
|
loadGroup);
|
|
|
|
|
2013-06-10 19:30:00 +04:00
|
|
|
NS_ENSURE_TRUE_VOID(NS_SUCCEEDED(rv));
|
|
|
|
|
2013-09-19 19:26:00 +04:00
|
|
|
mListener = new WebVTTListener(this);
|
|
|
|
rv = mListener->LoadResource();
|
2013-06-10 19:30:00 +04:00
|
|
|
NS_ENSURE_TRUE_VOID(NS_SUCCEEDED(rv));
|
2013-09-19 19:26:00 +04:00
|
|
|
channel->SetNotificationCallbacks(mListener);
|
2013-06-10 19:30:00 +04:00
|
|
|
|
2015-06-02 14:05:56 +03:00
|
|
|
LOG(PR_LOG_DEBUG, ("opening webvtt channel"));
|
2013-09-19 19:26:00 +04:00
|
|
|
rv = channel->AsyncOpen(mListener, nullptr);
|
2013-06-10 19:30:00 +04:00
|
|
|
NS_ENSURE_TRUE_VOID(NS_SUCCEEDED(rv));
|
|
|
|
|
|
|
|
mChannel = channel;
|
|
|
|
}
|
|
|
|
|
2013-05-21 20:14:00 +04: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-02 14:05:56 +03:00
|
|
|
LOG(PR_LOG_DEBUG, ("Track Element bound to tree."));
|
2013-05-21 20:14:00 +04: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-02 14:05:56 +03:00
|
|
|
LOG(PR_LOG_DEBUG, ("Track element sent notification to parent."));
|
2013-05-21 20:14:00 +04:00
|
|
|
|
2013-06-28 05:05:03 +04:00
|
|
|
mMediaParent->RunInStableState(
|
2013-06-10 19:30:00 +04:00
|
|
|
NS_NewRunnableMethod(this, &HTMLTrackElement::LoadResource));
|
2013-05-21 20:14:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
HTMLTrackElement::UnbindFromTree(bool aDeep, bool aNullParent)
|
|
|
|
{
|
2013-06-24 19:35:58 +04: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 20:14:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsGenericHTMLElement::UnbindFromTree(aDeep, aNullParent);
|
|
|
|
}
|
|
|
|
|
2013-10-25 08:14:36 +04:00
|
|
|
uint16_t
|
|
|
|
HTMLTrackElement::ReadyState() const
|
|
|
|
{
|
|
|
|
if (!mTrack) {
|
2014-03-13 22:29:32 +04:00
|
|
|
return TextTrackReadyState::NotLoaded;
|
2013-10-25 08:14:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return mTrack->ReadyState();
|
|
|
|
}
|
|
|
|
|
2014-03-14 20:13:41 +04:00
|
|
|
void
|
|
|
|
HTMLTrackElement::SetReadyState(uint16_t aReadyState)
|
|
|
|
{
|
|
|
|
if (mTrack) {
|
|
|
|
switch (aReadyState) {
|
|
|
|
case TextTrackReadyState::Loaded:
|
2014-07-07 18:49:00 +04:00
|
|
|
DispatchTrackRunnable(NS_LITERAL_STRING("load"));
|
2014-03-14 20:13:41 +04: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-19 00:10:24 +04:00
|
|
|
void
|
|
|
|
HTMLTrackElement::DropChannel()
|
|
|
|
{
|
|
|
|
mChannel = nullptr;
|
|
|
|
}
|
|
|
|
|
2013-05-21 20:14:00 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|