OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * Copyright (C) 2011, 2012, 2013 Apple Inc. All rights reserved. | 3 * Copyright (C) 2011, 2012, 2013 Apple Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
227 { | 227 { |
228 if (!prpCue) | 228 if (!prpCue) |
229 return; | 229 return; |
230 | 230 |
231 RefPtrWillBeRawPtr<TextTrackCue> cue = prpCue; | 231 RefPtrWillBeRawPtr<TextTrackCue> cue = prpCue; |
232 | 232 |
233 // TODO(93143): Add spec-compliant behavior for negative time values. | 233 // TODO(93143): Add spec-compliant behavior for negative time values. |
234 if (std::isnan(cue->startTime()) || std::isnan(cue->endTime()) || cue->start Time() < 0 || cue->endTime() < 0) | 234 if (std::isnan(cue->startTime()) || std::isnan(cue->endTime()) || cue->start Time() < 0 || cue->endTime() < 0) |
235 return; | 235 return; |
236 | 236 |
237 // 4.8.10.12.5 Text track API | 237 // https://html.spec.whatwg.org/multipage/embedded-content.html#dom-texttrac k-addcue |
238 | 238 |
239 // The addCue(cue) method of TextTrack objects, when invoked, must run the f ollowing steps: | 239 // The addCue(cue) method of TextTrack objects, when invoked, must run the f ollowing steps: |
240 | 240 |
241 // 1. If the given cue is in a text track list of cues, then remove cue from that text track | 241 // (Steps 1 and 2 - pertaining to association of rendering rules - are not i mplemented.) |
242 // list of cues. | 242 |
243 TextTrack* cueTrack = cue->track(); | 243 // 3. If the given cue is in a text track list of cues, then remove cue |
244 if (cueTrack && cueTrack != this) | 244 // from that text track list of cues. |
245 if (TextTrack* cueTrack = cue->track()) | |
245 cueTrack->removeCue(cue.get(), ASSERT_NO_EXCEPTION); | 246 cueTrack->removeCue(cue.get(), ASSERT_NO_EXCEPTION); |
246 | 247 |
247 // 2. Add cue to the method's TextTrack object's text track's text track lis t of cues. | 248 // 4. Add cue to the method's TextTrack object's text track's text track lis t of cues. |
248 cue->setTrack(this); | 249 cue->setTrack(this); |
249 ensureTextTrackCueList()->add(cue); | 250 ensureTextTrackCueList()->add(cue); |
250 | 251 |
251 if (cueTimeline() && m_mode != disabledKeyword()) | 252 if (cueTimeline() && m_mode != disabledKeyword()) |
252 cueTimeline()->addCue(this, cue.get()); | 253 cueTimeline()->addCue(this, cue.get()); |
253 } | 254 } |
254 | 255 |
255 void TextTrack::removeCue(TextTrackCue* cue, ExceptionState& exceptionState) | 256 void TextTrack::removeCue(TextTrackCue* cue, ExceptionState& exceptionState) |
256 { | 257 { |
257 if (!cue) | 258 if (!cue) |
258 return; | 259 return; |
259 | 260 |
260 // 4.8.10.12.5 Text track API | 261 // https://html.spec.whatwg.org/multipage/embedded-content.html#dom-texttrac k-removecue |
261 | 262 |
262 // The removeCue(cue) method of TextTrack objects, when invoked, must run th e following steps: | 263 // The removeCue(cue) method of TextTrack objects, when invoked, must run th e following steps: |
263 | 264 |
264 // 1. If the given cue is not currently listed in the method's TextTrack | 265 // 1. If the given cue is not currently listed in the method's TextTrack |
265 // object's text track's text track list of cues, then throw a NotFoundError exception. | 266 // object's text track's text track list of cues, then throw a NotFoundError exception. |
266 if (cue->track() != this) { | 267 // 2. Remove cue from the method's TextTrack object's text track's text trac k list of cues. |
268 if (cue->track() != this || !m_cues || !m_cues->remove(cue)) { | |
267 exceptionState.throwDOMException(NotFoundError, "The specified cue is no t listed in the TextTrack's list of cues."); | 269 exceptionState.throwDOMException(NotFoundError, "The specified cue is no t listed in the TextTrack's list of cues."); |
268 return; | 270 return; |
269 } | 271 } |
270 | 272 |
271 // 2. Remove cue from the method's TextTrack object's text track's text trac k list of cues. | |
272 if (!m_cues || !m_cues->remove(cue)) { | |
philipj_slow
2015/02/23 13:32:13
If this shouldn't be possible, can we assert it in
fs
2015/02/23 14:04:49
Yes. There're a few of these invariants - in this
| |
273 exceptionState.throwDOMException(InvalidStateError, "Failed to remove th e specified cue."); | |
274 return; | |
275 } | |
276 | |
277 cue->setTrack(0); | 273 cue->setTrack(0); |
278 if (cueTimeline()) | 274 if (cueTimeline()) |
279 cueTimeline()->removeCue(this, cue); | 275 cueTimeline()->removeCue(this, cue); |
280 } | 276 } |
281 | 277 |
282 VTTRegionList* TextTrack::ensureVTTRegionList() | 278 VTTRegionList* TextTrack::ensureVTTRegionList() |
283 { | 279 { |
284 if (!m_regions) | 280 if (!m_regions) |
285 m_regions = VTTRegionList::create(); | 281 m_regions = VTTRegionList::create(); |
286 | 282 |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
449 DEFINE_TRACE(TextTrack) | 445 DEFINE_TRACE(TextTrack) |
450 { | 446 { |
451 visitor->trace(m_cues); | 447 visitor->trace(m_cues); |
452 visitor->trace(m_regions); | 448 visitor->trace(m_regions); |
453 visitor->trace(m_trackList); | 449 visitor->trace(m_trackList); |
454 TrackBase::trace(visitor); | 450 TrackBase::trace(visitor); |
455 EventTargetWithInlineData::trace(visitor); | 451 EventTargetWithInlineData::trace(visitor); |
456 } | 452 } |
457 | 453 |
458 } // namespace blink | 454 } // namespace blink |
OLD | NEW |