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