| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 | 55 |
| 56 TextTrackCue* TextTrackCueList::getCueById(const AtomicString& id) const | 56 TextTrackCue* TextTrackCueList::getCueById(const AtomicString& id) const |
| 57 { | 57 { |
| 58 for (size_t i = 0; i < m_list.size(); ++i) { | 58 for (size_t i = 0; i < m_list.size(); ++i) { |
| 59 if (m_list[i]->id() == id) | 59 if (m_list[i]->id() == id) |
| 60 return m_list[i].get(); | 60 return m_list[i].get(); |
| 61 } | 61 } |
| 62 return nullptr; | 62 return nullptr; |
| 63 } | 63 } |
| 64 | 64 |
| 65 TextTrackCueList* TextTrackCueList::activeCues() | 65 void TextTrackCueList::collectActiveCues(TextTrackCueList& activeCues) const |
| 66 { | 66 { |
| 67 if (!m_activeCues) | 67 activeCues.clear(); |
| 68 m_activeCues = create(); | 68 for (auto& cue : m_list) { |
| 69 | |
| 70 m_activeCues->clear(); | |
| 71 for (size_t i = 0; i < m_list.size(); ++i) { | |
| 72 RefPtrWillBeRawPtr<TextTrackCue> cue = m_list[i]; | |
| 73 if (cue->isActive()) | 69 if (cue->isActive()) |
| 74 m_activeCues->add(cue); | 70 activeCues.add(cue); |
| 75 } | 71 } |
| 76 return m_activeCues.get(); | |
| 77 } | 72 } |
| 78 | 73 |
| 79 bool TextTrackCueList::add(PassRefPtrWillBeRawPtr<TextTrackCue> cue) | 74 bool TextTrackCueList::add(PassRefPtrWillBeRawPtr<TextTrackCue> cue) |
| 80 { | 75 { |
| 81 ASSERT(cue->startTime() >= 0); | 76 ASSERT(cue->startTime() >= 0); |
| 82 ASSERT(cue->endTime() >= 0); | 77 ASSERT(cue->endTime() >= 0); |
| 83 | 78 |
| 84 // Maintain text track cue order: | 79 // Maintain text track cue order: |
| 85 // https://html.spec.whatwg.org/#text-track-cue-order | 80 // https://html.spec.whatwg.org/#text-track-cue-order |
| 86 size_t index = findInsertionIndex(cue.get()); | 81 size_t index = findInsertionIndex(cue.get()); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 void TextTrackCueList::invalidateCueIndexes(size_t start) | 141 void TextTrackCueList::invalidateCueIndexes(size_t start) |
| 147 { | 142 { |
| 148 // FIXME: When iterating cues we could as well update their cached indices t
oo. | 143 // FIXME: When iterating cues we could as well update their cached indices t
oo. |
| 149 for (size_t i = start; i < m_list.size(); ++i) | 144 for (size_t i = start; i < m_list.size(); ++i) |
| 150 m_list[i]->invalidateCueIndex(); | 145 m_list[i]->invalidateCueIndex(); |
| 151 } | 146 } |
| 152 | 147 |
| 153 DEFINE_TRACE(TextTrackCueList) | 148 DEFINE_TRACE(TextTrackCueList) |
| 154 { | 149 { |
| 155 visitor->trace(m_list); | 150 visitor->trace(m_list); |
| 156 visitor->trace(m_activeCues); | |
| 157 } | 151 } |
| 158 | 152 |
| 159 } // namespace blink | 153 } // namespace blink |
| OLD | NEW |