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

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

Issue 2283843002: Hoist updateAnimation() calls from SVGSMILElement::progress (Closed)
Patch Set: Created 4 years, 3 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 | « third_party/WebKit/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 1105 matching lines...) Expand 10 before | Expand all | Expand 10 after
1116 1116
1117 return fill() == FillFreeze ? Frozen : Inactive; 1117 return fill() == FillFreeze ? Frozen : Inactive;
1118 } 1118 }
1119 1119
1120 bool SVGSMILElement::isContributing(SMILTime elapsed) const 1120 bool SVGSMILElement::isContributing(SMILTime elapsed) const
1121 { 1121 {
1122 // Animation does not contribute during the active time if it is past its re peating duration and has fill=remove. 1122 // Animation does not contribute during the active time if it is past its re peating duration and has fill=remove.
1123 return (m_activeState == Active && (fill() == FillFreeze || elapsed <= m_int erval.begin + repeatingDuration())) || m_activeState == Frozen; 1123 return (m_activeState == Active && (fill() == FillFreeze || elapsed <= m_int erval.begin + repeatingDuration())) || m_activeState == Frozen;
1124 } 1124 }
1125 1125
1126 bool SVGSMILElement::progress(SMILTime elapsed, SVGSMILElement* resultElement, b ool seekToTime) 1126 bool SVGSMILElement::progress(SMILTime elapsed, bool seekToTime)
1127 { 1127 {
1128 ASSERT(resultElement);
1129 ASSERT(m_timeContainer); 1128 ASSERT(m_timeContainer);
1130 ASSERT(m_isWaitingForFirstInterval || m_interval.begin.isFinite()); 1129 ASSERT(m_isWaitingForFirstInterval || m_interval.begin.isFinite());
1131 1130
1132 if (!m_syncBaseConditionsConnected) 1131 if (!m_syncBaseConditionsConnected)
1133 connectSyncBaseConditions(); 1132 connectSyncBaseConditions();
1134 1133
1135 if (!m_interval.begin.isFinite()) { 1134 if (!m_interval.begin.isFinite()) {
1136 ASSERT(m_activeState == Inactive); 1135 ASSERT(m_activeState == Inactive);
1137 m_nextProgressTime = SMILTime::unresolved(); 1136 m_nextProgressTime = SMILTime::unresolved();
1138 return false; 1137 return false;
1139 } 1138 }
1140 1139
1141 if (elapsed < m_interval.begin) { 1140 if (elapsed < m_interval.begin) {
1142 ASSERT(m_activeState != Active); 1141 ASSERT(m_activeState != Active);
1143 bool isFrozen = (m_activeState == Frozen);
1144 if (isFrozen) {
1145 if (this == resultElement)
1146 resetAnimatedType();
1147 updateAnimation(m_lastPercent, m_lastRepeat, resultElement);
1148 }
1149 m_nextProgressTime = m_interval.begin; 1142 m_nextProgressTime = m_interval.begin;
1150 // If the animation is frozen, it's still contributing. 1143 // If the animation is frozen, it's still contributing.
1151 return isFrozen; 1144 return m_activeState == Frozen;
1152 } 1145 }
1153 1146
1154 m_previousIntervalBegin = m_interval.begin; 1147 m_previousIntervalBegin = m_interval.begin;
1155 1148
1156 if (m_isWaitingForFirstInterval) { 1149 if (m_isWaitingForFirstInterval) {
1157 m_isWaitingForFirstInterval = false; 1150 m_isWaitingForFirstInterval = false;
1158 resolveFirstInterval(); 1151 resolveFirstInterval();
1159 } 1152 }
1160 1153
1161 // This call may obtain a new interval -- never call calculateAnimationPerce ntAndRepeat() before! 1154 // This call may obtain a new interval -- never call calculateAnimationPerce ntAndRepeat() before!
1162 if (seekToTime) { 1155 if (seekToTime) {
1163 seekToIntervalCorrespondingToTime(elapsed); 1156 seekToIntervalCorrespondingToTime(elapsed);
1164 if (elapsed < m_interval.begin) { 1157 if (elapsed < m_interval.begin) {
1165 // elapsed is not within an interval. 1158 // elapsed is not within an interval.
1166 m_nextProgressTime = m_interval.begin; 1159 m_nextProgressTime = m_interval.begin;
1167 return false; 1160 return false;
1168 } 1161 }
1169 } 1162 }
1170 1163
1171 unsigned repeat = 0; 1164 unsigned repeat = 0;
1172 float percent = calculateAnimationPercentAndRepeat(elapsed, repeat); 1165 float percent = calculateAnimationPercentAndRepeat(elapsed, repeat);
1173 RestartedInterval restartedInterval = maybeRestartInterval(elapsed); 1166 RestartedInterval restartedInterval = maybeRestartInterval(elapsed);
1174 1167
1175 ActiveState oldActiveState = m_activeState; 1168 ActiveState oldActiveState = m_activeState;
1176 m_activeState = determineActiveState(elapsed); 1169 m_activeState = determineActiveState(elapsed);
1177 bool animationIsContributing = isContributing(elapsed); 1170 bool animationIsContributing = isContributing(elapsed);
1178 1171
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.
1180 if (this == resultElement && animationIsContributing)
1181 resetAnimatedType();
1182
1183 if (animationIsContributing) { 1172 if (animationIsContributing) {
1184 if (oldActiveState == Inactive || restartedInterval == DidRestartInterva l) { 1173 if (oldActiveState == Inactive || restartedInterval == DidRestartInterva l) {
1185 smilBeginEventSender().dispatchEventSoon(this); 1174 smilBeginEventSender().dispatchEventSoon(this);
1186 startedActiveInterval(); 1175 startedActiveInterval();
1187 } 1176 }
1188 1177
1189 if (repeat && repeat != m_lastRepeat) 1178 if (repeat && repeat != m_lastRepeat)
1190 dispatchRepeatEvents(repeat); 1179 dispatchRepeatEvents(repeat);
1191 1180
1192 updateAnimation(percent, repeat, resultElement);
1193 m_lastPercent = percent; 1181 m_lastPercent = percent;
1194 m_lastRepeat = repeat; 1182 m_lastRepeat = repeat;
1195 } 1183 }
1196 1184
1197 if ((oldActiveState == Active && m_activeState != Active) || restartedInterv al == DidRestartInterval) { 1185 if ((oldActiveState == Active && m_activeState != Active) || restartedInterv al == DidRestartInterval) {
1198 smilEndEventSender().dispatchEventSoon(this); 1186 smilEndEventSender().dispatchEventSoon(this);
1199 endedActiveInterval(); 1187 endedActiveInterval();
1200 } 1188 }
1201 1189
1202 // Triggering all the pending events if the animation timeline is changed. 1190 // Triggering all the pending events if the animation timeline is changed.
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
1361 { 1349 {
1362 visitor->trace(m_targetElement); 1350 visitor->trace(m_targetElement);
1363 visitor->trace(m_timeContainer); 1351 visitor->trace(m_timeContainer);
1364 visitor->trace(m_conditions); 1352 visitor->trace(m_conditions);
1365 visitor->trace(m_syncBaseDependents); 1353 visitor->trace(m_syncBaseDependents);
1366 SVGElement::trace(visitor); 1354 SVGElement::trace(visitor);
1367 SVGTests::trace(visitor); 1355 SVGTests::trace(visitor);
1368 } 1356 }
1369 1357
1370 } // namespace blink 1358 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/svg/animation/SVGSMILElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698