OSDN Git Service

Support the setAccumulate method
authordhrname <dhrname@users.sourceforge.jp>
Sat, 28 Nov 2015 14:01:46 +0000 (23:01 +0900)
committerdhrname <dhrname@users.sourceforge.jp>
Sat, 28 Nov 2015 14:01:46 +0000 (23:01 +0900)
org/w3c/dom/smil.js
tool/Spec/spec/SvgDomSpec.js

index 46b69be..91c09e9 100644 (file)
@@ -536,13 +536,13 @@ base("$from").of( {
   call: function() {\r
     if (this.numList.length) {\r
       var additive = [],\r
-          accumlate = [];\r
+          accumulate = [];\r
       for (var i=0;i<this.numList.length;++i) {\r
         /*0で配列を初期化しておく*/\r
-        additive[i] = accumlate[i] = 0;\r
+        additive[i] = accumulate[i] = 0;\r
       }\r
       this.additive = additive;\r
-      this.accumlate = accumlate;\r
+      this.accumulate = accumulate;\r
     }\r
     /*文字部分の配置パターンは4通りあるので、ここでstrListを処理\r
      * (1) a 0 の場合\r
@@ -571,9 +571,9 @@ base("$from").of( {
    /*advanceメソッドで使われる有効数字の桁数 (小数点の桁数を決めるときに使う)*/\r
    degit: 0,\r
    \r
-   /*additve属性やaccumlate属性が設定された、累積アニメーションか、加法アニメーションで使われる*/\r
+   /*additve属性やaccumulate属性が設定された、累積アニメーションか、加法アニメーションで使われる*/\r
    additive: [0],\r
-   accumlate: [0],\r
+   accumulate: [0],\r
    \r
    /*advance メソッド\r
     * アニメーションの進行具合を示す進捗率 t (0 <= t <= 1)をもとに、現在の呈示値を算出するためのもの\r
@@ -591,19 +591,19 @@ base("$from").of( {
           fromNumList = this.from,\r
           deg = this.degit,\r
           additive = this.additive,\r
-          accumlate = this.accumlate;\r
+          accumulate = this.accumulate;\r
       \r
       for (var i=0,nuli=numList.length;i<nuli;++i) {\r
         /*原点Oを(0,0,...0)とおく\r
          *$fromと$toを、原点Oからの二つのベクトル (n次空間のベクトル)、ベクトルOFとベクトルOTと考える\r
          *$fromと$toの二つの端の点FとTを結ぶ線分を、t : 1-t で内分する点をPとおく\r
          * このときのベクトルOPを求めたのが以下の式*/\r
-        str += ( t * numList[i] + (1 - t) * fromNumList[i] + additive[i] + accumlate[i]).toFixed(deg);\r
+        str += ( t * numList[i] + (1 - t) * fromNumList[i] + additive[i] + accumulate[i]).toFixed(deg);\r
         strList && ( str += strList[i+1] );\r
       }\r
       /*文字列はcallメソッドにより、a0aのパターンになっているので、aの部分を追加*/\r
       str = (strList ? strList[0] : "") + str;\r
-      numList = strList = fromNumList = i = nuli = deg = additive = accumlate = void 0;\r
+      numList = strList = fromNumList = i = nuli = deg = additive = accumulate = void 0;\r
       return str;\r
     },\r
     \r
@@ -637,6 +637,20 @@ base("$from").of( {
         var s = from.call();\r
         this.additive = s;\r
         return s;\r
+      },\r
+     \r
+     /*setAccumulate メソッド\r
+      * accumulate属性がsumのときに使われるメソッド\r
+      * 引数は親要素の、現在の属性値*/\r
+      setAccumulate: 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.accumulate = s;\r
+        return s;\r
       }\r
   } )\r
   /*fromプロパティの初期化*/\r
index a88501a..ebec5f6 100644 (file)
@@ -2963,7 +2963,7 @@ describe("SMIL Animation Spec", function() {
       } ).toThrow();\r
       \r
       expect(from.additive[0]).toBe(0);\r
-      expect(from.accumlate[0]).toBe(0);\r
+      expect(from.accumulate[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
@@ -3178,10 +3178,10 @@ describe("SMIL Animation Spec", function() {
         expect(from.$to.advance(1)).toBe("a10.0s-3.0");\r
         \r
         from.$to.additive[0] = 1;\r
-        from.$to.accumlate[1] = 2;\r
+        from.$to.accumulate[1] = 2;\r
         expect(from.$to.advance(0.4)).toBe("a-1.0s1.7");\r
         from.$to.additive[0] = 0.5;\r
-        from.$to.accumlate[1] = 0.8;\r
+        from.$to.accumulate[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
@@ -3268,10 +3268,11 @@ describe("SMIL Animation Spec", function() {
        } );\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
+        expect(from.setAccumulate()).toBe(0);\r
+        expect(from.setAccumulate("")).toBe(0);\r
+        expect(from.accumulate).toEqual([0]);\r
+        expect(from.setAccumulate("1")).toEqual([1]);\r
+        expect(from.accumulate).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