OSDN Git Service

Modify object
authordhrname <dhrname@users.sourceforge.jp>
Sun, 8 Feb 2015 14:28:27 +0000 (23:28 +0900)
committerdhrname <dhrname@users.sourceforge.jp>
Sun, 8 Feb 2015 14:28:27 +0000 (23:28 +0900)
org/w3c/dom/smil.js
tool/Spec/spec/SvgDomSpec.js

index c89b63e..fd1c7e7 100644 (file)
@@ -288,6 +288,7 @@ base("$frame").mix ( {
     listener: function(evt) {\r
       var s = this.$activate.up();\r
       s.begin = this.begin;\r
+      s.end = s.end.up();\r
       s.timeStamp= evt.timeStamp;\r
       this.activeTime = s.call();\r
       this.addLine(this);\r
@@ -323,16 +324,47 @@ base("$frame").mix ( {
      * base.jsのofメソッドを活用して、関数型っぽい処理をする\r
      * 以下では、活動持続時間を算出*/\r
     call: function() {\r
-      var isIndefDur = (this.dur === "indefinite"),\r
+      var isIndefDur = (this.dur === "indefinite") || !this.dur,\r
           isIndefRepeatCount = (this.repeatCount === "indefinite"),\r
           isIndefRepeatDur = (this.repeatDur === "indefinite"),\r
           actTime = null;\r
-      if (!isIndefDur) {\r
+      if (indef(this)) {\r
+        actTime = null;\r
+      } else if (!isIndefDur) {\r
         actTime = Math.floor( this.offset(this.dur) * this.fpms);\r
       }\r
+      if (!isIndefDur && !isIndefRepeatCount && this.repeatCount) {\r
+        actTime = actTime * this.repeatCount;\r
+      }\r
+\r
+      /*長くなるため、インライン関数を活用\r
+       * indef関数は活動持続時間が不定かどうか、もし、不定なら真を返す*/\r
+      function indef(obj) {\r
+        if (obj.end) {\r
+          return true;\r
+        }\r
+        return !!( (isIndefDur && !obj.repeatDur)\r
+                   || (isIndefRepeatCount && !obj.repeatDur)\r
+                   || (isIndefRepeatDur && !obj.repeatCount)\r
+                   || (isIndefRepeatCount && isIndefRepeatDur)\r
+                 );\r
+      };\r
+      indef = void 0;\r
       return actTime;\r
     }\r
   } );\r
+  $frame.$begin.$end.of( {\r
+    call: function() {\r
+      if (!this.string) {\r
+        return null;\r
+      }\r
+      this.parse(this.string);\r
+      if (!this.isResolved) {\r
+        return null;\r
+      }\r
+      return this.begin;\r
+    }\r
+  } );\r
 } );\r
 /*$presentvalue オブジェクト\r
  * 呈示値 (presentation value)の計算をする。値そのものを返すための計算実体*/\r
index 59b26a1..77b2d03 100644 (file)
@@ -2414,10 +2414,21 @@ describe("SMIL Animation Spec", function() {
     } );\r
     /*境界条件を調べておく (limit value analysis)*/\r
     it("should be this for the value  (limit value analysis)", function() {\r
+      expect(end.up().call()).toBeNull();\r
+      end.string = "0";\r
+      expect(end.up().call()).toBe(0);\r
+      end.string = "hoge";\r
+      expect(end.up().call()).toBeNull();\r
       \r
     } );\r
     /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
     it("should be this for the value (the valid partion)", function() {\r
+      end.string = "hoge+0";\r
+      expect(end.up().call()).toBeNull();\r
+      end.string = "12ms";\r
+      expect(end.up().call()).toBe(Math.floor(12*end.fpms));\r
+      end.string = "hoge+12ms";\r
+      expect(end.up().call()).toBeNull();\r
 \r
     } );\r
     /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
@@ -2430,6 +2441,8 @@ describe("SMIL Animation Spec", function() {
      beforeEach( function() {\r
       act.dur = "indefinite";\r
       act.begin = 0;\r
+      act.repeatCount = null;\r
+      act.repeatDur = null;\r
     } );\r
     /*境界条件を調べておく (limit value analysis)*/\r
     it("should be this for the value  (limit value analysis)", function() {\r
@@ -2450,11 +2463,33 @@ describe("SMIL Animation Spec", function() {
       act.up("$b");\r
       act.$b.dur = "132ms";\r
       var abc = act.$b.call();\r
-      expect(abc).toEqual(Math.floor(132*act.fpms))\r
+      expect(abc).toEqual(Math.floor(132*act.fpms));\r
+      act.dur = null;\r
+      expect(act.up().call()).toBeNull();\r
+      \r
+      act.up("$c").end = act.end.up().mix( { string: "12ms" } );\r
+      act.dur = "10";\r
+      expect(act.$c.call()).toEqual(Math.floor(10000*act.fpms));\r
+      \r
+      act.$c.end = act.end;\r
+      act.$c.repeatCount = "2";\r
+      expect(act.$c.call()).toEqual(Math.floor(2*10000*act.fpms));\r
+      \r
     } );\r
     /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
     it("should be this for the value (the invalid partion)", function() {\r
-\r
+      act.repeatDur = null;\r
+      act.repeatCount = "indefinite";\r
+      act.dur = "1";\r
+      expect(act.call()).toBeNull();\r
+      act.repeatCount = null;\r
+      act.repeatDur = "indefinite";\r
+      act.dur = "1";\r
+      expect(act.call()).toBeNull();\r
+      act.repeatDur = "indefinite";\r
+      act.repeatCount = "indefinite";\r
+      act.dur = "1";\r
+      expect(act.call()).toBeNull();\r
     } );\r
   } );\r
 } )\r