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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
203 | 203 |
204 invalidateTrackIndexesAfterTrack(track); | 204 invalidateTrackIndexesAfterTrack(track); |
205 | 205 |
206 ASSERT(track->mediaElement() == m_owner); | 206 ASSERT(track->mediaElement() == m_owner); |
207 track->setMediaElement(0); | 207 track->setMediaElement(0); |
208 | 208 |
209 tracks->remove(index); | 209 tracks->remove(index); |
210 | 210 |
211 if (inbandTrack) | 211 if (inbandTrack) |
212 inbandTrack->trackRemoved(); | 212 inbandTrack->trackRemoved(); |
213 | |
214 scheduleRemoveTrackEvent(track); | |
213 } | 215 } |
214 | 216 |
215 bool TextTrackList::contains(TextTrack* track) const | 217 bool TextTrackList::contains(TextTrack* track) const |
216 { | 218 { |
217 const Vector<RefPtr<TextTrack> >* tracks = 0; | 219 const Vector<RefPtr<TextTrack> >* tracks = 0; |
218 | 220 |
219 if (track->trackType() == TextTrack::TrackElement) | 221 if (track->trackType() == TextTrack::TrackElement) |
220 tracks = &m_elementTracks; | 222 tracks = &m_elementTracks; |
221 else if (track->trackType() == TextTrack::AddTrack) | 223 else if (track->trackType() == TextTrack::AddTrack) |
222 tracks = &m_addTrackTracks; | 224 tracks = &m_addTrackTracks; |
(...skipping 29 matching lines...) Expand all Loading... | |
252 TrackEventInit initializer; | 254 TrackEventInit initializer; |
253 initializer.track = trackRef; | 255 initializer.track = trackRef; |
254 initializer.bubbles = false; | 256 initializer.bubbles = false; |
255 initializer.cancelable = false; | 257 initializer.cancelable = false; |
256 | 258 |
257 m_pendingEvents.append(TrackEvent::create(EventTypeNames::addtrack, initiali zer)); | 259 m_pendingEvents.append(TrackEvent::create(EventTypeNames::addtrack, initiali zer)); |
258 if (!m_pendingEventTimer.isActive()) | 260 if (!m_pendingEventTimer.isActive()) |
259 m_pendingEventTimer.startOneShot(0); | 261 m_pendingEventTimer.startOneShot(0); |
260 } | 262 } |
261 | 263 |
264 void TextTrackList::scheduleChangeEvent() | |
265 { | |
266 // 4.8.10.12.1 Text track model | |
267 // Whenever a text track that is in a media element's list of text tracks | |
268 // has its text track mode change value, the user agent must run the | |
269 // following steps for the media element: | |
270 // ... | |
271 // Fire a simple event named change at the media element's textTracks | |
272 // attribute's TextTrackList object. | |
273 | |
274 EventInit initializer; | |
275 initializer.bubbles = false; | |
276 initializer.cancelable = false; | |
277 | |
278 m_pendingEvents.append(Event::create(EventTypeNames::change, initializer)); | |
279 if (!m_pendingEventTimer.isActive()) | |
280 m_pendingEventTimer.startOneShot(0); | |
281 } | |
282 | |
283 void TextTrackList::scheduleRemoveTrackEvent(PassRefPtr<TextTrack> track) | |
284 { | |
285 // 4.8.10.12.3 Sourcing out-of-band text tracks | |
286 // When a track element's parent element changes and the old parent was a | |
287 // media element, then the user agent must remove the track element's | |
288 // corresponding text track from the media element's list of text tracks, | |
289 // and then queue a task to fire a trusted event with the name removetrack, | |
290 // that does not bubble and is not cancelable, and that uses the TrackEvent | |
291 // interface, with the track attribute initialized to the text track's | |
292 // TextTrack object, at the media element's textTracks attribute's | |
293 // TextTrackList object. | |
294 | |
295 RefPtr<TrackBase> trackRef = track; | |
acolwell GONE FROM CHROMIUM
2013/11/22 23:47:58
nit: Please move this to a scheduleTrackEvent(cons
| |
296 TrackEventInit initializer; | |
297 initializer.track = trackRef; | |
298 initializer.bubbles = false; | |
299 initializer.cancelable = false; | |
300 | |
301 m_pendingEvents.append(TrackEvent::create(EventTypeNames::removetrack, initi alizer)); | |
acolwell GONE FROM CHROMIUM
2013/11/22 23:47:58
m_pendingEvents & m_pendingEventTimer should reall
| |
302 if (!m_pendingEventTimer.isActive()) | |
303 m_pendingEventTimer.startOneShot(0); | |
304 } | |
305 | |
262 void TextTrackList::asyncEventTimerFired(Timer<TextTrackList>*) | 306 void TextTrackList::asyncEventTimerFired(Timer<TextTrackList>*) |
263 { | 307 { |
264 Vector<RefPtr<Event> > pendingEvents; | 308 Vector<RefPtr<Event> > pendingEvents; |
265 | 309 |
266 ++m_dispatchingEvents; | 310 ++m_dispatchingEvents; |
267 m_pendingEvents.swap(pendingEvents); | 311 m_pendingEvents.swap(pendingEvents); |
268 size_t count = pendingEvents.size(); | 312 size_t count = pendingEvents.size(); |
269 for (size_t index = 0; index < count; ++index) | 313 for (size_t index = 0; index < count; ++index) |
270 dispatchEvent(pendingEvents[index].release(), IGNORE_EXCEPTION); | 314 dispatchEvent(pendingEvents[index].release(), IGNORE_EXCEPTION); |
271 --m_dispatchingEvents; | 315 --m_dispatchingEvents; |
272 } | 316 } |
273 | 317 |
274 Node* TextTrackList::owner() const | 318 Node* TextTrackList::owner() const |
275 { | 319 { |
276 return m_owner; | 320 return m_owner; |
277 } | 321 } |
OLD | NEW |