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 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 // The removeCue(cue) method of TextTrack objects, when invoked, must run th
e following steps: | 282 // The removeCue(cue) method of TextTrack objects, when invoked, must run th
e following steps: |
283 | 283 |
284 // 1. If the given cue is not currently listed in the method's TextTrack | 284 // 1. If the given cue is not currently listed in the method's TextTrack |
285 // object's text track's text track list of cues, then throw a NotFoundError
exception. | 285 // object's text track's text track list of cues, then throw a NotFoundError
exception. |
286 // 2. Remove cue from the method's TextTrack object's text track's text trac
k list of cues. | 286 // 2. Remove cue from the method's TextTrack object's text track's text trac
k list of cues. |
287 if (cue->track() != this || !m_cues || !m_cues->remove(cue)) { | 287 if (cue->track() != this || !m_cues || !m_cues->remove(cue)) { |
288 exceptionState.throwDOMException(NotFoundError, "The specified cue is no
t listed in the TextTrack's list of cues."); | 288 exceptionState.throwDOMException(NotFoundError, "The specified cue is no
t listed in the TextTrack's list of cues."); |
289 return; | 289 return; |
290 } | 290 } |
291 | 291 |
292 cue->setIsActive(false); | 292 // If the cue is active, a timeline needs to be available. |
293 cue->removeDisplayTree(); | 293 ASSERT(!cue->isActive() || cueTimeline()); |
294 | 294 |
295 cue->setTrack(0); | 295 cue->setTrack(0); |
| 296 |
296 if (cueTimeline()) | 297 if (cueTimeline()) |
297 cueTimeline()->removeCue(this, cue); | 298 cueTimeline()->removeCue(this, cue); |
298 } | 299 } |
299 | 300 |
300 VTTRegionList* TextTrack::ensureVTTRegionList() | 301 VTTRegionList* TextTrack::ensureVTTRegionList() |
301 { | 302 { |
302 if (!m_regions) | 303 if (!m_regions) |
303 m_regions = VTTRegionList::create(); | 304 m_regions = VTTRegionList::create(); |
304 | 305 |
305 return m_regions.get(); | 306 return m_regions.get(); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 if (!m_regions || !m_regions->remove(region)) { | 364 if (!m_regions || !m_regions->remove(region)) { |
364 exceptionState.throwDOMException(InvalidStateError, "Failed to remove th
e specified region."); | 365 exceptionState.throwDOMException(InvalidStateError, "Failed to remove th
e specified region."); |
365 return; | 366 return; |
366 } | 367 } |
367 | 368 |
368 region->setTrack(0); | 369 region->setTrack(0); |
369 } | 370 } |
370 | 371 |
371 void TextTrack::cueWillChange(TextTrackCue* cue) | 372 void TextTrack::cueWillChange(TextTrackCue* cue) |
372 { | 373 { |
373 if (!cueTimeline()) | |
374 return; | |
375 | |
376 // The cue may need to be repositioned in the media element's interval tree,
may need to | 374 // The cue may need to be repositioned in the media element's interval tree,
may need to |
377 // be re-rendered, etc, so remove it before the modification... | 375 // be re-rendered, etc, so remove it before the modification... |
378 cueTimeline()->removeCue(this, cue); | 376 if (cueTimeline()) |
| 377 cueTimeline()->removeCue(this, cue); |
379 } | 378 } |
380 | 379 |
381 void TextTrack::cueDidChange(TextTrackCue* cue) | 380 void TextTrack::cueDidChange(TextTrackCue* cue) |
382 { | 381 { |
383 if (!cueTimeline()) | |
384 return; | |
385 | |
386 // Make sure the TextTrackCueList order is up-to-date. | 382 // Make sure the TextTrackCueList order is up-to-date. |
| 383 // FIXME: Only need to do this if the change was to any of the timestamps. |
387 ensureTextTrackCueList()->updateCueIndex(cue); | 384 ensureTextTrackCueList()->updateCueIndex(cue); |
388 | 385 |
389 // ... and add it back again if the track is enabled. | 386 // Since a call to cueDidChange is always preceded by a call to |
| 387 // cueWillChange, the cue should no longer be active when we reach this |
| 388 // point (since it was removed from the timeline in cueWillChange). |
| 389 ASSERT(!cue->isActive()); |
| 390 |
390 if (m_mode == disabledKeyword()) | 391 if (m_mode == disabledKeyword()) |
391 return; | 392 return; |
392 | 393 |
393 cueTimeline()->addCue(this, cue); | 394 // ... and add it back again if the track is enabled. |
| 395 if (cueTimeline()) |
| 396 cueTimeline()->addCue(this, cue); |
394 } | 397 } |
395 | 398 |
396 int TextTrack::trackIndex() | 399 int TextTrack::trackIndex() |
397 { | 400 { |
398 ASSERT(m_trackList); | 401 ASSERT(m_trackList); |
399 | 402 |
400 if (m_trackIndex == invalidTrackIndex) | 403 if (m_trackIndex == invalidTrackIndex) |
401 m_trackIndex = m_trackList->getTrackIndex(this); | 404 m_trackIndex = m_trackList->getTrackIndex(this); |
402 | 405 |
403 return m_trackIndex; | 406 return m_trackIndex; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 DEFINE_TRACE(TextTrack) | 470 DEFINE_TRACE(TextTrack) |
468 { | 471 { |
469 visitor->trace(m_cues); | 472 visitor->trace(m_cues); |
470 visitor->trace(m_regions); | 473 visitor->trace(m_regions); |
471 visitor->trace(m_trackList); | 474 visitor->trace(m_trackList); |
472 TrackBase::trace(visitor); | 475 TrackBase::trace(visitor); |
473 EventTargetWithInlineData::trace(visitor); | 476 EventTargetWithInlineData::trace(visitor); |
474 } | 477 } |
475 | 478 |
476 } // namespace blink | 479 } // namespace blink |
OLD | NEW |