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 | 43 #if !LOG_DISABLED |
42 static String urlForLoggingTrack(const KURL& url) | 44 static String urlForLoggingTrack(const KURL& url) |
43 { | 45 { |
44 static const unsigned maximumURLLengthForLogging = 128; | 46 static const unsigned maximumURLLengthForLogging = 128; |
45 | 47 |
46 if (url.getString().length() < maximumURLLengthForLogging) | 48 if (url.getString().length() < maximumURLLengthForLogging) |
47 return url.getString(); | 49 return url.getString(); |
48 return url.getString().substring(0, maximumURLLengthForLogging) + "..."; | 50 return url.getString().substring(0, maximumURLLengthForLogging) + "..."; |
49 } | 51 } |
50 #endif | 52 #endif |
51 | 53 |
52 inline HTMLTrackElement::HTMLTrackElement(Document& document) | 54 inline HTMLTrackElement::HTMLTrackElement(Document& document) |
53 : HTMLElement(trackTag, document) | 55 : HTMLElement(trackTag, document) |
54 , m_loadTimer(this, &HTMLTrackElement::loadTimerFired) | 56 , m_loadTimer(this, &HTMLTrackElement::loadTimerFired) |
55 { | 57 { |
56 WTF_LOG(Media, "HTMLTrackElement::HTMLTrackElement - %p", this); | 58 DVLOG(TRACK_LOG_LEVEL) << "HTMLTrackElement - ", (void*)this; |
fs
2016/05/19 11:05:36
<< (not ,)
Srirama
2016/05/19 12:14:53
Done.
| |
57 } | 59 } |
58 | 60 |
59 DEFINE_NODE_FACTORY(HTMLTrackElement) | 61 DEFINE_NODE_FACTORY(HTMLTrackElement) |
60 | 62 |
61 HTMLTrackElement::~HTMLTrackElement() | 63 HTMLTrackElement::~HTMLTrackElement() |
62 { | 64 { |
63 } | 65 } |
64 | 66 |
65 Node::InsertionNotificationRequest HTMLTrackElement::insertedInto(ContainerNode* insertionPoint) | 67 Node::InsertionNotificationRequest HTMLTrackElement::insertedInto(ContainerNode* insertionPoint) |
66 { | 68 { |
67 WTF_LOG(Media, "HTMLTrackElement::insertedInto"); | 69 DVLOG(TRACK_LOG_LEVEL) << "insertedInto"; |
68 | 70 |
69 // Since we've moved to a new parent, we may now be able to load. | 71 // Since we've moved to a new parent, we may now be able to load. |
70 scheduleLoad(); | 72 scheduleLoad(); |
71 | 73 |
72 HTMLElement::insertedInto(insertionPoint); | 74 HTMLElement::insertedInto(insertionPoint); |
73 HTMLMediaElement* parent = mediaElement(); | 75 HTMLMediaElement* parent = mediaElement(); |
74 if (insertionPoint == parent) | 76 if (insertionPoint == parent) |
75 parent->didAddTrackElement(this); | 77 parent->didAddTrackElement(this); |
76 return InsertionDone; | 78 return InsertionDone; |
77 } | 79 } |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
130 return ensureTrack(); | 132 return ensureTrack(); |
131 } | 133 } |
132 | 134 |
133 bool HTMLTrackElement::isURLAttribute(const Attribute& attribute) const | 135 bool HTMLTrackElement::isURLAttribute(const Attribute& attribute) const |
134 { | 136 { |
135 return attribute.name() == srcAttr || HTMLElement::isURLAttribute(attribute) ; | 137 return attribute.name() == srcAttr || HTMLElement::isURLAttribute(attribute) ; |
136 } | 138 } |
137 | 139 |
138 void HTMLTrackElement::scheduleLoad() | 140 void HTMLTrackElement::scheduleLoad() |
139 { | 141 { |
140 WTF_LOG(Media, "HTMLTrackElement::scheduleLoad"); | 142 DVLOG(TRACK_LOG_LEVEL) << "scheduleLoad"; |
141 | 143 |
142 // 1. If another occurrence of this algorithm is already running for this te xt track and its track element, | 144 // 1. If another occurrence of this algorithm is already running for this te xt track and its track element, |
143 // abort these steps, letting that other algorithm take care of this element . | 145 // abort these steps, letting that other algorithm take care of this element . |
144 if (m_loadTimer.isActive()) | 146 if (m_loadTimer.isActive()) |
145 return; | 147 return; |
146 | 148 |
147 // 2. If the text track's text track mode is not set to one of hidden or sho wing, abort these steps. | 149 // 2. If the text track's text track mode is not set to one of hidden or sho wing, abort these steps. |
148 if (ensureTrack()->mode() != TextTrack::hiddenKeyword() && ensureTrack()->mo de() != TextTrack::showingKeyword()) | 150 if (ensureTrack()->mode() != TextTrack::hiddenKeyword() && ensureTrack()->mo de() != TextTrack::showingKeyword()) |
149 return; | 151 return; |
150 | 152 |
151 // 3. If the text track's track element does not have a media element as a p arent, abort these steps. | 153 // 3. If the text track's track element does not have a media element as a p arent, abort these steps. |
152 if (!mediaElement()) | 154 if (!mediaElement()) |
153 return; | 155 return; |
154 | 156 |
155 // 4. Run the remainder of these steps in parallel, allowing whatever caused these steps to run to continue. | 157 // 4. Run the remainder of these steps in parallel, allowing whatever caused these steps to run to continue. |
156 m_loadTimer.startOneShot(0, BLINK_FROM_HERE); | 158 m_loadTimer.startOneShot(0, BLINK_FROM_HERE); |
157 | 159 |
158 // 5. Top: Await a stable state. The synchronous section consists of the fol lowing steps. (The steps in the | 160 // 5. Top: Await a stable state. The synchronous section consists of the fol lowing steps. (The steps in the |
159 // synchronous section are marked with [X]) | 161 // synchronous section are marked with [X]) |
160 // FIXME: We use a timer to approximate a "stable state" - i.e. this is not 100% per spec. | 162 // FIXME: We use a timer to approximate a "stable state" - i.e. this is not 100% per spec. |
161 } | 163 } |
162 | 164 |
163 void HTMLTrackElement::loadTimerFired(Timer<HTMLTrackElement>*) | 165 void HTMLTrackElement::loadTimerFired(Timer<HTMLTrackElement>*) |
164 { | 166 { |
165 WTF_LOG(Media, "HTMLTrackElement::loadTimerFired"); | 167 DVLOG(TRACK_LOG_LEVEL) << "loadTimerFired"; |
166 | 168 |
167 // 6. [X] Set the text track readiness state to loading. | 169 // 6. [X] Set the text track readiness state to loading. |
168 setReadyState(LOADING); | 170 setReadyState(LOADING); |
169 | 171 |
170 // 7. [X] Let URL be the track URL of the track element. | 172 // 7. [X] Let URL be the track URL of the track element. |
171 KURL url = getNonEmptyURLAttribute(srcAttr); | 173 KURL url = getNonEmptyURLAttribute(srcAttr); |
172 | 174 |
173 // 8. [X] If the track element's parent is a media element then let CORS mod e be the state of the parent media | 175 // 8. [X] If the track element's parent is a media element then let CORS mod e be the state of the parent media |
174 // element's crossorigin content attribute. Otherwise, let CORS mode be No C ORS. | 176 // element's crossorigin content attribute. Otherwise, let CORS mode be No C ORS. |
175 const AtomicString& corsMode = mediaElementCrossOriginAttribute(); | 177 const AtomicString& corsMode = mediaElementCrossOriginAttribute(); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
216 bool HTMLTrackElement::canLoadUrl(const KURL& url) | 218 bool HTMLTrackElement::canLoadUrl(const KURL& url) |
217 { | 219 { |
218 HTMLMediaElement* parent = mediaElement(); | 220 HTMLMediaElement* parent = mediaElement(); |
219 if (!parent) | 221 if (!parent) |
220 return false; | 222 return false; |
221 | 223 |
222 if (url.isEmpty()) | 224 if (url.isEmpty()) |
223 return false; | 225 return false; |
224 | 226 |
225 if (!document().contentSecurityPolicy()->allowMediaFromSource(url)) { | 227 if (!document().contentSecurityPolicy()->allowMediaFromSource(url)) { |
226 WTF_LOG(Media, "HTMLTrackElement::canLoadUrl(%s) -> rejected by Content Security Policy", urlForLoggingTrack(url).utf8().data()); | 228 DVLOG(TRACK_LOG_LEVEL) << "canLoadUrl(" << urlForLoggingTrack(url) << ") -> rejected by Content Security Policy"; |
227 return false; | 229 return false; |
228 } | 230 } |
229 | 231 |
230 return true; | 232 return true; |
231 } | 233 } |
232 | 234 |
233 void HTMLTrackElement::didCompleteLoad(LoadStatus status) | 235 void HTMLTrackElement::didCompleteLoad(LoadStatus status) |
234 { | 236 { |
235 // 10. ... (continued) | 237 // 10. ... (continued) |
236 | 238 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
325 } | 327 } |
326 | 328 |
327 DEFINE_TRACE(HTMLTrackElement) | 329 DEFINE_TRACE(HTMLTrackElement) |
328 { | 330 { |
329 visitor->trace(m_track); | 331 visitor->trace(m_track); |
330 visitor->trace(m_loader); | 332 visitor->trace(m_loader); |
331 HTMLElement::trace(visitor); | 333 HTMLElement::trace(visitor); |
332 } | 334 } |
333 | 335 |
334 } // namespace blink | 336 } // namespace blink |
OLD | NEW |