Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Side by Side Diff: Source/core/svg/animation/SVGSMILElement.cpp

Issue 141013017: Make sure begin and end events are dispatched for back-to-back intervals (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/svg/animation/SVGSMILElement.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 bool SVGSMILElement::checkRestart(SMILTime elapsed)
pdr. 2014/02/03 23:23:00 Can we clean this up a bit? I'll offer a suggesti
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 false;
1011 1011
1012 if (elapsed < m_intervalEnd) { 1012 if (elapsed < m_intervalEnd) {
1013 if (restart != RestartAlways) 1013 if (restart != RestartAlways)
1014 return; 1014 return false;
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 return resolveNextInterval();
1024
1025 return false;
1024 } 1026 }
1025 1027
1026 void SVGSMILElement::seekToIntervalCorrespondingToTime(SMILTime elapsed) 1028 void SVGSMILElement::seekToIntervalCorrespondingToTime(SMILTime elapsed)
1027 { 1029 {
1028 ASSERT(!m_isWaitingForFirstInterval); 1030 ASSERT(!m_isWaitingForFirstInterval);
1029 ASSERT(elapsed >= m_intervalBegin); 1031 ASSERT(elapsed >= m_intervalBegin);
1030 1032
1031 // Manually seek from interval to interval, just as if the animation would r un regulary. 1033 // Manually seek from interval to interval, just as if the animation would r un regulary.
1032 while (true) { 1034 while (true) {
1033 // Figure out the next value in the begin time list after the current in terval begin. 1035 // 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
1160 seekToIntervalCorrespondingToTime(elapsed); 1162 seekToIntervalCorrespondingToTime(elapsed);
1161 if (elapsed < m_intervalBegin) { 1163 if (elapsed < m_intervalBegin) {
1162 // elapsed is not within an interval. 1164 // elapsed is not within an interval.
1163 m_nextProgressTime = m_intervalBegin; 1165 m_nextProgressTime = m_intervalBegin;
1164 return false; 1166 return false;
1165 } 1167 }
1166 } 1168 }
1167 1169
1168 unsigned repeat = 0; 1170 unsigned repeat = 0;
1169 float percent = calculateAnimationPercentAndRepeat(elapsed, repeat); 1171 float percent = calculateAnimationPercentAndRepeat(elapsed, repeat);
1170 checkRestart(elapsed); 1172 bool didRestart = checkRestart(elapsed);
1171 1173
1172 ActiveState oldActiveState = m_activeState; 1174 ActiveState oldActiveState = m_activeState;
1173 m_activeState = determineActiveState(elapsed); 1175 m_activeState = determineActiveState(elapsed);
1174 bool animationIsContributing = isContributing(elapsed); 1176 bool animationIsContributing = isContributing(elapsed);
1175 1177
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. 1178 // 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) 1179 if (this == resultElement && animationIsContributing)
1178 resetAnimatedType(); 1180 resetAnimatedType();
1179 1181
1182 ASSERT(!didRestart || m_activeState == Active);
1183
1180 if (animationIsContributing) { 1184 if (animationIsContributing) {
1181 if (oldActiveState == Inactive) { 1185 if (oldActiveState == Inactive || didRestart) {
1182 smilBeginEventSender().dispatchEventSoon(this); 1186 smilBeginEventSender().dispatchEventSoon(this);
1183 startedActiveInterval(); 1187 startedActiveInterval();
1184 } 1188 }
1185 1189
1186 if (repeat && repeat != m_lastRepeat) 1190 if (repeat && repeat != m_lastRepeat)
1187 dispatchRepeatEvents(repeat); 1191 dispatchRepeatEvents(repeat);
1188 1192
1189 updateAnimation(percent, repeat, resultElement); 1193 updateAnimation(percent, repeat, resultElement);
1190 m_lastPercent = percent; 1194 m_lastPercent = percent;
1191 m_lastRepeat = repeat; 1195 m_lastRepeat = repeat;
1192 } 1196 }
1193 1197
1194 if (oldActiveState == Active && m_activeState != Active) { 1198 if ((oldActiveState == Active && m_activeState != Active) || didRestart) {
1195 smilEndEventSender().dispatchEventSoon(this); 1199 smilEndEventSender().dispatchEventSoon(this);
1196 endedActiveInterval(); 1200 endedActiveInterval();
1197 if (m_activeState != Frozen && this == resultElement) 1201 if (!didRestart && m_activeState != Frozen && this == resultElement)
1198 clearAnimatedType(m_targetElement); 1202 clearAnimatedType(m_targetElement);
1199 } 1203 }
1200 1204
1201 // Triggering all the pending events if the animation timeline is changed. 1205 // Triggering all the pending events if the animation timeline is changed.
1202 if (seekToTime) { 1206 if (seekToTime) {
1203 if (m_activeState == Inactive) 1207 if (m_activeState == Inactive)
1204 smilBeginEventSender().dispatchEventSoon(this); 1208 smilBeginEventSender().dispatchEventSoon(this);
1205 1209
1206 if (repeat) { 1210 if (repeat) {
1207 for (unsigned repeatEventCount = 1; repeatEventCount < repeat; repea tEventCount++) 1211 for (unsigned repeatEventCount = 1; repeatEventCount < repeat; repea tEventCount++)
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1308 if (eventType == "repeatn") { 1312 if (eventType == "repeatn") {
1309 unsigned repeatEventCount = m_repeatEventCountList.first(); 1313 unsigned repeatEventCount = m_repeatEventCountList.first();
1310 m_repeatEventCountList.remove(0); 1314 m_repeatEventCountList.remove(0);
1311 dispatchEvent(RepeatEvent::create(eventType, repeatEventCount)); 1315 dispatchEvent(RepeatEvent::create(eventType, repeatEventCount));
1312 } else { 1316 } else {
1313 dispatchEvent(Event::create(eventType)); 1317 dispatchEvent(Event::create(eventType));
1314 } 1318 }
1315 } 1319 }
1316 1320
1317 } 1321 }
OLDNEW
« no previous file with comments | « Source/core/svg/animation/SVGSMILElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698