OSDN Git Service

Support a call method in object
authordhrname <dhrname@users.sourceforge.jp>
Sat, 7 Feb 2015 12:57:21 +0000 (21:57 +0900)
committerdhrname <dhrname@users.sourceforge.jp>
Sat, 7 Feb 2015 12:57:21 +0000 (21:57 +0900)
org/w3c/dom/smil.js
tool/Spec/spec/SvgDomSpec.js

index 7b7e200..60a209e 100644 (file)
@@ -305,12 +305,27 @@ base("$frame").mix ( {
     /*単純持続時間のパース去れる前の文字列*/\r
     dur: "indefinite",\r
     \r
-    /*活動をストップさせるための文字列*/\r
-    end: "",\r
+    /*活動をストップさせるためのオブジェクト*/\r
+    end: $frame.$begin.up("$end"),\r
      \r
     /*解決した(計算する)ときの時間*/\r
     resolvedTime: function() {\r
       return Date.now();\r
+    },\r
+    \r
+    /*関数型の呼び出しメソッド\r
+     * base.jsのofメソッドを活用して、関数型っぽい処理をする\r
+     * 以下では、活動持続時間を算出*/\r
+    call: function() {\r
+      var isIndefiniteDur = (this.dur === "indefinite"),\r
+          isIndefiniteEnd = (this.end === this.$begin.$end),\r
+          actTime = null;\r
+      if (!isIndefiniteDur) {\r
+        actTime = Math.floor( this.offset(this.dur) * this.fpms);\r
+      }\r
+      return {\r
+        activeTime: actTime\r
+      };\r
     }\r
   } );\r
 } );\r
index 7b765dd..9ed0f3e 100644 (file)
@@ -2411,17 +2411,27 @@ describe("SMIL Animation Spec", function() {
     var act = base("$frame").$begin.$activate;\r
      beforeEach( function() {\r
       act.dur = "indefinite";\r
+      act.begin = 0;\r
     } );\r
     /*境界条件を調べておく (limit value analysis)*/\r
     it("should be this for the value  (limit value analysis)", function() {\r
       expect(act.timeStamp).toEqual(0);\r
       expect(act.dur).toBe("indefinite");\r
       expect(typeof act.resolvedTime).toBe("function");\r
-      expect(act.end).toBe("");\r
+      expect(act.end).toBe(act.$begin.$end);\r
+\r
+      act.up("$a");\r
+      expect(act.$a.call()).not.toBe(act.$a);\r
+      expect(act.$a.call().activeTime).toBeNull();\r
     } );\r
     /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
     it("should be this for the value (the valid partion)", function() {\r
+      expect(act.resolvedTime()).toEqual((+new Date()));\r
 \r
+      act.up("$b");\r
+      act.$b.dur = "132ms";\r
+      var abc = act.$b.call();\r
+      expect(abc.activeTime).toEqual(Math.floor(132*act.fpms))\r
     } );\r
     /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
     it("should be this for the value (the invalid partion)", function() {\r