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

Side by Side Diff: Source/core/html/track/TextTrackList.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, 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 30 matching lines...) Expand all
41 , m_asyncEventQueue(GenericEventQueue::create(this)) 41 , m_asyncEventQueue(GenericEventQueue::create(this))
42 { 42 {
43 ScriptWrappable::init(this); 43 ScriptWrappable::init(this);
44 } 44 }
45 45
46 TextTrackList::~TextTrackList() 46 TextTrackList::~TextTrackList()
47 { 47 {
48 ASSERT(!m_owner); 48 ASSERT(!m_owner);
49 49
50 m_asyncEventQueue->close(); 50 m_asyncEventQueue->close();
51 }
51 52
53 void TextTrackList::dispose()
54 {
52 for (unsigned i = 0; i < length(); ++i) { 55 for (unsigned i = 0; i < length(); ++i) {
53 item(i)->setTrackList(0); 56 item(i)->setTrackList(0);
haraken 2014/04/22 02:37:47 Just help me understand: Why do we need to explici
sof 2014/04/22 06:27:52 Yes, no need to do the clearing for any of those.
haraken 2014/04/22 06:41:09 ah, that makes sense. Thanks for the clarification
54 } 57 }
55 } 58 }
56 59
57 unsigned TextTrackList::length() const 60 unsigned TextTrackList::length() const
58 { 61 {
59 return m_addTrackTracks.size() + m_elementTracks.size() + m_inbandTracks.siz e(); 62 return m_addTrackTracks.size() + m_elementTracks.size() + m_inbandTracks.siz e();
60 } 63 }
61 64
62 int TextTrackList::getTrackIndex(TextTrack *textTrack) 65 int TextTrackList::getTrackIndex(TextTrack *textTrack)
63 { 66 {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 if (track->id() == id) 149 if (track->id() == id)
147 return track; 150 return track;
148 } 151 }
149 152
150 // When no tracks match the given argument, the method must return null. 153 // When no tracks match the given argument, the method must return null.
151 return 0; 154 return 0;
152 } 155 }
153 156
154 void TextTrackList::invalidateTrackIndexesAfterTrack(TextTrack* track) 157 void TextTrackList::invalidateTrackIndexesAfterTrack(TextTrack* track)
155 { 158 {
156 Vector<RefPtr<TextTrack> >* tracks = 0; 159 WillBeHeapVector<RefPtrWillBeMember<TextTrack> >* tracks = 0;
157 160
158 if (track->trackType() == TextTrack::TrackElement) { 161 if (track->trackType() == TextTrack::TrackElement) {
159 tracks = &m_elementTracks; 162 tracks = &m_elementTracks;
160 for (size_t i = 0; i < m_addTrackTracks.size(); ++i) 163 for (size_t i = 0; i < m_addTrackTracks.size(); ++i)
161 m_addTrackTracks[i]->invalidateTrackIndex(); 164 m_addTrackTracks[i]->invalidateTrackIndex();
162 for (size_t i = 0; i < m_inbandTracks.size(); ++i) 165 for (size_t i = 0; i < m_inbandTracks.size(); ++i)
163 m_inbandTracks[i]->invalidateTrackIndex(); 166 m_inbandTracks[i]->invalidateTrackIndex();
164 } else if (track->trackType() == TextTrack::AddTrack) { 167 } else if (track->trackType() == TextTrack::AddTrack) {
165 tracks = &m_addTrackTracks; 168 tracks = &m_addTrackTracks;
166 for (size_t i = 0; i < m_inbandTracks.size(); ++i) 169 for (size_t i = 0; i < m_inbandTracks.size(); ++i)
167 m_inbandTracks[i]->invalidateTrackIndex(); 170 m_inbandTracks[i]->invalidateTrackIndex();
168 } else if (track->trackType() == TextTrack::InBand) 171 } else if (track->trackType() == TextTrack::InBand)
169 tracks = &m_inbandTracks; 172 tracks = &m_inbandTracks;
170 else 173 else
171 ASSERT_NOT_REACHED(); 174 ASSERT_NOT_REACHED();
172 175
173 size_t index = tracks->find(track); 176 size_t index = tracks->find(track);
174 if (index == kNotFound) 177 if (index == kNotFound)
175 return; 178 return;
176 179
177 for (size_t i = index; i < tracks->size(); ++i) 180 for (size_t i = index; i < tracks->size(); ++i)
178 tracks->at(index)->invalidateTrackIndex(); 181 tracks->at(index)->invalidateTrackIndex();
179 } 182 }
180 183
181 void TextTrackList::append(PassRefPtr<TextTrack> prpTrack) 184 void TextTrackList::append(PassRefPtrWillBeRawPtr<TextTrack> prpTrack)
182 { 185 {
183 RefPtr<TextTrack> track = prpTrack; 186 RefPtrWillBeRawPtr<TextTrack> track = prpTrack;
184 187
185 if (track->trackType() == TextTrack::AddTrack) 188 if (track->trackType() == TextTrack::AddTrack)
186 m_addTrackTracks.append(track); 189 m_addTrackTracks.append(track);
187 else if (track->trackType() == TextTrack::TrackElement) { 190 else if (track->trackType() == TextTrack::TrackElement) {
188 // Insert tracks added for <track> element in tree order. 191 // Insert tracks added for <track> element in tree order.
189 size_t index = static_cast<LoadableTextTrack*>(track.get())->trackElemen tIndex(); 192 size_t index = static_cast<LoadableTextTrack*>(track.get())->trackElemen tIndex();
190 m_elementTracks.insert(index, track); 193 m_elementTracks.insert(index, track);
191 } else if (track->trackType() == TextTrack::InBand) { 194 } else if (track->trackType() == TextTrack::InBand) {
192 // Insert tracks added for in-band in the media file order. 195 // Insert tracks added for in-band in the media file order.
193 size_t index = static_cast<InbandTextTrack*>(track.get())->inbandTrackIn dex(); 196 size_t index = static_cast<InbandTextTrack*>(track.get())->inbandTrackIn dex();
194 m_inbandTracks.insert(index, track); 197 m_inbandTracks.insert(index, track);
195 } else 198 } else
196 ASSERT_NOT_REACHED(); 199 ASSERT_NOT_REACHED();
197 200
198 invalidateTrackIndexesAfterTrack(track.get()); 201 invalidateTrackIndexesAfterTrack(track.get());
199 202
200 ASSERT(!track->trackList()); 203 ASSERT(!track->trackList());
201 track->setTrackList(this); 204 track->setTrackList(this);
202 205
203 scheduleAddTrackEvent(track.release()); 206 scheduleAddTrackEvent(track.release());
204 } 207 }
205 208
206 void TextTrackList::remove(TextTrack* track) 209 void TextTrackList::remove(TextTrack* track)
207 { 210 {
208 Vector<RefPtr<TextTrack> >* tracks = 0; 211 WillBeHeapVector<RefPtrWillBeMember<TextTrack> >* tracks = 0;
209 212
210 if (track->trackType() == TextTrack::TrackElement) { 213 if (track->trackType() == TextTrack::TrackElement) {
211 tracks = &m_elementTracks; 214 tracks = &m_elementTracks;
212 } else if (track->trackType() == TextTrack::AddTrack) { 215 } else if (track->trackType() == TextTrack::AddTrack) {
213 tracks = &m_addTrackTracks; 216 tracks = &m_addTrackTracks;
214 } else if (track->trackType() == TextTrack::InBand) { 217 } else if (track->trackType() == TextTrack::InBand) {
215 tracks = &m_inbandTracks; 218 tracks = &m_inbandTracks;
216 } else { 219 } else {
217 ASSERT_NOT_REACHED(); 220 ASSERT_NOT_REACHED();
218 } 221 }
(...skipping 15 matching lines...) Expand all
234 void TextTrackList::removeAllInbandTracks() 237 void TextTrackList::removeAllInbandTracks()
235 { 238 {
236 for (unsigned i = 0; i < m_inbandTracks.size(); ++i) { 239 for (unsigned i = 0; i < m_inbandTracks.size(); ++i) {
237 m_inbandTracks[i]->setTrackList(0); 240 m_inbandTracks[i]->setTrackList(0);
238 } 241 }
239 m_inbandTracks.clear(); 242 m_inbandTracks.clear();
240 } 243 }
241 244
242 bool TextTrackList::contains(TextTrack* track) const 245 bool TextTrackList::contains(TextTrack* track) const
243 { 246 {
244 const Vector<RefPtr<TextTrack> >* tracks = 0; 247 const WillBeHeapVector<RefPtrWillBeMember<TextTrack> >* tracks = 0;
245 248
246 if (track->trackType() == TextTrack::TrackElement) 249 if (track->trackType() == TextTrack::TrackElement)
247 tracks = &m_elementTracks; 250 tracks = &m_elementTracks;
248 else if (track->trackType() == TextTrack::AddTrack) 251 else if (track->trackType() == TextTrack::AddTrack)
249 tracks = &m_addTrackTracks; 252 tracks = &m_addTrackTracks;
250 else if (track->trackType() == TextTrack::InBand) 253 else if (track->trackType() == TextTrack::InBand)
251 tracks = &m_inbandTracks; 254 tracks = &m_inbandTracks;
252 else 255 else
253 ASSERT_NOT_REACHED(); 256 ASSERT_NOT_REACHED();
254 257
255 return tracks->find(track) != kNotFound; 258 return tracks->find(track) != kNotFound;
256 } 259 }
257 260
258 const AtomicString& TextTrackList::interfaceName() const 261 const AtomicString& TextTrackList::interfaceName() const
259 { 262 {
260 return EventTargetNames::TextTrackList; 263 return EventTargetNames::TextTrackList;
261 } 264 }
262 265
263 ExecutionContext* TextTrackList::executionContext() const 266 ExecutionContext* TextTrackList::executionContext() const
264 { 267 {
265 ASSERT(m_owner); 268 ASSERT(m_owner);
266 return m_owner->executionContext(); 269 return m_owner->executionContext();
267 } 270 }
268 271
269 void TextTrackList::clearOwner() 272 void TextTrackList::clearOwner()
270 { 273 {
271 m_owner = 0; 274 m_owner = 0;
272 } 275 }
273 276
274 void TextTrackList::scheduleTrackEvent(const AtomicString& eventName, PassRefPtr <TextTrack> track) 277 void TextTrackList::scheduleTrackEvent(const AtomicString& eventName, PassRefPtr WillBeRawPtr<TextTrack> track)
275 { 278 {
276 TrackEventInit initializer; 279 TrackEventInit initializer;
277 initializer.track = track; 280 initializer.track = track;
278 initializer.bubbles = false; 281 initializer.bubbles = false;
279 initializer.cancelable = false; 282 initializer.cancelable = false;
280 283
281 m_asyncEventQueue->enqueueEvent(TrackEvent::create(eventName, initializer)); 284 m_asyncEventQueue->enqueueEvent(TrackEvent::create(eventName, initializer));
282 } 285 }
283 286
284 void TextTrackList::scheduleAddTrackEvent(PassRefPtr<TextTrack> track) 287 void TextTrackList::scheduleAddTrackEvent(PassRefPtrWillBeRawPtr<TextTrack> trac k)
285 { 288 {
286 // 4.8.10.12.3 Sourcing out-of-band text tracks 289 // 4.8.10.12.3 Sourcing out-of-band text tracks
287 // 4.8.10.12.4 Text track API 290 // 4.8.10.12.4 Text track API
288 // ... then queue a task to fire an event with the name addtrack, that does not 291 // ... then queue a task to fire an event with the name addtrack, that does not
289 // bubble and is not cancelable, and that uses the TrackEvent interface, wit h 292 // bubble and is not cancelable, and that uses the TrackEvent interface, wit h
290 // the track attribute initialized to the text track's TextTrack object, at 293 // the track attribute initialized to the text track's TextTrack object, at
291 // the media element's textTracks attribute's TextTrackList object. 294 // the media element's textTracks attribute's TextTrackList object.
292 scheduleTrackEvent(EventTypeNames::addtrack, track); 295 scheduleTrackEvent(EventTypeNames::addtrack, track);
293 } 296 }
294 297
295 void TextTrackList::scheduleChangeEvent() 298 void TextTrackList::scheduleChangeEvent()
296 { 299 {
297 // 4.8.10.12.1 Text track model 300 // 4.8.10.12.1 Text track model
298 // Whenever a text track that is in a media element's list of text tracks 301 // Whenever a text track that is in a media element's list of text tracks
299 // has its text track mode change value, the user agent must run the 302 // has its text track mode change value, the user agent must run the
300 // following steps for the media element: 303 // following steps for the media element:
301 // ... 304 // ...
302 // Fire a simple event named change at the media element's textTracks 305 // Fire a simple event named change at the media element's textTracks
303 // attribute's TextTrackList object. 306 // attribute's TextTrackList object.
304 307
305 EventInit initializer; 308 EventInit initializer;
306 initializer.bubbles = false; 309 initializer.bubbles = false;
307 initializer.cancelable = false; 310 initializer.cancelable = false;
308 311
309 m_asyncEventQueue->enqueueEvent(Event::create(EventTypeNames::change, initia lizer)); 312 m_asyncEventQueue->enqueueEvent(Event::create(EventTypeNames::change, initia lizer));
310 } 313 }
311 314
312 void TextTrackList::scheduleRemoveTrackEvent(PassRefPtr<TextTrack> track) 315 void TextTrackList::scheduleRemoveTrackEvent(PassRefPtrWillBeRawPtr<TextTrack> t rack)
313 { 316 {
314 // 4.8.10.12.3 Sourcing out-of-band text tracks 317 // 4.8.10.12.3 Sourcing out-of-band text tracks
315 // When a track element's parent element changes and the old parent was a 318 // When a track element's parent element changes and the old parent was a
316 // media element, then the user agent must remove the track element's 319 // media element, then the user agent must remove the track element's
317 // corresponding text track from the media element's list of text tracks, 320 // corresponding text track from the media element's list of text tracks,
318 // and then queue a task to fire a trusted event with the name removetrack, 321 // and then queue a task to fire a trusted event with the name removetrack,
319 // that does not bubble and is not cancelable, and that uses the TrackEvent 322 // that does not bubble and is not cancelable, and that uses the TrackEvent
320 // interface, with the track attribute initialized to the text track's 323 // interface, with the track attribute initialized to the text track's
321 // TextTrack object, at the media element's textTracks attribute's 324 // TextTrack object, at the media element's textTracks attribute's
322 // TextTrackList object. 325 // TextTrackList object.
323 scheduleTrackEvent(EventTypeNames::removetrack, track); 326 scheduleTrackEvent(EventTypeNames::removetrack, track);
324 } 327 }
325 328
326 HTMLMediaElement* TextTrackList::owner() const 329 HTMLMediaElement* TextTrackList::owner() const
327 { 330 {
328 return m_owner; 331 return m_owner;
329 } 332 }
333
334 void TextTrackList::trace(Visitor* visitor)
335 {
336 visitor->trace(m_addTrackTracks);
337 visitor->trace(m_elementTracks);
338 visitor->trace(m_inbandTracks);
339 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698