void TextTrackList::remove(TextTrack* track) { WillBeHeapVector<RefPtrWillBeMember<TextTrack>>* tracks = 0; if (track->trackType() == TextTrack::TrackElement) { tracks = &m_elementTracks; } else if (track->trackType() == TextTrack::AddTrack) { tracks = &m_addTrackTracks; } else if (track->trackType() == TextTrack::InBand) { tracks = &m_inbandTracks; } else { ASSERT_NOT_REACHED(); } size_t index = tracks->find(track); if (index == kNotFound) return; invalidateTrackIndexesAfterTrack(track); ASSERT(track->trackList() == this); track->setTrackList(0); tracks->remove(index); scheduleRemoveTrackEvent(track); }
void TextTrackList::invalidateTrackIndexesAfterTrack(TextTrack* track) { WillBeHeapVector<RefPtrWillBeMember<TextTrack>>* tracks = 0; if (track->trackType() == TextTrack::TrackElement) { tracks = &m_elementTracks; for (size_t i = 0; i < m_addTrackTracks.size(); ++i) m_addTrackTracks[i]->invalidateTrackIndex(); for (size_t i = 0; i < m_inbandTracks.size(); ++i) m_inbandTracks[i]->invalidateTrackIndex(); } else if (track->trackType() == TextTrack::AddTrack) { tracks = &m_addTrackTracks; for (size_t i = 0; i < m_inbandTracks.size(); ++i) m_inbandTracks[i]->invalidateTrackIndex(); } else if (track->trackType() == TextTrack::InBand) { tracks = &m_inbandTracks; } else { ASSERT_NOT_REACHED(); } size_t index = tracks->find(track); if (index == kNotFound) return; for (size_t i = index; i < tracks->size(); ++i) tracks->at(index)->invalidateTrackIndex(); }