Chromium Code Reviews| 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 { | 93 { |
| 94 DEFINE_STATIC_LOCAL(const AtomicString, ended, ("showing", AtomicString::Con structFromLiteral)); | 94 DEFINE_STATIC_LOCAL(const AtomicString, ended, ("showing", AtomicString::Con structFromLiteral)); |
| 95 return ended; | 95 return ended; |
| 96 } | 96 } |
| 97 | 97 |
| 98 TextTrack::TextTrack(Document& document, const AtomicString& kind, const AtomicS tring& label, const AtomicString& language, const AtomicString& id, TextTrackTyp e type) | 98 TextTrack::TextTrack(Document& document, const AtomicString& kind, const AtomicS tring& label, const AtomicString& language, const AtomicString& id, TextTrackTyp e type) |
| 99 : TrackBase(TrackBase::TextTrack, label, language, id) | 99 : TrackBase(TrackBase::TextTrack, label, language, id) |
| 100 , m_cues(nullptr) | 100 , m_cues(nullptr) |
| 101 , m_regions(nullptr) | 101 , m_regions(nullptr) |
| 102 , m_document(&document) | 102 , m_document(&document) |
| 103 , m_trackList(0) | 103 , m_trackList(nullptr) |
| 104 , m_mode(disabledKeyword()) | 104 , m_mode(disabledKeyword()) |
| 105 , m_trackType(type) | 105 , m_trackType(type) |
| 106 , m_readinessState(NotLoaded) | 106 , m_readinessState(NotLoaded) |
| 107 , m_trackIndex(invalidTrackIndex) | 107 , m_trackIndex(invalidTrackIndex) |
| 108 , m_renderedTrackIndex(invalidTrackIndex) | 108 , m_renderedTrackIndex(invalidTrackIndex) |
| 109 , m_hasBeenConfigured(false) | 109 , m_hasBeenConfigured(false) |
| 110 { | 110 { |
| 111 ScriptWrappable::init(this); | 111 ScriptWrappable::init(this); |
| 112 setKind(kind); | 112 setKind(kind); |
| 113 } | 113 } |
| 114 | 114 |
| 115 TextTrack::~TextTrack() | 115 TextTrack::~TextTrack() |
| 116 { | 116 { |
| 117 #if !ENABLE(OILPAN) | |
| 117 ASSERT(!m_trackList); | 118 ASSERT(!m_trackList); |
| 118 | 119 |
| 119 if (m_cues) { | 120 if (m_cues) { |
| 120 for (size_t i = 0; i < m_cues->length(); ++i) | 121 for (size_t i = 0; i < m_cues->length(); ++i) |
| 121 m_cues->item(i)->setTrack(0); | 122 m_cues->item(i)->setTrack(0); |
| 122 } | 123 } |
| 123 | 124 |
| 124 if (m_regions) { | 125 if (m_regions) { |
| 125 for (size_t i = 0; i < m_regions->length(); ++i) | 126 for (size_t i = 0; i < m_regions->length(); ++i) |
| 126 m_regions->item(i)->setTrack(0); | 127 m_regions->item(i)->setTrack(0); |
| 127 } | 128 } |
|
haraken
2014/04/21 01:30:54
Actually I don't fully understand the relationship
sof
2014/04/21 15:23:42
Cues and regions for a text track are explicitly a
haraken
2014/04/22 02:37:47
Thanks for the detailed explanation. You explanati
sof
2014/04/22 06:27:51
That is a good observation. As the pointers in the
| |
| 129 #endif | |
| 128 } | 130 } |
| 129 | 131 |
| 130 bool TextTrack::isValidKindKeyword(const AtomicString& value) | 132 bool TextTrack::isValidKindKeyword(const AtomicString& value) |
| 131 { | 133 { |
| 132 if (value == subtitlesKeyword()) | 134 if (value == subtitlesKeyword()) |
| 133 return true; | 135 return true; |
| 134 if (value == captionsKeyword()) | 136 if (value == captionsKeyword()) |
| 135 return true; | 137 return true; |
| 136 if (value == descriptionsKeyword()) | 138 if (value == descriptionsKeyword()) |
| 137 return true; | 139 return true; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 217 // then the activeCues attribute must return a live TextTrackCueList object ... | 219 // then the activeCues attribute must return a live TextTrackCueList object ... |
| 218 // ... whose active flag was set when the script started, in text track cue | 220 // ... whose active flag was set when the script started, in text track cue |
| 219 // order. Otherwise, it must return null. When an object is returned, the | 221 // order. Otherwise, it must return null. When an object is returned, the |
| 220 // same object must be returned each time. | 222 // same object must be returned each time. |
| 221 // http://www.whatwg.org/specs/web-apps/current-work/#dom-texttrack-activecu es | 223 // http://www.whatwg.org/specs/web-apps/current-work/#dom-texttrack-activecu es |
| 222 if (m_cues && m_mode != disabledKeyword()) | 224 if (m_cues && m_mode != disabledKeyword()) |
| 223 return m_cues->activeCues(); | 225 return m_cues->activeCues(); |
| 224 return 0; | 226 return 0; |
| 225 } | 227 } |
| 226 | 228 |
| 227 void TextTrack::addCue(PassRefPtr<TextTrackCue> prpCue) | 229 void TextTrack::addCue(PassRefPtrWillBeRawPtr<TextTrackCue> prpCue) |
| 228 { | 230 { |
| 229 if (!prpCue) | 231 if (!prpCue) |
| 230 return; | 232 return; |
| 231 | 233 |
| 232 RefPtr<TextTrackCue> cue = prpCue; | 234 RefPtrWillBeRawPtr<TextTrackCue> cue = prpCue; |
| 233 | 235 |
| 234 // TODO(93143): Add spec-compliant behavior for negative time values. | 236 // TODO(93143): Add spec-compliant behavior for negative time values. |
| 235 if (std::isnan(cue->startTime()) || std::isnan(cue->endTime()) || cue->start Time() < 0 || cue->endTime() < 0) | 237 if (std::isnan(cue->startTime()) || std::isnan(cue->endTime()) || cue->start Time() < 0 || cue->endTime() < 0) |
| 236 return; | 238 return; |
| 237 | 239 |
| 238 // 4.8.10.12.5 Text track API | 240 // 4.8.10.12.5 Text track API |
| 239 | 241 |
| 240 // The addCue(cue) method of TextTrack objects, when invoked, must run the f ollowing steps: | 242 // The addCue(cue) method of TextTrack objects, when invoked, must run the f ollowing steps: |
| 241 | 243 |
| 242 // 1. If the given cue is in a text track list of cues, then remove cue from that text track | 244 // 1. If the given cue is in a text track list of cues, then remove cue from that text track |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 294 // represents is not the text track disabled mode, then the regions | 296 // represents is not the text track disabled mode, then the regions |
| 295 // attribute must return a live VTTRegionList object that represents | 297 // attribute must return a live VTTRegionList object that represents |
| 296 // the text track list of regions of the text track. Otherwise, it must | 298 // the text track list of regions of the text track. Otherwise, it must |
| 297 // return null. When an object is returned, the same object must be returned | 299 // return null. When an object is returned, the same object must be returned |
| 298 // each time. | 300 // each time. |
| 299 if (RuntimeEnabledFeatures::webVTTRegionsEnabled() && m_mode != disabledKeyw ord()) | 301 if (RuntimeEnabledFeatures::webVTTRegionsEnabled() && m_mode != disabledKeyw ord()) |
| 300 return ensureVTTRegionList(); | 302 return ensureVTTRegionList(); |
| 301 return 0; | 303 return 0; |
| 302 } | 304 } |
| 303 | 305 |
| 304 void TextTrack::addRegion(PassRefPtr<VTTRegion> prpRegion) | 306 void TextTrack::addRegion(PassRefPtrWillBeRawPtr<VTTRegion> prpRegion) |
| 305 { | 307 { |
| 306 if (!prpRegion) | 308 if (!prpRegion) |
| 307 return; | 309 return; |
| 308 | 310 |
| 309 RefPtr<VTTRegion> region = prpRegion; | 311 RefPtrWillBeRawPtr<VTTRegion> region = prpRegion; |
| 310 VTTRegionList* regionList = ensureVTTRegionList(); | 312 VTTRegionList* regionList = ensureVTTRegionList(); |
| 311 | 313 |
| 312 // 1. If the given region is in a text track list of regions, then remove | 314 // 1. If the given region is in a text track list of regions, then remove |
| 313 // region from that text track list of regions. | 315 // region from that text track list of regions. |
| 314 TextTrack* regionTrack = region->track(); | 316 TextTrack* regionTrack = region->track(); |
| 315 if (regionTrack && regionTrack != this) | 317 if (regionTrack && regionTrack != this) |
| 316 regionTrack->removeRegion(region.get(), ASSERT_NO_EXCEPTION); | 318 regionTrack->removeRegion(region.get(), ASSERT_NO_EXCEPTION); |
| 317 | 319 |
| 318 // 2. If the method's TextTrack object's text track list of regions contains | 320 // 2. If the method's TextTrack object's text track list of regions contains |
| 319 // a region with the same identifier as region replace the values of that | 321 // a region with the same identifier as region replace the values of that |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 426 ExecutionContext* TextTrack::executionContext() const | 428 ExecutionContext* TextTrack::executionContext() const |
| 427 { | 429 { |
| 428 return m_document; | 430 return m_document; |
| 429 } | 431 } |
| 430 | 432 |
| 431 HTMLMediaElement* TextTrack::mediaElement() | 433 HTMLMediaElement* TextTrack::mediaElement() |
| 432 { | 434 { |
| 433 return m_trackList ? m_trackList->owner() : 0; | 435 return m_trackList ? m_trackList->owner() : 0; |
| 434 } | 436 } |
| 435 | 437 |
| 438 void TextTrack::trace(Visitor* visitor) | |
| 439 { | |
| 440 visitor->trace(m_cues); | |
| 441 visitor->trace(m_regions); | |
| 442 visitor->trace(m_trackList); | |
| 443 TrackBase::trace(visitor); | |
| 444 } | |
| 445 | |
| 436 } // namespace WebCore | 446 } // namespace WebCore |
| OLD | NEW |