Bug 1246893 - Fix boundary values of nsSMILKeySpline::GetTForX. r=birtles
authorHiroyuki Ikezoe <hiikezoe@mozilla-japan.org>
Tue, 16 Feb 2016 13:59:36 +0900
changeset 331302 34fa562d20dca4ae870ffb86101d9c0a9649315f
parent 331301 ff879c6f1d7ba95b3d1b55e6f089544783b79d01
child 331303 768ce03913e743a9cc5ef5c816d5b3b1ea5facba
push id10956
push userjolesen@mozilla.com
push dateTue, 16 Feb 2016 19:12:12 +0000
reviewersbirtles
bugs1246893
milestone47.0a1
Bug 1246893 - Fix boundary values of nsSMILKeySpline::GetTForX. r=birtles MozReview-Commit-ID: 9KX0aLPRP31
dom/smil/nsSMILKeySpline.cpp
--- 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;
   }