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

Unified Diff: Source/core/svg/SVGAnimationElement.cpp

Issue 197283002: Compute the keyTimes index correctly for discrete (values) animations (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Drop ASSERT about calcMode 'paced'. Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/svg/animations/animate-elem-18-t-drt-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/svg/SVGAnimationElement.cpp
diff --git a/Source/core/svg/SVGAnimationElement.cpp b/Source/core/svg/SVGAnimationElement.cpp
index 2507e8e770254bee41fc3b9940c2cea2480af3e8..e06ef9593a2fcdbed14b108cc4e127a93eaf10bf 100644
--- a/Source/core/svg/SVGAnimationElement.cpp
+++ b/Source/core/svg/SVGAnimationElement.cpp
@@ -415,10 +415,12 @@ unsigned SVGAnimationElement::calculateKeyTimesIndex(float percent) const
{
unsigned index;
unsigned keyTimesCount = m_keyTimes.size();
- // Compare index + 1 to keyTimesCount because the last keyTimes entry is
- // required to be 1, and percent can never exceed 1; i.e., the second last
- // keyTimes entry defines the beginning of the final interval
- for (index = 1; index + 1 < keyTimesCount; ++index) {
+ // For linear and spline animations, the last value must be '1'. In those
+ // cases we don't need to consider the last value, since |percent| is never
+ // greater than one.
+ if (keyTimesCount && calcMode() != CalcModeDiscrete)
+ keyTimesCount--;
+ for (index = 1; index < keyTimesCount; ++index) {
if (m_keyTimes[index] > percent)
break;
}
@@ -447,14 +449,15 @@ float SVGAnimationElement::calculatePercentFromKeyPoints(float percent) const
return m_keyPoints[m_keyPoints.size() - 1];
unsigned index = calculateKeyTimesIndex(percent);
- float fromPercent = m_keyTimes[index];
- float toPercent = m_keyTimes[index + 1];
float fromKeyPoint = m_keyPoints[index];
- float toKeyPoint = m_keyPoints[index + 1];
if (calcMode() == CalcModeDiscrete)
return fromKeyPoint;
+ ASSERT(index + 1 < m_keyTimes.size());
+ float fromPercent = m_keyTimes[index];
+ float toPercent = m_keyTimes[index + 1];
+ float toKeyPoint = m_keyPoints[index + 1];
float keyPointPercent = (percent - fromPercent) / (toPercent - fromPercent);
if (calcMode() == CalcModeSpline) {
« no previous file with comments | « LayoutTests/svg/animations/animate-elem-18-t-drt-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698