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

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

Issue 244493002: Oilpan: add transition types to track interface objects. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Explicitly dispose of TextTrackList + fix handling of {Inband,Loadable}TextTrack Created 6 years, 8 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 const AtomicString& TextTrack::showingKeyword() 92 const AtomicString& TextTrack::showingKeyword()
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_trackList(nullptr)
103 , m_trackList(0)
104 , m_mode(disabledKeyword()) 103 , m_mode(disabledKeyword())
105 , m_trackType(type) 104 , m_trackType(type)
106 , m_readinessState(NotLoaded) 105 , m_readinessState(NotLoaded)
107 , m_trackIndex(invalidTrackIndex) 106 , m_trackIndex(invalidTrackIndex)
108 , m_renderedTrackIndex(invalidTrackIndex) 107 , m_renderedTrackIndex(invalidTrackIndex)
109 , m_hasBeenConfigured(false) 108 , m_hasBeenConfigured(false)
110 { 109 {
111 ScriptWrappable::init(this); 110 ScriptWrappable::init(this);
112 setKind(kind); 111 setKind(kind);
113 } 112 }
114 113
115 TextTrack::~TextTrack() 114 TextTrack::~TextTrack()
116 { 115 {
116 #if !ENABLE(OILPAN)
117 ASSERT(!m_trackList); 117 ASSERT(!m_trackList);
118 118
119 if (m_cues) { 119 if (m_cues) {
120 for (size_t i = 0; i < m_cues->length(); ++i) 120 for (size_t i = 0; i < m_cues->length(); ++i)
121 m_cues->item(i)->setTrack(0); 121 m_cues->item(i)->setTrack(0);
122 } 122 }
123 123
124 if (m_regions) { 124 if (m_regions) {
125 for (size_t i = 0; i < m_regions->length(); ++i) 125 for (size_t i = 0; i < m_regions->length(); ++i)
126 m_regions->item(i)->setTrack(0); 126 m_regions->item(i)->setTrack(0);
127 } 127 }
128 #endif
128 } 129 }
129 130
130 bool TextTrack::isValidKindKeyword(const AtomicString& value) 131 bool TextTrack::isValidKindKeyword(const AtomicString& value)
131 { 132 {
132 if (value == subtitlesKeyword()) 133 if (value == subtitlesKeyword())
133 return true; 134 return true;
134 if (value == captionsKeyword()) 135 if (value == captionsKeyword())
135 return true; 136 return true;
136 if (value == descriptionsKeyword()) 137 if (value == descriptionsKeyword())
137 return true; 138 return true;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 // then the activeCues attribute must return a live TextTrackCueList object ... 218 // then the activeCues attribute must return a live TextTrackCueList object ...
218 // ... whose active flag was set when the script started, in text track cue 219 // ... 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 220 // order. Otherwise, it must return null. When an object is returned, the
220 // same object must be returned each time. 221 // same object must be returned each time.
221 // http://www.whatwg.org/specs/web-apps/current-work/#dom-texttrack-activecu es 222 // http://www.whatwg.org/specs/web-apps/current-work/#dom-texttrack-activecu es
222 if (m_cues && m_mode != disabledKeyword()) 223 if (m_cues && m_mode != disabledKeyword())
223 return m_cues->activeCues(); 224 return m_cues->activeCues();
224 return 0; 225 return 0;
225 } 226 }
226 227
227 void TextTrack::addCue(PassRefPtr<TextTrackCue> prpCue) 228 void TextTrack::addCue(PassRefPtrWillBeRawPtr<TextTrackCue> prpCue)
228 { 229 {
229 if (!prpCue) 230 if (!prpCue)
230 return; 231 return;
231 232
232 RefPtr<TextTrackCue> cue = prpCue; 233 RefPtrWillBeRawPtr<TextTrackCue> cue = prpCue;
233 234
234 // TODO(93143): Add spec-compliant behavior for negative time values. 235 // 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) 236 if (std::isnan(cue->startTime()) || std::isnan(cue->endTime()) || cue->start Time() < 0 || cue->endTime() < 0)
236 return; 237 return;
237 238
238 // 4.8.10.12.5 Text track API 239 // 4.8.10.12.5 Text track API
239 240
240 // 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:
241 242
242 // 1. If the given cue is in a text track list of cues, then remove cue from that text track 243 // 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
294 // represents is not the text track disabled mode, then the regions 295 // represents is not the text track disabled mode, then the regions
295 // attribute must return a live VTTRegionList object that represents 296 // attribute must return a live VTTRegionList object that represents
296 // the text track list of regions of the text track. Otherwise, it must 297 // 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 298 // return null. When an object is returned, the same object must be returned
298 // each time. 299 // each time.
299 if (RuntimeEnabledFeatures::webVTTRegionsEnabled() && m_mode != disabledKeyw ord()) 300 if (RuntimeEnabledFeatures::webVTTRegionsEnabled() && m_mode != disabledKeyw ord())
300 return ensureVTTRegionList(); 301 return ensureVTTRegionList();
301 return 0; 302 return 0;
302 } 303 }
303 304
304 void TextTrack::addRegion(PassRefPtr<VTTRegion> prpRegion) 305 void TextTrack::addRegion(PassRefPtrWillBeRawPtr<VTTRegion> prpRegion)
305 { 306 {
306 if (!prpRegion) 307 if (!prpRegion)
307 return; 308 return;
308 309
309 RefPtr<VTTRegion> region = prpRegion; 310 RefPtrWillBeRawPtr<VTTRegion> region = prpRegion;
310 VTTRegionList* regionList = ensureVTTRegionList(); 311 VTTRegionList* regionList = ensureVTTRegionList();
311 312
312 // 1. If the given region is in a text track list of regions, then remove 313 // 1. If the given region is in a text track list of regions, then remove
313 // region from that text track list of regions. 314 // region from that text track list of regions.
314 TextTrack* regionTrack = region->track(); 315 TextTrack* regionTrack = region->track();
315 if (regionTrack && regionTrack != this) 316 if (regionTrack && regionTrack != this)
316 regionTrack->removeRegion(region.get(), ASSERT_NO_EXCEPTION); 317 regionTrack->removeRegion(region.get(), ASSERT_NO_EXCEPTION);
317 318
318 // 2. If the method's TextTrack object's text track list of regions contains 319 // 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 320 // a region with the same identifier as region replace the values of that
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 return m_renderedTrackIndex; 419 return m_renderedTrackIndex;
419 } 420 }
420 421
421 const AtomicString& TextTrack::interfaceName() const 422 const AtomicString& TextTrack::interfaceName() const
422 { 423 {
423 return EventTargetNames::TextTrack; 424 return EventTargetNames::TextTrack;
424 } 425 }
425 426
426 ExecutionContext* TextTrack::executionContext() const 427 ExecutionContext* TextTrack::executionContext() const
427 { 428 {
428 return m_document; 429 HTMLMediaElement* owner = mediaElement();
430 return owner ? owner->executionContext() : 0;
429 } 431 }
430 432
431 HTMLMediaElement* TextTrack::mediaElement() 433 HTMLMediaElement* TextTrack::mediaElement() const
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698