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 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 // attribute must return a live VTTRegionList object that represents | 294 // attribute must return a live VTTRegionList object that represents |
295 // the text track list of regions of the text track. Otherwise, it must | 295 // the text track list of regions of the text track. Otherwise, it must |
296 // return null. When an object is returned, the same object must be returned | 296 // return null. When an object is returned, the same object must be returned |
297 // each time. | 297 // each time. |
298 if (RuntimeEnabledFeatures::webVTTRegionsEnabled() && | 298 if (RuntimeEnabledFeatures::webVTTRegionsEnabled() && |
299 m_mode != disabledKeyword()) | 299 m_mode != disabledKeyword()) |
300 return ensureVTTRegionList(); | 300 return ensureVTTRegionList(); |
301 return nullptr; | 301 return nullptr; |
302 } | 302 } |
303 | 303 |
304 void TextTrack::addRegion(VTTRegion* region) { | |
305 if (!region) | |
306 return; | |
307 | |
308 VTTRegionList* regionList = ensureVTTRegionList(); | |
309 | |
310 // 1. If the given region is in a text track list of regions, then remove | |
311 // region from that text track list of regions. | |
312 TextTrack* regionTrack = region->track(); | |
313 if (regionTrack && regionTrack != this) | |
314 regionTrack->removeRegion(region, ASSERT_NO_EXCEPTION); | |
315 | |
316 // 2. If the method's TextTrack object's text track list of regions contains | |
317 // a region with the same identifier as region replace the values of that | |
318 // region's width, height, anchor point, viewport anchor point and scroll | |
319 // attributes with those of region. | |
320 VTTRegion* existingRegion = regionList->getRegionById(region->id()); | |
321 if (existingRegion) { | |
322 existingRegion->updateParametersFromRegion(region); | |
323 return; | |
324 } | |
325 | |
326 // Otherwise: add region to the method's TextTrack object's text track | |
327 // list of regions. | |
328 region->setTrack(this); | |
329 regionList->add(region); | |
330 } | |
331 | |
332 void TextTrack::removeRegion(VTTRegion* region, | |
333 ExceptionState& exceptionState) { | |
334 if (!region) | |
335 return; | |
336 | |
337 // 1. If the given region is not currently listed in the method's TextTrack | |
338 // object's text track list of regions, then throw a NotFoundError exception. | |
339 if (region->track() != this) { | |
340 exceptionState.throwDOMException(NotFoundError, | |
341 "The specified region is not listed in " | |
342 "the TextTrack's list of regions."); | |
343 return; | |
344 } | |
345 | |
346 if (!m_regions || !m_regions->remove(region)) { | |
347 exceptionState.throwDOMException(InvalidStateError, | |
348 "Failed to remove the specified region."); | |
349 return; | |
350 } | |
351 | |
352 region->setTrack(0); | |
353 } | |
354 | |
355 void TextTrack::cueWillChange(TextTrackCue* cue) { | 304 void TextTrack::cueWillChange(TextTrackCue* cue) { |
356 // The cue may need to be repositioned in the media element's interval tree, | 305 // The cue may need to be repositioned in the media element's interval tree, |
357 // may need to be re-rendered, etc, so remove it before the modification... | 306 // may need to be re-rendered, etc, so remove it before the modification... |
358 if (cueTimeline()) | 307 if (cueTimeline()) |
359 cueTimeline()->removeCue(this, cue); | 308 cueTimeline()->removeCue(this, cue); |
360 } | 309 } |
361 | 310 |
362 void TextTrack::cueDidChange(TextTrackCue* cue) { | 311 void TextTrack::cueDidChange(TextTrackCue* cue) { |
363 // This method is called through cue->track(), which should imply that this | 312 // This method is called through cue->track(), which should imply that this |
364 // track has a list of cues. | 313 // track has a list of cues. |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 visitor->trace(m_trackList); | 401 visitor->trace(m_trackList); |
453 TrackBase::trace(visitor); | 402 TrackBase::trace(visitor); |
454 EventTargetWithInlineData::trace(visitor); | 403 EventTargetWithInlineData::trace(visitor); |
455 } | 404 } |
456 | 405 |
457 DEFINE_TRACE_WRAPPERS(TextTrack) { | 406 DEFINE_TRACE_WRAPPERS(TextTrack) { |
458 visitor->traceWrappers(m_cues); | 407 visitor->traceWrappers(m_cues); |
459 EventTargetWithInlineData::traceWrappers(visitor); | 408 EventTargetWithInlineData::traceWrappers(visitor); |
460 } | 409 } |
461 } // namespace blink | 410 } // namespace blink |
OLD | NEW |