OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 | 91 |
92 void DocumentTimeline::serviceAnimations() | 92 void DocumentTimeline::serviceAnimations() |
93 { | 93 { |
94 TRACE_EVENT0("webkit", "DocumentTimeline::serviceAnimations"); | 94 TRACE_EVENT0("webkit", "DocumentTimeline::serviceAnimations"); |
95 | 95 |
96 m_timing->cancelWake(); | 96 m_timing->cancelWake(); |
97 m_hasOutdatedAnimationPlayer = false; | 97 m_hasOutdatedAnimationPlayer = false; |
98 | 98 |
99 double timeToNextEffect = std::numeric_limits<double>::infinity(); | 99 double timeToNextEffect = std::numeric_limits<double>::infinity(); |
100 Vector<AnimationPlayer*> players; | 100 Vector<AnimationPlayer*> players; |
101 for (HashSet<RefPtr<AnimationPlayer> >::iterator it = m_playersNeedingUpdate
.begin(); it != m_playersNeedingUpdate.end(); ++it) | 101 for (ListHashSet<RefPtr<AnimationPlayer> >::iterator it = m_playersNeedingUp
date.begin(); it != m_playersNeedingUpdate.end(); ++it) |
102 players.append(it->get()); | 102 players.append(it->get()); |
103 | 103 |
104 std::sort(players.begin(), players.end(), AnimationPlayer::hasLowerPriority)
; | 104 std::sort(players.begin(), players.end(), AnimationPlayer::hasLowerPriority)
; |
105 | 105 |
106 for (size_t i = 0; i < players.size(); ++i) { | 106 for (size_t i = 0; i < players.size(); ++i) { |
107 AnimationPlayer* player = players[i]; | 107 AnimationPlayer* player = players[i]; |
108 if (player->update()) | 108 if (player->update()) |
109 timeToNextEffect = std::min(timeToNextEffect, player->timeToEffectCh
ange()); | 109 timeToNextEffect = std::min(timeToNextEffect, player->timeToEffectCh
ange()); |
110 else | 110 else |
111 m_playersNeedingUpdate.remove(player); | 111 m_playersNeedingUpdate.remove(player); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 } | 152 } |
153 | 153 |
154 double DocumentTimeline::effectiveTime() | 154 double DocumentTimeline::effectiveTime() |
155 { | 155 { |
156 double time = currentTime(); | 156 double time = currentTime(); |
157 return std::isnan(time) ? 0 : time; | 157 return std::isnan(time) ? 0 : time; |
158 } | 158 } |
159 | 159 |
160 void DocumentTimeline::pauseAnimationsForTesting(double pauseTime) | 160 void DocumentTimeline::pauseAnimationsForTesting(double pauseTime) |
161 { | 161 { |
162 for (HashSet<RefPtr<AnimationPlayer> >::iterator it = m_playersNeedingUpdate
.begin(); it != m_playersNeedingUpdate.end(); ++it) | 162 for (ListHashSet<RefPtr<AnimationPlayer> >::iterator it = m_playersNeedingUp
date.begin(); it != m_playersNeedingUpdate.end(); ++it) |
163 (*it)->pauseForTesting(pauseTime); | 163 (*it)->pauseForTesting(pauseTime); |
164 serviceAnimations(); | 164 serviceAnimations(); |
165 } | 165 } |
166 | 166 |
167 void DocumentTimeline::setOutdatedAnimationPlayer(AnimationPlayer* player) | 167 void DocumentTimeline::setOutdatedAnimationPlayer(AnimationPlayer* player) |
168 { | 168 { |
169 m_playersNeedingUpdate.add(player); | 169 m_playersNeedingUpdate.add(player); |
170 m_hasOutdatedAnimationPlayer = true; | 170 m_hasOutdatedAnimationPlayer = true; |
171 if (m_document && m_document->page() && !m_document->page()->animator().isSe
rvicingAnimations()) | 171 if (m_document && m_document->page() && !m_document->page()->animator().isSe
rvicingAnimations()) |
172 m_timing->serviceOnNextFrame(); | 172 m_timing->serviceOnNextFrame(); |
173 } | 173 } |
174 | 174 |
175 size_t DocumentTimeline::numberOfActiveAnimationsForTesting() const | 175 size_t DocumentTimeline::numberOfActiveAnimationsForTesting() const |
176 { | 176 { |
177 if (isNull(m_zeroTime)) | 177 if (isNull(m_zeroTime)) |
178 return 0; | 178 return 0; |
179 // Includes all players whose directly associated timed items | 179 // Includes all players whose directly associated timed items |
180 // are current or in effect. | 180 // are current or in effect. |
181 if (isNull(m_zeroTime)) | 181 if (isNull(m_zeroTime)) |
182 return 0; | 182 return 0; |
183 size_t count = 0; | 183 size_t count = 0; |
184 for (HashSet<RefPtr<AnimationPlayer> >::iterator it = m_playersNeedingUpdate
.begin(); it != m_playersNeedingUpdate.end(); ++it) { | 184 for (ListHashSet<RefPtr<AnimationPlayer> >::const_iterator it = m_playersNee
dingUpdate.begin(); it != m_playersNeedingUpdate.end(); ++it) { |
185 const TimedItem* timedItem = (*it)->source(); | 185 const TimedItem* timedItem = (*it)->source(); |
186 if ((*it)->hasStartTime()) | 186 if ((*it)->hasStartTime()) |
187 count += (timedItem && (timedItem->isCurrent() || timedItem->isInEff
ect())); | 187 count += (timedItem && (timedItem->isCurrent() || timedItem->isInEff
ect())); |
188 } | 188 } |
189 return count; | 189 return count; |
190 } | 190 } |
191 | 191 |
192 void DocumentTimeline::detachFromDocument() { | 192 void DocumentTimeline::detachFromDocument() { |
193 m_document = 0; | 193 m_document = 0; |
194 } | 194 } |
195 | 195 |
196 } // namespace | 196 } // namespace |
OLD | NEW |