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

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: Rebased 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 {
117 ASSERT(!m_trackList); 116 ASSERT(!m_trackList);
118
119 if (m_cues) {
120 for (size_t i = 0; i < m_cues->length(); ++i)
121 m_cues->item(i)->setTrack(0);
122 }
123
124 if (m_regions) {
125 for (size_t i = 0; i < m_regions->length(); ++i)
126 m_regions->item(i)->setTrack(0);
127 }
128 } 117 }
129 118
130 bool TextTrack::isValidKindKeyword(const AtomicString& value) 119 bool TextTrack::isValidKindKeyword(const AtomicString& value)
131 { 120 {
132 if (value == subtitlesKeyword()) 121 if (value == subtitlesKeyword())
133 return true; 122 return true;
134 if (value == captionsKeyword()) 123 if (value == captionsKeyword())
135 return true; 124 return true;
136 if (value == descriptionsKeyword()) 125 if (value == descriptionsKeyword())
137 return true; 126 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 ... 206 // then the activeCues attribute must return a live TextTrackCueList object ...
218 // ... whose active flag was set when the script started, in text track cue 207 // ... 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 208 // order. Otherwise, it must return null. When an object is returned, the
220 // same object must be returned each time. 209 // same object must be returned each time.
221 // http://www.whatwg.org/specs/web-apps/current-work/#dom-texttrack-activecu es 210 // http://www.whatwg.org/specs/web-apps/current-work/#dom-texttrack-activecu es
222 if (m_cues && m_mode != disabledKeyword()) 211 if (m_cues && m_mode != disabledKeyword())
223 return m_cues->activeCues(); 212 return m_cues->activeCues();
224 return 0; 213 return 0;
225 } 214 }
226 215
227 void TextTrack::addCue(PassRefPtr<TextTrackCue> prpCue) 216 void TextTrack::addCue(PassRefPtrWillBeRawPtr<TextTrackCue> prpCue)
228 { 217 {
229 if (!prpCue) 218 if (!prpCue)
230 return; 219 return;
231 220
232 RefPtr<TextTrackCue> cue = prpCue; 221 RefPtrWillBeRawPtr<TextTrackCue> cue = prpCue;
233 222
234 // TODO(93143): Add spec-compliant behavior for negative time values. 223 // 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) 224 if (std::isnan(cue->startTime()) || std::isnan(cue->endTime()) || cue->start Time() < 0 || cue->endTime() < 0)
236 return; 225 return;
237 226
238 // 4.8.10.12.5 Text track API 227 // 4.8.10.12.5 Text track API
239 228
240 // The addCue(cue) method of TextTrack objects, when invoked, must run the f ollowing steps: 229 // The addCue(cue) method of TextTrack objects, when invoked, must run the f ollowing steps:
241 230
242 // 1. If the given cue is in a text track list of cues, then remove cue from that text track 231 // 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 283 // represents is not the text track disabled mode, then the regions
295 // attribute must return a live VTTRegionList object that represents 284 // attribute must return a live VTTRegionList object that represents
296 // the text track list of regions of the text track. Otherwise, it must 285 // 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 286 // return null. When an object is returned, the same object must be returned
298 // each time. 287 // each time.
299 if (RuntimeEnabledFeatures::webVTTRegionsEnabled() && m_mode != disabledKeyw ord()) 288 if (RuntimeEnabledFeatures::webVTTRegionsEnabled() && m_mode != disabledKeyw ord())
300 return ensureVTTRegionList(); 289 return ensureVTTRegionList();
301 return 0; 290 return 0;
302 } 291 }
303 292
304 void TextTrack::addRegion(PassRefPtr<VTTRegion> prpRegion) 293 void TextTrack::addRegion(PassRefPtrWillBeRawPtr<VTTRegion> prpRegion)
305 { 294 {
306 if (!prpRegion) 295 if (!prpRegion)
307 return; 296 return;
308 297
309 RefPtr<VTTRegion> region = prpRegion; 298 RefPtrWillBeRawPtr<VTTRegion> region = prpRegion;
310 VTTRegionList* regionList = ensureVTTRegionList(); 299 VTTRegionList* regionList = ensureVTTRegionList();
311 300
312 // 1. If the given region is in a text track list of regions, then remove 301 // 1. If the given region is in a text track list of regions, then remove
313 // region from that text track list of regions. 302 // region from that text track list of regions.
314 TextTrack* regionTrack = region->track(); 303 TextTrack* regionTrack = region->track();
315 if (regionTrack && regionTrack != this) 304 if (regionTrack && regionTrack != this)
316 regionTrack->removeRegion(region.get(), ASSERT_NO_EXCEPTION); 305 regionTrack->removeRegion(region.get(), ASSERT_NO_EXCEPTION);
317 306
318 // 2. If the method's TextTrack object's text track list of regions contains 307 // 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 308 // 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; 407 return m_renderedTrackIndex;
419 } 408 }
420 409
421 const AtomicString& TextTrack::interfaceName() const 410 const AtomicString& TextTrack::interfaceName() const
422 { 411 {
423 return EventTargetNames::TextTrack; 412 return EventTargetNames::TextTrack;
424 } 413 }
425 414
426 ExecutionContext* TextTrack::executionContext() const 415 ExecutionContext* TextTrack::executionContext() const
427 { 416 {
428 return m_document; 417 HTMLMediaElement* owner = mediaElement();
418 return owner ? owner->executionContext() : 0;
429 } 419 }
430 420
431 HTMLMediaElement* TextTrack::mediaElement() const 421 HTMLMediaElement* TextTrack::mediaElement() const
432 { 422 {
433 return m_trackList ? m_trackList->owner() : 0; 423 return m_trackList ? m_trackList->owner() : 0;
434 } 424 }
435 425
436 Node* TextTrack::owner() const 426 Node* TextTrack::owner() const
437 { 427 {
438 return mediaElement(); 428 return mediaElement();
439 } 429 }
440 430
431 void TextTrack::trace(Visitor* visitor)
432 {
433 visitor->trace(m_cues);
434 visitor->trace(m_regions);
435 visitor->trace(m_trackList);
436 TrackBase::trace(visitor);
437 }
438
441 } // namespace WebCore 439 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698