OSDN Git Service

Add an additive property to the object
authordhrname <dhrname@users.sourceforge.jp>
Sat, 28 Nov 2015 13:37:16 +0000 (22:37 +0900)
committerdhrname <dhrname@users.sourceforge.jp>
Sat, 28 Nov 2015 13:37:16 +0000 (22:37 +0900)
org/w3c/dom/smil.js
tool/Spec/spec/SvgDomSpec.js

index 144f65c..46b69be 100644 (file)
@@ -536,14 +536,13 @@ base("$from").of( {
   call: function() {\r
     if (this.numList.length) {\r
       var additive = [],\r
-          accumlate = [],\r
-          tu = this.underlying;\r
+          accumlate = [];\r
       for (var i=0;i<this.numList.length;++i) {\r
         /*0で配列を初期化しておく*/\r
         additive[i] = accumlate[i] = 0;\r
       }\r
-      tu.additive = additive;\r
-      tu.accumlate = accumlate;\r
+      this.additive = additive;\r
+      this.accumlate = accumlate;\r
     }\r
     /*文字部分の配置パターンは4通りあるので、ここでstrListを処理\r
      * (1) a 0 の場合\r
@@ -573,10 +572,8 @@ base("$from").of( {
    degit: 0,\r
    \r
    /*additve属性やaccumlate属性が設定された、累積アニメーションか、加法アニメーションで使われる*/\r
-   underlying: {\r
-     additive: [0],\r
-     accumlate: [0]\r
-   },\r
+   additive: [0],\r
+   accumlate: [0],\r
    \r
    /*advance メソッド\r
     * アニメーションの進行具合を示す進捗率 t (0 <= t <= 1)をもとに、現在の呈示値を算出するためのもの\r
@@ -593,9 +590,8 @@ base("$from").of( {
           strList = this.strList,\r
           fromNumList = this.from,\r
           deg = this.degit,\r
-          underlying = this.underlying,\r
-          additive = underlying.additive,\r
-          accumlate = underlying.accumlate;\r
+          additive = this.additive,\r
+          accumlate = this.accumlate;\r
       \r
       for (var i=0,nuli=numList.length;i<nuli;++i) {\r
         /*原点Oを(0,0,...0)とおく\r
@@ -607,7 +603,7 @@ base("$from").of( {
       }\r
       /*文字列はcallメソッドにより、a0aのパターンになっているので、aの部分を追加*/\r
       str = (strList ? strList[0] : "") + str;\r
-      numList = strList = fromNumList = i = nuli = deg = underlying = additive = accumlate = void 0;\r
+      numList = strList = fromNumList = i = nuli = deg = additive = accumlate = void 0;\r
       return str;\r
     },\r
     \r
@@ -627,7 +623,21 @@ base("$from").of( {
          s += (toList[i] - fromList[i])*(toList[i] - fromList[i]);\r
        }\r
        return Math.sqrt(s);\r
-     }\r
+     },\r
+     \r
+     /*setAdditive メソッド\r
+      * additve属性がsumのときに使われるメソッド\r
+      * 引数は親要素の、現在の属性値*/\r
+      setAdditive: function(str) {\r
+        if (!str) {\r
+          return 0;\r
+        }\r
+        var from = this.$from.up();\r
+        from.string = str;\r
+        var s = from.call();\r
+        this.additive = s;\r
+        return s;\r
+      }\r
   } )\r
   /*fromプロパティの初期化*/\r
  .up("$to").from = null;\r
index 2446667..593a664 100644 (file)
@@ -2962,8 +2962,8 @@ describe("SMIL Animation Spec", function() {
         from.strList();\r
       } ).toThrow();\r
       \r
-      expect(from.underlying.additive[0]).toBe(0);\r
-      expect(from.underlying.accumlate[0]).toBe(0);\r
+      expect(from.additive[0]).toBe(0);\r
+      expect(from.accumlate[0]).toBe(0);\r
     } );\r
     /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
     it("should be this for the value (the valid partion)", function() {\r
@@ -3177,11 +3177,11 @@ describe("SMIL Animation Spec", function() {
         expect(from.$to.advance(0.4)).toBe("a-2.0s-0.3");\r
         expect(from.$to.advance(1)).toBe("a10.0s-3.0");\r
         \r
-        from.$to.underlying.additive[0] = 1;\r
-        from.$to.underlying.accumlate[1] = 2;\r
+        from.$to.additive[0] = 1;\r
+        from.$to.accumlate[1] = 2;\r
         expect(from.$to.advance(0.4)).toBe("a-1.0s1.7");\r
-        from.$to.underlying.additive[0] = 0.5;\r
-        from.$to.underlying.accumlate[1] = 0.8;\r
+        from.$to.additive[0] = 0.5;\r
+        from.$to.accumlate[1] = 0.8;\r
         expect(from.$to.advance(1)).toBe("a10.5s-2.2");\r
       } );\r
       /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
@@ -3195,7 +3195,7 @@ describe("SMIL Animation Spec", function() {
       } );\r
     } )\r
   } );\r
-   describe("A distance method", function() {\r
+  describe("A distance method", function() {\r
       var from = base("$from");\r
        beforeEach( function() {\r
          from = base("$from").up();\r
@@ -3220,7 +3220,7 @@ describe("SMIL Animation Spec", function() {
         expect(from.$to.distance(from)).toBe(12);\r
         expect(from.$to.distance(from)).toBe(12);\r
         expect(from.$to.distance(from.call())).toBe(12);\r
-\r
+  \r
         from = base("$from").up();\r
         from.up("$to");\r
         from.string = "rgb(1, 0, 0)";\r
@@ -3234,7 +3234,32 @@ describe("SMIL Animation Spec", function() {
         from.$to.string = "s";\r
         expect(from.$to.distance(from)).toBe(0);\r
       } );\r
-   } );\r
+  } );\r
+    describe("A setAdditive method", function() {\r
+      var from = base("$from");\r
+       beforeEach( function() {\r
+         from = base("$from").up();\r
+         from.string = "";\r
+         from.up("$to");\r
+       } );\r
+      /*境界条件を調べておく (limit value analysis)*/\r
+      it("should be this for the value  (limit value analysis)", function() {\r
+        expect(from.setAdditive()).toBe(0);\r
+        expect(from.setAdditive("")).toBe(0);\r
+        expect(from.setAdditive("1")).toEqual([1]);\r
+        expect(from.additive).toEqual([1]);\r
+      } );\r
+      /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
+      it("should be this for the value (the valid partion)", function() {\r
+\r
+      } );\r
+      /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
+      it("should be this for the value (the invalid partion)", function() {\r
+        from.string = "s";\r
+        from.$to.string = "s";\r
+        expect(from.$to.distance(from)).toBe(0);\r
+      } );\r
+  } );\r
   describe("A $calcMode object", function() {\r
     var calc = base("$calcMode"),\r
         to = calc.to,\r