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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 | 85 |
86 bool TextTrackCueList::add(PassRefPtr<TextTrackCue> prpCue, size_t start, size_t
end) | 86 bool TextTrackCueList::add(PassRefPtr<TextTrackCue> prpCue, size_t start, size_t
end) |
87 { | 87 { |
88 ASSERT(start <= m_list.size()); | 88 ASSERT(start <= m_list.size()); |
89 ASSERT(end <= m_list.size()); | 89 ASSERT(end <= m_list.size()); |
90 | 90 |
91 // Maintain text track cue order: | 91 // Maintain text track cue order: |
92 // http://www.whatwg.org/specs/web-apps/current-work/#text-track-cue-order | 92 // http://www.whatwg.org/specs/web-apps/current-work/#text-track-cue-order |
93 RefPtr<TextTrackCue> cue = prpCue; | 93 RefPtr<TextTrackCue> cue = prpCue; |
94 if (start == end) { | 94 if (start == end) { |
95 if (!m_list.isEmpty() && (m_list[start - 1].get() == cue.get())) | 95 if (!m_list.isEmpty() && (start > 0) && (m_list[start - 1].get() == cue.
get())) |
96 return false; | 96 return false; |
97 | 97 |
98 m_list.insert(start, cue); | 98 m_list.insert(start, cue); |
99 invalidateCueIndexes(start); | 99 invalidateCueIndexes(start); |
100 return true; | 100 return true; |
101 } | 101 } |
102 | 102 |
103 size_t index = (start + end) / 2; | 103 size_t index = (start + end) / 2; |
104 if (cue->startTime() < m_list[index]->startTime() || (cue->startTime() == m_
list[index]->startTime() && cue->endTime() > m_list[index]->endTime())) | 104 if (cue->startTime() < m_list[index]->startTime() || (cue->startTime() == m_
list[index]->startTime() && cue->endTime() > m_list[index]->endTime())) |
105 return add(cue.release(), start, index); | 105 return add(cue.release(), start, index); |
106 | 106 |
107 return add(cue.release(), index + 1, end); | 107 return add(cue.release(), index + 1, end); |
108 } | 108 } |
109 | 109 |
110 bool TextTrackCueList::remove(TextTrackCue* cue) | 110 bool TextTrackCueList::remove(TextTrackCue* cue) |
(...skipping 19 matching lines...) Expand all Loading... |
130 | 130 |
131 void TextTrackCueList::invalidateCueIndexes(size_t start) | 131 void TextTrackCueList::invalidateCueIndexes(size_t start) |
132 { | 132 { |
133 for (size_t i = start; i < m_list.size(); ++i) | 133 for (size_t i = start; i < m_list.size(); ++i) |
134 m_list[i]->invalidateCueIndex(); | 134 m_list[i]->invalidateCueIndex(); |
135 } | 135 } |
136 | 136 |
137 } // namespace WebCore | 137 } // namespace WebCore |
138 | 138 |
139 #endif | 139 #endif |
OLD | NEW |