OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008 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 982 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
993 notifyDependentsIntervalChanged(); | 993 notifyDependentsIntervalChanged(); |
994 } | 994 } |
995 } | 995 } |
996 } | 996 } |
997 m_nextProgressTime = elapsed; | 997 m_nextProgressTime = elapsed; |
998 | 998 |
999 if (m_timeContainer) | 999 if (m_timeContainer) |
1000 m_timeContainer->notifyIntervalsChanged(); | 1000 m_timeContainer->notifyIntervalsChanged(); |
1001 } | 1001 } |
1002 | 1002 |
1003 void SVGSMILElement::checkRestart(SMILTime elapsed) | 1003 SVGSMILElement::RestartedInterval SVGSMILElement::maybeRestartInterval(SMILTime
elapsed) |
1004 { | 1004 { |
1005 ASSERT(!m_isWaitingForFirstInterval); | 1005 ASSERT(!m_isWaitingForFirstInterval); |
1006 ASSERT(elapsed >= m_intervalBegin); | 1006 ASSERT(elapsed >= m_intervalBegin); |
1007 | 1007 |
1008 Restart restart = this->restart(); | 1008 Restart restart = this->restart(); |
1009 if (restart == RestartNever) | 1009 if (restart == RestartNever) |
1010 return; | 1010 return DidNotRestartInterval; |
1011 | 1011 |
1012 if (elapsed < m_intervalEnd) { | 1012 if (elapsed < m_intervalEnd) { |
1013 if (restart != RestartAlways) | 1013 if (restart != RestartAlways) |
1014 return; | 1014 return DidNotRestartInterval; |
1015 SMILTime nextBegin = findInstanceTime(Begin, m_intervalBegin, false); | 1015 SMILTime nextBegin = findInstanceTime(Begin, m_intervalBegin, false); |
1016 if (nextBegin < m_intervalEnd) { | 1016 if (nextBegin < m_intervalEnd) { |
1017 m_intervalEnd = nextBegin; | 1017 m_intervalEnd = nextBegin; |
1018 notifyDependentsIntervalChanged(); | 1018 notifyDependentsIntervalChanged(); |
1019 } | 1019 } |
1020 } | 1020 } |
1021 | 1021 |
1022 if (elapsed >= m_intervalEnd) | 1022 if (elapsed >= m_intervalEnd) { |
1023 resolveNextInterval(); | 1023 if (resolveNextInterval()) |
| 1024 return DidRestartInterval; |
| 1025 } |
| 1026 return DidNotRestartInterval; |
1024 } | 1027 } |
1025 | 1028 |
1026 void SVGSMILElement::seekToIntervalCorrespondingToTime(SMILTime elapsed) | 1029 void SVGSMILElement::seekToIntervalCorrespondingToTime(SMILTime elapsed) |
1027 { | 1030 { |
1028 ASSERT(!m_isWaitingForFirstInterval); | 1031 ASSERT(!m_isWaitingForFirstInterval); |
1029 ASSERT(elapsed >= m_intervalBegin); | 1032 ASSERT(elapsed >= m_intervalBegin); |
1030 | 1033 |
1031 // Manually seek from interval to interval, just as if the animation would r
un regulary. | 1034 // Manually seek from interval to interval, just as if the animation would r
un regulary. |
1032 while (true) { | 1035 while (true) { |
1033 // Figure out the next value in the begin time list after the current in
terval begin. | 1036 // Figure out the next value in the begin time list after the current in
terval begin. |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1160 seekToIntervalCorrespondingToTime(elapsed); | 1163 seekToIntervalCorrespondingToTime(elapsed); |
1161 if (elapsed < m_intervalBegin) { | 1164 if (elapsed < m_intervalBegin) { |
1162 // elapsed is not within an interval. | 1165 // elapsed is not within an interval. |
1163 m_nextProgressTime = m_intervalBegin; | 1166 m_nextProgressTime = m_intervalBegin; |
1164 return false; | 1167 return false; |
1165 } | 1168 } |
1166 } | 1169 } |
1167 | 1170 |
1168 unsigned repeat = 0; | 1171 unsigned repeat = 0; |
1169 float percent = calculateAnimationPercentAndRepeat(elapsed, repeat); | 1172 float percent = calculateAnimationPercentAndRepeat(elapsed, repeat); |
1170 checkRestart(elapsed); | 1173 RestartedInterval restartedInterval = maybeRestartInterval(elapsed); |
1171 | 1174 |
1172 ActiveState oldActiveState = m_activeState; | 1175 ActiveState oldActiveState = m_activeState; |
1173 m_activeState = determineActiveState(elapsed); | 1176 m_activeState = determineActiveState(elapsed); |
1174 bool animationIsContributing = isContributing(elapsed); | 1177 bool animationIsContributing = isContributing(elapsed); |
1175 | 1178 |
1176 // Only reset the animated type to the base value once for the lowest priori
ty animation that animates and contributes to a particular element/attribute pai
r. | 1179 // Only reset the animated type to the base value once for the lowest priori
ty animation that animates and contributes to a particular element/attribute pai
r. |
1177 if (this == resultElement && animationIsContributing) | 1180 if (this == resultElement && animationIsContributing) |
1178 resetAnimatedType(); | 1181 resetAnimatedType(); |
1179 | 1182 |
1180 if (animationIsContributing) { | 1183 if (animationIsContributing) { |
1181 if (oldActiveState == Inactive) { | 1184 if (oldActiveState == Inactive || restartedInterval == DidRestartInterva
l) { |
1182 smilBeginEventSender().dispatchEventSoon(this); | 1185 smilBeginEventSender().dispatchEventSoon(this); |
1183 startedActiveInterval(); | 1186 startedActiveInterval(); |
1184 } | 1187 } |
1185 | 1188 |
1186 if (repeat && repeat != m_lastRepeat) | 1189 if (repeat && repeat != m_lastRepeat) |
1187 dispatchRepeatEvents(repeat); | 1190 dispatchRepeatEvents(repeat); |
1188 | 1191 |
1189 updateAnimation(percent, repeat, resultElement); | 1192 updateAnimation(percent, repeat, resultElement); |
1190 m_lastPercent = percent; | 1193 m_lastPercent = percent; |
1191 m_lastRepeat = repeat; | 1194 m_lastRepeat = repeat; |
1192 } | 1195 } |
1193 | 1196 |
1194 if (oldActiveState == Active && m_activeState != Active) { | 1197 if ((oldActiveState == Active && m_activeState != Active) || restartedInterv
al == DidRestartInterval) { |
1195 smilEndEventSender().dispatchEventSoon(this); | 1198 smilEndEventSender().dispatchEventSoon(this); |
1196 endedActiveInterval(); | 1199 endedActiveInterval(); |
1197 if (m_activeState != Frozen && this == resultElement) | 1200 if (restartedInterval == DidNotRestartInterval && m_activeState != Froze
n && this == resultElement) |
1198 clearAnimatedType(m_targetElement); | 1201 clearAnimatedType(m_targetElement); |
1199 } | 1202 } |
1200 | 1203 |
1201 // Triggering all the pending events if the animation timeline is changed. | 1204 // Triggering all the pending events if the animation timeline is changed. |
1202 if (seekToTime) { | 1205 if (seekToTime) { |
1203 if (m_activeState == Inactive) | 1206 if (m_activeState == Inactive) |
1204 smilBeginEventSender().dispatchEventSoon(this); | 1207 smilBeginEventSender().dispatchEventSoon(this); |
1205 | 1208 |
1206 if (repeat) { | 1209 if (repeat) { |
1207 for (unsigned repeatEventCount = 1; repeatEventCount < repeat; repea
tEventCount++) | 1210 for (unsigned repeatEventCount = 1; repeatEventCount < repeat; repea
tEventCount++) |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1308 if (eventType == "repeatn") { | 1311 if (eventType == "repeatn") { |
1309 unsigned repeatEventCount = m_repeatEventCountList.first(); | 1312 unsigned repeatEventCount = m_repeatEventCountList.first(); |
1310 m_repeatEventCountList.remove(0); | 1313 m_repeatEventCountList.remove(0); |
1311 dispatchEvent(RepeatEvent::create(eventType, repeatEventCount)); | 1314 dispatchEvent(RepeatEvent::create(eventType, repeatEventCount)); |
1312 } else { | 1315 } else { |
1313 dispatchEvent(Event::create(eventType)); | 1316 dispatchEvent(Event::create(eventType)); |
1314 } | 1317 } |
1315 } | 1318 } |
1316 | 1319 |
1317 } | 1320 } |
OLD | NEW |