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

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

Issue 2003543002: media/track: Replace wtf/Assertions.h macros in favor of base/logging.h macros (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 4 years, 7 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 * 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
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
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 DCHECK(m_cues->remove(cue));
280 ASSERT_UNUSED(wasRemoved, wasRemoved);
281 280
282 // If the cue is active, a timeline needs to be available. 281 // If the cue is active, a timeline needs to be available.
283 ASSERT(!cue->isActive() || cueTimeline()); 282 DCHECK(!cue->isActive() || cueTimeline());
284 283
285 cue->setTrack(0); 284 cue->setTrack(0);
286 285
287 if (cueTimeline()) 286 if (cueTimeline())
288 cueTimeline()->removeCue(this, cue); 287 cueTimeline()->removeCue(this, cue);
289 } 288 }
290 289
291 VTTRegionList* TextTrack::ensureVTTRegionList() 290 VTTRegionList* TextTrack::ensureVTTRegionList()
292 { 291 {
293 if (!m_regions) 292 if (!m_regions)
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 // The cue may need to be repositioned in the media element's interval tree, may need to 362 // 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... 363 // be re-rendered, etc, so remove it before the modification...
365 if (cueTimeline()) 364 if (cueTimeline())
366 cueTimeline()->removeCue(this, cue); 365 cueTimeline()->removeCue(this, cue);
367 } 366 }
368 367
369 void TextTrack::cueDidChange(TextTrackCue* cue) 368 void TextTrack::cueDidChange(TextTrackCue* cue)
370 { 369 {
371 // This method is called through cue->track(), which should imply that this 370 // This method is called through cue->track(), which should imply that this
372 // track has a list of cues. 371 // track has a list of cues.
373 ASSERT(m_cues && cue->track() == this); 372 DCHECK(m_cues && cue->track() == this);
374 373
375 // Make sure the TextTrackCueList order is up-to-date. 374 // 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. 375 // FIXME: Only need to do this if the change was to any of the timestamps.
377 m_cues->updateCueIndex(cue); 376 m_cues->updateCueIndex(cue);
378 377
379 // Since a call to cueDidChange is always preceded by a call to 378 // 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 379 // cueWillChange, the cue should no longer be active when we reach this
381 // point (since it was removed from the timeline in cueWillChange). 380 // point (since it was removed from the timeline in cueWillChange).
382 ASSERT(!cue->isActive()); 381 DCHECK(!cue->isActive());
383 382
384 if (m_mode == disabledKeyword()) 383 if (m_mode == disabledKeyword())
385 return; 384 return;
386 385
387 // ... and add it back again if the track is enabled. 386 // ... and add it back again if the track is enabled.
388 if (cueTimeline()) 387 if (cueTimeline())
389 cueTimeline()->addCue(this, cue); 388 cueTimeline()->addCue(this, cue);
390 } 389 }
391 390
392 int TextTrack::trackIndex() 391 int TextTrack::trackIndex()
393 { 392 {
394 ASSERT(m_trackList); 393 DCHECK(m_trackList);
395 394
396 if (m_trackIndex == invalidTrackIndex) 395 if (m_trackIndex == invalidTrackIndex)
397 m_trackIndex = m_trackList->getTrackIndex(this); 396 m_trackIndex = m_trackList->getTrackIndex(this);
398 397
399 return m_trackIndex; 398 return m_trackIndex;
400 } 399 }
401 400
402 void TextTrack::invalidateTrackIndex() 401 void TextTrack::invalidateTrackIndex()
403 { 402 {
404 m_trackIndex = invalidTrackIndex; 403 m_trackIndex = invalidTrackIndex;
(...skipping 14 matching lines...) Expand all
419 TextTrackCueList* TextTrack::ensureTextTrackCueList() 418 TextTrackCueList* TextTrack::ensureTextTrackCueList()
420 { 419 {
421 if (!m_cues) 420 if (!m_cues)
422 m_cues = TextTrackCueList::create(); 421 m_cues = TextTrackCueList::create();
423 422
424 return m_cues.get(); 423 return m_cues.get();
425 } 424 }
426 425
427 int TextTrack::trackIndexRelativeToRenderedTracks() 426 int TextTrack::trackIndexRelativeToRenderedTracks()
428 { 427 {
429 ASSERT(m_trackList); 428 DCHECK(m_trackList);
430 429
431 if (m_renderedTrackIndex == invalidTrackIndex) 430 if (m_renderedTrackIndex == invalidTrackIndex)
432 m_renderedTrackIndex = m_trackList->getTrackIndexRelativeToRenderedTrack s(this); 431 m_renderedTrackIndex = m_trackList->getTrackIndexRelativeToRenderedTrack s(this);
433 432
434 return m_renderedTrackIndex; 433 return m_renderedTrackIndex;
435 } 434 }
436 435
437 const AtomicString& TextTrack::interfaceName() const 436 const AtomicString& TextTrack::interfaceName() const
438 { 437 {
439 return EventTargetNames::TextTrack; 438 return EventTargetNames::TextTrack;
(...skipping 28 matching lines...) Expand all
468 visitor->trace(m_trackList); 467 visitor->trace(m_trackList);
469 TrackBase::trace(visitor); 468 TrackBase::trace(visitor);
470 EventTargetWithInlineData::trace(visitor); 469 EventTargetWithInlineData::trace(visitor);
471 } 470 }
472 471
473 DEFINE_TRACE_WRAPPERS(TextTrack) 472 DEFINE_TRACE_WRAPPERS(TextTrack)
474 { 473 {
475 visitor->traceWrappers(m_cues); 474 visitor->traceWrappers(m_cues);
476 } 475 }
477 } // namespace blink 476 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698