Bug 974698 - Check that keyPoints and keyTimes numbers match for animateMotion. r=dholbert
authorRobert Longson <longsonr@gmail.com>
Fri, 18 Apr 2014 10:47:28 +0100
changeset 179616 13cad5da4f9a8ff534ae5c3db62245466aaf8153
parent 179615 f180f4ba7a9851cf942e3198523ec1caa6c955cf
child 179617 93d3946fd9e0f292ee90a55964d0b11e56e8992d
push id272
push userpvanderbeken@mozilla.com
push dateMon, 05 May 2014 16:31:18 +0000
reviewersdholbert
bugs974698
milestone31.0a1
Bug 974698 - Check that keyPoints and keyTimes numbers match for animateMotion. r=dholbert
content/svg/content/src/SVGMotionSMILAnimationFunction.cpp
dom/smil/test/smilAnimateMotionValueLists.js
--- a/content/svg/content/src/SVGMotionSMILAnimationFunction.cpp
+++ b/content/svg/content/src/SVGMotionSMILAnimationFunction.cpp
@@ -372,30 +372,26 @@ SVGMotionSMILAnimationFunction::CheckKey
   if (!HasAttr(nsGkAtoms::keyPoints))
     return;
 
   // attribute is ignored for calcMode="paced" (even if it's got errors)
   if (GetCalcMode() == CALC_PACED) {
     SetKeyPointsErrorFlag(false);
   }
 
-  if (mKeyPoints.IsEmpty()) {
-    // keyPoints attr is set, but array is empty => it failed preliminary checks
+  if (mKeyPoints.Length() != mKeyTimes.Length()) {
+    // there must be exactly as many keyPoints as keyTimes
     SetKeyPointsErrorFlag(true);
     return;
   }
 
   // Nothing else to check -- we can catch all keyPoints errors elsewhere.
   // -  Formatting & range issues will be caught in SetKeyPoints, and will
   //  result in an empty mKeyPoints array, which will drop us into the error
   //  case above.
-  // -  Number-of-entries issues will be caught in CheckKeyTimes (and flagged
-  //  as a problem with |keyTimes|), since we use our keyPoints entries to
-  //  populate the "values" list, and that list's count gets passed to
-  //  CheckKeyTimes.
 }
 
 nsresult
 SVGMotionSMILAnimationFunction::SetKeyPoints(const nsAString& aKeyPoints,
                                              nsAttrValue& aResult)
 {
   mKeyPoints.Clear();
   aResult.SetTo(aKeyPoints);
--- a/dom/smil/test/smilAnimateMotionValueLists.js
+++ b/dom/smil/test/smilAnimateMotionValueLists.js
@@ -103,18 +103,21 @@ const gValidKeyPoints = [
   "0; 0; 1",
   "0; 1; 1",
   "0; 0; 1;", // Trailing semicolons are allowed
   "0; 0; 1; ",
   "0; 0.000; 1",
   "0; 0.000001; 1",
 ];
 
+// Should have 3 values to be valid.
+// Same as number of keyTimes values
 const gInvalidKeyPoints = [
   "0; 1",
+  "0; 0.5; 0.75; 1",
   "0; 1;",
   "0",
   "1",
   "a",
   "",
   "  ",
   "0; -0.1; 1",
   "0; 1.1; 1",