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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 ASSERT_NOT_REACHED(); | 191 ASSERT_NOT_REACHED(); |
192 | 192 |
193 invalidateTrackIndexesAfterTrack(track.get()); | 193 invalidateTrackIndexesAfterTrack(track.get()); |
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, bool fireRemoveTrackEvent) |
202 { | 202 { |
203 Vector<RefPtr<TextTrack> >* tracks = 0; | 203 Vector<RefPtr<TextTrack> >* tracks = 0; |
204 RefPtr<InbandTextTrack> inbandTrack; | 204 RefPtr<InbandTextTrack> inbandTrack; |
205 | 205 |
206 if (track->trackType() == TextTrack::TrackElement) { | 206 if (track->trackType() == TextTrack::TrackElement) { |
207 tracks = &m_elementTracks; | 207 tracks = &m_elementTracks; |
208 } else if (track->trackType() == TextTrack::AddTrack) { | 208 } else if (track->trackType() == TextTrack::AddTrack) { |
209 tracks = &m_addTrackTracks; | 209 tracks = &m_addTrackTracks; |
210 } else if (track->trackType() == TextTrack::InBand) { | 210 } else if (track->trackType() == TextTrack::InBand) { |
211 tracks = &m_inbandTracks; | 211 tracks = &m_inbandTracks; |
212 inbandTrack = static_cast<InbandTextTrack*>(track); | 212 inbandTrack = static_cast<InbandTextTrack*>(track); |
213 } else { | 213 } else { |
214 ASSERT_NOT_REACHED(); | 214 ASSERT_NOT_REACHED(); |
215 } | 215 } |
216 | 216 |
217 size_t index = tracks->find(track); | 217 size_t index = tracks->find(track); |
218 if (index == kNotFound) | 218 if (index == kNotFound) |
219 return; | 219 return; |
220 | 220 |
221 invalidateTrackIndexesAfterTrack(track); | 221 invalidateTrackIndexesAfterTrack(track); |
222 | 222 |
223 ASSERT(track->trackList() == this); | 223 ASSERT(track->trackList() == this); |
224 track->setTrackList(0); | 224 track->setTrackList(0); |
225 | 225 |
226 tracks->remove(index); | 226 tracks->remove(index); |
227 | 227 |
228 if (inbandTrack) | 228 if (inbandTrack) |
229 inbandTrack->trackRemoved(); | 229 inbandTrack->trackRemoved(); |
230 | 230 |
231 scheduleRemoveTrackEvent(track); | 231 if (fireRemoveTrackEvent) |
| 232 scheduleRemoveTrackEvent(track); |
232 } | 233 } |
233 | 234 |
234 bool TextTrackList::contains(TextTrack* track) const | 235 bool TextTrackList::contains(TextTrack* track) const |
235 { | 236 { |
236 const Vector<RefPtr<TextTrack> >* tracks = 0; | 237 const Vector<RefPtr<TextTrack> >* tracks = 0; |
237 | 238 |
238 if (track->trackType() == TextTrack::TrackElement) | 239 if (track->trackType() == TextTrack::TrackElement) |
239 tracks = &m_elementTracks; | 240 tracks = &m_elementTracks; |
240 else if (track->trackType() == TextTrack::AddTrack) | 241 else if (track->trackType() == TextTrack::AddTrack) |
241 tracks = &m_addTrackTracks; | 242 tracks = &m_addTrackTracks; |
242 else if (track->trackType() == TextTrack::InBand) | 243 else if (track->trackType() == TextTrack::InBand) |
243 tracks = &m_inbandTracks; | 244 tracks = &m_inbandTracks; |
244 else | 245 else |
245 ASSERT_NOT_REACHED(); | 246 ASSERT_NOT_REACHED(); |
246 | 247 |
247 return tracks->find(track) != kNotFound; | 248 return tracks->find(track) != kNotFound; |
248 } | 249 } |
249 | 250 |
250 const AtomicString& TextTrackList::interfaceName() const | 251 const AtomicString& TextTrackList::interfaceName() const |
251 { | 252 { |
252 return EventTargetNames::TextTrackList; | 253 return EventTargetNames::TextTrackList; |
253 } | 254 } |
254 | 255 |
255 ExecutionContext* TextTrackList::executionContext() const | 256 ExecutionContext* TextTrackList::executionContext() const |
256 { | 257 { |
257 ASSERT(m_owner); | 258 ASSERT(m_owner); |
258 return m_owner->executionContext(); | 259 return m_owner->executionContext(); |
259 } | 260 } |
260 | 261 |
| 262 void TextTrackList::clearOwnerAndClients() |
| 263 { |
| 264 m_owner = 0; |
| 265 |
| 266 for (unsigned i = 0; i < length(); ++i) |
| 267 item(i)->clearClient(); |
| 268 } |
| 269 |
261 void TextTrackList::scheduleTrackEvent(const AtomicString& eventName, PassRefPtr
<TextTrack> track) | 270 void TextTrackList::scheduleTrackEvent(const AtomicString& eventName, PassRefPtr
<TextTrack> track) |
262 { | 271 { |
263 TrackEventInit initializer; | 272 TrackEventInit initializer; |
264 initializer.track = track; | 273 initializer.track = track; |
265 initializer.bubbles = false; | 274 initializer.bubbles = false; |
266 initializer.cancelable = false; | 275 initializer.cancelable = false; |
267 | 276 |
268 m_asyncEventQueue->enqueueEvent(TrackEvent::create(eventName, initializer)); | 277 m_asyncEventQueue->enqueueEvent(TrackEvent::create(eventName, initializer)); |
269 } | 278 } |
270 | 279 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 // interface, with the track attribute initialized to the text track's | 316 // interface, with the track attribute initialized to the text track's |
308 // TextTrack object, at the media element's textTracks attribute's | 317 // TextTrack object, at the media element's textTracks attribute's |
309 // TextTrackList object. | 318 // TextTrackList object. |
310 scheduleTrackEvent(EventTypeNames::removetrack, track); | 319 scheduleTrackEvent(EventTypeNames::removetrack, track); |
311 } | 320 } |
312 | 321 |
313 Node* TextTrackList::owner() const | 322 Node* TextTrackList::owner() const |
314 { | 323 { |
315 return m_owner; | 324 return m_owner; |
316 } | 325 } |
OLD | NEW |