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

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

Powered by Google App Engine
This is Rietveld 408576698