OSDN Git Service

New a removeLine method
authordhrname <dhrname@users.sourceforge.jp>
Sat, 24 Jan 2015 13:59:10 +0000 (22:59 +0900)
committerdhrname <dhrname@users.sourceforge.jp>
Sat, 24 Jan 2015 13:59:10 +0000 (22:59 +0900)
org/w3c/dom/smil.js
tool/Spec/spec/SvgDomSpec.js

index dd1c135..736b167 100644 (file)
@@ -171,6 +171,21 @@ if(window.requestAnimationFrame && requestAnimationFrame
       /*objを適用*/\r
       this.timelines.push( this.up("$line").of(obj) );\r
       return true;\r
+    },\r
+    \r
+    /*removeLine メソッド\r
+     * 指定されたタイムラインのオブジェクトを、リストから削除する*/\r
+    removeLine: function( /*Object*/ timeline ) {\r
+      var list = this.timelines,\r
+          j = 0,\r
+          t;\r
+      while (t = list[j]) {\r
+        if (t === timeline) {\r
+          list.splice(j, 1);      //Arrayのspliceを利用して、リストからtimelineを排除\r
+          break;\r
+        }\r
+        ++j;\r
+      }\r
     }\r
   } );\r
 \r
index df648d9..1f17659 100644 (file)
@@ -2058,6 +2058,7 @@ describe("SMIL Animation Spec", function() {
       frame.setFrame(0);\r
       /*負の値も許される*/\r
       frame.setFrame(-1);\r
+      \r
       expect(frame.addLine()).toBe(false);\r
       expect(frame.addLine({})).toBe(false);\r
       expect(frame.addLine({\r
@@ -2066,6 +2067,9 @@ describe("SMIL Animation Spec", function() {
       expect(frame.addLine({\r
         activeTime: 1\r
       })).toBe(false);\r
+      \r
+      expect(frame.removeLine()).toBeUndefined();\r
+      expect(frame.removeLine({})).toBeUndefined();\r
     });\r
     /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
     it("should be this for the value (the valid partion)", function() {\r
@@ -2097,6 +2101,11 @@ describe("SMIL Animation Spec", function() {
       var timeline = frame.timelines[0];\r
       expect(timeline.begin).toBe(0);\r
       expect(timeline.activeTime).toBe(0);\r
+      \r
+      frame.removeLine({});\r
+      expect(frame.timelines[0]).toBe(timeline);\r
+      frame.removeLine(timeline);\r
+      expect(frame.timelines[0]).not.toBe(timeline);\r
     });\r
     /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
     it("should be this for the value (the invalid partion)", function() {\r