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 284358 34fa562d20dca4ae870ffb86101d9c0a9649315f
parent 284357 ff879c6f1d7ba95b3d1b55e6f089544783b79d01
child 284359 768ce03913e743a9cc5ef5c816d5b3b1ea5facba
push id71924
push usercbook@mozilla.com
push dateTue, 16 Feb 2016 15:45:51 +0000
treeherdermozilla-inbound@34fa562d20dc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbirtles
bugs1246893
milestone47.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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;
   }