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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 | 194 |
195 ASSERT(!track->trackList()); | 195 ASSERT(!track->trackList()); |
196 track->setTrackList(this); | 196 track->setTrackList(this); |
197 | 197 |
198 scheduleAddTrackEvent(track.release()); | 198 scheduleAddTrackEvent(track.release()); |
199 } | 199 } |
200 | 200 |
201 void TextTrackList::remove(TextTrack* track) | 201 void TextTrackList::remove(TextTrack* track) |
202 { | 202 { |
203 Vector<RefPtr<TextTrack> >* tracks = 0; | 203 Vector<RefPtr<TextTrack> >* tracks = 0; |
204 RefPtr<InbandTextTrack> inbandTrack; | |
205 | 204 |
206 if (track->trackType() == TextTrack::TrackElement) { | 205 if (track->trackType() == TextTrack::TrackElement) { |
207 tracks = &m_elementTracks; | 206 tracks = &m_elementTracks; |
208 } else if (track->trackType() == TextTrack::AddTrack) { | 207 } else if (track->trackType() == TextTrack::AddTrack) { |
209 tracks = &m_addTrackTracks; | 208 tracks = &m_addTrackTracks; |
210 } else if (track->trackType() == TextTrack::InBand) { | 209 } else if (track->trackType() == TextTrack::InBand) { |
211 tracks = &m_inbandTracks; | 210 tracks = &m_inbandTracks; |
212 inbandTrack = static_cast<InbandTextTrack*>(track); | |
213 } else { | 211 } else { |
214 ASSERT_NOT_REACHED(); | 212 ASSERT_NOT_REACHED(); |
215 } | 213 } |
216 | 214 |
217 size_t index = tracks->find(track); | 215 size_t index = tracks->find(track); |
218 if (index == kNotFound) | 216 if (index == kNotFound) |
219 return; | 217 return; |
220 | 218 |
221 invalidateTrackIndexesAfterTrack(track); | 219 invalidateTrackIndexesAfterTrack(track); |
222 | 220 |
223 ASSERT(track->trackList() == this); | 221 ASSERT(track->trackList() == this); |
224 track->setTrackList(0); | 222 track->setTrackList(0); |
225 | 223 |
226 tracks->remove(index); | 224 tracks->remove(index); |
227 | 225 |
228 if (inbandTrack) | 226 scheduleRemoveTrackEvent(track); |
229 inbandTrack->trackRemoved(); | 227 } |
230 | 228 |
231 scheduleRemoveTrackEvent(track); | 229 void TextTrackList::removeAllInbandTracks() |
| 230 { |
| 231 for (unsigned i = 0; i < m_inbandTracks.size(); ++i) { |
| 232 m_inbandTracks[i]->invalidateTrackIndex(); |
| 233 m_inbandTracks[i]->setTrackList(0); |
| 234 } |
| 235 m_inbandTracks.clear(); |
232 } | 236 } |
233 | 237 |
234 bool TextTrackList::contains(TextTrack* track) const | 238 bool TextTrackList::contains(TextTrack* track) const |
235 { | 239 { |
236 const Vector<RefPtr<TextTrack> >* tracks = 0; | 240 const Vector<RefPtr<TextTrack> >* tracks = 0; |
237 | 241 |
238 if (track->trackType() == TextTrack::TrackElement) | 242 if (track->trackType() == TextTrack::TrackElement) |
239 tracks = &m_elementTracks; | 243 tracks = &m_elementTracks; |
240 else if (track->trackType() == TextTrack::AddTrack) | 244 else if (track->trackType() == TextTrack::AddTrack) |
241 tracks = &m_addTrackTracks; | 245 tracks = &m_addTrackTracks; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 // 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 |
312 // 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, |
313 // 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, |
314 // 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 |
315 // interface, with the track attribute initialized to the text track's | 319 // interface, with the track attribute initialized to the text track's |
316 // TextTrack object, at the media element's textTracks attribute's | 320 // TextTrack object, at the media element's textTracks attribute's |
317 // TextTrackList object. | 321 // TextTrackList object. |
318 scheduleTrackEvent(EventTypeNames::removetrack, track); | 322 scheduleTrackEvent(EventTypeNames::removetrack, track); |
319 } | 323 } |
320 | 324 |
321 Node* TextTrackList::owner() const | 325 HTMLMediaElement* TextTrackList::owner() const |
322 { | 326 { |
323 return m_owner; | 327 return m_owner; |
324 } | 328 } |
OLD | NEW |