OSDN Git Service

Modify the object
authordhrname <dhrname@users.sourceforge.jp>
Sat, 21 Feb 2015 11:09:19 +0000 (20:09 +0900)
committerdhrname <dhrname@users.sourceforge.jp>
Sat, 21 Feb 2015 11:09:19 +0000 (20:09 +0900)
org/w3c/dom/smil.js
tool/Spec/spec/SvgDomSpec.js

index fb81d57..3765d1f 100644 (file)
@@ -350,43 +350,47 @@ base("$frame").mix ( {
           isIndefRepeatCount = (this.repeatCount === ind),\r
           isIndefRepeatDur = (this.repeatDur === ind),\r
           isIndefEnd = (this.end === ind),\r
+          isDur = dur || (dur === 0),\r
+          isEnd = this.end || (this.end === 0),\r
+          isRepeatCount = this.repeatCount || (this.repeatCount === 0),\r
+          isRepeatDur = this.repeatDur || (this.repeatDur === 0),\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
+      if (indef()) {\r
         return null;\r
       }\r
-      if (dur && this.repeatCount && !isIndefRepeatCount) {\r
+      if (isDur && this.repeatCount && !isIndefRepeatCount) {\r
         actList.push( dur * this.repeatCount );\r
       }\r
-      if (this.repeatDur && !isIndefRepeatDur) {\r
+      if (isRepeatDur && !isIndefRepeatDur) {\r
         actList.push( Math.floor( this.offset(this.repeatDur) * this.fpms) );\r
       }\r
-      if (this.end && !isIndefEnd) {\r
+      if (isEnd && !isIndefEnd) {\r
         actList.push( this.end - this.begin );\r
       }\r
-      if (dur && !this.repeatCount && !this.repeatDur) {\r
+      if (isDur && !isRepeatCount && !isRepeatDur) {\r
         /*repeatCountやrepeatDur属性が指定されていない場合*/\r
         actList.push( dur );\r
       }\r
 \r
       /*長くなるため、インライン関数を活用\r
        * indef関数は活動持続時間が不定かどうか、もし、不定なら真を返す*/\r
-      function indef(obj) {\r
+      function indef() {\r
         if(isIndefEnd) {\r
           return true;\r
-        } else if (obj.end) {\r
+        } else if (isEnd) {\r
           return false;\r
         }\r
-        return !!( (!dur && !obj.repeatDur)\r
-                   || (isIndefRepeatCount && !obj.repeatDur)\r
-                   || (isIndefRepeatDur && !obj.repeatCount)\r
+        return !!( (!isDur && !isRepeatDur)\r
+                   || (isIndefRepeatCount && !isRepeatDur)\r
+                   || (isIndefRepeatDur && !isRepeatCount)\r
                    || (isIndefRepeatCount && isIndefRepeatDur)\r
                  );\r
       };\r
       \r
-      ind = dur = isIndefRepeatCount = isIndefRepeatDurindef  = indef = void 0;\r
+      ind = dur = isIndefRepeatCount = isIndefRepeatDurindef = isDur = isEnd = isRepeatDur = isRepeatCount = indef = void 0;\r
 \r
       if (actList.length === 1) {\r
         s = actList[0];\r
@@ -417,11 +421,19 @@ base("$frame").mix ( {
   } ).mix( {\r
     /*イベントリスナー用の関数*/\r
     listener: function(evt) {\r
-      var offset = this.begin;\r
-      if (offset > 0) {\r
-      } else {\r
+      evt = evt || { timeStamp: 0 };\r
+      if (!evt.timeStamp && (evt.timeStamp !== 0)) {\r
+        throw new Error();\r
+      }\r
+      if (this.begin <= 0) {\r
+        /*強制的に終了させる*/\r
         this.removeLine(this.$begin);\r
       }\r
+      this.begin += Math.floor( (evt.timeStamp - this.startTime ) * this.fpms );\r
+      var s = this.$begin.$activate;\r
+      s.end = this.begin;\r
+      this.$begin.activeTime = s.call();\r
+      s = void 0;\r
     }\r
   } );\r
 } );\r
index 1a6c79d..8bf0f95 100644 (file)
@@ -2498,8 +2498,11 @@ describe("SMIL Animation Spec", function() {
         /*配列は初期化しておく*/\r
         end.timelines.length = 0;\r
         obj = end.up();\r
-        obj.$begin = begin.up();\r
-        obj.$activate = begin.$activate.up();\r
+        obj.$begin = begin.up().mix( {\r
+          begin: 12,\r
+          activeTime: 120\r
+        } );\r
+        obj.$begin.$activate = begin.$activate.up();\r
         obj.addLine(obj.$begin);\r
       } );\r
       /*境界条件を調べておく (limit value analysis)*/\r
@@ -2509,28 +2512,48 @@ describe("SMIL Animation Spec", function() {
         obj.listener();\r
         expect(obj.timelines[0]).not.toBe(obj.$begin);\r
 \r
-        obj.addLine(obj.$begin);\r
+        obj.addLine(obj.$begin.mix( {\r
+          begin: 12,\r
+          activeTime: 120\r
+        } ) );\r
         obj.listener({\r
           timeStamp: 12\r
         } );\r
         expect(obj.timelines[0]).not.toBe(obj.$begin);\r
+      } );\r
+      /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
+      it("should be this for the value (the valid partion)", function() {\r
+        obj.$begin.$activate.begin = 0;\r
+        obj.mix( {\r
+          string: "event"\r
+        } ).parse();\r
+        obj.listener({\r
+          timeStamp: 120\r
+        } );\r
+        expect(obj.timelines[0]).not.toBe(obj.$begin);\r
+        expect(obj.begin).toEqual(Math.floor(120*obj.fpms));\r
+        expect(obj.$begin.activeTime).toEqual(Math.floor(120*obj.fpms));\r
 \r
-        obj.addLine(obj.$begin);\r
+        obj.addLine(obj.$begin.mix( {\r
+          begin: 12,\r
+          activeTime: 120\r
+        } ) );\r
+        obj.$begin.$activate.begin = 0;\r
         obj.mix( {\r
-          string: "event+100ms"\r
+          string: "event+1000ms"\r
         } ).parse();\r
         obj.listener({\r
           timeStamp: 12\r
         } );\r
         expect(obj.timelines[0]).toBe(obj.$begin);\r
-      } );\r
-      /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
-      it("should be this for the value (the valid partion)", function() {\r
+        expect(obj.begin).toEqual(Math.floor(1012*obj.fpms));\r
+        expect(obj.$begin.activeTime).toEqual(Math.floor(1012*obj.fpms));\r
       } );\r
       /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
       it("should be this for the value (the invalid partion)", function() {\r
-        obj.listener({});\r
-        expect(obj.timelines[0]).not.toBe(obj.$begin);\r
+        expect(function() {\r
+          obj.listener({});\r
+        } ).toThrow();\r
       } );\r
     } )\r
   } );\r
@@ -2743,6 +2766,22 @@ describe("SMIL Animation Spec", function() {
         simpleDur: act.simpleDur\r
       } );\r
       expect(act.$d.call()).toEqual(Math.floor(2000*act.fpms));\r
+      \r
+      /*endで0が指定されている場合*/\r
+      act.begin = 0;\r
+      act.end = 0;\r
+      act.repeatDur = null;\r
+      act.repeatCount = "indefinite";\r
+      act.dur = "1";\r
+      expect(act.call()).toEqual(0);\r
+      act.repeatCount = null;\r
+      act.repeatDur = "indefinite";\r
+      act.dur = "1";\r
+      expect(act.call()).toEqual(0);\r
+      act.repeatDur = "indefinite";\r
+      act.repeatCount = "indefinite";\r
+      act.dur = "1";\r
+      expect(act.call()).toEqual(0);\r
     } );\r
     /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
     it("should be this for the value (the invalid partion)", function() {\r