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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 if (m_inbandTracks[i] == textTrack) | 105 if (m_inbandTracks[i] == textTrack) |
106 return trackIndex; | 106 return trackIndex; |
107 ++trackIndex; | 107 ++trackIndex; |
108 } | 108 } |
109 | 109 |
110 ASSERT_NOT_REACHED(); | 110 ASSERT_NOT_REACHED(); |
111 | 111 |
112 return -1; | 112 return -1; |
113 } | 113 } |
114 | 114 |
115 TextTrack* TextTrackList::item(unsigned index) | 115 TextTrack* TextTrackList::anonymousIndexedGetter(unsigned index) |
116 { | 116 { |
117 // 4.8.10.12.1 Text track model | 117 // 4.8.10.12.1 Text track model |
118 // The text tracks are sorted as follows: | 118 // The text tracks are sorted as follows: |
119 // 1. The text tracks corresponding to track element children of the media e
lement, in tree order. | 119 // 1. The text tracks corresponding to track element children of the media e
lement, in tree order. |
120 // 2. Any text tracks added using the addTextTrack() method, in the order th
ey were added, oldest first. | 120 // 2. Any text tracks added using the addTextTrack() method, in the order th
ey were added, oldest first. |
121 // 3. Any media-resource-specific text tracks (text tracks corresponding to
data in the media | 121 // 3. Any media-resource-specific text tracks (text tracks corresponding to
data in the media |
122 // resource), in the order defined by the media resource's format specificat
ion. | 122 // resource), in the order defined by the media resource's format specificat
ion. |
123 | 123 |
124 if (index < m_elementTracks.size()) | 124 if (index < m_elementTracks.size()) |
125 return m_elementTracks[index]; | 125 return m_elementTracks[index]; |
126 | 126 |
127 index -= m_elementTracks.size(); | 127 index -= m_elementTracks.size(); |
128 if (index < m_addTrackTracks.size()) | 128 if (index < m_addTrackTracks.size()) |
129 return m_addTrackTracks[index]; | 129 return m_addTrackTracks[index]; |
130 | 130 |
131 index -= m_addTrackTracks.size(); | 131 index -= m_addTrackTracks.size(); |
132 if (index < m_inbandTracks.size()) | 132 if (index < m_inbandTracks.size()) |
133 return m_inbandTracks[index]; | 133 return m_inbandTracks[index]; |
134 | 134 |
135 return 0; | 135 return 0; |
136 } | 136 } |
137 | 137 |
138 TextTrack* TextTrackList::getTrackById(const AtomicString& id) | 138 TextTrack* TextTrackList::getTrackById(const AtomicString& id) |
139 { | 139 { |
140 // 4.8.10.12.5 Text track API | 140 // 4.8.10.12.5 Text track API |
141 // The getTrackById(id) method must return the first TextTrack in the | 141 // The getTrackById(id) method must return the first TextTrack in the |
142 // TextTrackList object whose id IDL attribute would return a value equal | 142 // TextTrackList object whose id IDL attribute would return a value equal |
143 // to the value of the id argument. | 143 // to the value of the id argument. |
144 for (unsigned i = 0; i < length(); ++i) { | 144 for (unsigned i = 0; i < length(); ++i) { |
145 TextTrack* track = item(i); | 145 TextTrack* track = anonymousIndexedGetter(i); |
146 if (track->id() == id) | 146 if (track->id() == id) |
147 return track; | 147 return track; |
148 } | 148 } |
149 | 149 |
150 // When no tracks match the given argument, the method must return null. | 150 // When no tracks match the given argument, the method must return null. |
151 return 0; | 151 return 0; |
152 } | 152 } |
153 | 153 |
154 void TextTrackList::invalidateTrackIndexesAfterTrack(TextTrack* track) | 154 void TextTrackList::invalidateTrackIndexesAfterTrack(TextTrack* track) |
155 { | 155 { |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 // that does not bubble and is not cancelable, and that uses the TrackEvent | 309 // that does not bubble and is not cancelable, and that uses the TrackEvent |
310 // interface, with the track attribute initialized to the text track's | 310 // interface, with the track attribute initialized to the text track's |
311 // TextTrack object, at the media element's textTracks attribute's | 311 // TextTrack object, at the media element's textTracks attribute's |
312 // TextTrackList object. | 312 // TextTrackList object. |
313 scheduleTrackEvent(EventTypeNames::removetrack, track); | 313 scheduleTrackEvent(EventTypeNames::removetrack, track); |
314 } | 314 } |
315 | 315 |
316 bool TextTrackList::hasShowingTracks() | 316 bool TextTrackList::hasShowingTracks() |
317 { | 317 { |
318 for (unsigned i = 0; i < length(); ++i) { | 318 for (unsigned i = 0; i < length(); ++i) { |
319 if (item(i)->mode() == TextTrack::showingKeyword()) | 319 if (anonymousIndexedGetter(i)->mode() == TextTrack::showingKeyword()) |
320 return true; | 320 return true; |
321 } | 321 } |
322 return false; | 322 return false; |
323 } | 323 } |
324 | 324 |
325 HTMLMediaElement* TextTrackList::owner() const | 325 HTMLMediaElement* TextTrackList::owner() const |
326 { | 326 { |
327 return m_owner; | 327 return m_owner; |
328 } | 328 } |
329 | 329 |
330 DEFINE_TRACE(TextTrackList) | 330 DEFINE_TRACE(TextTrackList) |
331 { | 331 { |
332 visitor->trace(m_owner); | 332 visitor->trace(m_owner); |
333 visitor->trace(m_asyncEventQueue); | 333 visitor->trace(m_asyncEventQueue); |
334 visitor->trace(m_addTrackTracks); | 334 visitor->trace(m_addTrackTracks); |
335 visitor->trace(m_elementTracks); | 335 visitor->trace(m_elementTracks); |
336 visitor->trace(m_inbandTracks); | 336 visitor->trace(m_inbandTracks); |
337 RefCountedGarbageCollectedEventTargetWithInlineData<TextTrackList>::trace(vi
sitor); | 337 RefCountedGarbageCollectedEventTargetWithInlineData<TextTrackList>::trace(vi
sitor); |
338 } | 338 } |
OLD | NEW |