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

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

Issue 177003025: Remove TextTrackClient interface to simplify TextTrack code. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/html/track/TextTrackList.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011, 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 28 matching lines...) Expand all
39 39
40 TextTrackList::TextTrackList(HTMLMediaElement* owner) 40 TextTrackList::TextTrackList(HTMLMediaElement* owner)
41 : m_owner(owner) 41 : m_owner(owner)
42 , m_asyncEventQueue(GenericEventQueue::create(this)) 42 , m_asyncEventQueue(GenericEventQueue::create(this))
43 { 43 {
44 ScriptWrappable::init(this); 44 ScriptWrappable::init(this);
45 } 45 }
46 46
47 TextTrackList::~TextTrackList() 47 TextTrackList::~TextTrackList()
48 { 48 {
49 ASSERT(!m_owner);
50
49 m_asyncEventQueue->close(); 51 m_asyncEventQueue->close();
52
53 for (unsigned i = 0; i < length(); ++i) {
54 item(i)->setTrackList(0);
55 }
50 } 56 }
51 57
52 unsigned TextTrackList::length() const 58 unsigned TextTrackList::length() const
53 { 59 {
54 return m_addTrackTracks.size() + m_elementTracks.size() + m_inbandTracks.siz e(); 60 return m_addTrackTracks.size() + m_elementTracks.size() + m_inbandTracks.siz e();
55 } 61 }
56 62
57 int TextTrackList::getTrackIndex(TextTrack *textTrack) 63 int TextTrackList::getTrackIndex(TextTrack *textTrack)
58 { 64 {
59 if (textTrack->trackType() == TextTrack::TrackElement) 65 if (textTrack->trackType() == TextTrack::TrackElement)
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 track->setTrackList(0); 228 track->setTrackList(0);
223 229
224 tracks->remove(index); 230 tracks->remove(index);
225 231
226 scheduleRemoveTrackEvent(track); 232 scheduleRemoveTrackEvent(track);
227 } 233 }
228 234
229 void TextTrackList::removeAllInbandTracks() 235 void TextTrackList::removeAllInbandTracks()
230 { 236 {
231 for (unsigned i = 0; i < m_inbandTracks.size(); ++i) { 237 for (unsigned i = 0; i < m_inbandTracks.size(); ++i) {
232 m_inbandTracks[i]->invalidateTrackIndex();
233 m_inbandTracks[i]->setTrackList(0); 238 m_inbandTracks[i]->setTrackList(0);
234 } 239 }
235 m_inbandTracks.clear(); 240 m_inbandTracks.clear();
236 } 241 }
237 242
238 bool TextTrackList::contains(TextTrack* track) const 243 bool TextTrackList::contains(TextTrack* track) const
239 { 244 {
240 const Vector<RefPtr<TextTrack> >* tracks = 0; 245 const Vector<RefPtr<TextTrack> >* tracks = 0;
241 246
242 if (track->trackType() == TextTrack::TrackElement) 247 if (track->trackType() == TextTrack::TrackElement)
(...skipping 12 matching lines...) Expand all
255 { 260 {
256 return EventTargetNames::TextTrackList; 261 return EventTargetNames::TextTrackList;
257 } 262 }
258 263
259 ExecutionContext* TextTrackList::executionContext() const 264 ExecutionContext* TextTrackList::executionContext() const
260 { 265 {
261 ASSERT(m_owner); 266 ASSERT(m_owner);
262 return m_owner->executionContext(); 267 return m_owner->executionContext();
263 } 268 }
264 269
265 void TextTrackList::clearOwnerAndClients() 270 void TextTrackList::clearOwner()
266 { 271 {
267 m_owner = 0; 272 m_owner = 0;
268
269 for (unsigned i = 0; i < length(); ++i)
270 item(i)->clearClient();
271 } 273 }
272 274
273 void TextTrackList::scheduleTrackEvent(const AtomicString& eventName, PassRefPtr <TextTrack> track) 275 void TextTrackList::scheduleTrackEvent(const AtomicString& eventName, PassRefPtr <TextTrack> track)
274 { 276 {
275 TrackEventInit initializer; 277 TrackEventInit initializer;
276 initializer.track = track; 278 initializer.track = track;
277 initializer.bubbles = false; 279 initializer.bubbles = false;
278 initializer.cancelable = false; 280 initializer.cancelable = false;
279 281
280 m_asyncEventQueue->enqueueEvent(TrackEvent::create(eventName, initializer)); 282 m_asyncEventQueue->enqueueEvent(TrackEvent::create(eventName, initializer));
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 // interface, with the track attribute initialized to the text track's 321 // interface, with the track attribute initialized to the text track's
320 // TextTrack object, at the media element's textTracks attribute's 322 // TextTrack object, at the media element's textTracks attribute's
321 // TextTrackList object. 323 // TextTrackList object.
322 scheduleTrackEvent(EventTypeNames::removetrack, track); 324 scheduleTrackEvent(EventTypeNames::removetrack, track);
323 } 325 }
324 326
325 HTMLMediaElement* TextTrackList::owner() const 327 HTMLMediaElement* TextTrackList::owner() const
326 { 328 {
327 return m_owner; 329 return m_owner;
328 } 330 }
OLDNEW
« no previous file with comments | « Source/core/html/track/TextTrackList.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698