Bug 1246893 - Fix boundary values of nsSMILKeySpline::GetTForX. r?birtles
MozReview-Commit-ID: 9KX0aLPRP31
--- a/dom/smil/nsSMILKeySpline.cpp
+++ b/dom/smil/nsSMILKeySpline.cpp
@@ -71,16 +71,20 @@ nsSMILKeySpline::GetSlope(double aT,
double aA2)
{
return 3.0 * A(aA1, aA2)*aT*aT + 2.0 * B(aA1, aA2) * aT + C(aA1);
}
double
nsSMILKeySpline::GetTForX(double aX) const
{
+ // Early return when aX == 1.0 to avoid floating-point inaccuracies.
+ if (aX == 1.0) {
+ return 1.0;
+ }
// Find interval where t lies
double intervalStart = 0.0;
const double* currentSample = &mSampleValues[1];
const double* const lastSample = &mSampleValues[kSplineTableSize - 1];
for (; currentSample != lastSample && *currentSample <= aX;
++currentSample) {
intervalStart += kSampleStepSize;
}