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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 void TextTrack::removeCue(TextTrackCue* cue, ExceptionState& exceptionState) | 281 void TextTrack::removeCue(TextTrackCue* cue, ExceptionState& exceptionState) |
282 { | 282 { |
283 ASSERT(cue); | 283 ASSERT(cue); |
284 | 284 |
285 // https://html.spec.whatwg.org/multipage/embedded-content.html#dom-texttrac
k-removecue | 285 // https://html.spec.whatwg.org/multipage/embedded-content.html#dom-texttrac
k-removecue |
286 | 286 |
287 // The removeCue(cue) method of TextTrack objects, when invoked, must run th
e following steps: | 287 // The removeCue(cue) method of TextTrack objects, when invoked, must run th
e following steps: |
288 | 288 |
289 // 1. If the given cue is not currently listed in the method's TextTrack | 289 // 1. If the given cue is not currently listed in the method's TextTrack |
290 // object's text track's text track list of cues, then throw a NotFoundError
exception. | 290 // object's text track's text track list of cues, then throw a NotFoundError
exception. |
291 // 2. Remove cue from the method's TextTrack object's text track's text trac
k list of cues. | 291 if (cue->track() != this) { |
292 if (cue->track() != this || !m_cues || !m_cues->remove(cue)) { | |
293 exceptionState.throwDOMException(NotFoundError, "The specified cue is no
t listed in the TextTrack's list of cues."); | 292 exceptionState.throwDOMException(NotFoundError, "The specified cue is no
t listed in the TextTrack's list of cues."); |
294 return; | 293 return; |
295 } | 294 } |
296 | 295 |
| 296 // cue->track() == this implies that cue is in this track's list of cues, |
| 297 // so this track should have a list of cues and the cue being removed |
| 298 // should be in it. |
| 299 ASSERT(m_cues); |
| 300 |
| 301 // 2. Remove cue from the method's TextTrack object's text track's text trac
k list of cues. |
| 302 bool wasRemoved = m_cues->remove(cue); |
| 303 ASSERT_UNUSED(wasRemoved, wasRemoved); |
| 304 |
297 // If the cue is active, a timeline needs to be available. | 305 // If the cue is active, a timeline needs to be available. |
298 ASSERT(!cue->isActive() || cueTimeline()); | 306 ASSERT(!cue->isActive() || cueTimeline()); |
299 | 307 |
300 cue->setTrack(0); | 308 cue->setTrack(0); |
301 | 309 |
302 if (cueTimeline()) | 310 if (cueTimeline()) |
303 cueTimeline()->removeCue(this, cue); | 311 cueTimeline()->removeCue(this, cue); |
304 } | 312 } |
305 | 313 |
306 VTTRegionList* TextTrack::ensureVTTRegionList() | 314 VTTRegionList* TextTrack::ensureVTTRegionList() |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 void TextTrack::cueWillChange(TextTrackCue* cue) | 385 void TextTrack::cueWillChange(TextTrackCue* cue) |
378 { | 386 { |
379 // The cue may need to be repositioned in the media element's interval tree,
may need to | 387 // The cue may need to be repositioned in the media element's interval tree,
may need to |
380 // be re-rendered, etc, so remove it before the modification... | 388 // be re-rendered, etc, so remove it before the modification... |
381 if (cueTimeline()) | 389 if (cueTimeline()) |
382 cueTimeline()->removeCue(this, cue); | 390 cueTimeline()->removeCue(this, cue); |
383 } | 391 } |
384 | 392 |
385 void TextTrack::cueDidChange(TextTrackCue* cue) | 393 void TextTrack::cueDidChange(TextTrackCue* cue) |
386 { | 394 { |
| 395 // This method is called through cue->track(), which should imply that this |
| 396 // track has a list of cues. |
| 397 ASSERT(m_cues && cue->track() == this); |
| 398 |
387 // Make sure the TextTrackCueList order is up-to-date. | 399 // Make sure the TextTrackCueList order is up-to-date. |
388 // FIXME: Only need to do this if the change was to any of the timestamps. | 400 // FIXME: Only need to do this if the change was to any of the timestamps. |
389 ensureTextTrackCueList()->updateCueIndex(cue); | 401 m_cues->updateCueIndex(cue); |
390 | 402 |
391 // Since a call to cueDidChange is always preceded by a call to | 403 // Since a call to cueDidChange is always preceded by a call to |
392 // cueWillChange, the cue should no longer be active when we reach this | 404 // cueWillChange, the cue should no longer be active when we reach this |
393 // point (since it was removed from the timeline in cueWillChange). | 405 // point (since it was removed from the timeline in cueWillChange). |
394 ASSERT(!cue->isActive()); | 406 ASSERT(!cue->isActive()); |
395 | 407 |
396 if (m_mode == disabledKeyword()) | 408 if (m_mode == disabledKeyword()) |
397 return; | 409 return; |
398 | 410 |
399 // ... and add it back again if the track is enabled. | 411 // ... and add it back again if the track is enabled. |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
476 { | 488 { |
477 visitor->trace(m_cues); | 489 visitor->trace(m_cues); |
478 visitor->trace(m_activeCues); | 490 visitor->trace(m_activeCues); |
479 visitor->trace(m_regions); | 491 visitor->trace(m_regions); |
480 visitor->trace(m_trackList); | 492 visitor->trace(m_trackList); |
481 TrackBase::trace(visitor); | 493 TrackBase::trace(visitor); |
482 EventTargetWithInlineData::trace(visitor); | 494 EventTargetWithInlineData::trace(visitor); |
483 } | 495 } |
484 | 496 |
485 } // namespace blink | 497 } // namespace blink |
OLD | NEW |