OSDN Git Service

Support for the call method of the object
authordhrname <dhrname@users.sourceforge.jp>
Tue, 3 Mar 2015 14:20:01 +0000 (23:20 +0900)
committerdhrname <dhrname@users.sourceforge.jp>
Tue, 3 Mar 2015 14:20:01 +0000 (23:20 +0900)
org/w3c/dom/smil.js
tool/Spec/spec/SvgDomSpec.js

index 95e45e7..d93ea2a 100644 (file)
@@ -462,7 +462,7 @@ base("$from").of( {
   },\r
 \r
   /*計算モード。advanceメソッドで時間の圧縮率を求めるのに使う*/\r
-  calcMode: base("$from").up("$calcMode"),\r
+  calcMode: base("$calcMode"),\r
   \r
   /*$toオブジェクトにこのオブジェクトを適用させる関数*/\r
   call: function() {\r
@@ -523,8 +523,30 @@ base("$from").of( {
   /*fromプロパティの初期化*/\r
  .up("$to").from = null;\r
  \r
- /*計算モードを定めるための計算実体*/\r
- base("$from").$calcMode.of( {\r
-   strList: {}\r
+ /*計算モードを定めるための計算実体\r
+  *補間の細かい制御などを行う*/\r
+ base("$calcMode").of( {\r
+\r
+   /*計算モード (calcMode属性の値)*/\r
+   mode: "linear",\r
+\r
+   /*keyTimesの区間\r
+    * たとえば、"0, 0.5, 0.7, 1"の場合、時間の区間はそれぞれ、0.5 (=0.5-0)  0.2 (=0.7-0.5)  0.3 (=1-0.7)である\r
+    * このうち、どれか一つが値として入力される*/\r
+   keyTime: 0,\r
+   \r
+   /*keySpline属性の値を設定*/\r
+   keySpline: null,\r
+   \r
+   /*与えられたアニメーションの進捗率を使った時間の圧縮率を計算するための関数を返す*/\r
+   call: function() {\r
+     return function(t) {\r
+       /*tは進捗率*/\r
+       if (!this.keyTime) {\r
+         return 0;\r
+       } \r
+       return t / this.keyTime;\r
+     }.bind(this);\r
+   }\r
 } );\r
 //#endif // _SMIL_IDL_\r
index ef6aee4..88473ec 100644 (file)
@@ -3055,15 +3055,24 @@ describe("SMIL Animation Spec", function() {
     } )\r
   } );\r
   describe("A $calcMode object", function() {\r
-    var calc = base("$from").$calcMode;\r
+    var calc = base("$calcMode");\r
      beforeEach( function() {\r
        calc = calc.up();\r
      } );\r
     /*境界条件を調べておく (limit value analysis)*/\r
     it("should be this for the value  (limit value analysis)", function() {\r
+      expect(calc.mode).toBe("linear");\r
+      expect(calc.keyTime).toEqual(0);\r
+      expect(calc.keySpline).toBeNull();\r
+\r
+      expect(calc.call()(0)).toEqual(0);\r
+      expect(calc.keyTime).toBe(0);\r
+      expect(calc.call()(1)).toEqual(0);\r
     } );\r
     /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
     it("should be this for the value (the valid partion)", function() {\r
+      calc.keyTime = 0.5;\r
+      expect(calc.call()(0.2)).toEqual(0.4);\r
     } );\r
     /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
     it("should be this for the value (the invalid partion)", function() {\r