Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(141)

Side by Side Diff: Source/core/html/track/TextTrackList.cpp

Issue 177243018: Prevent 'removetrack' events from firing when all inband text tracks are removed. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix expectations Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 scheduleEvent)
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 (scheduleEvent)
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;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 // interface, with the track attribute initialized to the text track's 316 // interface, with the track attribute initialized to the text track's
316 // TextTrack object, at the media element's textTracks attribute's 317 // TextTrack object, at the media element's textTracks attribute's
317 // TextTrackList object. 318 // TextTrackList object.
318 scheduleTrackEvent(EventTypeNames::removetrack, track); 319 scheduleTrackEvent(EventTypeNames::removetrack, track);
319 } 320 }
320 321
321 Node* TextTrackList::owner() const 322 Node* TextTrackList::owner() const
322 { 323 {
323 return m_owner; 324 return m_owner;
324 } 325 }
OLDNEW
« Source/core/html/HTMLMediaElement.cpp ('K') | « Source/core/html/track/TextTrackList.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698