OSDN Git Service

Modify the activeTime property of the object
authordhrname <dhrname@users.sourceforge.jp>
Sat, 5 Nov 2016 13:37:22 +0000 (22:37 +0900)
committerdhrname <dhrname@users.sourceforge.jp>
Sat, 5 Nov 2016 13:37:22 +0000 (22:37 +0900)
org/w3c/dom/smil.js
tool/Spec/spec/SvgDomSpec.js

index 67e21aa..d0ba046 100644 (file)
@@ -108,6 +108,10 @@ base("$frame").mix ( {
     /*終了時刻(単位フレーム数)のキャッシュとして使う*/\r
     end: 0,\r
     \r
+    /*開始時刻から終了時刻までのフレーム数\r
+     * これがactiveTimeより短ければ、活動継続時間とみなす*/\r
+    beginEnd: Number.MAX_VALUE,\r
+    \r
     /*開始時刻(単位フレーム数)リスト (後述のupdateStateメソッドで使う)*/\r
     beginList: { \r
       next: null,\r
@@ -201,6 +205,7 @@ base("$frame").mix ( {
           this.begin = startTime;\r
         } else if (!startTime) {\r
           /*開始時刻が0ならば、アニメーションを開始*/\r
+          this.begin = 0;\r
           this.state = begin;\r
         }\r
       } else if (state === begin) {\r
@@ -209,23 +214,30 @@ base("$frame").mix ( {
           this.state = end;\r
           /*現時点を終了時刻とみなす*/\r
           this.end = f;\r
+          /*activeTimeプロパティは、begin属性とend属性が反映されていないため、\r
+           * beginEndプロパティに別に設定しておく*/\r
+          this.beginEnd = 0;\r
         } else {\r
           this.state = play;\r
         }\r
       } else if (state === play) {\r
-        if ( (endTime >= cacheBegin) || (startTime > cacheBegin) ) {\r
+        if ( (f >= cacheBegin + this.activeTime)\r
+            || (endTime >= cacheBegin) || (startTime > cacheBegin) ) {\r
           /*終了時刻に到達したか、再び開始イベントが発火されたとき*/\r
           this.state = end;\r
           /*現時点を終了時刻とみなす*/\r
           this.end = f;\r
+          /*activeTimeプロパティは、begin属性とend属性が反映されていないため、\r
+           * beginEndプロパティに別に設定しておく*/\r
+          (endTime > 0) && (this.beginEnd = endTime - startTime);\r
         }\r
       } else if (state === end) {\r
-        if (endTime >= cacheBegin) {\r
-          this.state = post;\r
-        } else {\r
+        if (startTime > cacheBegin) {\r
           /*再生中に開始イベントが発火されて、終了状態となったとき*/\r
           this.state = begin;\r
           this.begin = startTime;\r
+        } else {\r
+          this.state = post;\r
         }\r
       } else {\r
         this.state = begin;\r
@@ -418,7 +430,6 @@ base("$frame").mix ( {
         /*イベントのリスナーとして使う*/\r
             listener = function(evt) {\r
               objList.value = this.begin = eventOffset + base("$frame").currentFrame;\r
-              endList.value = this.begin + this.activeTime;\r
               this.isResolved = true;\r
             };\r
         this.eventOffset = eventOffset;\r
@@ -440,8 +451,6 @@ base("$frame").mix ( {
       } else {\r
         /*開始リストに登録しておく($endの場合は終了リストに登録)*/\r
         this.$list.addList(this.begin);\r
-        /*活動継続時間から算出される終了フレーム数は、終了リストに入れておく*/\r
-        endList.value = this.begin + this.activeTime;\r
       }\r
       s = event = str = plusminus = ele = void 0;\r
     },\r
@@ -473,7 +482,7 @@ base("$frame").mix ( {
       var s = ( this.$activate = this.$activate.up() );\r
       /*$endオブジェクトに付属している$listプロパティを更新したものと一致させておく*/\r
       s.end && (s.end.$list = this.$list);\r
-      this.activeTime = s.call() || Number.MAX_VALUE;\r
+      this.activeTime = this.$list.activeTime = s.call() || Number.MAX_VALUE;\r
       this.simpleDuration = s.simpleDur;\r
       return this;\r
     }\r
@@ -1191,7 +1200,6 @@ base("$calcMode").up("$attribute").mix( {
     ele.beginElement = (frame.string !== "indefinite") ? function(){}\r
                         : function() {\r
                             objList.value = frame.begin = base("$frame").currentFrame;\r
-                            endList.value = frame.begin + frame.activeTime;\r
                             frame.isResolved = true;\r
                             var evt = this.ownerDocument.createEvent("MouseEvents");\r
                             evt.initMouseEvent("beginEvent" ,true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, this);\r
@@ -1202,8 +1210,8 @@ base("$calcMode").up("$attribute").mix( {
     ele.endElement = (endFrame.string !== "indefinite") ? function(){}\r
                         : function() {\r
                             if (frame.isResolved) {\r
-                              endList.value = frame.begin + frame.activeTime;\r
                               endFrame.isResolved = true;\r
+                              endList.value  = base("$frame").currentFrame;\r
                               var evt = this.ownerDocument.createEvent("MouseEvents");\r
                               evt.initMouseEvent("endEvent" ,true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, this);\r
                               this.dispatchEvent(evt);\r
@@ -1465,7 +1473,9 @@ base("$calcMode").up("$attribute").mix( {
       var line = this.timeline,\r
           duration = line.simpleDuration;\r
       if (duration) {\r
-        var advance = ( line.activeTime % duration ) / duration;\r
+        var time = (line.activeTime > $list.beginEnd) ? $list.beginEnd\r
+                    : line.activeTime;\r
+        var advance = ( time % duration ) / duration;\r
         /*例外が発生するため、進捗率が1を超えないように処理*/\r
         advance = (advance > 1) ? 1 : advance;\r
          /*活動継続時間と単純継続時間が一致すると、余りは0となるため以下の処理*/\r
index edd03ce..729e8fc 100644 (file)
@@ -167,6 +167,7 @@ describe("SMIL Animation Spec", function() {
       expect(frame.POSTWAITING).toBe(4);\r
       expect(frame.state).toBe(frame.WAITING);\r
       expect(frame.end).toBe(0);\r
+      expect(frame.beginEnd).toBe(Number.MAX_VALUE);\r
       \r
       expect(frame.beginList).toEqual({\r
               next: null,\r
@@ -269,6 +270,7 @@ describe("SMIL Animation Spec", function() {
       expect(frame.begin).toBe(0);\r
       expect(frame.updateState(1).state).toBe(frame.ENDING);\r
       expect(frame.end).toBe(1);\r
+      expect(frame.beginEnd).toBe(Number.MAX_VALUE);\r
       expect(frame.updateState(1).state).toBe(frame.BEGINNING);\r
       expect(frame.begin).toBe(1);\r
       expect(frame.updateState(1).state).toBe(frame.PLAYING);\r
@@ -291,6 +293,7 @@ describe("SMIL Animation Spec", function() {
       expect(frame.updateState(3).state).toBe(frame.ENDING);\r
       expect(frame.state).toBe(frame.ENDING);\r
       expect(frame.end).toBe(3);\r
+      expect(frame.beginEnd).toBe(2);\r
       expect(frame.updateState(4).state).toBe(frame.POSTWAITING);\r
       expect(frame.state).toBe(frame.POSTWAITING);\r
       \r
@@ -303,6 +306,7 @@ describe("SMIL Animation Spec", function() {
       expect(frame.updateState(3).state).toBe(frame.ENDING);\r
       expect(frame.state).toBe(frame.ENDING);\r
       expect(frame.end).toBe(3);\r
+      expect(frame.beginEnd).toBe(2);\r
       expect(frame.updateState(4).state).toBe(frame.POSTWAITING);\r
       expect(frame.state).toBe(frame.POSTWAITING);\r
       expect(frame.updateState(4).state).toBe(frame.POSTWAITING);\r
@@ -312,6 +316,7 @@ describe("SMIL Animation Spec", function() {
       expect(frame.updateState(1).state).toBe(frame.BEGINNING);\r
       expect(frame.updateState(1).state).toBe(frame.ENDING);\r
       expect(frame.end).toBe(1);\r
+      expect(frame.beginEnd).toBe(0);\r
       expect(frame.updateState(1).state).toBe(frame.POSTWAITING);\r
     } );\r
     /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r