OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 16 matching lines...) Expand all Loading... |
27 | 27 |
28 #include "core/HTMLNames.h" | 28 #include "core/HTMLNames.h" |
29 #include "core/dom/Document.h" | 29 #include "core/dom/Document.h" |
30 #include "core/events/Event.h" | 30 #include "core/events/Event.h" |
31 #include "core/frame/csp/ContentSecurityPolicy.h" | 31 #include "core/frame/csp/ContentSecurityPolicy.h" |
32 #include "core/html/CrossOriginAttribute.h" | 32 #include "core/html/CrossOriginAttribute.h" |
33 #include "core/html/HTMLMediaElement.h" | 33 #include "core/html/HTMLMediaElement.h" |
34 #include "core/html/track/LoadableTextTrack.h" | 34 #include "core/html/track/LoadableTextTrack.h" |
35 #include "platform/Logging.h" | 35 #include "platform/Logging.h" |
36 | 36 |
| 37 #define TRACK_LOG_LEVEL 3 |
| 38 |
37 namespace blink { | 39 namespace blink { |
38 | 40 |
39 using namespace HTMLNames; | 41 using namespace HTMLNames; |
40 | 42 |
41 #if !LOG_DISABLED | |
42 static String urlForLoggingTrack(const KURL& url) | 43 static String urlForLoggingTrack(const KURL& url) |
43 { | 44 { |
44 static const unsigned maximumURLLengthForLogging = 128; | 45 static const unsigned maximumURLLengthForLogging = 128; |
45 | 46 |
46 if (url.getString().length() < maximumURLLengthForLogging) | 47 if (url.getString().length() < maximumURLLengthForLogging) |
47 return url.getString(); | 48 return url.getString(); |
48 return url.getString().substring(0, maximumURLLengthForLogging) + "..."; | 49 return url.getString().substring(0, maximumURLLengthForLogging) + "..."; |
49 } | 50 } |
50 #endif | |
51 | 51 |
52 inline HTMLTrackElement::HTMLTrackElement(Document& document) | 52 inline HTMLTrackElement::HTMLTrackElement(Document& document) |
53 : HTMLElement(trackTag, document) | 53 : HTMLElement(trackTag, document) |
54 , m_loadTimer(this, &HTMLTrackElement::loadTimerFired) | 54 , m_loadTimer(this, &HTMLTrackElement::loadTimerFired) |
55 { | 55 { |
56 WTF_LOG(Media, "HTMLTrackElement::HTMLTrackElement - %p", this); | 56 DVLOG(TRACK_LOG_LEVEL) << "HTMLTrackElement - " << (void*)this; |
57 } | 57 } |
58 | 58 |
59 DEFINE_NODE_FACTORY(HTMLTrackElement) | 59 DEFINE_NODE_FACTORY(HTMLTrackElement) |
60 | 60 |
61 HTMLTrackElement::~HTMLTrackElement() | 61 HTMLTrackElement::~HTMLTrackElement() |
62 { | 62 { |
63 } | 63 } |
64 | 64 |
65 Node::InsertionNotificationRequest HTMLTrackElement::insertedInto(ContainerNode*
insertionPoint) | 65 Node::InsertionNotificationRequest HTMLTrackElement::insertedInto(ContainerNode*
insertionPoint) |
66 { | 66 { |
67 WTF_LOG(Media, "HTMLTrackElement::insertedInto"); | 67 DVLOG(TRACK_LOG_LEVEL) << "insertedInto"; |
68 | 68 |
69 // Since we've moved to a new parent, we may now be able to load. | 69 // Since we've moved to a new parent, we may now be able to load. |
70 scheduleLoad(); | 70 scheduleLoad(); |
71 | 71 |
72 HTMLElement::insertedInto(insertionPoint); | 72 HTMLElement::insertedInto(insertionPoint); |
73 HTMLMediaElement* parent = mediaElement(); | 73 HTMLMediaElement* parent = mediaElement(); |
74 if (insertionPoint == parent) | 74 if (insertionPoint == parent) |
75 parent->didAddTrackElement(this); | 75 parent->didAddTrackElement(this); |
76 return InsertionDone; | 76 return InsertionDone; |
77 } | 77 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 return ensureTrack(); | 138 return ensureTrack(); |
139 } | 139 } |
140 | 140 |
141 bool HTMLTrackElement::isURLAttribute(const Attribute& attribute) const | 141 bool HTMLTrackElement::isURLAttribute(const Attribute& attribute) const |
142 { | 142 { |
143 return attribute.name() == srcAttr || HTMLElement::isURLAttribute(attribute)
; | 143 return attribute.name() == srcAttr || HTMLElement::isURLAttribute(attribute)
; |
144 } | 144 } |
145 | 145 |
146 void HTMLTrackElement::scheduleLoad() | 146 void HTMLTrackElement::scheduleLoad() |
147 { | 147 { |
148 WTF_LOG(Media, "HTMLTrackElement::scheduleLoad"); | 148 DVLOG(TRACK_LOG_LEVEL) << "scheduleLoad"; |
149 | 149 |
150 // 1. If another occurrence of this algorithm is already running for this te
xt track and its track element, | 150 // 1. If another occurrence of this algorithm is already running for this te
xt track and its track element, |
151 // abort these steps, letting that other algorithm take care of this element
. | 151 // abort these steps, letting that other algorithm take care of this element
. |
152 if (m_loadTimer.isActive()) | 152 if (m_loadTimer.isActive()) |
153 return; | 153 return; |
154 | 154 |
155 // 2. If the text track's text track mode is not set to one of hidden or sho
wing, abort these steps. | 155 // 2. If the text track's text track mode is not set to one of hidden or sho
wing, abort these steps. |
156 if (ensureTrack()->mode() != TextTrack::hiddenKeyword() && ensureTrack()->mo
de() != TextTrack::showingKeyword()) | 156 if (ensureTrack()->mode() != TextTrack::hiddenKeyword() && ensureTrack()->mo
de() != TextTrack::showingKeyword()) |
157 return; | 157 return; |
158 | 158 |
159 // 3. If the text track's track element does not have a media element as a p
arent, abort these steps. | 159 // 3. If the text track's track element does not have a media element as a p
arent, abort these steps. |
160 if (!mediaElement()) | 160 if (!mediaElement()) |
161 return; | 161 return; |
162 | 162 |
163 // 4. Run the remainder of these steps in parallel, allowing whatever caused
these steps to run to continue. | 163 // 4. Run the remainder of these steps in parallel, allowing whatever caused
these steps to run to continue. |
164 m_loadTimer.startOneShot(0, BLINK_FROM_HERE); | 164 m_loadTimer.startOneShot(0, BLINK_FROM_HERE); |
165 | 165 |
166 // 5. Top: Await a stable state. The synchronous section consists of the fol
lowing steps. (The steps in the | 166 // 5. Top: Await a stable state. The synchronous section consists of the fol
lowing steps. (The steps in the |
167 // synchronous section are marked with [X]) | 167 // synchronous section are marked with [X]) |
168 // FIXME: We use a timer to approximate a "stable state" - i.e. this is not
100% per spec. | 168 // FIXME: We use a timer to approximate a "stable state" - i.e. this is not
100% per spec. |
169 } | 169 } |
170 | 170 |
171 void HTMLTrackElement::loadTimerFired(Timer<HTMLTrackElement>*) | 171 void HTMLTrackElement::loadTimerFired(Timer<HTMLTrackElement>*) |
172 { | 172 { |
173 WTF_LOG(Media, "HTMLTrackElement::loadTimerFired"); | 173 DVLOG(TRACK_LOG_LEVEL) << "loadTimerFired"; |
174 | 174 |
175 // 6. [X] Set the text track readiness state to loading. | 175 // 6. [X] Set the text track readiness state to loading. |
176 setReadyState(LOADING); | 176 setReadyState(LOADING); |
177 | 177 |
178 // 7. [X] Let URL be the track URL of the track element. | 178 // 7. [X] Let URL be the track URL of the track element. |
179 KURL url = getNonEmptyURLAttribute(srcAttr); | 179 KURL url = getNonEmptyURLAttribute(srcAttr); |
180 | 180 |
181 // 8. [X] If the track element's parent is a media element then let CORS mod
e be the state of the parent media | 181 // 8. [X] If the track element's parent is a media element then let CORS mod
e be the state of the parent media |
182 // element's crossorigin content attribute. Otherwise, let CORS mode be No C
ORS. | 182 // element's crossorigin content attribute. Otherwise, let CORS mode be No C
ORS. |
183 const AtomicString& corsMode = mediaElementCrossOriginAttribute(); | 183 const AtomicString& corsMode = mediaElementCrossOriginAttribute(); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 bool HTMLTrackElement::canLoadUrl(const KURL& url) | 224 bool HTMLTrackElement::canLoadUrl(const KURL& url) |
225 { | 225 { |
226 HTMLMediaElement* parent = mediaElement(); | 226 HTMLMediaElement* parent = mediaElement(); |
227 if (!parent) | 227 if (!parent) |
228 return false; | 228 return false; |
229 | 229 |
230 if (url.isEmpty()) | 230 if (url.isEmpty()) |
231 return false; | 231 return false; |
232 | 232 |
233 if (!document().contentSecurityPolicy()->allowMediaFromSource(url)) { | 233 if (!document().contentSecurityPolicy()->allowMediaFromSource(url)) { |
234 WTF_LOG(Media, "HTMLTrackElement::canLoadUrl(%s) -> rejected by Content
Security Policy", urlForLoggingTrack(url).utf8().data()); | 234 DVLOG(TRACK_LOG_LEVEL) << "canLoadUrl(" << urlForLoggingTrack(url) << ")
-> rejected by Content Security Policy"; |
235 return false; | 235 return false; |
236 } | 236 } |
237 | 237 |
238 return true; | 238 return true; |
239 } | 239 } |
240 | 240 |
241 void HTMLTrackElement::didCompleteLoad(LoadStatus status) | 241 void HTMLTrackElement::didCompleteLoad(LoadStatus status) |
242 { | 242 { |
243 // 10. ... (continued) | 243 // 10. ... (continued) |
244 | 244 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 } | 333 } |
334 | 334 |
335 DEFINE_TRACE(HTMLTrackElement) | 335 DEFINE_TRACE(HTMLTrackElement) |
336 { | 336 { |
337 visitor->trace(m_track); | 337 visitor->trace(m_track); |
338 visitor->trace(m_loader); | 338 visitor->trace(m_loader); |
339 HTMLElement::trace(visitor); | 339 HTMLElement::trace(visitor); |
340 } | 340 } |
341 | 341 |
342 } // namespace blink | 342 } // namespace blink |
OLD | NEW |