| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 { | 54 { |
| 55 if (textTrack->trackType() == TextTrack::TrackElement) | 55 if (textTrack->trackType() == TextTrack::TrackElement) |
| 56 return static_cast<LoadableTextTrack*>(textTrack)->trackElementIndex(); | 56 return static_cast<LoadableTextTrack*>(textTrack)->trackElementIndex(); |
| 57 | 57 |
| 58 if (textTrack->trackType() == TextTrack::AddTrack) | 58 if (textTrack->trackType() == TextTrack::AddTrack) |
| 59 return m_elementTracks.size() + m_addTrackTracks.find(textTrack); | 59 return m_elementTracks.size() + m_addTrackTracks.find(textTrack); |
| 60 | 60 |
| 61 if (textTrack->trackType() == TextTrack::InBand) | 61 if (textTrack->trackType() == TextTrack::InBand) |
| 62 return m_elementTracks.size() + m_addTrackTracks.size() + m_inbandTracks
.find(textTrack); | 62 return m_elementTracks.size() + m_addTrackTracks.size() + m_inbandTracks
.find(textTrack); |
| 63 | 63 |
| 64 ASSERT_NOT_REACHED(); | 64 NOTREACHED(); |
| 65 | 65 |
| 66 return -1; | 66 return -1; |
| 67 } | 67 } |
| 68 | 68 |
| 69 int TextTrackList::getTrackIndexRelativeToRenderedTracks(TextTrack *textTrack) | 69 int TextTrackList::getTrackIndexRelativeToRenderedTracks(TextTrack *textTrack) |
| 70 { | 70 { |
| 71 // Calculate the "Let n be the number of text tracks whose text track mode i
s showing and that are in the media element's list of text tracks before track." | 71 // Calculate the "Let n be the number of text tracks whose text track mode i
s showing and that are in the media element's list of text tracks before track." |
| 72 int trackIndex = 0; | 72 int trackIndex = 0; |
| 73 | 73 |
| 74 for (size_t i = 0; i < m_elementTracks.size(); ++i) { | 74 for (size_t i = 0; i < m_elementTracks.size(); ++i) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 91 | 91 |
| 92 for (size_t i = 0; i < m_inbandTracks.size(); ++i) { | 92 for (size_t i = 0; i < m_inbandTracks.size(); ++i) { |
| 93 if (!m_inbandTracks[i]->isRendered()) | 93 if (!m_inbandTracks[i]->isRendered()) |
| 94 continue; | 94 continue; |
| 95 | 95 |
| 96 if (m_inbandTracks[i] == textTrack) | 96 if (m_inbandTracks[i] == textTrack) |
| 97 return trackIndex; | 97 return trackIndex; |
| 98 ++trackIndex; | 98 ++trackIndex; |
| 99 } | 99 } |
| 100 | 100 |
| 101 ASSERT_NOT_REACHED(); | 101 NOTREACHED(); |
| 102 | 102 |
| 103 return -1; | 103 return -1; |
| 104 } | 104 } |
| 105 | 105 |
| 106 TextTrack* TextTrackList::anonymousIndexedGetter(unsigned index) | 106 TextTrack* TextTrackList::anonymousIndexedGetter(unsigned index) |
| 107 { | 107 { |
| 108 // 4.8.10.12.1 Text track model | 108 // 4.8.10.12.1 Text track model |
| 109 // The text tracks are sorted as follows: | 109 // The text tracks are sorted as follows: |
| 110 // 1. The text tracks corresponding to track element children of the media e
lement, in tree order. | 110 // 1. The text tracks corresponding to track element children of the media e
lement, in tree order. |
| 111 // 2. Any text tracks added using the addTextTrack() method, in the order th
ey were added, oldest first. | 111 // 2. Any text tracks added using the addTextTrack() method, in the order th
ey were added, oldest first. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 m_addTrackTracks[i]->invalidateTrackIndex(); | 152 m_addTrackTracks[i]->invalidateTrackIndex(); |
| 153 for (size_t i = 0; i < m_inbandTracks.size(); ++i) | 153 for (size_t i = 0; i < m_inbandTracks.size(); ++i) |
| 154 m_inbandTracks[i]->invalidateTrackIndex(); | 154 m_inbandTracks[i]->invalidateTrackIndex(); |
| 155 } else if (track->trackType() == TextTrack::AddTrack) { | 155 } else if (track->trackType() == TextTrack::AddTrack) { |
| 156 tracks = &m_addTrackTracks; | 156 tracks = &m_addTrackTracks; |
| 157 for (size_t i = 0; i < m_inbandTracks.size(); ++i) | 157 for (size_t i = 0; i < m_inbandTracks.size(); ++i) |
| 158 m_inbandTracks[i]->invalidateTrackIndex(); | 158 m_inbandTracks[i]->invalidateTrackIndex(); |
| 159 } else if (track->trackType() == TextTrack::InBand) { | 159 } else if (track->trackType() == TextTrack::InBand) { |
| 160 tracks = &m_inbandTracks; | 160 tracks = &m_inbandTracks; |
| 161 } else { | 161 } else { |
| 162 ASSERT_NOT_REACHED(); | 162 NOTREACHED(); |
| 163 } | 163 } |
| 164 | 164 |
| 165 size_t index = tracks->find(track); | 165 size_t index = tracks->find(track); |
| 166 if (index == kNotFound) | 166 if (index == kNotFound) |
| 167 return; | 167 return; |
| 168 | 168 |
| 169 for (size_t i = index; i < tracks->size(); ++i) | 169 for (size_t i = index; i < tracks->size(); ++i) |
| 170 tracks->at(index)->invalidateTrackIndex(); | 170 tracks->at(index)->invalidateTrackIndex(); |
| 171 } | 171 } |
| 172 | 172 |
| 173 void TextTrackList::append(TextTrack* track) | 173 void TextTrackList::append(TextTrack* track) |
| 174 { | 174 { |
| 175 if (track->trackType() == TextTrack::AddTrack) { | 175 if (track->trackType() == TextTrack::AddTrack) { |
| 176 m_addTrackTracks.append(track); | 176 m_addTrackTracks.append(track); |
| 177 } else if (track->trackType() == TextTrack::TrackElement) { | 177 } else if (track->trackType() == TextTrack::TrackElement) { |
| 178 // Insert tracks added for <track> element in tree order. | 178 // Insert tracks added for <track> element in tree order. |
| 179 size_t index = static_cast<LoadableTextTrack*>(track)->trackElementIndex
(); | 179 size_t index = static_cast<LoadableTextTrack*>(track)->trackElementIndex
(); |
| 180 m_elementTracks.insert(index, track); | 180 m_elementTracks.insert(index, track); |
| 181 } else if (track->trackType() == TextTrack::InBand) { | 181 } else if (track->trackType() == TextTrack::InBand) { |
| 182 m_inbandTracks.append(track); | 182 m_inbandTracks.append(track); |
| 183 } else { | 183 } else { |
| 184 ASSERT_NOT_REACHED(); | 184 NOTREACHED(); |
| 185 } | 185 } |
| 186 | 186 |
| 187 invalidateTrackIndexesAfterTrack(track); | 187 invalidateTrackIndexesAfterTrack(track); |
| 188 | 188 |
| 189 ASSERT(!track->trackList()); | 189 DCHECK(!track->trackList()); |
| 190 track->setTrackList(this); | 190 track->setTrackList(this); |
| 191 | 191 |
| 192 scheduleAddTrackEvent(track); | 192 scheduleAddTrackEvent(track); |
| 193 } | 193 } |
| 194 | 194 |
| 195 void TextTrackList::remove(TextTrack* track) | 195 void TextTrackList::remove(TextTrack* track) |
| 196 { | 196 { |
| 197 HeapVector<Member<TextTrack>>* tracks = nullptr; | 197 HeapVector<Member<TextTrack>>* tracks = nullptr; |
| 198 | 198 |
| 199 if (track->trackType() == TextTrack::TrackElement) { | 199 if (track->trackType() == TextTrack::TrackElement) { |
| 200 tracks = &m_elementTracks; | 200 tracks = &m_elementTracks; |
| 201 } else if (track->trackType() == TextTrack::AddTrack) { | 201 } else if (track->trackType() == TextTrack::AddTrack) { |
| 202 tracks = &m_addTrackTracks; | 202 tracks = &m_addTrackTracks; |
| 203 } else if (track->trackType() == TextTrack::InBand) { | 203 } else if (track->trackType() == TextTrack::InBand) { |
| 204 tracks = &m_inbandTracks; | 204 tracks = &m_inbandTracks; |
| 205 } else { | 205 } else { |
| 206 ASSERT_NOT_REACHED(); | 206 NOTREACHED(); |
| 207 } | 207 } |
| 208 | 208 |
| 209 size_t index = tracks->find(track); | 209 size_t index = tracks->find(track); |
| 210 if (index == kNotFound) | 210 if (index == kNotFound) |
| 211 return; | 211 return; |
| 212 | 212 |
| 213 invalidateTrackIndexesAfterTrack(track); | 213 invalidateTrackIndexesAfterTrack(track); |
| 214 | 214 |
| 215 ASSERT(track->trackList() == this); | 215 DCHECK_EQ(track->trackList(), this); |
| 216 track->setTrackList(0); | 216 track->setTrackList(0); |
| 217 | 217 |
| 218 tracks->remove(index); | 218 tracks->remove(index); |
| 219 | 219 |
| 220 scheduleRemoveTrackEvent(track); | 220 scheduleRemoveTrackEvent(track); |
| 221 } | 221 } |
| 222 | 222 |
| 223 void TextTrackList::removeAllInbandTracks() | 223 void TextTrackList::removeAllInbandTracks() |
| 224 { | 224 { |
| 225 for (unsigned i = 0; i < m_inbandTracks.size(); ++i) { | 225 for (unsigned i = 0; i < m_inbandTracks.size(); ++i) { |
| 226 m_inbandTracks[i]->setTrackList(0); | 226 m_inbandTracks[i]->setTrackList(0); |
| 227 } | 227 } |
| 228 m_inbandTracks.clear(); | 228 m_inbandTracks.clear(); |
| 229 } | 229 } |
| 230 | 230 |
| 231 bool TextTrackList::contains(TextTrack* track) const | 231 bool TextTrackList::contains(TextTrack* track) const |
| 232 { | 232 { |
| 233 const HeapVector<Member<TextTrack>>* tracks = nullptr; | 233 const HeapVector<Member<TextTrack>>* tracks = nullptr; |
| 234 | 234 |
| 235 if (track->trackType() == TextTrack::TrackElement) | 235 if (track->trackType() == TextTrack::TrackElement) |
| 236 tracks = &m_elementTracks; | 236 tracks = &m_elementTracks; |
| 237 else if (track->trackType() == TextTrack::AddTrack) | 237 else if (track->trackType() == TextTrack::AddTrack) |
| 238 tracks = &m_addTrackTracks; | 238 tracks = &m_addTrackTracks; |
| 239 else if (track->trackType() == TextTrack::InBand) | 239 else if (track->trackType() == TextTrack::InBand) |
| 240 tracks = &m_inbandTracks; | 240 tracks = &m_inbandTracks; |
| 241 else | 241 else |
| 242 ASSERT_NOT_REACHED(); | 242 NOTREACHED(); |
| 243 | 243 |
| 244 return tracks->find(track) != kNotFound; | 244 return tracks->find(track) != kNotFound; |
| 245 } | 245 } |
| 246 | 246 |
| 247 const AtomicString& TextTrackList::interfaceName() const | 247 const AtomicString& TextTrackList::interfaceName() const |
| 248 { | 248 { |
| 249 return EventTargetNames::TextTrackList; | 249 return EventTargetNames::TextTrackList; |
| 250 } | 250 } |
| 251 | 251 |
| 252 ExecutionContext* TextTrackList::getExecutionContext() const | 252 ExecutionContext* TextTrackList::getExecutionContext() const |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 | 323 |
| 324 DEFINE_TRACE_WRAPPERS(TextTrackList) | 324 DEFINE_TRACE_WRAPPERS(TextTrackList) |
| 325 { | 325 { |
| 326 for (auto track : m_addTrackTracks) | 326 for (auto track : m_addTrackTracks) |
| 327 visitor->traceWrappers(track); | 327 visitor->traceWrappers(track); |
| 328 for (auto track : m_elementTracks) | 328 for (auto track : m_elementTracks) |
| 329 visitor->traceWrappers(track); | 329 visitor->traceWrappers(track); |
| 330 for (auto track : m_inbandTracks) | 330 for (auto track : m_inbandTracks) |
| 331 visitor->traceWrappers(track); | 331 visitor->traceWrappers(track); |
| 332 } | 332 } |
| OLD | NEW |