OSDN Git Service

New object from the
authordhrname <dhrname@users.sourceforge.jp>
Sun, 15 May 2016 12:34:24 +0000 (21:34 +0900)
committerdhrname <dhrname@users.sourceforge.jp>
Sun, 15 May 2016 12:34:24 +0000 (21:34 +0900)
org/w3c/dom/smil.js
tool/Spec/spec/SvgDomSpec.js

index f4adce9..0e864b0 100644 (file)
@@ -77,11 +77,6 @@ base("$frame").mix ( {
   /*現在のフレーム数*/\r
   currentFrame: 0,\r
   \r
-  /*タイムラインがbeginフレームであるかどうか\r
-   * もし、trueあれば、終了処理をしない\r
-   * 後述のaddLineメソッドで使う*/\r
-  isBegin: false,\r
-  \r
   /*アニメーションを開始させるメソッド*/\r
   startAnimation: function() {\r
     /*__step関数は最後に書く*/\r
@@ -126,12 +121,7 @@ base("$frame").mix ( {
     if ( timelines.indexOf(obj) >= 0 ) {\r
       this.removeLine(obj);\r
     }\r
-    if (obj.isBegin) {\r
-      timelines.unshift(obj);\r
-    } else {\r
-      /*終了処理をするフレームはリストの末尾に追加*/\r
-      timelines.push(obj);\r
-    }\r
+    timelines.push(obj);\r
     timelines = void 0;
     return true;\r
   },\r
@@ -146,7 +136,13 @@ base("$frame").mix ( {
     }\r
     list = j = void 0;\r
   }\r
-} ).mix( function($frame) {  \r
+} ).mix( function($frame) {\r
+  /*$endFrame オブジェクト\r
+   * 終了時の処理をするためのフレームを集める*/\r
+  $frame.up("$endFrame").mix( {\r
+    timelines: []\r
+  } );\r
+   \r
   /*$begin オブジェクト\r
    * 開始のタイミングを計算する*/\r
   $frame.up("$begin").mix( {\r
@@ -1192,15 +1188,13 @@ base("$calcMode").up("$attribute").mix( {
       line.addLine(\r
        { setFrame: this._setFrame.bind(this),\r
          begin: 1,\r
-         activeTime: 1,\r
-         isBegin: true\r
+         activeTime: 1\r
        }\r
       );\r
-      base("$frame").addLine(\r
+      base("$frame").$endFrame.addLine(\r
         { setFrame: this._setEndFrame.bind(this),\r
           begin: 1,\r
-          activeTime: 1,\r
-          isBegin: false\r
+          activeTime: 1\r
         }\r
       );\r
     }\r
@@ -1875,6 +1869,7 @@ if (!document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#Anim
           frame++;\r
           try {\r
             $f.setFrame(frame);\r
+            $f.$endFrame.setFrame(frame);\r
           } catch(e) {\r
           }\r
           _cancel.handle = requestAnimationFrame(step);\r
index 7202cf6..196f094 100644 (file)
@@ -175,23 +175,17 @@ describe("SMIL Animation Spec", function() {
       frame.timelines.length = 0;\r
       frame.addLine( {\r
         begin: 1,\r
-        activeTime: 1,\r
-        isBegin: true\r
+        activeTime: 1\r
       } );\r
       frame.addLine( {\r
         begin: 1,\r
-        activeTime: 1,\r
-        isBegin: false\r
+        activeTime: 1\r
       } );\r
       frame.addLine( {\r
         begin: 1,\r
-        activeTime: 2,\r
-        isBegin: true\r
+        activeTime: 2\r
       } );\r
-      expect(frame.timelines[0].isBegin).toBeTruthy();\r
-      expect(frame.timelines[1].isBegin).toBeTruthy();\r
-      expect(frame.timelines[0].activeTime).toBe(2)\r
-      expect(frame.timelines[2].isBegin).toBeFalsy();\r
+      expect(frame.timelines[2].activeTime).toBe(2)\r
     });\r
     /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
     it("should be this for the value (the invalid partion)", function() {\r
@@ -2057,9 +2051,10 @@ describe("SMIL Animation Spec", function() {
         ele = document.createElementNS("http://www.w3.org/2000/svg", "set");\r
         p.appendChild(ele);\r
         frame = base("$frame");\r
-        frame.timelines.length = 0; //配列の初期化\r
+        frame.timelines.length = frame.$endFrame.timelines.length = 0; //配列の初期化\r
         frame.startTime = Date.now();\r
         frame.setFrame(0);\r
+        frame.$endFrame.setFrame(0);\r
       } );\r
       afterEach( function() {\r
         $set.isCSS = false;\r
@@ -2076,10 +2071,12 @@ describe("SMIL Animation Spec", function() {
         $set.isCSS = false;\r
         expect($set.timeline).not.toBe(frame.$begin);\r
         frame.setFrame(0);\r
+        frame.$endFrame.setFrame(0);\r
         expect(ele.parentNode.getAttributeNS(null, "fill")).toBe("red");\r
         expect($set.state).toBe("playing");\r
         \r
         frame.setFrame(24);\r
+        frame.$endFrame.setFrame(24);\r
         expect(ele.parentNode.hasAttributeNS(null, "fill")).toBeFalsy();\r
         expect($set.state).toBe("idling");\r
       } );\r
@@ -2094,14 +2091,17 @@ describe("SMIL Animation Spec", function() {
         $set.isCSS = false;\r
         var f = function(num) {\r
           frame.setFrame(num);\r
+          frame.$endFrame.setFrame(num);\r
           expect(ele.parentNode.getAttributeNS(null, "fill") || null).toBeNull();\r
         }\r
         f(0);\r
         f(1);\r
         f(23);\r
         frame.setFrame(24);\r
+        frame.$endFrame.setFrame(24);\r
         expect(ele.parentNode.getAttributeNS(null, "fill")).toBe("red");\r
         frame.setFrame(25);\r
+        frame.$endFrame.setFrame(25);\r
         expect(ele.parentNode.getAttributeNS(null, "fill")).toBe("red");\r
         f(48);\r
         f(49);\r
@@ -2113,12 +2113,16 @@ describe("SMIL Animation Spec", function() {
         f(1);\r
         f(23);\r
         frame.setFrame(24);\r
+        frame.$endFrame.setFrame(24);\r
         expect(ele.parentNode.getAttributeNS(null, "fill")).toBe("red");\r
         frame.setFrame(25);\r
+        frame.$endFrame.setFrame(25);\r
         expect(ele.parentNode.getAttributeNS(null, "fill")).toBe("red");\r
         frame.setFrame(48);\r
+        frame.$endFrame.setFrame(48);\r
         expect(ele.parentNode.getAttributeNS(null, "fill") || null).toBe("red");\r
         frame.setFrame(49);\r
+        frame.$endFrame.setFrame(49);\r
         expect(ele.parentNode.getAttributeNS(null, "fill") || null).toBe("red");\r
         ele.setAttributeNS(null, "begin", "1s");\r
         ele.setAttributeNS(null, "attributeName", "fill");\r
@@ -2128,6 +2132,7 @@ describe("SMIL Animation Spec", function() {
         $set.isCSS = false;\r
         var f = function(num) {\r
           frame.setFrame(num);\r
+          frame.$endFrame.setFrame(num);\r
           expect(ele.parentNode.getAttributeNS(null, "fill") || null).toBe("red");\r
         }\r
         f(0);\r
@@ -2154,6 +2159,7 @@ describe("SMIL Animation Spec", function() {
           frame.timelines.length = 0;\r
           frame.startTime = Date.now();\r
           frame.setFrame(0);\r
+          frame.$endFrame.setFrame(0);\r
         } );\r
         /*境界条件を調べておく (limit value analysis)*/\r
         it("should be this for the value  (limit value analysis)", function() {\r
@@ -2167,6 +2173,7 @@ describe("SMIL Animation Spec", function() {
           $animate.init(ele);\r
           expect($animate.isCSS).toBeFalsy();\r
           frame.setFrame(0);\r
+          frame.$endFrame.setFrame(0);\r
           var p = ele.parentNode;\r
           /*getAttributeNSメソッドは、IE11では空文字列を返す(DOM 2に準拠)のに対して、\r
            * 他のブラウザではnullを返すため、その対策をする*/\r
@@ -2174,6 +2181,7 @@ describe("SMIL Animation Spec", function() {
           \r
           function f(fr, result) {\r
             frame.setFrame(fr);\r
+            frame.$endFrame.setFrame(fr);\r
             expect(p.getAttributeNS(null, "d") || "").toBe(result);\r
           };\r
           \r
@@ -2207,6 +2215,7 @@ describe("SMIL Animation Spec", function() {
                 to = attr[2];\r
             function g(fr, result) {\r
               frame.setFrame(fr);\r
+              frame.$endFrame.setFrame(fr);\r
               expect(p.style.getPropertyValue(attrName) || p.getAttribute(attrName) || "").toBe(result);\r
             };\r
 \r
@@ -2240,6 +2249,7 @@ describe("SMIL Animation Spec", function() {
           \r
           function f(fr, result) {\r
             frame.setFrame(fr);\r
+            frame.$endFrame.setFrame(fr);\r
             expect(p.getAttributeNS(null, "d")).toBe(result);\r
           };\r
           \r
@@ -2372,6 +2382,7 @@ describe("SMIL Animation Spec", function() {
           ( function(attrName) {\r
             function g(fr, result) {\r
               frame.setFrame(fr);\r
+              frame.$endFrame.setFrame(fr);\r
               expect(p.style.getPropertyValue(attrName)).toBe(result);\r
             };\r
 \r
@@ -2428,6 +2439,7 @@ describe("SMIL Animation Spec", function() {
           \r
           function f(fr, result) {\r
             frame.setFrame(fr);\r
+            frame.$endFrame.setFrame(fr);\r
             expect(p.getAttributeNS(null, "d") || null).toBe(result);\r
           };\r
           f(0, null);\r
@@ -2475,6 +2487,7 @@ describe("SMIL Animation Spec", function() {
           \r
           f = function (fr, result, attr) {\r
             frame.setFrame(fr);\r
+            frame.$endFrame.setFrame(fr);\r
             expect(p.style.getPropertyValue(attr)).toBe(result);\r
           };\r
         } );\r
@@ -2553,6 +2566,7 @@ describe("SMIL Animation Spec", function() {
           \r
           function f (fr, result, attr) {\r
             frame.setFrame(fr);\r
+            frame.$endFrame.setFrame(fr);\r
             expect(ele.parentNode.getAttributeNS(null,attr)).toBe(result);\r
           };\r
           f(0, "#83.0C", "fi");\r
@@ -2652,8 +2666,10 @@ describe("SMIL Animation Spec", function() {
           expect(isFiredBeginEvent).toBeTruthy();\r
         } );\r
         frame.setFrame(0);\r
+        frame.$endFrame.setFrame(0);\r
         expect(frame.first).toBeNull();\r
         frame.setFrame(0);\r
+        frame.$endFrame.setFrame(0);\r
         expect(frame.first).toBeNull();\r
         \r
         frame.timelines = [];\r
@@ -2705,6 +2721,7 @@ describe("SMIL Animation Spec", function() {
           };\r
         expect(frame.first).toEqual(a);\r
         frame.setFrame(11);\r
+        frame.$endFrame.setFrame(11);\r
         expect(frame.first).toEqual( {frame: 12,\r
                 eventType: "end",\r
                 target: ele,\r
@@ -2742,11 +2759,14 @@ describe("SMIL Animation Spec", function() {
           };\r
         expect(frame.first).toEqual(a);\r
         frame.setFrame(0);\r
+        frame.$endFrame.setFrame(0);\r
         expect(frame.first).toEqual(a);\r
         frame.setFrame(1);\r
+        frame.$endFrame.setFrame(1);\r
         a = a.next;\r
         expect(frame.first).toEqual(a);\r
         frame.setFrame(5);\r
+        frame.$endFrame.setFrame(5);\r
         a.count = 1;\r
         a.frame = 9;\r
         expect(frame.first).toEqual(a);\r
@@ -2764,6 +2784,7 @@ describe("SMIL Animation Spec", function() {
           target: ele\r
         }) );\r
         frame.setFrame(9);\r
+        frame.$endFrame.setFrame(9);\r
         a.count = 2;\r
         a.limit = 16;\r
         a.next.frame = 16;\r
@@ -2785,6 +2806,7 @@ describe("SMIL Animation Spec", function() {
           frame.timelines.length = 0;\r
           frame.startTime = Date.now();\r
           frame.setFrame(0);\r
+          frame.$endFrame.setFrame(0);\r
         } );\r
         afterEach( function() {\r
           $animate.numberOfList = -1;\r
@@ -2988,6 +3010,7 @@ describe("SMIL Animation Spec", function() {
           frame.timelines.length = 0;\r
           frame.startTime = Date.now();\r
           frame.setFrame(0);\r
+          frame.$endFrame.setFrame(0);\r
         } );\r
         afterEach( function() {\r
           $animate.numberOfList = -1;\r
@@ -3030,6 +3053,7 @@ describe("SMIL Animation Spec", function() {
         frame.pauseAnimation();\r
         frame.timelines.length = 0; //配列の初期化\r
         frame.setFrame(0);\r
+        frame.$endFrame.setFrame(0);\r
       } );\r
       /*境界条件を調べておく (limit value analysis)*/\r
       it("should be this for the value  (limit value analysis)", function() {\r
@@ -3060,12 +3084,15 @@ describe("SMIL Animation Spec", function() {
         evt = ele.ownerDocument.createEvent("MouseEvents");\r
         evt.initMouseEvent("mousedown",true, true, window, 0, 0, 0, 0, 0, false, false, false, false,0, p);\r
         frame.setFrame(frame.currentFrame);\r
+        frame.$endFrame.setFrame(frame.currentFrame);\r
         expect($animate.isEnd).toBeFalsy();\r
         expect($animate.state).toBe("idling");\r
         p.dispatchEvent(evt);\r
         frame.setFrame(frame.currentFrame + 1);\r
+        frame.$endFrame.setFrame(frame.currentFrame + 1);\r
         expect($animate.state).toBe("playing");\r
         frame.setFrame(frame.currentFrame + 24);\r
+        frame.$endFrame.setFrame(frame.currentFrame + 24);\r
         expect($animate.state).toBe("idling");\r
         expect(evt.target.getAttributeNS(null, "fill") || null).toBe("rgb(10, 10, 1)");\r
       } );\r
@@ -3080,6 +3107,7 @@ describe("SMIL Animation Spec", function() {
           frame = base("$frame");\r
           frame.timelines.length = 0; //配列の初期化\r
           frame.setFrame(0);\r
+          frame.$endFrame.setFrame(0);\r
           ele.setAttributeNS(null, "begin", "indefinite");\r
           ele.setAttributeNS(null, "dur", "1s");\r
           ele.setAttributeNS(null, "dur", "1s");\r