| 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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 invalidateTrackIndex(); | 137 invalidateTrackIndex(); |
| 138 } | 138 } |
| 139 | 139 |
| 140 bool TextTrack::isVisualKind() const | 140 bool TextTrack::isVisualKind() const |
| 141 { | 141 { |
| 142 return kind() == subtitlesKeyword() || kind() == captionsKeyword(); | 142 return kind() == subtitlesKeyword() || kind() == captionsKeyword(); |
| 143 } | 143 } |
| 144 | 144 |
| 145 void TextTrack::setMode(const AtomicString& mode) | 145 void TextTrack::setMode(const AtomicString& mode) |
| 146 { | 146 { |
| 147 ASSERT(mode == disabledKeyword() || mode == hiddenKeyword() || mode == showi
ngKeyword()); | 147 DCHECK(mode == disabledKeyword() || mode == hiddenKeyword() || mode == showi
ngKeyword()); |
| 148 | 148 |
| 149 // On setting, if the new value isn't equal to what the attribute would curr
ently | 149 // On setting, if the new value isn't equal to what the attribute would curr
ently |
| 150 // return, the new value must be processed as follows ... | 150 // return, the new value must be processed as follows ... |
| 151 if (m_mode == mode) | 151 if (m_mode == mode) |
| 152 return; | 152 return; |
| 153 | 153 |
| 154 if (m_cues && cueTimeline()) { | 154 if (m_cues && cueTimeline()) { |
| 155 // If mode changes to disabled, remove this track's cues from the client | 155 // If mode changes to disabled, remove this track's cues from the client |
| 156 // because they will no longer be accessible from the cues() function. | 156 // because they will no longer be accessible from the cues() function. |
| 157 if (mode == disabledKeyword()) | 157 if (mode == disabledKeyword()) |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 | 223 |
| 224 if (!m_activeCues) | 224 if (!m_activeCues) |
| 225 m_activeCues = TextTrackCueList::create(); | 225 m_activeCues = TextTrackCueList::create(); |
| 226 | 226 |
| 227 m_cues->collectActiveCues(*m_activeCues); | 227 m_cues->collectActiveCues(*m_activeCues); |
| 228 return m_activeCues; | 228 return m_activeCues; |
| 229 } | 229 } |
| 230 | 230 |
| 231 void TextTrack::addCue(TextTrackCue* cue) | 231 void TextTrack::addCue(TextTrackCue* cue) |
| 232 { | 232 { |
| 233 ASSERT(cue); | 233 DCHECK(cue); |
| 234 | 234 |
| 235 // TODO(93143): Add spec-compliant behavior for negative time values. | 235 // TODO(93143): Add spec-compliant behavior for negative time values. |
| 236 if (std::isnan(cue->startTime()) || std::isnan(cue->endTime()) || cue->start
Time() < 0 || cue->endTime() < 0) | 236 if (std::isnan(cue->startTime()) || std::isnan(cue->endTime()) || cue->start
Time() < 0 || cue->endTime() < 0) |
| 237 return; | 237 return; |
| 238 | 238 |
| 239 // https://html.spec.whatwg.org/multipage/embedded-content.html#dom-texttrac
k-addcue | 239 // https://html.spec.whatwg.org/multipage/embedded-content.html#dom-texttrac
k-addcue |
| 240 | 240 |
| 241 // The addCue(cue) method of TextTrack objects, when invoked, must run the f
ollowing steps: | 241 // The addCue(cue) method of TextTrack objects, when invoked, must run the f
ollowing steps: |
| 242 | 242 |
| 243 // (Steps 1 and 2 - pertaining to association of rendering rules - are not i
mplemented.) | 243 // (Steps 1 and 2 - pertaining to association of rendering rules - are not i
mplemented.) |
| 244 | 244 |
| 245 // 3. If the given cue is in a text track list of cues, then remove cue | 245 // 3. If the given cue is in a text track list of cues, then remove cue |
| 246 // from that text track list of cues. | 246 // from that text track list of cues. |
| 247 if (TextTrack* cueTrack = cue->track()) | 247 if (TextTrack* cueTrack = cue->track()) |
| 248 cueTrack->removeCue(cue, ASSERT_NO_EXCEPTION); | 248 cueTrack->removeCue(cue, ASSERT_NO_EXCEPTION); |
| 249 | 249 |
| 250 // 4. Add cue to the method's TextTrack object's text track's text track lis
t of cues. | 250 // 4. Add cue to the method's TextTrack object's text track's text track lis
t of cues. |
| 251 cue->setTrack(this); | 251 cue->setTrack(this); |
| 252 ensureTextTrackCueList()->add(cue); | 252 ensureTextTrackCueList()->add(cue); |
| 253 | 253 |
| 254 if (cueTimeline() && m_mode != disabledKeyword()) | 254 if (cueTimeline() && m_mode != disabledKeyword()) |
| 255 cueTimeline()->addCue(this, cue); | 255 cueTimeline()->addCue(this, cue); |
| 256 } | 256 } |
| 257 | 257 |
| 258 void TextTrack::removeCue(TextTrackCue* cue, ExceptionState& exceptionState) | 258 void TextTrack::removeCue(TextTrackCue* cue, ExceptionState& exceptionState) |
| 259 { | 259 { |
| 260 ASSERT(cue); | 260 DCHECK(cue); |
| 261 | 261 |
| 262 // https://html.spec.whatwg.org/multipage/embedded-content.html#dom-texttrac
k-removecue | 262 // https://html.spec.whatwg.org/multipage/embedded-content.html#dom-texttrac
k-removecue |
| 263 | 263 |
| 264 // The removeCue(cue) method of TextTrack objects, when invoked, must run th
e following steps: | 264 // The removeCue(cue) method of TextTrack objects, when invoked, must run th
e following steps: |
| 265 | 265 |
| 266 // 1. If the given cue is not currently listed in the method's TextTrack | 266 // 1. If the given cue is not currently listed in the method's TextTrack |
| 267 // object's text track's text track list of cues, then throw a NotFoundError
exception. | 267 // object's text track's text track list of cues, then throw a NotFoundError
exception. |
| 268 if (cue->track() != this) { | 268 if (cue->track() != this) { |
| 269 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."); |
| 270 return; | 270 return; |
| 271 } | 271 } |
| 272 | 272 |
| 273 // cue->track() == this implies that cue is in this track's list of cues, | 273 // cue->track() == this implies that cue is in this track's list of cues, |
| 274 // so this track should have a list of cues and the cue being removed | 274 // so this track should have a list of cues and the cue being removed |
| 275 // should be in it. | 275 // should be in it. |
| 276 ASSERT(m_cues); | 276 DCHECK(m_cues); |
| 277 | 277 |
| 278 // 2. Remove cue from the method's TextTrack object's text track's text trac
k list of cues. | 278 // 2. Remove cue from the method's TextTrack object's text track's text trac
k list of cues. |
| 279 bool wasRemoved = m_cues->remove(cue); | 279 bool wasRemoved = m_cues->remove(cue); |
| 280 ASSERT_UNUSED(wasRemoved, wasRemoved); | 280 DCHECK(wasRemoved); |
| 281 | 281 |
| 282 // If the cue is active, a timeline needs to be available. | 282 // If the cue is active, a timeline needs to be available. |
| 283 ASSERT(!cue->isActive() || cueTimeline()); | 283 DCHECK(!cue->isActive() || cueTimeline()); |
| 284 | 284 |
| 285 cue->setTrack(0); | 285 cue->setTrack(0); |
| 286 | 286 |
| 287 if (cueTimeline()) | 287 if (cueTimeline()) |
| 288 cueTimeline()->removeCue(this, cue); | 288 cueTimeline()->removeCue(this, cue); |
| 289 } | 289 } |
| 290 | 290 |
| 291 VTTRegionList* TextTrack::ensureVTTRegionList() | 291 VTTRegionList* TextTrack::ensureVTTRegionList() |
| 292 { | 292 { |
| 293 if (!m_regions) | 293 if (!m_regions) |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 // The cue may need to be repositioned in the media element's interval tree,
may need to | 363 // The cue may need to be repositioned in the media element's interval tree,
may need to |
| 364 // be re-rendered, etc, so remove it before the modification... | 364 // be re-rendered, etc, so remove it before the modification... |
| 365 if (cueTimeline()) | 365 if (cueTimeline()) |
| 366 cueTimeline()->removeCue(this, cue); | 366 cueTimeline()->removeCue(this, cue); |
| 367 } | 367 } |
| 368 | 368 |
| 369 void TextTrack::cueDidChange(TextTrackCue* cue) | 369 void TextTrack::cueDidChange(TextTrackCue* cue) |
| 370 { | 370 { |
| 371 // This method is called through cue->track(), which should imply that this | 371 // This method is called through cue->track(), which should imply that this |
| 372 // track has a list of cues. | 372 // track has a list of cues. |
| 373 ASSERT(m_cues && cue->track() == this); | 373 DCHECK(m_cues && cue->track() == this); |
| 374 | 374 |
| 375 // Make sure the TextTrackCueList order is up-to-date. | 375 // Make sure the TextTrackCueList order is up-to-date. |
| 376 // FIXME: Only need to do this if the change was to any of the timestamps. | 376 // FIXME: Only need to do this if the change was to any of the timestamps. |
| 377 m_cues->updateCueIndex(cue); | 377 m_cues->updateCueIndex(cue); |
| 378 | 378 |
| 379 // Since a call to cueDidChange is always preceded by a call to | 379 // Since a call to cueDidChange is always preceded by a call to |
| 380 // cueWillChange, the cue should no longer be active when we reach this | 380 // cueWillChange, the cue should no longer be active when we reach this |
| 381 // point (since it was removed from the timeline in cueWillChange). | 381 // point (since it was removed from the timeline in cueWillChange). |
| 382 ASSERT(!cue->isActive()); | 382 DCHECK(!cue->isActive()); |
| 383 | 383 |
| 384 if (m_mode == disabledKeyword()) | 384 if (m_mode == disabledKeyword()) |
| 385 return; | 385 return; |
| 386 | 386 |
| 387 // ... and add it back again if the track is enabled. | 387 // ... and add it back again if the track is enabled. |
| 388 if (cueTimeline()) | 388 if (cueTimeline()) |
| 389 cueTimeline()->addCue(this, cue); | 389 cueTimeline()->addCue(this, cue); |
| 390 } | 390 } |
| 391 | 391 |
| 392 int TextTrack::trackIndex() | 392 int TextTrack::trackIndex() |
| 393 { | 393 { |
| 394 ASSERT(m_trackList); | 394 DCHECK(m_trackList); |
| 395 | 395 |
| 396 if (m_trackIndex == invalidTrackIndex) | 396 if (m_trackIndex == invalidTrackIndex) |
| 397 m_trackIndex = m_trackList->getTrackIndex(this); | 397 m_trackIndex = m_trackList->getTrackIndex(this); |
| 398 | 398 |
| 399 return m_trackIndex; | 399 return m_trackIndex; |
| 400 } | 400 } |
| 401 | 401 |
| 402 void TextTrack::invalidateTrackIndex() | 402 void TextTrack::invalidateTrackIndex() |
| 403 { | 403 { |
| 404 m_trackIndex = invalidTrackIndex; | 404 m_trackIndex = invalidTrackIndex; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 419 TextTrackCueList* TextTrack::ensureTextTrackCueList() | 419 TextTrackCueList* TextTrack::ensureTextTrackCueList() |
| 420 { | 420 { |
| 421 if (!m_cues) | 421 if (!m_cues) |
| 422 m_cues = TextTrackCueList::create(); | 422 m_cues = TextTrackCueList::create(); |
| 423 | 423 |
| 424 return m_cues.get(); | 424 return m_cues.get(); |
| 425 } | 425 } |
| 426 | 426 |
| 427 int TextTrack::trackIndexRelativeToRenderedTracks() | 427 int TextTrack::trackIndexRelativeToRenderedTracks() |
| 428 { | 428 { |
| 429 ASSERT(m_trackList); | 429 DCHECK(m_trackList); |
| 430 | 430 |
| 431 if (m_renderedTrackIndex == invalidTrackIndex) | 431 if (m_renderedTrackIndex == invalidTrackIndex) |
| 432 m_renderedTrackIndex = m_trackList->getTrackIndexRelativeToRenderedTrack
s(this); | 432 m_renderedTrackIndex = m_trackList->getTrackIndexRelativeToRenderedTrack
s(this); |
| 433 | 433 |
| 434 return m_renderedTrackIndex; | 434 return m_renderedTrackIndex; |
| 435 } | 435 } |
| 436 | 436 |
| 437 const AtomicString& TextTrack::interfaceName() const | 437 const AtomicString& TextTrack::interfaceName() const |
| 438 { | 438 { |
| 439 return EventTargetNames::TextTrack; | 439 return EventTargetNames::TextTrack; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 468 visitor->trace(m_trackList); | 468 visitor->trace(m_trackList); |
| 469 TrackBase::trace(visitor); | 469 TrackBase::trace(visitor); |
| 470 EventTargetWithInlineData::trace(visitor); | 470 EventTargetWithInlineData::trace(visitor); |
| 471 } | 471 } |
| 472 | 472 |
| 473 DEFINE_TRACE_WRAPPERS(TextTrack) | 473 DEFINE_TRACE_WRAPPERS(TextTrack) |
| 474 { | 474 { |
| 475 visitor->traceWrappers(m_cues); | 475 visitor->traceWrappers(m_cues); |
| 476 } | 476 } |
| 477 } // namespace blink | 477 } // namespace blink |
| OLD | NEW |