alexis.menard@openbossa.org | d41eb53 | 2011-04-11 23:11:00 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions |
| 6 | * are met: |
| 7 | * 1. Redistributions of source code must retain the above copyright |
| 8 | * notice, this list of conditions and the following disclaimer. |
| 9 | * 2. Redistributions in binary form must reproduce the above copyright |
| 10 | * notice, this list of conditions and the following disclaimer in the |
| 11 | * documentation and/or other materials provided with the distribution. |
| 12 | * |
| 13 | * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
| 14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
| 17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 | */ |
| 25 | |
beidson@apple.com | 0347970 | 2011-04-12 00:11:44 +0000 | [diff] [blame] | 26 | #include "config.h" |
alexis.menard@openbossa.org | d41eb53 | 2011-04-11 23:11:00 +0000 | [diff] [blame] | 27 | |
commit-queue@webkit.org | aa4244a | 2011-04-15 07:13:49 +0000 | [diff] [blame] | 28 | #if ENABLE(VIDEO_TRACK) |
alexis.menard@openbossa.org | d41eb53 | 2011-04-11 23:11:00 +0000 | [diff] [blame] | 29 | #include "HTMLTrackElement.h" |
| 30 | |
eric.carlson@apple.com | e3f1e6d | 2011-12-05 15:38:11 +0000 | [diff] [blame] | 31 | #include "ContentSecurityPolicy.h" |
eric.carlson@apple.com | ac33ead | 2011-10-18 17:34:27 +0000 | [diff] [blame] | 32 | #include "Event.h" |
alexis.menard@openbossa.org | d41eb53 | 2011-04-11 23:11:00 +0000 | [diff] [blame] | 33 | #include "HTMLMediaElement.h" |
| 34 | #include "HTMLNames.h" |
| 35 | #include "Logging.h" |
eric.carlson@apple.com | 5c26c75 | 2011-11-11 17:33:51 +0000 | [diff] [blame] | 36 | #include "RuntimeEnabledFeatures.h" |
annacc@chromium.org | b6ae44b | 2011-10-31 16:35:56 +0000 | [diff] [blame] | 37 | #include "ScriptEventListener.h" |
alexis.menard@openbossa.org | d41eb53 | 2011-04-11 23:11:00 +0000 | [diff] [blame] | 38 | |
| 39 | using namespace std; |
| 40 | |
| 41 | namespace WebCore { |
| 42 | |
| 43 | using namespace HTMLNames; |
| 44 | |
eric.carlson@apple.com | e3f1e6d | 2011-12-05 15:38:11 +0000 | [diff] [blame] | 45 | #if !LOG_DISABLED |
| 46 | static String urlForLogging(const KURL& url) |
| 47 | { |
| 48 | static const unsigned maximumURLLengthForLogging = 128; |
| 49 | |
| 50 | if (url.string().length() < maximumURLLengthForLogging) |
| 51 | return url.string(); |
| 52 | return url.string().substring(0, maximumURLLengthForLogging) + "..."; |
| 53 | } |
| 54 | #endif |
| 55 | |
alexis.menard@openbossa.org | d41eb53 | 2011-04-11 23:11:00 +0000 | [diff] [blame] | 56 | inline HTMLTrackElement::HTMLTrackElement(const QualifiedName& tagName, Document* document) |
| 57 | : HTMLElement(tagName, document) |
eric.carlson@apple.com | 456a0c4 | 2011-12-15 19:18:54 +0000 | [diff] [blame] | 58 | , m_hasBeenConfigured(false) |
alexis.menard@openbossa.org | d41eb53 | 2011-04-11 23:11:00 +0000 | [diff] [blame] | 59 | { |
| 60 | LOG(Media, "HTMLTrackElement::HTMLTrackElement - %p", this); |
| 61 | ASSERT(hasTagName(trackTag)); |
| 62 | } |
| 63 | |
hclam@chromium.org | 6f06824 | 2011-06-24 23:06:01 +0000 | [diff] [blame] | 64 | HTMLTrackElement::~HTMLTrackElement() |
| 65 | { |
eric.carlson@apple.com | 5c26c75 | 2011-11-11 17:33:51 +0000 | [diff] [blame] | 66 | if (m_track) |
| 67 | m_track->clearClient(); |
hclam@chromium.org | 6f06824 | 2011-06-24 23:06:01 +0000 | [diff] [blame] | 68 | } |
| 69 | |
alexis.menard@openbossa.org | d41eb53 | 2011-04-11 23:11:00 +0000 | [diff] [blame] | 70 | PassRefPtr<HTMLTrackElement> HTMLTrackElement::create(const QualifiedName& tagName, Document* document) |
| 71 | { |
| 72 | return adoptRef(new HTMLTrackElement(tagName, document)); |
| 73 | } |
| 74 | |
darin@apple.com | 183547b | 2012-05-23 16:56:33 +0000 | [diff] [blame] | 75 | Node::InsertionNotificationRequest HTMLTrackElement::insertedInto(ContainerNode* insertionPoint) |
alexis.menard@openbossa.org | d41eb53 | 2011-04-11 23:11:00 +0000 | [diff] [blame] | 76 | { |
commit-queue@webkit.org | 9ea0080 | 2012-04-17 06:40:55 +0000 | [diff] [blame] | 77 | HTMLElement::insertedInto(insertionPoint); |
| 78 | if (insertionPoint->inDocument()) { |
| 79 | if (HTMLMediaElement* parent = mediaElement()) |
| 80 | parent->didAddTrack(this); |
| 81 | } |
eric.carlson@apple.com | 5c26c75 | 2011-11-11 17:33:51 +0000 | [diff] [blame] | 82 | |
commit-queue@webkit.org | 9ea0080 | 2012-04-17 06:40:55 +0000 | [diff] [blame] | 83 | return InsertionDone; |
alexis.menard@openbossa.org | d41eb53 | 2011-04-11 23:11:00 +0000 | [diff] [blame] | 84 | } |
| 85 | |
darin@apple.com | 183547b | 2012-05-23 16:56:33 +0000 | [diff] [blame] | 86 | void HTMLTrackElement::removedFrom(ContainerNode* insertionPoint) |
alexis.menard@openbossa.org | d41eb53 | 2011-04-11 23:11:00 +0000 | [diff] [blame] | 87 | { |
morrita@google.com | 1b44b4d | 2012-05-10 11:37:09 +0000 | [diff] [blame] | 88 | HTMLMediaElement* parent = mediaElement(); |
| 89 | if (!parent && WebCore::isMediaElement(insertionPoint)) |
| 90 | parent = toMediaElement(insertionPoint); |
| 91 | if (parent) |
eric.carlson@apple.com | 35424bc | 2012-03-21 18:28:48 +0000 | [diff] [blame] | 92 | parent->willRemoveTrack(this); |
eric.carlson@apple.com | 5c26c75 | 2011-11-11 17:33:51 +0000 | [diff] [blame] | 93 | |
morrita@google.com | 1b44b4d | 2012-05-10 11:37:09 +0000 | [diff] [blame] | 94 | HTMLElement::removedFrom(insertionPoint); |
annacc@chromium.org | 6896b34 | 2011-10-28 17:54:32 +0000 | [diff] [blame] | 95 | } |
| 96 | |
kling@webkit.org | 260fca8 | 2012-05-16 00:34:16 +0000 | [diff] [blame] | 97 | void HTMLTrackElement::parseAttribute(const Attribute& attribute) |
annacc@chromium.org | b6ae44b | 2011-10-31 16:35:56 +0000 | [diff] [blame] | 98 | { |
kling@webkit.org | cea5fce | 2012-02-18 19:58:57 +0000 | [diff] [blame] | 99 | if (RuntimeEnabledFeatures::webkitVideoTrackEnabled()) { |
kling@webkit.org | 260fca8 | 2012-05-16 00:34:16 +0000 | [diff] [blame] | 100 | if (attribute.name() == srcAttr) { |
| 101 | if (!attribute.isEmpty() && mediaElement()) |
kling@webkit.org | cea5fce | 2012-02-18 19:58:57 +0000 | [diff] [blame] | 102 | scheduleLoad(); |
| 103 | // 4.8.10.12.3 Sourcing out-of-band text tracks |
| 104 | // As the kind, label, and srclang attributes are set, changed, or removed, the text track must update accordingly... |
kling@webkit.org | 260fca8 | 2012-05-16 00:34:16 +0000 | [diff] [blame] | 105 | } else if (attribute.name() == kindAttr) |
| 106 | track()->setKind(attribute.value()); |
| 107 | else if (attribute.name() == labelAttr) |
| 108 | track()->setLabel(attribute.value()); |
| 109 | else if (attribute.name() == srclangAttr) |
| 110 | track()->setLanguage(attribute.value()); |
kling@webkit.org | cea5fce | 2012-02-18 19:58:57 +0000 | [diff] [blame] | 111 | } |
| 112 | |
kling@webkit.org | 260fca8 | 2012-05-16 00:34:16 +0000 | [diff] [blame] | 113 | if (attribute.name() == onloadAttr) |
annacc@chromium.org | b6ae44b | 2011-10-31 16:35:56 +0000 | [diff] [blame] | 114 | setAttributeEventListener(eventNames().loadEvent, createAttributeEventListener(this, attribute)); |
kling@webkit.org | 260fca8 | 2012-05-16 00:34:16 +0000 | [diff] [blame] | 115 | else if (attribute.name() == onerrorAttr) |
annacc@chromium.org | b6ae44b | 2011-10-31 16:35:56 +0000 | [diff] [blame] | 116 | setAttributeEventListener(eventNames().errorEvent, createAttributeEventListener(this, attribute)); |
| 117 | else |
kling@webkit.org | 8a3d4af | 2012-02-06 02:21:57 +0000 | [diff] [blame] | 118 | HTMLElement::parseAttribute(attribute); |
annacc@chromium.org | b6ae44b | 2011-10-31 16:35:56 +0000 | [diff] [blame] | 119 | } |
| 120 | |
alexis.menard@openbossa.org | d41eb53 | 2011-04-11 23:11:00 +0000 | [diff] [blame] | 121 | KURL HTMLTrackElement::src() const |
| 122 | { |
commit-queue@webkit.org | 03477c8 | 2011-09-02 17:07:51 +0000 | [diff] [blame] | 123 | return document()->completeURL(getAttribute(srcAttr)); |
alexis.menard@openbossa.org | d41eb53 | 2011-04-11 23:11:00 +0000 | [diff] [blame] | 124 | } |
| 125 | |
| 126 | void HTMLTrackElement::setSrc(const String& url) |
| 127 | { |
| 128 | setAttribute(srcAttr, url); |
| 129 | } |
| 130 | |
eric.carlson@apple.com | 892b711 | 2011-11-16 16:05:45 +0000 | [diff] [blame] | 131 | String HTMLTrackElement::kind() |
alexis.menard@openbossa.org | d41eb53 | 2011-04-11 23:11:00 +0000 | [diff] [blame] | 132 | { |
eric.carlson@apple.com | 892b711 | 2011-11-16 16:05:45 +0000 | [diff] [blame] | 133 | return track()->kind(); |
alexis.menard@openbossa.org | d41eb53 | 2011-04-11 23:11:00 +0000 | [diff] [blame] | 134 | } |
| 135 | |
| 136 | void HTMLTrackElement::setKind(const String& kind) |
| 137 | { |
| 138 | setAttribute(kindAttr, kind); |
| 139 | } |
| 140 | |
| 141 | String HTMLTrackElement::srclang() const |
| 142 | { |
commit-queue@webkit.org | 03477c8 | 2011-09-02 17:07:51 +0000 | [diff] [blame] | 143 | return getAttribute(srclangAttr); |
alexis.menard@openbossa.org | d41eb53 | 2011-04-11 23:11:00 +0000 | [diff] [blame] | 144 | } |
| 145 | |
| 146 | void HTMLTrackElement::setSrclang(const String& srclang) |
| 147 | { |
| 148 | setAttribute(srclangAttr, srclang); |
| 149 | } |
| 150 | |
| 151 | String HTMLTrackElement::label() const |
| 152 | { |
commit-queue@webkit.org | 03477c8 | 2011-09-02 17:07:51 +0000 | [diff] [blame] | 153 | return getAttribute(labelAttr); |
alexis.menard@openbossa.org | d41eb53 | 2011-04-11 23:11:00 +0000 | [diff] [blame] | 154 | } |
| 155 | |
| 156 | void HTMLTrackElement::setLabel(const String& label) |
| 157 | { |
| 158 | setAttribute(labelAttr, label); |
| 159 | } |
| 160 | |
| 161 | bool HTMLTrackElement::isDefault() const |
| 162 | { |
eric.carlson@apple.com | 5c26c75 | 2011-11-11 17:33:51 +0000 | [diff] [blame] | 163 | return fastHasAttribute(defaultAttr); |
alexis.menard@openbossa.org | d41eb53 | 2011-04-11 23:11:00 +0000 | [diff] [blame] | 164 | } |
| 165 | |
| 166 | void HTMLTrackElement::setIsDefault(bool isDefault) |
| 167 | { |
| 168 | setBooleanAttribute(defaultAttr, isDefault); |
| 169 | } |
| 170 | |
eric.carlson@apple.com | 5c26c75 | 2011-11-11 17:33:51 +0000 | [diff] [blame] | 171 | LoadableTextTrack* HTMLTrackElement::ensureTrack() |
annacc@chromium.org | ef5d1dc | 2011-10-20 02:53:38 +0000 | [diff] [blame] | 172 | { |
eric.carlson@apple.com | 892b711 | 2011-11-16 16:05:45 +0000 | [diff] [blame] | 173 | if (!m_track) { |
| 174 | // The kind attribute is an enumerated attribute, limited only to know values. It defaults to 'subtitles' if missing or invalid. |
| 175 | String kind = getAttribute(kindAttr); |
| 176 | if (!TextTrack::isValidKindKeyword(kind)) |
| 177 | kind = TextTrack::subtitlesKeyword(); |
| 178 | m_track = LoadableTextTrack::create(this, kind, label(), srclang(), isDefault()); |
| 179 | } |
eric.carlson@apple.com | 5c26c75 | 2011-11-11 17:33:51 +0000 | [diff] [blame] | 180 | return m_track.get(); |
| 181 | } |
| 182 | |
| 183 | TextTrack* HTMLTrackElement::track() |
| 184 | { |
| 185 | return ensureTrack(); |
annacc@chromium.org | ef5d1dc | 2011-10-20 02:53:38 +0000 | [diff] [blame] | 186 | } |
| 187 | |
kling@webkit.org | d8a6d15 | 2012-05-08 16:27:04 +0000 | [diff] [blame] | 188 | bool HTMLTrackElement::isURLAttribute(const Attribute& attribute) const |
alexis.menard@openbossa.org | d41eb53 | 2011-04-11 23:11:00 +0000 | [diff] [blame] | 189 | { |
kling@webkit.org | d8a6d15 | 2012-05-08 16:27:04 +0000 | [diff] [blame] | 190 | return attribute.name() == srcAttr || HTMLElement::isURLAttribute(attribute); |
alexis.menard@openbossa.org | d41eb53 | 2011-04-11 23:11:00 +0000 | [diff] [blame] | 191 | } |
| 192 | |
eric.carlson@apple.com | 5c26c75 | 2011-11-11 17:33:51 +0000 | [diff] [blame] | 193 | void HTMLTrackElement::scheduleLoad() |
hclam@chromium.org | 6f06824 | 2011-06-24 23:06:01 +0000 | [diff] [blame] | 194 | { |
eric.carlson@apple.com | 7010aef | 2011-11-26 04:28:39 +0000 | [diff] [blame] | 195 | if (!RuntimeEnabledFeatures::webkitVideoTrackEnabled()) |
| 196 | return; |
| 197 | |
eric.carlson@apple.com | 5c26c75 | 2011-11-11 17:33:51 +0000 | [diff] [blame] | 198 | if (!mediaElement()) |
| 199 | return; |
hclam@chromium.org | 6f06824 | 2011-06-24 23:06:01 +0000 | [diff] [blame] | 200 | |
eric.carlson@apple.com | 5c26c75 | 2011-11-11 17:33:51 +0000 | [diff] [blame] | 201 | if (!fastHasAttribute(srcAttr)) |
| 202 | return; |
| 203 | |
eric.carlson@apple.com | e3f1e6d | 2011-12-05 15:38:11 +0000 | [diff] [blame] | 204 | // 4.8.10.12.3 Sourcing out-of-band text tracks |
| 205 | |
| 206 | // 1. Set the text track readiness state to loading. |
| 207 | setReadyState(HTMLTrackElement::LOADING); |
| 208 | |
| 209 | KURL url = getNonEmptyURLAttribute(srcAttr); |
| 210 | if (!canLoadUrl(url)) { |
| 211 | didCompleteLoad(ensureTrack(), HTMLTrackElement::Failure); |
| 212 | return; |
| 213 | } |
| 214 | |
| 215 | ensureTrack()->scheduleLoad(url); |
hclam@chromium.org | 6f06824 | 2011-06-24 23:06:01 +0000 | [diff] [blame] | 216 | } |
| 217 | |
eric.carlson@apple.com | e3f1e6d | 2011-12-05 15:38:11 +0000 | [diff] [blame] | 218 | bool HTMLTrackElement::canLoadUrl(const KURL& url) |
eric.carlson@apple.com | 5c26c75 | 2011-11-11 17:33:51 +0000 | [diff] [blame] | 219 | { |
eric.carlson@apple.com | 7010aef | 2011-11-26 04:28:39 +0000 | [diff] [blame] | 220 | if (!RuntimeEnabledFeatures::webkitVideoTrackEnabled()) |
| 221 | return false; |
| 222 | |
eric.carlson@apple.com | 5c26c75 | 2011-11-11 17:33:51 +0000 | [diff] [blame] | 223 | HTMLMediaElement* parent = mediaElement(); |
| 224 | if (!parent) |
| 225 | return false; |
| 226 | |
eric.carlson@apple.com | e3f1e6d | 2011-12-05 15:38:11 +0000 | [diff] [blame] | 227 | // 4.8.10.12.3 Sourcing out-of-band text tracks |
| 228 | |
| 229 | // 4. Download: If URL is not the empty string, perform a potentially CORS-enabled fetch of URL, with the |
| 230 | // mode being the state of the media element's crossorigin content attribute, the origin being the |
| 231 | // origin of the media element's Document, and the default origin behaviour set to fail. |
| 232 | if (url.isEmpty()) |
eric.carlson@apple.com | 5c26c75 | 2011-11-11 17:33:51 +0000 | [diff] [blame] | 233 | return false; |
eric.carlson@apple.com | e3f1e6d | 2011-12-05 15:38:11 +0000 | [diff] [blame] | 234 | |
| 235 | if (!document()->contentSecurityPolicy()->allowMediaFromSource(url)) { |
| 236 | DEFINE_STATIC_LOCAL(String, consoleMessage, ("Text track load denied by Content Security Policy.")); |
| 237 | document()->addConsoleMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, consoleMessage); |
| 238 | LOG(Media, "HTMLTrackElement::canLoadUrl(%s) -> rejected by Content Security Policy", urlForLogging(url).utf8().data()); |
| 239 | return false; |
| 240 | } |
eric.carlson@apple.com | 5c26c75 | 2011-11-11 17:33:51 +0000 | [diff] [blame] | 241 | |
| 242 | return dispatchBeforeLoadEvent(url.string()); |
| 243 | } |
| 244 | |
eric.carlson@apple.com | e3f1e6d | 2011-12-05 15:38:11 +0000 | [diff] [blame] | 245 | void HTMLTrackElement::didCompleteLoad(LoadableTextTrack*, LoadStatus status) |
eric.carlson@apple.com | ac33ead | 2011-10-18 17:34:27 +0000 | [diff] [blame] | 246 | { |
| 247 | ExceptionCode ec = 0; |
eric.carlson@apple.com | e3f1e6d | 2011-12-05 15:38:11 +0000 | [diff] [blame] | 248 | |
| 249 | // 4.8.10.12.3 Sourcing out-of-band text tracks (continued) |
| 250 | |
| 251 | // 4. Download: ... |
| 252 | // If the fetching algorithm fails for any reason (network error, the server returns an error |
| 253 | // code, a cross-origin check fails, etc), or if URL is the empty string or has the wrong origin |
| 254 | // as determined by the condition at the start of this step, or if the fetched resource is not in |
| 255 | // a supported format, then queue a task to first change the text track readiness state to failed |
| 256 | // to load and then fire a simple event named error at the track element; and then, once that task |
| 257 | // is queued, move on to the step below labeled monitoring. |
| 258 | |
| 259 | if (status == Failure) { |
| 260 | setReadyState(HTMLTrackElement::TRACK_ERROR); |
| 261 | dispatchEvent(Event::create(eventNames().errorEvent, false, false), ec); |
| 262 | return; |
| 263 | } |
| 264 | |
| 265 | // If the fetching algorithm does not fail, then the final task that is queued by the networking |
| 266 | // task source must run the following steps: |
| 267 | // 1. Change the text track readiness state to loaded. |
| 268 | setReadyState(HTMLTrackElement::LOADED); |
| 269 | |
| 270 | // 2. If the file was successfully processed, fire a simple event named load at the |
| 271 | // track element. |
| 272 | dispatchEvent(Event::create(eventNames().loadEvent, false, false), ec); |
eric.carlson@apple.com | ac33ead | 2011-10-18 17:34:27 +0000 | [diff] [blame] | 273 | } |
annacc@chromium.org | 333ded8 | 2011-11-27 23:25:52 +0000 | [diff] [blame] | 274 | |
eric.carlson@apple.com | 0fa3f58 | 2011-12-01 16:42:49 +0000 | [diff] [blame] | 275 | // NOTE: The values in the TextTrack::ReadinessState enum must stay in sync with those in HTMLTrackElement::ReadyState. |
| 276 | COMPILE_ASSERT(HTMLTrackElement::NONE == static_cast<HTMLTrackElement::ReadyState>(TextTrack::NotLoaded), TextTrackEnumNotLoaded_Is_Wrong_Should_Be_HTMLTrackElementEnumNONE); |
| 277 | COMPILE_ASSERT(HTMLTrackElement::LOADING == static_cast<HTMLTrackElement::ReadyState>(TextTrack::Loading), TextTrackEnumLoadingIsWrong_ShouldBe_HTMLTrackElementEnumLOADING); |
| 278 | COMPILE_ASSERT(HTMLTrackElement::LOADED == static_cast<HTMLTrackElement::ReadyState>(TextTrack::Loaded), TextTrackEnumLoaded_Is_Wrong_Should_Be_HTMLTrackElementEnumLOADED); |
| 279 | COMPILE_ASSERT(HTMLTrackElement::TRACK_ERROR == static_cast<HTMLTrackElement::ReadyState>(TextTrack::FailedToLoad), TextTrackEnumFailedToLoad_Is_Wrong_Should_Be_HTMLTrackElementEnumTRACK_ERROR); |
| 280 | |
annacc@chromium.org | 333ded8 | 2011-11-27 23:25:52 +0000 | [diff] [blame] | 281 | void HTMLTrackElement::setReadyState(ReadyState state) |
eric.carlson@apple.com | 5c26c75 | 2011-11-11 17:33:51 +0000 | [diff] [blame] | 282 | { |
eric.carlson@apple.com | 0fa3f58 | 2011-12-01 16:42:49 +0000 | [diff] [blame] | 283 | ensureTrack()->setReadinessState(static_cast<TextTrack::ReadinessState>(state)); |
eric.carlson@apple.com | 5c26c75 | 2011-11-11 17:33:51 +0000 | [diff] [blame] | 284 | if (HTMLMediaElement* parent = mediaElement()) |
annacc@chromium.org | 333ded8 | 2011-11-27 23:25:52 +0000 | [diff] [blame] | 285 | return parent->textTrackReadyStateChanged(m_track.get()); |
eric.carlson@apple.com | 5c26c75 | 2011-11-11 17:33:51 +0000 | [diff] [blame] | 286 | } |
eric.carlson@apple.com | 0fa3f58 | 2011-12-01 16:42:49 +0000 | [diff] [blame] | 287 | |
| 288 | HTMLTrackElement::ReadyState HTMLTrackElement::readyState() |
| 289 | { |
| 290 | return static_cast<ReadyState>(ensureTrack()->readinessState()); |
| 291 | } |
eric.carlson@apple.com | e3f1e6d | 2011-12-05 15:38:11 +0000 | [diff] [blame] | 292 | |
| 293 | const AtomicString& HTMLTrackElement::mediaElementCrossOriginAttribute() const |
| 294 | { |
| 295 | if (HTMLMediaElement* parent = mediaElement()) |
| 296 | return parent->fastGetAttribute(HTMLNames::crossoriginAttr); |
eric.carlson@apple.com | 5c26c75 | 2011-11-11 17:33:51 +0000 | [diff] [blame] | 297 | |
eric.carlson@apple.com | e3f1e6d | 2011-12-05 15:38:11 +0000 | [diff] [blame] | 298 | return nullAtom; |
| 299 | } |
| 300 | |
eric.carlson@apple.com | 892b711 | 2011-11-16 16:05:45 +0000 | [diff] [blame] | 301 | void HTMLTrackElement::textTrackKindChanged(TextTrack* track) |
| 302 | { |
| 303 | if (HTMLMediaElement* parent = mediaElement()) |
| 304 | return parent->textTrackKindChanged(track); |
| 305 | } |
| 306 | |
eric.carlson@apple.com | 5c26c75 | 2011-11-11 17:33:51 +0000 | [diff] [blame] | 307 | void HTMLTrackElement::textTrackModeChanged(TextTrack* track) |
| 308 | { |
| 309 | if (HTMLMediaElement* parent = mediaElement()) |
| 310 | return parent->textTrackModeChanged(track); |
| 311 | } |
eric.carlson@apple.com | 892b711 | 2011-11-16 16:05:45 +0000 | [diff] [blame] | 312 | |
eric.carlson@apple.com | 5c26c75 | 2011-11-11 17:33:51 +0000 | [diff] [blame] | 313 | void HTMLTrackElement::textTrackAddCues(TextTrack* track, const TextTrackCueList* cues) |
| 314 | { |
| 315 | if (HTMLMediaElement* parent = mediaElement()) |
| 316 | return parent->textTrackAddCues(track, cues); |
| 317 | } |
| 318 | |
| 319 | void HTMLTrackElement::textTrackRemoveCues(TextTrack* track, const TextTrackCueList* cues) |
| 320 | { |
| 321 | if (HTMLMediaElement* parent = mediaElement()) |
annacc@chromium.org | 729c40e | 2012-04-12 20:29:50 +0000 | [diff] [blame] | 322 | return parent->textTrackRemoveCues(track, cues); |
eric.carlson@apple.com | 5c26c75 | 2011-11-11 17:33:51 +0000 | [diff] [blame] | 323 | } |
| 324 | |
| 325 | void HTMLTrackElement::textTrackAddCue(TextTrack* track, PassRefPtr<TextTrackCue> cue) |
| 326 | { |
| 327 | if (HTMLMediaElement* parent = mediaElement()) |
| 328 | return parent->textTrackAddCue(track, cue); |
| 329 | } |
| 330 | |
| 331 | void HTMLTrackElement::textTrackRemoveCue(TextTrack* track, PassRefPtr<TextTrackCue> cue) |
| 332 | { |
| 333 | if (HTMLMediaElement* parent = mediaElement()) |
| 334 | return parent->textTrackRemoveCue(track, cue); |
| 335 | } |
| 336 | |
| 337 | HTMLMediaElement* HTMLTrackElement::mediaElement() const |
| 338 | { |
| 339 | Element* parent = parentElement(); |
| 340 | if (parent && parent->isMediaElement()) |
| 341 | return static_cast<HTMLMediaElement*>(parentNode()); |
| 342 | |
| 343 | return 0; |
| 344 | } |
rniwa@webkit.org | d10f670 | 2011-10-25 00:13:34 +0000 | [diff] [blame] | 345 | |
| 346 | #if ENABLE(MICRODATA) |
| 347 | String HTMLTrackElement::itemValueText() const |
| 348 | { |
| 349 | return getURLAttribute(srcAttr); |
| 350 | } |
| 351 | |
commit-queue@webkit.org | 7feb953 | 2012-01-24 01:36:56 +0000 | [diff] [blame] | 352 | void HTMLTrackElement::setItemValueText(const String& value, ExceptionCode&) |
rniwa@webkit.org | d10f670 | 2011-10-25 00:13:34 +0000 | [diff] [blame] | 353 | { |
commit-queue@webkit.org | 7feb953 | 2012-01-24 01:36:56 +0000 | [diff] [blame] | 354 | setAttribute(srcAttr, value); |
rniwa@webkit.org | d10f670 | 2011-10-25 00:13:34 +0000 | [diff] [blame] | 355 | } |
| 356 | #endif |
| 357 | |
alexis.menard@openbossa.org | d41eb53 | 2011-04-11 23:11:00 +0000 | [diff] [blame] | 358 | } |
| 359 | |
| 360 | #endif |