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 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 // order. Otherwise, it must return null. When an object is returned, the | 218 // order. Otherwise, it must return null. When an object is returned, the |
219 // same object must be returned each time. | 219 // same object must be returned each time. |
220 // http://www.whatwg.org/specs/web-apps/current-work/#dom-texttrack-activecu
es | 220 // http://www.whatwg.org/specs/web-apps/current-work/#dom-texttrack-activecu
es |
221 if (m_cues && m_mode != disabledKeyword()) | 221 if (m_cues && m_mode != disabledKeyword()) |
222 return m_cues->activeCues(); | 222 return m_cues->activeCues(); |
223 return nullptr; | 223 return nullptr; |
224 } | 224 } |
225 | 225 |
226 void TextTrack::addCue(PassRefPtrWillBeRawPtr<TextTrackCue> prpCue) | 226 void TextTrack::addCue(PassRefPtrWillBeRawPtr<TextTrackCue> prpCue) |
227 { | 227 { |
228 if (!prpCue) | 228 ASSERT(prpCue); |
229 return; | |
230 | |
231 RefPtrWillBeRawPtr<TextTrackCue> cue = prpCue; | 229 RefPtrWillBeRawPtr<TextTrackCue> cue = prpCue; |
232 | 230 |
233 // TODO(93143): Add spec-compliant behavior for negative time values. | 231 // 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) | 232 if (std::isnan(cue->startTime()) || std::isnan(cue->endTime()) || cue->start
Time() < 0 || cue->endTime() < 0) |
235 return; | 233 return; |
236 | 234 |
237 // 4.8.10.12.5 Text track API | 235 // 4.8.10.12.5 Text track API |
238 | 236 |
239 // The addCue(cue) method of TextTrack objects, when invoked, must run the f
ollowing steps: | 237 // The addCue(cue) method of TextTrack objects, when invoked, must run the f
ollowing steps: |
240 | 238 |
241 // 1. If the given cue is in a text track list of cues, then remove cue from
that text track | 239 // 1. If the given cue is in a text track list of cues, then remove cue from
that text track |
242 // list of cues. | 240 // list of cues. |
243 TextTrack* cueTrack = cue->track(); | 241 TextTrack* cueTrack = cue->track(); |
244 if (cueTrack && cueTrack != this) | 242 if (cueTrack && cueTrack != this) |
245 cueTrack->removeCue(cue.get(), ASSERT_NO_EXCEPTION); | 243 cueTrack->removeCue(cue.get(), ASSERT_NO_EXCEPTION); |
246 | 244 |
247 // 2. Add cue to the method's TextTrack object's text track's text track lis
t of cues. | 245 // 2. Add cue to the method's TextTrack object's text track's text track lis
t of cues. |
248 cue->setTrack(this); | 246 cue->setTrack(this); |
249 ensureTextTrackCueList()->add(cue); | 247 ensureTextTrackCueList()->add(cue); |
250 | 248 |
251 if (cueTimeline() && m_mode != disabledKeyword()) | 249 if (cueTimeline() && m_mode != disabledKeyword()) |
252 cueTimeline()->addCue(this, cue.get()); | 250 cueTimeline()->addCue(this, cue.get()); |
253 } | 251 } |
254 | 252 |
255 void TextTrack::removeCue(TextTrackCue* cue, ExceptionState& exceptionState) | 253 void TextTrack::removeCue(TextTrackCue* cue, ExceptionState& exceptionState) |
256 { | 254 { |
257 if (!cue) | 255 ASSERT(cue); |
258 return; | |
259 | 256 |
260 // 4.8.10.12.5 Text track API | 257 // 4.8.10.12.5 Text track API |
261 | 258 |
262 // The removeCue(cue) method of TextTrack objects, when invoked, must run th
e following steps: | 259 // The removeCue(cue) method of TextTrack objects, when invoked, must run th
e following steps: |
263 | 260 |
264 // 1. If the given cue is not currently listed in the method's TextTrack | 261 // 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. | 262 // object's text track's text track list of cues, then throw a NotFoundError
exception. |
266 if (cue->track() != this) { | 263 if (cue->track() != this) { |
267 exceptionState.throwDOMException(NotFoundError, "The specified cue is no
t listed in the TextTrack's list of cues."); | 264 exceptionState.throwDOMException(NotFoundError, "The specified cue is no
t listed in the TextTrack's list of cues."); |
268 return; | 265 return; |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 DEFINE_TRACE(TextTrack) | 446 DEFINE_TRACE(TextTrack) |
450 { | 447 { |
451 visitor->trace(m_cues); | 448 visitor->trace(m_cues); |
452 visitor->trace(m_regions); | 449 visitor->trace(m_regions); |
453 visitor->trace(m_trackList); | 450 visitor->trace(m_trackList); |
454 TrackBase::trace(visitor); | 451 TrackBase::trace(visitor); |
455 EventTargetWithInlineData::trace(visitor); | 452 EventTargetWithInlineData::trace(visitor); |
456 } | 453 } |
457 | 454 |
458 } // namespace blink | 455 } // namespace blink |
OLD | NEW |