Bug 556841: In paced-calcMode SMIL animation, don't bother computing distance in trivial 2-values case. r=roc
authorDaniel Holbert <dholbert@cs.stanford.edu>
Mon, 05 Apr 2010 09:59:42 -0700
changeset 40220 fabb17b2c94eb5e9ea9d494873a1fab22c45ee77
parent 40219 d31c87f6d2028562c5e202e69fb25e09e0978345
child 40456 1942c0b4e1018bb85fc17676c634d6e631662073
push id12609
push userdholbert@mozilla.com
push dateMon, 05 Apr 2010 17:00:27 +0000
treeherdermozilla-central@fabb17b2c94e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs556841
milestone1.9.3a4pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
Bug 556841: In paced-calcMode SMIL animation, don't bother computing distance in trivial 2-values case. r=roc
content/smil/crashtests/556841-1.svg
content/smil/crashtests/crashtests.list
content/smil/nsSMILAnimationFunction.cpp
new file mode 100644
--- /dev/null
+++ b/content/smil/crashtests/556841-1.svg
@@ -0,0 +1,16 @@
+<?xml version="1.0"?>
+<svg xmlns="http://www.w3.org/2000/svg"
+     class="reftest-wait"
+     onload="go()">
+  <script>
+    function go() {
+      // setCurrentTime to force a sample
+      document.documentElement.setCurrentTime(2);
+      document.documentElement.removeAttribute("class");
+    }
+  </script>
+  <rect fill="teal" x="50" y="50" width="20" height="20">
+    <animateTransform attributeName="transform" type="rotate" by="30"
+                      calcMode="paced" dur="4s"/>
+  </rect>
+</svg>
--- a/content/smil/crashtests/crashtests.list
+++ b/content/smil/crashtests/crashtests.list
@@ -4,8 +4,9 @@ load 523188-1.svg
 load 525099-1.svg
 load 526536-1.svg
 load 526875-1.svg
 load 526875-2.svg
 load 529387-1.xhtml
 load 537157-1.svg
 load 547333-1.svg
 load 548899-1.svg
+load 556841-1.svg
--- a/content/smil/nsSMILAnimationFunction.cpp
+++ b/content/smil/nsSMILAnimationFunction.cpp
@@ -517,16 +517,27 @@ nsSMILAnimationFunction::ComputePacedPos
                                               double& aIntervalProgress,
                                               const nsSMILValue*& aFrom,
                                               const nsSMILValue*& aTo)
 {
   NS_ASSERTION(0.0f <= aSimpleProgress && aSimpleProgress < 1.0f,
                "aSimpleProgress is out of bounds");
   NS_ASSERTION(GetCalcMode() == CALC_PACED,
                "Calling paced-specific function, but not in paced mode");
+  NS_ABORT_IF_FALSE(aValues.Length() >= 2, "Unexpected number of values");
+
+  // Trivial case: If we have just 2 values, then there's only one interval
+  // for us to traverse, and our progress across that interval is the exact
+  // same as our overall progress.
+  if (aValues.Length() == 2) {
+    aIntervalProgress = aSimpleProgress;
+    aFrom = &aValues[0];
+    aTo = &aValues[1];
+    return NS_OK;
+  }
 
   double totalDistance = ComputePacedTotalDistance(aValues);
   if (totalDistance == COMPUTE_DISTANCE_ERROR)
     return NS_ERROR_FAILURE;
 
   // total distance we should have moved at this point in time.
   // (called 'remainingDist' due to how it's used in loop below)
   double remainingDist = aSimpleProgress * totalDistance;