Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLTrackElement.cpp

Issue 2384273007: reflow comments in core/html/*.{cpp,h},core/html/imports (Closed)
Patch Set: comments Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 void HTMLTrackElement::parseAttribute(const QualifiedName& name, 80 void HTMLTrackElement::parseAttribute(const QualifiedName& name,
81 const AtomicString& oldValue, 81 const AtomicString& oldValue,
82 const AtomicString& value) { 82 const AtomicString& value) {
83 if (name == srcAttr) { 83 if (name == srcAttr) {
84 if (!value.isEmpty()) 84 if (!value.isEmpty())
85 scheduleLoad(); 85 scheduleLoad();
86 else if (m_track) 86 else if (m_track)
87 m_track->removeAllCues(); 87 m_track->removeAllCues();
88 88
89 // 4.8.10.12.3 Sourcing out-of-band text tracks 89 // 4.8.10.12.3 Sourcing out-of-band text tracks
90 // As the kind, label, and srclang attributes are set, changed, or removed, the text track must update accordingly... 90 // As the kind, label, and srclang attributes are set, changed, or removed,
91 // the text track must update accordingly...
91 } else if (name == kindAttr) { 92 } else if (name == kindAttr) {
92 AtomicString lowerCaseValue = value.lower(); 93 AtomicString lowerCaseValue = value.lower();
93 // 'missing value default' ("subtitles") 94 // 'missing value default' ("subtitles")
94 if (lowerCaseValue.isNull()) 95 if (lowerCaseValue.isNull())
95 lowerCaseValue = TextTrack::subtitlesKeyword(); 96 lowerCaseValue = TextTrack::subtitlesKeyword();
96 // 'invalid value default' ("metadata") 97 // 'invalid value default' ("metadata")
97 else if (!TextTrack::isValidKindKeyword(lowerCaseValue)) 98 else if (!TextTrack::isValidKindKeyword(lowerCaseValue))
98 lowerCaseValue = TextTrack::metadataKeyword(); 99 lowerCaseValue = TextTrack::metadataKeyword();
99 100
100 track()->setKind(lowerCaseValue); 101 track()->setKind(lowerCaseValue);
(...skipping 28 matching lines...) Expand all
129 return ensureTrack(); 130 return ensureTrack();
130 } 131 }
131 132
132 bool HTMLTrackElement::isURLAttribute(const Attribute& attribute) const { 133 bool HTMLTrackElement::isURLAttribute(const Attribute& attribute) const {
133 return attribute.name() == srcAttr || HTMLElement::isURLAttribute(attribute); 134 return attribute.name() == srcAttr || HTMLElement::isURLAttribute(attribute);
134 } 135 }
135 136
136 void HTMLTrackElement::scheduleLoad() { 137 void HTMLTrackElement::scheduleLoad() {
137 DVLOG(TRACK_LOG_LEVEL) << "scheduleLoad"; 138 DVLOG(TRACK_LOG_LEVEL) << "scheduleLoad";
138 139
139 // 1. If another occurrence of this algorithm is already running for this text track and its track element, 140 // 1. If another occurrence of this algorithm is already running for this text
140 // abort these steps, letting that other algorithm take care of this element. 141 // track and its track element, abort these steps, letting that other
142 // algorithm take care of this element.
141 if (m_loadTimer.isActive()) 143 if (m_loadTimer.isActive())
142 return; 144 return;
143 145
144 // 2. If the text track's text track mode is not set to one of hidden or showi ng, abort these steps. 146 // 2. If the text track's text track mode is not set to one of hidden or
147 // showing, abort these steps.
145 if (ensureTrack()->mode() != TextTrack::hiddenKeyword() && 148 if (ensureTrack()->mode() != TextTrack::hiddenKeyword() &&
146 ensureTrack()->mode() != TextTrack::showingKeyword()) 149 ensureTrack()->mode() != TextTrack::showingKeyword())
147 return; 150 return;
148 151
149 // 3. If the text track's track element does not have a media element as a par ent, abort these steps. 152 // 3. If the text track's track element does not have a media element as a
153 // parent, abort these steps.
150 if (!mediaElement()) 154 if (!mediaElement())
151 return; 155 return;
152 156
153 // 4. Run the remainder of these steps in parallel, allowing whatever caused t hese steps to run to continue. 157 // 4. Run the remainder of these steps in parallel, allowing whatever caused
158 // these steps to run to continue.
154 m_loadTimer.startOneShot(0, BLINK_FROM_HERE); 159 m_loadTimer.startOneShot(0, BLINK_FROM_HERE);
155 160
156 // 5. Top: Await a stable state. The synchronous section consists of the follo wing steps. (The steps in the 161 // 5. Top: Await a stable state. The synchronous section consists of the
157 // synchronous section are marked with [X]) 162 // following steps. (The steps in the synchronous section are marked with [X])
158 // FIXME: We use a timer to approximate a "stable state" - i.e. this is not 10 0% per spec. 163 // FIXME: We use a timer to approximate a "stable state" - i.e. this is not
164 // 100% per spec.
159 } 165 }
160 166
161 void HTMLTrackElement::loadTimerFired(TimerBase*) { 167 void HTMLTrackElement::loadTimerFired(TimerBase*) {
162 DVLOG(TRACK_LOG_LEVEL) << "loadTimerFired"; 168 DVLOG(TRACK_LOG_LEVEL) << "loadTimerFired";
163 169
164 // 6. [X] Set the text track readiness state to loading. 170 // 6. [X] Set the text track readiness state to loading.
165 setReadyState(kLoading); 171 setReadyState(kLoading);
166 172
167 // 7. [X] Let URL be the track URL of the track element. 173 // 7. [X] Let URL be the track URL of the track element.
168 KURL url = getNonEmptyURLAttribute(srcAttr); 174 KURL url = getNonEmptyURLAttribute(srcAttr);
169 175
170 // 8. [X] If the track element's parent is a media element then let CORS mode be the state of the parent media 176 // 8. [X] If the track element's parent is a media element then let CORS mode
171 // element's crossorigin content attribute. Otherwise, let CORS mode be No COR S. 177 // be the state of the parent media element's crossorigin content attribute.
178 // Otherwise, let CORS mode be No CORS.
172 const AtomicString& corsMode = mediaElementCrossOriginAttribute(); 179 const AtomicString& corsMode = mediaElementCrossOriginAttribute();
173 180
174 // 9. End the synchronous section, continuing the remaining steps in parallel. 181 // 9. End the synchronous section, continuing the remaining steps in parallel.
175 182
176 // 10. If URL is not the empty string, perform a potentially CORS-enabled fetc h of URL, with the mode being CORS 183 // 10. If URL is not the empty string, perform a potentially CORS-enabled
177 // mode, the origin being the origin of the track element's node document, and the default origin behaviour set to 184 // fetch of URL, with the mode being CORS mode, the origin being the origin of
185 // the track element's node document, and the default origin behaviour set to
178 // fail. 186 // fail.
179 if (!canLoadUrl(url)) { 187 if (!canLoadUrl(url)) {
180 didCompleteLoad(Failure); 188 didCompleteLoad(Failure);
181 return; 189 return;
182 } 190 }
183 191
184 if (url == m_url) { 192 if (url == m_url) {
185 DCHECK(m_loader); 193 DCHECK(m_loader);
186 switch (m_loader->loadState()) { 194 switch (m_loader->loadState()) {
187 case TextTrackLoader::Idle: 195 case TextTrackLoader::Idle:
188 case TextTrackLoader::Loading: 196 case TextTrackLoader::Loading:
189 // If loading of the resource from this URL is in progress, return early . 197 // If loading of the resource from this URL is in progress, return
198 // early.
190 break; 199 break;
191 case TextTrackLoader::Finished: 200 case TextTrackLoader::Finished:
192 didCompleteLoad(Success); 201 didCompleteLoad(Success);
193 break; 202 break;
194 case TextTrackLoader::Failed: 203 case TextTrackLoader::Failed:
195 didCompleteLoad(Failure); 204 didCompleteLoad(Failure);
196 break; 205 break;
197 default: 206 default:
198 NOTREACHED(); 207 NOTREACHED();
199 } 208 }
(...skipping 23 matching lines...) Expand all
223 << ") -> rejected by Content Security Policy"; 232 << ") -> rejected by Content Security Policy";
224 return false; 233 return false;
225 } 234 }
226 235
227 return true; 236 return true;
228 } 237 }
229 238
230 void HTMLTrackElement::didCompleteLoad(LoadStatus status) { 239 void HTMLTrackElement::didCompleteLoad(LoadStatus status) {
231 // 10. ... (continued) 240 // 10. ... (continued)
232 241
233 // If the fetching algorithm fails for any reason (network error, the server r eturns an error code, a cross-origin 242 // If the fetching algorithm fails for any reason (network error, the server
234 // check fails, etc), or if URL is the empty string, then queue a task to firs t change the text track readiness 243 // returns an error code, a cross-origin check fails, etc), or if URL is the
235 // state to failed to load and then fire a simple event named error at the tra ck element. This task must use the DOM 244 // empty string, then queue a task to first change the text track readiness
236 // manipulation task source. 245 // state to failed to load and then fire a simple event named error at the
246 // track element. This task must use the DOM manipulation task source.
237 // 247 //
238 // (Note: We don't "queue a task" here because this method will only be called from a timer - m_loadTimer or 248 // (Note: We don't "queue a task" here because this method will only be called
239 // TextTrackLoader::m_cueLoadTimer - which should be a reasonable, and hopeful ly non-observable, approximation of 249 // from a timer - m_loadTimer or TextTrackLoader::m_cueLoadTimer - which
240 // the spec text. I.e we could consider this to be run from the "networking ta sk source".) 250 // should be a reasonable, and hopefully non-observable, approximation of the
251 // spec text. I.e we could consider this to be run from the "networking task
252 // source".)
241 // 253 //
242 // If the fetching algorithm does not fail, but the type of the resource is no t a supported text track format, or 254 // If the fetching algorithm does not fail, but the type of the resource is
243 // the file was not successfully processed (e.g. the format in question is an XML format and the file contained a 255 // not a supported text track format, or the file was not successfully
244 // well-formedness error that the XML specification requires be detected and r eported to the application), then the 256 // processed (e.g. the format in question is an XML format and the file
245 // task that is queued by the networking task source in which the aforemention ed problem is found must change the 257 // contained a well-formedness error that the XML specification requires be
246 // text track readiness state to failed to load and fire a simple event named error at the track element. 258 // detected and reported to the application), then the task that is queued by
259 // the networking task source in which the aforementioned problem is found
260 // must change the text track readiness state to failed to load and fire a
261 // simple event named error at the track element.
247 if (status == Failure) { 262 if (status == Failure) {
248 setReadyState(kError); 263 setReadyState(kError);
249 dispatchEvent(Event::create(EventTypeNames::error)); 264 dispatchEvent(Event::create(EventTypeNames::error));
250 return; 265 return;
251 } 266 }
252 267
253 // If the fetching algorithm does not fail, and the file was successfully proc essed, then the final task that is 268 // If the fetching algorithm does not fail, and the file was successfully
254 // queued by the networking task source, after it has finished parsing the dat a, must change the text track 269 // processed, then the final task that is queued by the networking task
255 // readiness state to loaded, and fire a simple event named load at the track element. 270 // source, after it has finished parsing the data, must change the text track
271 // readiness state to loaded, and fire a simple event named load at the track
272 // element.
256 setReadyState(kLoaded); 273 setReadyState(kLoaded);
257 dispatchEvent(Event::create(EventTypeNames::load)); 274 dispatchEvent(Event::create(EventTypeNames::load));
258 } 275 }
259 276
260 void HTMLTrackElement::newCuesAvailable(TextTrackLoader* loader) { 277 void HTMLTrackElement::newCuesAvailable(TextTrackLoader* loader) {
261 DCHECK_EQ(m_loader, loader); 278 DCHECK_EQ(m_loader, loader);
262 DCHECK(m_track); 279 DCHECK(m_track);
263 280
264 HeapVector<Member<TextTrackCue>> newCues; 281 HeapVector<Member<TextTrackCue>> newCues;
265 m_loader->getNewCues(newCues); 282 m_loader->getNewCues(newCues);
(...skipping 11 matching lines...) Expand all
277 m_track->addRegions(newRegions); 294 m_track->addRegions(newRegions);
278 } 295 }
279 296
280 void HTMLTrackElement::cueLoadingCompleted(TextTrackLoader* loader, 297 void HTMLTrackElement::cueLoadingCompleted(TextTrackLoader* loader,
281 bool loadingFailed) { 298 bool loadingFailed) {
282 DCHECK_EQ(m_loader, loader); 299 DCHECK_EQ(m_loader, loader);
283 300
284 didCompleteLoad(loadingFailed ? Failure : Success); 301 didCompleteLoad(loadingFailed ? Failure : Success);
285 } 302 }
286 303
287 // NOTE: The values in the TextTrack::ReadinessState enum must stay in sync with those in HTMLTrackElement::ReadyState. 304 // NOTE: The values in the TextTrack::ReadinessState enum must stay in sync with
305 // those in HTMLTrackElement::ReadyState.
288 static_assert( 306 static_assert(
289 HTMLTrackElement::kNone == 307 HTMLTrackElement::kNone ==
290 static_cast<HTMLTrackElement::ReadyState>(TextTrack::NotLoaded), 308 static_cast<HTMLTrackElement::ReadyState>(TextTrack::NotLoaded),
291 "HTMLTrackElement::kNone should be in sync with TextTrack::NotLoaded"); 309 "HTMLTrackElement::kNone should be in sync with TextTrack::NotLoaded");
292 static_assert( 310 static_assert(
293 HTMLTrackElement::kLoading == 311 HTMLTrackElement::kLoading ==
294 static_cast<HTMLTrackElement::ReadyState>(TextTrack::Loading), 312 static_cast<HTMLTrackElement::ReadyState>(TextTrack::Loading),
295 "HTMLTrackElement::kLoading should be in sync with TextTrack::Loading"); 313 "HTMLTrackElement::kLoading should be in sync with TextTrack::Loading");
296 static_assert( 314 static_assert(
297 HTMLTrackElement::kLoaded == 315 HTMLTrackElement::kLoaded ==
(...skipping 29 matching lines...) Expand all
327 return nullptr; 345 return nullptr;
328 } 346 }
329 347
330 DEFINE_TRACE(HTMLTrackElement) { 348 DEFINE_TRACE(HTMLTrackElement) {
331 visitor->trace(m_track); 349 visitor->trace(m_track);
332 visitor->trace(m_loader); 350 visitor->trace(m_loader);
333 HTMLElement::trace(visitor); 351 HTMLElement::trace(visitor);
334 } 352 }
335 353
336 } // namespace blink 354 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698