OSDN Git Service

Support a min and a max property in the object
authordhrname <dhrname@users.sourceforge.jp>
Thu, 12 Feb 2015 13:08:29 +0000 (22:08 +0900)
committerdhrname <dhrname@users.sourceforge.jp>
Thu, 12 Feb 2015 13:08:29 +0000 (22:08 +0900)
org/w3c/dom/smil.js
tool/Spec/spec/SvgDomSpec.js

index f5adc1e..d7189bb 100644 (file)
@@ -322,6 +322,14 @@ base("$frame").mix ( {
               : Math.floor(this.offset(this.dur) * this.fpms) ;\r
     },\r
 \r
+    /*最小値に制限される\r
+     * 最小値 <= 活動持続時間 とならなければならない*/\r
+     min: "0",\r
+     \r
+    /*最大値に制限される\r
+     * 活動持続時間 <= 最大値 とならなければならない*/\r
+     max: "indefinite",\r
+    \r
     /*解決した(計算する)ときの時間*/\r
     resolvedTime: function() {\r
       return Date.now();\r
@@ -336,7 +344,10 @@ base("$frame").mix ( {
           isIndefRepeatCount = (this.repeatCount === ind),\r
           isIndefRepeatDur = (this.repeatDur === ind),\r
           isIndefEnd = (this.end === ind),\r
-          actList = [];\r
+          actList = [],\r
+          min = Math.floor(this.offset(this.min) * this.fpms),\r
+          max = (this.max === ind) ? null : Math.floor(this.offset(this.max) * this.fpms),\r
+          s;\r
       if (indef(this)) {\r
         return null;\r
       }\r
@@ -372,13 +383,19 @@ base("$frame").mix ( {
       ind = dur = isIndefRepeatCount = isIndefRepeatDurindef  = indef = void 0;\r
 \r
       if (actList.length === 1) {\r
-        return actList[0];\r
+        s = actList[0];\r
       } else if(actList.length > 1) {\r
         /*属性が競合するときは、最小値をとること (SMILアニメーション 3.3.4節)*/\r
-        return Math.min.apply(Math, actList);\r
+        s = Math.min.apply(Math, actList);\r
       } else {\r
         return null;\r
       }\r
+      if ( max && (min > max) ) {\r
+        return s;\r
+      }\r
+      min && (min > s) && (s = min);\r
+      max && (max < s) && (s = max);\r
+      return s;\r
     }\r
   } );\r
   $frame.$begin.$end.of( {\r
index aeb6c7f..307a101 100644 (file)
@@ -2444,7 +2444,7 @@ describe("SMIL Animation Spec", function() {
       act.begin = 0;\r
       act.repeatCount = null;\r
       act.repeatDur = null;\r
-      act.end = act.$begin.$end\r
+      act.end = act.$begin.$end;\r
     } );\r
     /*境界条件を調べておく (limit value analysis)*/\r
     it("should be this for the value  (limit value analysis)", function() {\r
@@ -2455,6 +2455,8 @@ describe("SMIL Animation Spec", function() {
       expect(act.repeatCount).toBeNull();\r
       expect(act.repeatDur).toBeNull();\r
       expect(act.simpleDur()).toBeNull();\r
+      expect(act.min).toBe("0");\r
+      expect(act.max).toBe("indefinite");\r
 \r
       act.up("$a");\r
       expect(act.$a.call()).toBeNull();\r
@@ -2631,6 +2633,28 @@ describe("SMIL Animation Spec", function() {
       act.$cd.repeatDur = "12";\r
       expect(act.$cd.call()).toEqual(Math.floor(12000*act.fpms));\r
       \r
+      act.up("$d").mix( {\r
+        min: "2",\r
+        max: "3",\r
+        dur: "1",\r
+        simpleDur: act.simpleDur\r
+      } );\r
+      expect(act.$d.call()).toEqual(Math.floor(2000*act.fpms));\r
+      act.up("$d").mix( {\r
+        min: "1",\r
+        max: "2",\r
+        dur: "12",\r
+        simpleDur: act.simpleDur\r
+      } );\r
+      expect(act.$d.call()).toEqual(Math.floor(2000*act.fpms));\r
+      /*min > max*/\r
+      act.up("$d").mix( {\r
+        min: "3",\r
+        max: "2",\r
+        dur: "1",\r
+        simpleDur: act.simpleDur\r
+      } );\r
+      expect(act.$d.call()).toEqual(Math.floor(1000*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