summaryrefslogtreecommitdiff
path: root/Source/WebCore/html/track/LoadableTextTrack.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/html/track/LoadableTextTrack.cpp
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebCore/html/track/LoadableTextTrack.cpp')
-rw-r--r--Source/WebCore/html/track/LoadableTextTrack.cpp73
1 files changed, 27 insertions, 46 deletions
diff --git a/Source/WebCore/html/track/LoadableTextTrack.cpp b/Source/WebCore/html/track/LoadableTextTrack.cpp
index e61cffc6a..5528de17b 100644
--- a/Source/WebCore/html/track/LoadableTextTrack.cpp
+++ b/Source/WebCore/html/track/LoadableTextTrack.cpp
@@ -1,5 +1,6 @@
/*
- * Copyright (C) 2011 Google Inc. All rights reserved.
+ * Copyright (C) 2011, 2013 Google Inc. All rights reserved.
+ * Copyright (C) 2011-2017 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -10,10 +11,10 @@
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
@@ -24,36 +25,24 @@
*/
#include "config.h"
+#include "LoadableTextTrack.h"
#if ENABLE(VIDEO_TRACK)
-#include "LoadableTextTrack.h"
-
-#include "Event.h"
#include "HTMLTrackElement.h"
-#include "ScriptExecutionContext.h"
#include "TextTrackCueList.h"
+#include "VTTRegionList.h"
namespace WebCore {
-LoadableTextTrack::LoadableTextTrack(HTMLTrackElement* track, const String& kind, const String& label, const String& language)
- : TextTrack(&track->document(), track, kind, emptyString(), label, language, TrackElement)
- , m_trackElement(track)
- , m_loadTimer(this, &LoadableTextTrack::loadTimerFired)
+LoadableTextTrack::LoadableTextTrack(HTMLTrackElement& track, const String& kind, const String& label, const String& language)
+ : TextTrack(&track.document(), &track, kind, emptyString(), label, language, TrackElement)
+ , m_trackElement(&track)
+ , m_loadTimer(*this, &LoadableTextTrack::loadTimerFired)
, m_isDefault(false)
{
}
-LoadableTextTrack::~LoadableTextTrack()
-{
-}
-
-void LoadableTextTrack::clearClient()
-{
- m_trackElement = 0;
- TextTrack::clearClient();
-}
-
void LoadableTextTrack::scheduleLoad(const URL& url)
{
if (url == m_url)
@@ -74,14 +63,8 @@ Element* LoadableTextTrack::element()
{
return m_trackElement;
}
-
-void LoadableTextTrack::setTrackElement(HTMLTrackElement* element)
-{
- ASSERT(!m_trackElement || m_trackElement == element);
- m_trackElement = element;
-}
-void LoadableTextTrack::loadTimerFired(Timer<LoadableTextTrack>&)
+void LoadableTextTrack::loadTimerFired()
{
if (m_loader)
m_loader->cancelLoad();
@@ -94,14 +77,14 @@ void LoadableTextTrack::loadTimerFired(Timer<LoadableTextTrack>&)
// 4. Download: If URL is not the empty string, perform a potentially CORS-enabled fetch of URL, with the
// mode being the state of the media element's crossorigin content attribute, the origin being the
// origin of the media element's Document, and the default origin behaviour set to fail.
- m_loader = TextTrackLoader::create(*this, static_cast<ScriptExecutionContext*>(&m_trackElement->document()));
- if (!m_loader->load(m_url, m_trackElement->mediaElementCrossOriginAttribute()))
+ m_loader = std::make_unique<TextTrackLoader>(static_cast<TextTrackLoaderClient&>(*this), static_cast<ScriptExecutionContext*>(&m_trackElement->document()));
+ if (!m_loader->load(m_url, m_trackElement->mediaElementCrossOriginAttribute(), m_trackElement->isInUserAgentShadowTree()))
m_trackElement->didCompleteLoad(HTMLTrackElement::Failure);
}
void LoadableTextTrack::newCuesAvailable(TextTrackLoader* loader)
{
- ASSERT_UNUSED(loader, m_loader == loader);
+ ASSERT_UNUSED(loader, m_loader.get() == loader);
Vector<RefPtr<TextTrackCue>> newCues;
m_loader->getNewCues(newCues);
@@ -109,18 +92,18 @@ void LoadableTextTrack::newCuesAvailable(TextTrackLoader* loader)
if (!m_cues)
m_cues = TextTrackCueList::create();
- for (size_t i = 0; i < newCues.size(); ++i) {
- newCues[i]->setTrack(this);
- m_cues->add(newCues[i]);
+ for (auto& newCue : newCues) {
+ newCue->setTrack(this);
+ m_cues->add(newCue.releaseNonNull());
}
if (client())
- client()->textTrackAddCues(this, m_cues.get());
+ client()->textTrackAddCues(*this, *m_cues);
}
void LoadableTextTrack::cueLoadingCompleted(TextTrackLoader* loader, bool loadingFailed)
{
- ASSERT_UNUSED(loader, m_loader == loader);
+ ASSERT_UNUSED(loader, m_loader.get() == loader);
if (!m_trackElement)
return;
@@ -128,26 +111,24 @@ void LoadableTextTrack::cueLoadingCompleted(TextTrackLoader* loader, bool loadin
m_trackElement->didCompleteLoad(loadingFailed ? HTMLTrackElement::Failure : HTMLTrackElement::Success);
}
-#if ENABLE(WEBVTT_REGIONS)
void LoadableTextTrack::newRegionsAvailable(TextTrackLoader* loader)
{
- ASSERT_UNUSED(loader, m_loader == loader);
+ ASSERT_UNUSED(loader, m_loader.get() == loader);
- Vector<RefPtr<TextTrackRegion>> newRegions;
+ Vector<RefPtr<VTTRegion>> newRegions;
m_loader->getNewRegions(newRegions);
- for (size_t i = 0; i < newRegions.size(); ++i) {
- newRegions[i]->setTrack(this);
- regionList()->add(newRegions[i]);
+ for (auto& newRegion : newRegions) {
+ newRegion->setTrack(this);
+ regions()->add(newRegion.releaseNonNull());
}
}
-#endif
AtomicString LoadableTextTrack::id() const
{
- if (m_trackElement)
- return m_trackElement->getAttribute("id");
- return emptyString();
+ if (!m_trackElement)
+ return emptyAtom;
+ return m_trackElement->attributeWithoutSynchronization(idAttr);
}
size_t LoadableTextTrack::trackElementIndex()