OSDN Git Service

Modify the Spec and Modify the object
authordhrname <dhrname@users.sourceforge.jp>
Sat, 13 May 2017 14:21:05 +0000 (23:21 +0900)
committerdhrname <dhrname@users.sourceforge.jp>
Sat, 13 May 2017 14:21:05 +0000 (23:21 +0900)
org/w3c/dom/smil.js
tool/Spec/spec/SvgDomSpec.js

index 7dd9c4f..0dd5e0c 100644 (file)
@@ -790,7 +790,7 @@ base("$from").of( {
  \r
  /*計算モードを定めるための計算実体\r
   *補間の細かい制御などを行う*/\r
- base("$calcMode").mix({\r
+base("$calcMode").mix({\r
    /*計算モード (calcMode属性の値)*/\r
    mode: "linear",\r
 \r
@@ -817,7 +817,7 @@ base("$from").of( {
          }\r
          tkey = void 0;\r
          return isNaN(t) ? this.string\r
-                         : this.to.advance(t);\r
+                         : this.to__.advance(t);\r
      },\r
      \r
      /*discreteモードのときには、上記の_f関数の代わりに、以下の関数を用いる*/\r
@@ -825,9 +825,9 @@ base("$from").of( {
         if (isNaN(t)) {\r
           return this.string;\r
         } else if (t === 1) {\r
-          return this.to.string;\r
+          return this.to__.string;\r
         } else {\r
-          return this.to.advance(0);\r
+          return this.to__.advance(0);\r
         }\r
       }\r
  }).of( {\r
@@ -838,15 +838,17 @@ base("$from").of( {
    /*無効だった場合の呈示値*/\r
    string: "",\r
    \r
+   /*$fromオブジェクトを使っているが、toオブジェクトを指している*/\r
+   to: base("$from").$to,\r
+  \r
    /*与えられたアニメーションの進捗率を使った時間の圧縮率を計算して呈示値を返すための関数を作る*/\r
    call: function() {\r
      var f = this._f.bind(this);\r
      if (this.mode === "linear") {\r
-       this.to.call();\r
        return f;\r
      } else if (this.mode === "paced") {\r
        /*keyTimes属性は無視され、ベクトルの距離の割合から計算される*/\r
-       this.keyTime = this.to.distance(this.to.from__) / this.norm;\r
+       this.keyTime = this.to__.distance(this.to__.from__) / this.norm;\r
        return f;\r
      } else if (this.mode === "spline") {\r
        var tk = this.keySplines,\r
@@ -867,7 +869,6 @@ base("$from").of( {
          return tf;\r
        }\r
      }\r
-     this.to.call();\r
      var x2 = tk[0],\r
          y2 = tk[1],\r
          x3 = tk[2],\r
@@ -886,7 +887,6 @@ base("$from").of( {
           && ( (x3 === 1) || (x3 === 0) )\r
           && (y3 === 1) ) {\r
             /*linearモードと同じ効果 (収束ではない可能性を考慮)*/\r
-            this.to.call();\r
             return f;\r
      }\r
      var tkey = this.keyTime;\r
@@ -913,11 +913,10 @@ base("$from").of( {
         return f(Ay*t*t*t + By*t*t + Cy*t);\r
       };\r
     } else if (this.mode === "discrete") {\r
-      this.to.call();\r
       return this.funcForDiscrete.bind(this);\r
     }\r
   }\r
-} ).to = base("$from").$to;\r
+} );\r
 \r
 \r
 /*ニュートン法により、三次方程式 a0x^3 + a1x^2 + a2x + a3 の解を求める\r
@@ -1400,7 +1399,7 @@ base("$calcMode").up("$attribute").mix( {
             call: function() {\r
               return function (t) {\r
                  return isNaN(t) ? this.string\r
-                                 : this.to.advance(1);\r
+                                 : this.to__.advance(1);\r
               }.bind(this);\r
             }\r
           } \r
@@ -1735,7 +1734,7 @@ base("$calcMode").up("$attribute").mix( {
       var attrValue = ele.parentNode.getAttributeNS(null, this.attrName);\r
       ele.addEventListener("beginEvent", function(evt) {\r
         to.forEach( function(x) {\r
-          x.to.setAdditive(attrValue);\r
+          x.to__.setAdditive(attrValue);\r
         } )\r
       }, false);\r
     }\r
@@ -1745,8 +1744,8 @@ base("$calcMode").up("$attribute").mix( {
     if (ele.getAttributeNS(null, "accumulate") === "sum") {\r
       ele.addEventListener("repeatEvent", function(evt) {\r
         to.forEach( function(x) {\r
-          x.to.call();\r
-          x.to.setAccumulate(evt.detail);\r
+          x.to__.call();\r
+          x.to__.setAccumulate(evt.detail);\r
         } )\r
       }, false);\r
     }\r
@@ -1765,7 +1764,7 @@ base("$calcMode").up("$attribute").mix( {
     var s = this.$attribute.setValues.apply(this, arguments),\r
         degits = this.degits;\r
     s && s.forEach(function(x) {\r
-      x.to.degit = degits;\r
+      x.to__.degit = degits;\r
     } );\r
     degits = void 0;\r
     return s;\r
@@ -1825,8 +1824,8 @@ base("$calcMode").up("$attribute").mix( {
     var aa = new Array(to.length);\r
     for (var i=0;i<to.length;++i) {\r
       var x = to[i];\r
-      x.to.string = toRGB(x.to.string);\r
-      x.to.from.string = toRGB(x.to.from.string);\r
+      x.to__.string = toRGB(x.to__.string);\r
+      x.to__.from__.string = toRGB(x.to__.from__.string);\r
       var s = x.call();\r
       /*x.keyTimeプロパティは区間を示しているため、区切り時刻に変換しておく\r
        * startKeyTimeプロパティは区間のスタート時点\r
index f5a1286..f887c39 100644 (file)
@@ -1526,8 +1526,8 @@ describe("SMIL Animation Spec", function() {
         from;\r
      beforeEach( function() {\r
        calc = base("$calcMode").up();\r
-       calc.to = base("$from").up().mix( {string: "1"} );\r
-       from = calc.to.from__ = base("$from").up().mix( {string: "0"} );\r
+       calc.to__ = base("$from").up().mix( {string: "1"} );\r
+       from = calc.to__.from__ = base("$from").up().mix( {string: "0"} );\r
      } );\r
     /*境界条件を調べておく (limit value analysis)*/\r
     it("should be this for the value  (limit value analysis)", function() {\r
@@ -1546,19 +1546,19 @@ describe("SMIL Animation Spec", function() {
       /*paced mode*/\r
       calc.mode = "paced";\r
       expect(calc.norm).toBe(1);\r
-      calc.to.from__ = from;\r
+      calc.to__.from__ = from;\r
       expect(calc.call()(0)).toBe("0");\r
       expect(calc.keyTime).toBe(1);\r
-      calc.to.from__ = from;\r
+      calc.to__.from__ = from;\r
       expect(calc.call()(1)).toBe("1");\r
       \r
       calc.keyTime = 0;\r
-      calc.to.from__ = from;\r
+      calc.to__.from__ = from;\r
       expect(calc.call()(1)).toBe("1");\r
       \r
       /*discrete mode*/\r
       calc.mode = "discrete";\r
-      calc.to.from__ = from;\r
+      calc.to__.from__ = from;\r
       calc.keyTime = 1;\r
       expect(calc.call()(0)).toBe("0");\r
       expect(calc.call()(1)).toBe("1");\r
@@ -1567,7 +1567,7 @@ describe("SMIL Animation Spec", function() {
     it("should be this for the value (the valid partion)", function() {\r
       calc.mode = "linear";\r
       calc.keyTime = 0.5;\r
-      calc.to.degit = 1;\r
+      calc.to__.degit = 1;\r
       expect(calc.call()(0.2)).toBe("0.4");\r
       expect(calc.call()(0.3)).toBe("0.6");\r
       /*もう一度確かめる*/\r
@@ -1575,75 +1575,75 @@ describe("SMIL Animation Spec", function() {
       \r
       calc = base("$calcMode").up();\r
       calc.keyTime = 0.2;\r
-      calc.to = base("$from").up();\r
-      calc.to.from__ = base("$from").up();    \r
-      calc.to.from__.string = "0s";\r
-      calc.to.string = "1s";\r
-      calc.to.degit = 1;\r
+      calc.to__ = base("$from").up();\r
+      calc.to__.from__ = base("$from").up();    \r
+      calc.to__.from__.string = "0s";\r
+      calc.to__.string = "1s";\r
+      calc.to__.degit = 1;\r
       expect(calc.call()(0.1)).toBe("0.5s");\r
 \r
       calc = base("$calcMode").up();\r
       calc.keyTime = 0.5;\r
-      calc.to = base("$from").up();\r
-      calc.to.from__ = base("$from").up();    \r
-      calc.to.from__.string = "rgb(100, 20, 32)";\r
-      calc.to.string = "rgb(0, 10, 50)";\r
+      calc.to__ = base("$from").up();\r
+      calc.to__.from__ = base("$from").up();    \r
+      calc.to__.from__.string = "rgb(100, 20, 32)";\r
+      calc.to__.string = "rgb(0, 10, 50)";\r
       expect(calc.call()(0.25)).toBe("rgb(50, 15, 41)");\r
       \r
       /*paced mode*/\r
-      calc.to = base("$from").up();\r
-      calc.to.from__ = base("$from").up();    \r
+      calc.to__ = base("$from").up();\r
+      calc.to__.from__ = base("$from").up();    \r
       calc.mode = "paced";\r
       calc.norm = 100;\r
-      calc.to.from__.string = "0s";\r
-      calc.to.string = "20s";\r
-      calc.to.degit = 1;\r
+      calc.to__.from__.string = "0s";\r
+      calc.to__.string = "20s";\r
+      calc.to__.degit = 1;\r
       calc.initToEval();\r
       expect(calc.call()(0.1)).toBe("10.0s");\r
       expect(calc.keyTime).toBe(0.2);\r
 \r
-      calc.to = base("$from").up();\r
-      calc.to.from__ = base("$from").up();    \r
+      calc.to__ = base("$from").up();\r
+      calc.to__.from__ = base("$from").up();    \r
       calc.mode = "paced";\r
       calc.norm = 100;\r
-      calc.to.from__.string = "rgb(0, 0, 20)";\r
-      calc.to.string = "rgb(0, 0, 0)";\r
+      calc.to__.from__.string = "rgb(0, 0, 20)";\r
+      calc.to__.string = "rgb(0, 0, 0)";\r
       calc.initToEval();\r
       expect(calc.call()(0.1)).toBe("rgb(0, 0, 10)");\r
       expect(calc.keyTime).toBe(0.2);\r
       \r
       /*discrete mode*/\r
-      calc.to = base("$from").up();\r
-      calc.to.from__ = base("$from").up();    \r
+      calc.to__ = base("$from").up();\r
+      calc.to__.from__ = base("$from").up();    \r
       calc.mode = "discrete";\r
       calc.keyTime = 0.5;\r
-      calc.to.degit = 1;\r
-      calc.to.string = "1";\r
-      calc.to.from__.string = "0.5";\r
+      calc.to__.degit = 1;\r
+      calc.to__.string = "1";\r
+      calc.to__.from__.string = "0.5";\r
       calc.initToEval();\r
       expect(calc.call()(0.2)).toBe("0.5");\r
       expect(calc.call()(0.3)).toBe("0.5");\r
       /*もう一度確かめる*/\r
       expect(calc.call()(0.2)).toBe("0.5");\r
       \r
-      calc.to = base("$from").up();\r
-      calc.to.from__ = base("$from").up();    \r
+      calc.to__ = base("$from").up();\r
+      calc.to__.from__ = base("$from").up();    \r
       calc.mode = "discrete";\r
       calc.keyTime = 0.5;\r
-      calc.to.degit = 1;\r
-      calc.to.string = "block";\r
-      calc.to.from__.string = "inline";\r
+      calc.to__.degit = 1;\r
+      calc.to__.string = "block";\r
+      calc.to__.from__.string = "inline";\r
       calc.initToEval();\r
       expect(calc.call()(0.2)).toBe("inline");\r
       expect(calc.call()(0.3)).toBe("inline");\r
       \r
-      calc.to = base("$from").up();\r
-      calc.to.from__ = base("$from").up();    \r
+      calc.to__ = base("$from").up();\r
+      calc.to__.from__ = base("$from").up();    \r
       calc.mode = "linear";\r
       calc.keyTime = 1;\r
-      calc.to.degit = 1;\r
-      calc.to.string = "1 1";\r
-      calc.to.from__.string = "0.0 1";\r
+      calc.to__.degit = 1;\r
+      calc.to__.string = "1 1";\r
+      calc.to__.from__.string = "0.0 1";\r
       calc.initToEval();\r
       expect(calc.call()(0.2)).toBe("0.2 1.0");\r
       expect(calc.call()(0.3)).toBe("0.3 1.0");\r
@@ -1666,7 +1666,7 @@ describe("SMIL Animation Spec", function() {
 \r
       calc = base("$calcMode").up();\r
       calc.mode = "paced";\r
-      calc.to.from__ = from;\r
+      calc.to__.from__ = from;\r
       expect(calc.call()()).toBe(calc.string);\r
       \r
       calc = base("$calcMode").up();\r
@@ -1690,12 +1690,12 @@ describe("SMIL Animation Spec", function() {
       calc.mode = "spline";\r
       expect( calc.call()("undef")).toBe(Math.PI);\r
       calc.keySplines = [0, 0, 1, 1];\r
-      calc.to.degit = 1;\r
-      calc.to.from__ = from;\r
+      calc.to__.degit = 1;\r
+      calc.to__.from__ = from;\r
       expect(calc.call()(0)).toBe(bezier(0,0, 0,0, 1,1, 1,1)(0)+".0");\r
-      calc.to.from__ = from;\r
+      calc.to__.from__ = from;\r
       expect(calc.call()(1)).toBe(bezier(0,0, 0,0, 1,1, 1,1)(1)+".0");\r
-      calc.to.from__ = from;\r
+      calc.to__.from__ = from;\r
       expect(calc.call()(0.5)).toBe(bezier(0,0, 0,0, 1,1, 1,1)(0.5)+"");\r
       \r
       df(0,0, 0,0, 1,1, 1,1, 0.1);\r
@@ -1729,23 +1729,23 @@ describe("SMIL Animation Spec", function() {
           };\r
       calc.mode = "spline";\r
       calc.keySplines = [0, 0.5, 0.5, 1];\r
-      calc.to.degit = 1;\r
+      calc.to__.degit = 1;\r
       var b = bezier(0,0, 0,0.5, 0.5,1, 1,1);\r
       expect(calc.call()(0)).toBe(b(0).y+".0");\r
-      calc.to.from__ = from;\r
+      calc.to__.from__ = from;\r
       expect(calc.call()(1)).toBe(b(1).y+".0");\r
-      calc.to.from__ = from;\r
+      calc.to__.from__ = from;\r
       expect(calc.call()( b(0.5).x )).toBe(b(0.5).y.toFixed(1));\r
       \r
       var ff = function(k) {\r
         calc.keySplines = k;\r
-        calc.to.degit = 10;\r
+        calc.to__.degit = 10;\r
         var b = bezier(0,0, k[0],k[1], k[2],k[3], 1,1),\r
             epsilon = 1e-5; //誤差\r
         expect(calc.call()(0)).toBe(b(0).y.toFixed(10));\r
-        calc.to.from__ = from;\r
+        calc.to__.from__ = from;\r
         expect(calc.call()(1)).toBe(b(1).y.toFixed(10));\r
-        calc.to.from__ = from;\r
+        calc.to__.from__ = from;\r
         b = b(Math.random());\r
         expect(Math.abs(calc.call()(b.x) - b.y.toFixed(10))).toBeLessThan(epsilon);\r
       };\r
@@ -1758,19 +1758,19 @@ describe("SMIL Animation Spec", function() {
     it("should be this for the value (the invalid partion on a spline mode )", function() {\r
       calc.mode = "spline";\r
       calc.keySplines = [0, NaN, 1, 1];\r
-      calc.to.degit = 1;\r
-      calc.to.from__ = from;\r
+      calc.to__.degit = 1;\r
+      calc.to__.from__ = from;\r
       expect( calc.up().call()("undef")).toBe(Math.PI);\r
 \r
       \r
       calc.keySplines = [0, 0, 1, 2];\r
-      calc.to.degit = 1;\r
-      calc.to.from__ = from;\r
+      calc.to__.degit = 1;\r
+      calc.to__.from__ = from;\r
       expect( calc.up().call()("undef")).toBe(Math.PI);\r
       \r
       calc.keySplines = null;\r
-      calc.to.degit = 1;\r
-      calc.to.from__ = from;\r
+      calc.to__.degit = 1;\r
+      calc.to__.from__ = from;\r
       expect( calc.up().call()("undef")).toBe(Math.PI);\r
     } );\r
   } );\r
@@ -2057,13 +2057,13 @@ describe("SMIL Animation Spec", function() {
         s.setAttributeNS(null, "from", "0");\r
         attr.setKey(s);\r
         s.setAttributeNS(null, "to", "0");\r
-        expect(attr.setKey(s)[0].to.from__.string).toBe("0");\r
-        expect(attr.setKey(s)[0].to.string).toBe("0");\r
+        expect(attr.setKey(s)[0].to__.from__.string).toBe("0");\r
+        expect(attr.setKey(s)[0].to__.string).toBe("0");\r
         s.setAttributeNS(null, "by", "0");\r
         attr.setKey(s);\r
         s.setAttributeNS(null, "values", "0;2");\r
-        expect(attr.setKey(s)[0].to.from__.string).toBe("0");\r
-        expect(attr.setKey(s)[0].to.string).toBe("2");\r
+        expect(attr.setKey(s)[0].to__.from__.string).toBe("0");\r
+        expect(attr.setKey(s)[0].to__.string).toBe("2");\r
         \r
         s.setAttributeNS(null, "keyTimes", "0;0.1");\r
         expect(attr.setKey(s)[0].keyTime).toBe(0.1);\r