OSDN Git Service

Support a values attribute
authordhrname <dhrname@users.sourceforge.jp>
Fri, 24 Apr 2015 14:33:18 +0000 (23:33 +0900)
committerdhrname <dhrname@users.sourceforge.jp>
Fri, 24 Apr 2015 14:33:18 +0000 (23:33 +0900)
org/w3c/dom/smil.js
tool/Spec/spec/SvgDomSpec.js

index 6308a12..57b715e 100644 (file)
@@ -736,7 +736,9 @@ base("$calcMode").up("$attribute").mix( {
   \r
   /*setValuesメソッド\r
    * values属性やfrom属性やto属性を処理するためのメソッド\r
-   * valuesは配列、それ以外の引数は文字列*/\r
+   * valuesは配列、それ以外の引数は文字列\r
+   * 返り値は、values属性は配列、それ以外の属性のときは、\r
+   * 自分自身となる$attributeオブジェクトのコピーを返す*/\r
    setValues: function(values, from, to, by) {\r
      var $from = base("$from"),\r
          s = this.up().mix( {\r
@@ -749,8 +751,17 @@ base("$calcMode").up("$attribute").mix( {
      if (values && values.length) {\r
        /*values属性が指定された場合、他の属性は無視される\r
         * W3C仕様 SMIL アニメーション 3.2.2. アニメーション関数の値*/\r
-       sto.string = values[1];\r
-       sto.from.string = values[0];\r
+        s = [];\r
+       for (var i=1;i<values.length;++i) {\r
+         s.push( this.up().mix( {\r
+               to: $from.up().mix( {\r
+                 from: $from.up()\r
+               } )\r
+             } ) );\r
+         sto = s[s.length-1].to;\r
+         sto.string = values[i];\r
+         sto.from.string = values[i-1];\r
+       }\r
      } else if (to) {\r
        sto.string = to;\r
        sto.from.string = from || "0";\r
index 33922ad..4e189ff 100644 (file)
@@ -3446,8 +3446,8 @@ describe("SMIL Animation Spec", function() {
         expect(attr.setValues()).toBeNull();\r
         expect(attr.setValues([])).toBeNull();\r
 \r
-        expect(attr.setValues(["0", "1"]).to.string).toBe("1");\r
-        expect(attr.setValues(["0", "1"]).to.from.string).toBe("0");\r
+        expect(attr.setValues(["0", "1"])[0].to.string).toBe("1");\r
+        expect(attr.setValues(["0", "1"])[0].to.from.string).toBe("0");\r
         \r
         /*from-to アニメーション*/\r
         expect(attr.setValues(null, "0", "1").to.string).toBe("1");\r
@@ -3474,11 +3474,19 @@ describe("SMIL Animation Spec", function() {
       } );\r
       /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
       it("should be this for the value (the valid partion on a spline mode )", function() {\r
-        var setv = attr.setValues(["0", "1"]).mix( function() {\r
+        var setv = attr.setValues(["0", "1"])[0].mix( function() {\r
             this.to.degit = 1;\r
           }\r
         ).call();\r
         expect(setv(0.5)).toBe("0.5");\r
+        expect(setv(1)).toBe("1.0");\r
+        \r
+        setv = attr.setValues(["0", "1", "2"])[0].mix( function() {\r
+            this.to.degit = 1;\r
+          }\r
+        ).call();\r
+        expect(setv(0.5)).toBe("0.5");\r
+        expect(setv(1)).toBe("1.0");\r
       } );\r
       /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
       it("should be this for the value (the invalid partion on a spline mode )", function() {\r