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

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

Issue 244493002: Oilpan: add transition types to track interface objects. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add crbug.com/365260 crashing test + expectation Created 6 years, 8 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
« no previous file with comments | « Source/core/html/track/TextTrackList.h ('k') | Source/core/html/track/TrackBase.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 27 matching lines...) Expand all
38 38
39 TextTrackList::TextTrackList(HTMLMediaElement* owner) 39 TextTrackList::TextTrackList(HTMLMediaElement* owner)
40 : m_owner(owner) 40 : m_owner(owner)
41 , m_asyncEventQueue(GenericEventQueue::create(this)) 41 , m_asyncEventQueue(GenericEventQueue::create(this))
42 { 42 {
43 ScriptWrappable::init(this); 43 ScriptWrappable::init(this);
44 } 44 }
45 45
46 TextTrackList::~TextTrackList() 46 TextTrackList::~TextTrackList()
47 { 47 {
48 #if !ENABLE(OILPAN)
48 ASSERT(!m_owner); 49 ASSERT(!m_owner);
49 50 #endif
50 m_asyncEventQueue->close(); 51 m_asyncEventQueue->close();
51 52 #if !ENABLE(OILPAN)
52 for (unsigned i = 0; i < length(); ++i) { 53 for (unsigned i = 0; i < length(); ++i) {
53 item(i)->setTrackList(0); 54 item(i)->setTrackList(0);
54 } 55 }
56 #endif
55 } 57 }
56 58
57 unsigned TextTrackList::length() const 59 unsigned TextTrackList::length() const
58 { 60 {
59 return m_addTrackTracks.size() + m_elementTracks.size() + m_inbandTracks.siz e(); 61 return m_addTrackTracks.size() + m_elementTracks.size() + m_inbandTracks.siz e();
60 } 62 }
61 63
62 int TextTrackList::getTrackIndex(TextTrack *textTrack) 64 int TextTrackList::getTrackIndex(TextTrack *textTrack)
63 { 65 {
64 if (textTrack->trackType() == TextTrack::TrackElement) 66 if (textTrack->trackType() == TextTrack::TrackElement)
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 if (track->id() == id) 148 if (track->id() == id)
147 return track; 149 return track;
148 } 150 }
149 151
150 // When no tracks match the given argument, the method must return null. 152 // When no tracks match the given argument, the method must return null.
151 return 0; 153 return 0;
152 } 154 }
153 155
154 void TextTrackList::invalidateTrackIndexesAfterTrack(TextTrack* track) 156 void TextTrackList::invalidateTrackIndexesAfterTrack(TextTrack* track)
155 { 157 {
156 Vector<RefPtr<TextTrack> >* tracks = 0; 158 WillBeHeapVector<RefPtrWillBeMember<TextTrack> >* tracks = 0;
157 159
158 if (track->trackType() == TextTrack::TrackElement) { 160 if (track->trackType() == TextTrack::TrackElement) {
159 tracks = &m_elementTracks; 161 tracks = &m_elementTracks;
160 for (size_t i = 0; i < m_addTrackTracks.size(); ++i) 162 for (size_t i = 0; i < m_addTrackTracks.size(); ++i)
161 m_addTrackTracks[i]->invalidateTrackIndex(); 163 m_addTrackTracks[i]->invalidateTrackIndex();
162 for (size_t i = 0; i < m_inbandTracks.size(); ++i) 164 for (size_t i = 0; i < m_inbandTracks.size(); ++i)
163 m_inbandTracks[i]->invalidateTrackIndex(); 165 m_inbandTracks[i]->invalidateTrackIndex();
164 } else if (track->trackType() == TextTrack::AddTrack) { 166 } else if (track->trackType() == TextTrack::AddTrack) {
165 tracks = &m_addTrackTracks; 167 tracks = &m_addTrackTracks;
166 for (size_t i = 0; i < m_inbandTracks.size(); ++i) 168 for (size_t i = 0; i < m_inbandTracks.size(); ++i)
167 m_inbandTracks[i]->invalidateTrackIndex(); 169 m_inbandTracks[i]->invalidateTrackIndex();
168 } else if (track->trackType() == TextTrack::InBand) 170 } else if (track->trackType() == TextTrack::InBand)
169 tracks = &m_inbandTracks; 171 tracks = &m_inbandTracks;
170 else 172 else
171 ASSERT_NOT_REACHED(); 173 ASSERT_NOT_REACHED();
172 174
173 size_t index = tracks->find(track); 175 size_t index = tracks->find(track);
174 if (index == kNotFound) 176 if (index == kNotFound)
175 return; 177 return;
176 178
177 for (size_t i = index; i < tracks->size(); ++i) 179 for (size_t i = index; i < tracks->size(); ++i)
178 tracks->at(index)->invalidateTrackIndex(); 180 tracks->at(index)->invalidateTrackIndex();
179 } 181 }
180 182
181 void TextTrackList::append(PassRefPtr<TextTrack> prpTrack) 183 void TextTrackList::append(PassRefPtrWillBeRawPtr<TextTrack> prpTrack)
182 { 184 {
183 RefPtr<TextTrack> track = prpTrack; 185 RefPtrWillBeRawPtr<TextTrack> track = prpTrack;
184 186
185 if (track->trackType() == TextTrack::AddTrack) 187 if (track->trackType() == TextTrack::AddTrack)
186 m_addTrackTracks.append(track); 188 m_addTrackTracks.append(track);
187 else if (track->trackType() == TextTrack::TrackElement) { 189 else if (track->trackType() == TextTrack::TrackElement) {
188 // Insert tracks added for <track> element in tree order. 190 // Insert tracks added for <track> element in tree order.
189 size_t index = static_cast<LoadableTextTrack*>(track.get())->trackElemen tIndex(); 191 size_t index = static_cast<LoadableTextTrack*>(track.get())->trackElemen tIndex();
190 m_elementTracks.insert(index, track); 192 m_elementTracks.insert(index, track);
191 } else if (track->trackType() == TextTrack::InBand) { 193 } else if (track->trackType() == TextTrack::InBand) {
192 // Insert tracks added for in-band in the media file order. 194 // Insert tracks added for in-band in the media file order.
193 size_t index = static_cast<InbandTextTrack*>(track.get())->inbandTrackIn dex(); 195 size_t index = static_cast<InbandTextTrack*>(track.get())->inbandTrackIn dex();
194 m_inbandTracks.insert(index, track); 196 m_inbandTracks.insert(index, track);
195 } else 197 } else
196 ASSERT_NOT_REACHED(); 198 ASSERT_NOT_REACHED();
197 199
198 invalidateTrackIndexesAfterTrack(track.get()); 200 invalidateTrackIndexesAfterTrack(track.get());
199 201
200 ASSERT(!track->trackList()); 202 ASSERT(!track->trackList());
201 track->setTrackList(this); 203 track->setTrackList(this);
202 204
203 scheduleAddTrackEvent(track.release()); 205 scheduleAddTrackEvent(track.release());
204 } 206 }
205 207
206 void TextTrackList::remove(TextTrack* track) 208 void TextTrackList::remove(TextTrack* track)
207 { 209 {
208 Vector<RefPtr<TextTrack> >* tracks = 0; 210 WillBeHeapVector<RefPtrWillBeMember<TextTrack> >* tracks = 0;
209 211
210 if (track->trackType() == TextTrack::TrackElement) { 212 if (track->trackType() == TextTrack::TrackElement) {
211 tracks = &m_elementTracks; 213 tracks = &m_elementTracks;
212 } else if (track->trackType() == TextTrack::AddTrack) { 214 } else if (track->trackType() == TextTrack::AddTrack) {
213 tracks = &m_addTrackTracks; 215 tracks = &m_addTrackTracks;
214 } else if (track->trackType() == TextTrack::InBand) { 216 } else if (track->trackType() == TextTrack::InBand) {
215 tracks = &m_inbandTracks; 217 tracks = &m_inbandTracks;
216 } else { 218 } else {
217 ASSERT_NOT_REACHED(); 219 ASSERT_NOT_REACHED();
218 } 220 }
(...skipping 15 matching lines...) Expand all
234 void TextTrackList::removeAllInbandTracks() 236 void TextTrackList::removeAllInbandTracks()
235 { 237 {
236 for (unsigned i = 0; i < m_inbandTracks.size(); ++i) { 238 for (unsigned i = 0; i < m_inbandTracks.size(); ++i) {
237 m_inbandTracks[i]->setTrackList(0); 239 m_inbandTracks[i]->setTrackList(0);
238 } 240 }
239 m_inbandTracks.clear(); 241 m_inbandTracks.clear();
240 } 242 }
241 243
242 bool TextTrackList::contains(TextTrack* track) const 244 bool TextTrackList::contains(TextTrack* track) const
243 { 245 {
244 const Vector<RefPtr<TextTrack> >* tracks = 0; 246 const WillBeHeapVector<RefPtrWillBeMember<TextTrack> >* tracks = 0;
245 247
246 if (track->trackType() == TextTrack::TrackElement) 248 if (track->trackType() == TextTrack::TrackElement)
247 tracks = &m_elementTracks; 249 tracks = &m_elementTracks;
248 else if (track->trackType() == TextTrack::AddTrack) 250 else if (track->trackType() == TextTrack::AddTrack)
249 tracks = &m_addTrackTracks; 251 tracks = &m_addTrackTracks;
250 else if (track->trackType() == TextTrack::InBand) 252 else if (track->trackType() == TextTrack::InBand)
251 tracks = &m_inbandTracks; 253 tracks = &m_inbandTracks;
252 else 254 else
253 ASSERT_NOT_REACHED(); 255 ASSERT_NOT_REACHED();
254 256
255 return tracks->find(track) != kNotFound; 257 return tracks->find(track) != kNotFound;
256 } 258 }
257 259
258 const AtomicString& TextTrackList::interfaceName() const 260 const AtomicString& TextTrackList::interfaceName() const
259 { 261 {
260 return EventTargetNames::TextTrackList; 262 return EventTargetNames::TextTrackList;
261 } 263 }
262 264
263 ExecutionContext* TextTrackList::executionContext() const 265 ExecutionContext* TextTrackList::executionContext() const
264 { 266 {
265 ASSERT(m_owner); 267 ASSERT(m_owner);
266 return m_owner->executionContext(); 268 return m_owner->executionContext();
267 } 269 }
268 270
271 #if !ENABLE(OILPAN)
269 void TextTrackList::clearOwner() 272 void TextTrackList::clearOwner()
270 { 273 {
271 m_owner = 0; 274 m_owner = nullptr;
272 } 275 }
276 #endif
273 277
274 void TextTrackList::scheduleTrackEvent(const AtomicString& eventName, PassRefPtr <TextTrack> track) 278 void TextTrackList::scheduleTrackEvent(const AtomicString& eventName, PassRefPtr WillBeRawPtr<TextTrack> track)
275 { 279 {
276 TrackEventInit initializer; 280 TrackEventInit initializer;
277 initializer.track = track; 281 initializer.track = track;
278 initializer.bubbles = false; 282 initializer.bubbles = false;
279 initializer.cancelable = false; 283 initializer.cancelable = false;
280 284
281 m_asyncEventQueue->enqueueEvent(TrackEvent::create(eventName, initializer)); 285 m_asyncEventQueue->enqueueEvent(TrackEvent::create(eventName, initializer));
282 } 286 }
283 287
284 void TextTrackList::scheduleAddTrackEvent(PassRefPtr<TextTrack> track) 288 void TextTrackList::scheduleAddTrackEvent(PassRefPtrWillBeRawPtr<TextTrack> trac k)
285 { 289 {
286 // 4.8.10.12.3 Sourcing out-of-band text tracks 290 // 4.8.10.12.3 Sourcing out-of-band text tracks
287 // 4.8.10.12.4 Text track API 291 // 4.8.10.12.4 Text track API
288 // ... then queue a task to fire an event with the name addtrack, that does not 292 // ... then queue a task to fire an event with the name addtrack, that does not
289 // bubble and is not cancelable, and that uses the TrackEvent interface, wit h 293 // bubble and is not cancelable, and that uses the TrackEvent interface, wit h
290 // the track attribute initialized to the text track's TextTrack object, at 294 // the track attribute initialized to the text track's TextTrack object, at
291 // the media element's textTracks attribute's TextTrackList object. 295 // the media element's textTracks attribute's TextTrackList object.
292 scheduleTrackEvent(EventTypeNames::addtrack, track); 296 scheduleTrackEvent(EventTypeNames::addtrack, track);
293 } 297 }
294 298
295 void TextTrackList::scheduleChangeEvent() 299 void TextTrackList::scheduleChangeEvent()
296 { 300 {
297 // 4.8.10.12.1 Text track model 301 // 4.8.10.12.1 Text track model
298 // Whenever a text track that is in a media element's list of text tracks 302 // Whenever a text track that is in a media element's list of text tracks
299 // has its text track mode change value, the user agent must run the 303 // has its text track mode change value, the user agent must run the
300 // following steps for the media element: 304 // following steps for the media element:
301 // ... 305 // ...
302 // Fire a simple event named change at the media element's textTracks 306 // Fire a simple event named change at the media element's textTracks
303 // attribute's TextTrackList object. 307 // attribute's TextTrackList object.
304 308
305 EventInit initializer; 309 EventInit initializer;
306 initializer.bubbles = false; 310 initializer.bubbles = false;
307 initializer.cancelable = false; 311 initializer.cancelable = false;
308 312
309 m_asyncEventQueue->enqueueEvent(Event::create(EventTypeNames::change, initia lizer)); 313 m_asyncEventQueue->enqueueEvent(Event::create(EventTypeNames::change, initia lizer));
310 } 314 }
311 315
312 void TextTrackList::scheduleRemoveTrackEvent(PassRefPtr<TextTrack> track) 316 void TextTrackList::scheduleRemoveTrackEvent(PassRefPtrWillBeRawPtr<TextTrack> t rack)
313 { 317 {
314 // 4.8.10.12.3 Sourcing out-of-band text tracks 318 // 4.8.10.12.3 Sourcing out-of-band text tracks
315 // When a track element's parent element changes and the old parent was a 319 // When a track element's parent element changes and the old parent was a
316 // media element, then the user agent must remove the track element's 320 // media element, then the user agent must remove the track element's
317 // corresponding text track from the media element's list of text tracks, 321 // corresponding text track from the media element's list of text tracks,
318 // and then queue a task to fire a trusted event with the name removetrack, 322 // and then queue a task to fire a trusted event with the name removetrack,
319 // that does not bubble and is not cancelable, and that uses the TrackEvent 323 // that does not bubble and is not cancelable, and that uses the TrackEvent
320 // interface, with the track attribute initialized to the text track's 324 // interface, with the track attribute initialized to the text track's
321 // TextTrack object, at the media element's textTracks attribute's 325 // TextTrack object, at the media element's textTracks attribute's
322 // TextTrackList object. 326 // TextTrackList object.
323 scheduleTrackEvent(EventTypeNames::removetrack, track); 327 scheduleTrackEvent(EventTypeNames::removetrack, track);
324 } 328 }
325 329
326 HTMLMediaElement* TextTrackList::owner() const 330 HTMLMediaElement* TextTrackList::owner() const
327 { 331 {
328 return m_owner; 332 return m_owner;
329 } 333 }
334
335 void TextTrackList::trace(Visitor* visitor)
336 {
337 visitor->trace(m_owner);
338 visitor->trace(m_addTrackTracks);
339 visitor->trace(m_elementTracks);
340 visitor->trace(m_inbandTracks);
341 }
OLDNEW
« no previous file with comments | « Source/core/html/track/TextTrackList.h ('k') | Source/core/html/track/TrackBase.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698