summaryrefslogtreecommitdiff
path: root/Source/WebCore/html/HTMLTrackElement.cpp
diff options
context:
space:
mode:
authorKonstantin Tokarev <annulen@yandex.ru>2016-08-25 19:20:41 +0300
committerKonstantin Tokarev <annulen@yandex.ru>2017-02-02 12:30:55 +0000
commit6882a04fb36642862b11efe514251d32070c3d65 (patch)
treeb7959826000b061fd5ccc7512035c7478742f7b0 /Source/WebCore/html/HTMLTrackElement.cpp
parentab6df191029eeeb0b0f16f127d553265659f739e (diff)
downloadqtwebkit-6882a04fb36642862b11efe514251d32070c3d65.tar.gz
Imported QtWebKit TP3 (git b57bc6801f1876c3220d5a4bfea33d620d477443)
Change-Id: I3b1d8a2808782c9f34d50240000e20cb38d3680f Reviewed-by: Konstantin Tokarev <annulen@yandex.ru>
Diffstat (limited to 'Source/WebCore/html/HTMLTrackElement.cpp')
-rw-r--r--Source/WebCore/html/HTMLTrackElement.cpp104
1 files changed, 40 insertions, 64 deletions
diff --git a/Source/WebCore/html/HTMLTrackElement.cpp b/Source/WebCore/html/HTMLTrackElement.cpp
index a1fd5f354..fa77be79b 100644
--- a/Source/WebCore/html/HTMLTrackElement.cpp
+++ b/Source/WebCore/html/HTMLTrackElement.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 Google Inc. All rights reserved.
+ * Copyright (C) 2011, 2013 Google 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 +10,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
@@ -33,16 +33,14 @@
#include "HTMLNames.h"
#include "Logging.h"
#include "RuntimeEnabledFeatures.h"
-#include "ScriptEventListener.h"
-
-using namespace std;
+#include <wtf/text/CString.h>
namespace WebCore {
using namespace HTMLNames;
#if !LOG_DISABLED
-static String urlForLoggingTrack(const KURL& url)
+static String urlForLoggingTrack(const URL& url)
{
static const unsigned maximumURLLengthForLogging = 128;
@@ -52,9 +50,9 @@ static String urlForLoggingTrack(const KURL& url)
}
#endif
-inline HTMLTrackElement::HTMLTrackElement(const QualifiedName& tagName, Document* document)
+inline HTMLTrackElement::HTMLTrackElement(const QualifiedName& tagName, Document& document)
: HTMLElement(tagName, document)
- , m_loadTimer(this, &HTMLTrackElement::loadTimerFired)
+ , m_loadTimer(*this, &HTMLTrackElement::loadTimerFired)
{
LOG(Media, "HTMLTrackElement::HTMLTrackElement - %p", this);
ASSERT(hasTagName(trackTag));
@@ -66,35 +64,35 @@ HTMLTrackElement::~HTMLTrackElement()
m_track->clearClient();
}
-PassRefPtr<HTMLTrackElement> HTMLTrackElement::create(const QualifiedName& tagName, Document* document)
+Ref<HTMLTrackElement> HTMLTrackElement::create(const QualifiedName& tagName, Document& document)
{
- return adoptRef(new HTMLTrackElement(tagName, document));
+ return adoptRef(*new HTMLTrackElement(tagName, document));
}
-Node::InsertionNotificationRequest HTMLTrackElement::insertedInto(ContainerNode* insertionPoint)
+Node::InsertionNotificationRequest HTMLTrackElement::insertedInto(ContainerNode& insertionPoint)
{
// Since we've moved to a new parent, we may now be able to load.
scheduleLoad();
HTMLElement::insertedInto(insertionPoint);
HTMLMediaElement* parent = mediaElement();
- if (insertionPoint == parent) {
+ if (&insertionPoint == parent) {
ensureTrack();
parent->didAddTextTrack(this);
}
return InsertionDone;
}
-void HTMLTrackElement::removedFrom(ContainerNode* insertionPoint)
+void HTMLTrackElement::removedFrom(ContainerNode& insertionPoint)
{
- if (!parentNode() && WebCore::isMediaElement(insertionPoint))
- toHTMLMediaElement(insertionPoint)->didRemoveTextTrack(this);
+ if (!parentNode() && is<HTMLMediaElement>(insertionPoint))
+ downcast<HTMLMediaElement>(insertionPoint).didRemoveTextTrack(this);
HTMLElement::removedFrom(insertionPoint);
}
void HTMLTrackElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
{
- if (RuntimeEnabledFeatures::webkitVideoTrackEnabled()) {
+ if (RuntimeEnabledFeatures::sharedFeatures().webkitVideoTrackEnabled()) {
if (name == srcAttr) {
if (!value.isEmpty())
scheduleLoad();
@@ -104,7 +102,7 @@ void HTMLTrackElement::parseAttribute(const QualifiedName& name, const AtomicStr
// 4.8.10.12.3 Sourcing out-of-band text tracks
// As the kind, label, and srclang attributes are set, changed, or removed, the text track must update accordingly...
} else if (name == kindAttr)
- track()->setKind(value.lower());
+ track()->setKind(value.convertToASCIILowercase());
else if (name == labelAttr)
track()->setLabel(value);
else if (name == srclangAttr)
@@ -116,16 +114,6 @@ void HTMLTrackElement::parseAttribute(const QualifiedName& name, const AtomicStr
HTMLElement::parseAttribute(name, value);
}
-KURL HTMLTrackElement::src() const
-{
- return document()->completeURL(getAttribute(srcAttr));
-}
-
-void HTMLTrackElement::setSrc(const String& url)
-{
- setAttribute(srcAttr, url);
-}
-
String HTMLTrackElement::kind()
{
return track()->kind();
@@ -166,23 +154,23 @@ void HTMLTrackElement::setIsDefault(bool isDefault)
setBooleanAttribute(defaultAttr, isDefault);
}
-LoadableTextTrack* HTMLTrackElement::ensureTrack()
+LoadableTextTrack& HTMLTrackElement::ensureTrack()
{
if (!m_track) {
- // The kind attribute is an enumerated attribute, limited only to know values. It defaults to 'subtitles' if missing or invalid.
- String kind = getAttribute(kindAttr).lower();
+ // The kind attribute is an enumerated attribute, limited only to known values. It defaults to 'subtitles' if missing or invalid.
+ String kind = fastGetAttribute(kindAttr).convertToASCIILowercase();
if (!TextTrack::isValidKindKeyword(kind))
kind = TextTrack::subtitlesKeyword();
m_track = LoadableTextTrack::create(this, kind, label(), srclang());
} else
m_track->setTrackElement(this);
- return m_track.get();
+ return *m_track;
}
TextTrack* HTMLTrackElement::track()
{
- return ensureTrack();
+ return &ensureTrack();
}
bool HTMLTrackElement::isURLAttribute(const Attribute& attribute) const
@@ -197,11 +185,11 @@ void HTMLTrackElement::scheduleLoad()
if (m_loadTimer.isActive())
return;
- if (!RuntimeEnabledFeatures::webkitVideoTrackEnabled())
+ if (!RuntimeEnabledFeatures::sharedFeatures().webkitVideoTrackEnabled())
return;
// 2. If the text track's text track mode is not set to one of hidden or showing, abort these steps.
- if (ensureTrack()->mode() != TextTrack::hiddenKeyword() && ensureTrack()->mode() != TextTrack::showingKeyword())
+ if (ensureTrack().mode() != TextTrack::hiddenKeyword() && ensureTrack().mode() != TextTrack::showingKeyword())
return;
// 3. If the text track's track element does not have a media element as a parent, abort these steps.
@@ -212,7 +200,7 @@ void HTMLTrackElement::scheduleLoad()
m_loadTimer.startOneShot(0);
}
-void HTMLTrackElement::loadTimerFired(Timer<HTMLTrackElement>*)
+void HTMLTrackElement::loadTimerFired()
{
if (!fastHasAttribute(srcAttr))
return;
@@ -221,21 +209,21 @@ void HTMLTrackElement::loadTimerFired(Timer<HTMLTrackElement>*)
setReadyState(HTMLTrackElement::LOADING);
// 7. Let URL be the track URL of the track element.
- KURL url = getNonEmptyURLAttribute(srcAttr);
+ URL url = getNonEmptyURLAttribute(srcAttr);
// 8. If the track element's parent is a media element then let CORS mode be the state of the parent media
// element's crossorigin content attribute. Otherwise, let CORS mode be No CORS.
- if (!canLoadUrl(url)) {
- didCompleteLoad(ensureTrack(), HTMLTrackElement::Failure);
+ if (!canLoadURL(url)) {
+ didCompleteLoad(HTMLTrackElement::Failure);
return;
}
- ensureTrack()->scheduleLoad(url);
+ ensureTrack().scheduleLoad(url);
}
-bool HTMLTrackElement::canLoadUrl(const KURL& url)
+bool HTMLTrackElement::canLoadURL(const URL& url)
{
- if (!RuntimeEnabledFeatures::webkitVideoTrackEnabled())
+ if (!RuntimeEnabledFeatures::sharedFeatures().webkitVideoTrackEnabled())
return false;
HTMLMediaElement* parent = mediaElement();
@@ -250,15 +238,15 @@ bool HTMLTrackElement::canLoadUrl(const KURL& url)
if (url.isEmpty())
return false;
- if (!document()->contentSecurityPolicy()->allowMediaFromSource(url)) {
- LOG(Media, "HTMLTrackElement::canLoadUrl(%s) -> rejected by Content Security Policy", urlForLoggingTrack(url).utf8().data());
+ if (!document().contentSecurityPolicy()->allowMediaFromSource(url, isInUserAgentShadowTree())) {
+ LOG(Media, "HTMLTrackElement::canLoadURL(%s) -> rejected by Content Security Policy", urlForLoggingTrack(url).utf8().data());
return false;
}
return dispatchBeforeLoadEvent(url.string());
}
-void HTMLTrackElement::didCompleteLoad(LoadableTextTrack*, LoadStatus status)
+void HTMLTrackElement::didCompleteLoad(LoadStatus status)
{
// 4.8.10.12.3 Sourcing out-of-band text tracks (continued)
@@ -272,7 +260,7 @@ void HTMLTrackElement::didCompleteLoad(LoadableTextTrack*, LoadStatus status)
if (status == Failure) {
setReadyState(HTMLTrackElement::TRACK_ERROR);
- dispatchEvent(Event::create(eventNames().errorEvent, false, false), IGNORE_EXCEPTION);
+ dispatchEvent(Event::create(eventNames().errorEvent, false, false));
return;
}
@@ -283,7 +271,7 @@ void HTMLTrackElement::didCompleteLoad(LoadableTextTrack*, LoadStatus status)
// 2. If the file was successfully processed, fire a simple event named load at the
// track element.
- dispatchEvent(Event::create(eventNames().loadEvent, false, false), IGNORE_EXCEPTION);
+ dispatchEvent(Event::create(eventNames().loadEvent, false, false));
}
// NOTE: The values in the TextTrack::ReadinessState enum must stay in sync with those in HTMLTrackElement::ReadyState.
@@ -294,14 +282,14 @@ COMPILE_ASSERT(HTMLTrackElement::TRACK_ERROR == static_cast<HTMLTrackElement::Re
void HTMLTrackElement::setReadyState(ReadyState state)
{
- ensureTrack()->setReadinessState(static_cast<TextTrack::ReadinessState>(state));
+ ensureTrack().setReadinessState(static_cast<TextTrack::ReadinessState>(state));
if (HTMLMediaElement* parent = mediaElement())
return parent->textTrackReadyStateChanged(m_track.get());
}
HTMLTrackElement::ReadyState HTMLTrackElement::readyState()
{
- return static_cast<ReadyState>(ensureTrack()->readinessState());
+ return static_cast<ReadyState>(ensureTrack().readinessState());
}
const AtomicString& HTMLTrackElement::mediaElementCrossOriginAttribute() const
@@ -355,24 +343,12 @@ void HTMLTrackElement::textTrackRemoveCue(TextTrack* track, PassRefPtr<TextTrack
HTMLMediaElement* HTMLTrackElement::mediaElement() const
{
Element* parent = parentElement();
- if (parent && parent->isMediaElement())
- return toHTMLMediaElement(parentNode());
+ if (is<HTMLMediaElement>(parent))
+ return downcast<HTMLMediaElement>(parentNode());
- return 0;
+ return nullptr;
}
-#if ENABLE(MICRODATA)
-String HTMLTrackElement::itemValueText() const
-{
- return getURLAttribute(srcAttr);
-}
-
-void HTMLTrackElement::setItemValueText(const String& value, ExceptionCode&)
-{
- setAttribute(srcAttr, value);
-}
-#endif
-
}
#endif