OSDN Git Service

Add an isSum property to the object
authordhrname <dhrname@users.sourceforge.jp>
Fri, 4 Mar 2016 14:22:12 +0000 (23:22 +0900)
committerdhrname <dhrname@users.sourceforge.jp>
Fri, 4 Mar 2016 14:22:12 +0000 (23:22 +0900)
org/w3c/dom/smil.js
tool/Spec/spec/SvgDomSpec.js

index 75dc0a0..da6ec03 100644 (file)
@@ -1414,20 +1414,21 @@ base("$calcMode").up("$attribute").mix( {
    type: "translate",\r
    \r
    /*additive属性がsumなら真*/\r
-   isAdditive: false,\r
+   isSum: false,\r
    \r
    /*$animateElementオブジェクトのtocallメソッドをオーバライド*/\r
    tocall: function (advance) {\r
      if (this.numberOfList < 0) {\r
        throw new Error("Number of The List Error");\r
      }\r
-     if (this.isAdditive\r
-      || (this.numberOfList === (this.element.__transformList.length - 1) )) {\r
-       this.element.__transformList[this.numberOfList] = this.type+ "(" +this.$animateElement.tocall.call(this, advance)+ ")";\r
-     }\r
+     this.element.__transformList[this.numberOfList] = this.type+ "(" +this.$animateElement.tocall.call(this, advance)+ ")";\r
      var d = this.defaultValue;\r
      d = d && (d + " ");\r
-     return d + this.element.__transformList.join(" ");\r
+     if (this.isSum) {\r
+       return d + this.element.__transformList.join(" ");\r
+     } else {\r
+       return this.element.__transformList[this.element.__transformList.length-1];\r
+     }\r
    }\r
   })\r
  .on("init", function (ele) {\r
@@ -1438,7 +1439,7 @@ base("$calcMode").up("$attribute").mix( {
    var parent = this.element;\r
    this.isDefault = parent.hasAttributeNS(null, "transform");\r
    this.defaultValue = parent.getAttributeNS(null, "transform") || "";\r
-   this.isAdditive = (parent.getAttributeNS(null, "additive") === "sum");\r
+   this.isSum = (this.getAttr("additive", "replace") === "sum");\r
    if (!parent.__transformList) {\r
      parent.__transformList = [];\r
    }\r
index cb214ea..84093bc 100644 (file)
@@ -2584,6 +2584,14 @@ describe("SMIL Animation Spec", function() {
           expect($animate.numberOfList).toBe(0);\r
           expect(p.__transformList).toEqual(["translate(0)"]);\r
           expect($animate.type).toBe("scale");\r
+          \r
+          expect($animate.isSum).toBeFalsy();\r
+          ele.setAttributeNS(null, "additive", "sum");\r
+          $animate.init(ele);\r
+          expect($animate.isSum).toBeTruthy();\r
+          ele.setAttributeNS(null, "additive", "replace");\r
+          $animate.init(ele);\r
+          expect($animate.isSum).toBeFalsy();\r
         } );\r
         /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
         it("should be this for the value (the valid partion )", function() {\r
@@ -2617,23 +2625,25 @@ describe("SMIL Animation Spec", function() {
           \r
           ele.setAttributeNS(null, "additive", "sum");\r
           ele.parentNode.appendChild(ele.cloneNode(true));\r
+          ele.parentNode.__transformList = [];\r
           $animate.numberOfList = -1;\r
           $animate.init(ele.parentNode.lastChild);\r
-          expect($animate.numberOfList).toBe(1);\r
-          expect($animate.tocall(0)).toBe("scale(1.0) scale(0.0)");\r
-          expect($animate.tocall(1)).toBe("scale(1.0) scale(1.0)");\r
+          expect($animate.numberOfList).toBe(0);\r
+          expect($animate.tocall(0)).toBe("matrix(0 0 0 0 0 0) scale(0.0)");\r
+          expect($animate.tocall(1)).toBe("matrix(0 0 0 0 0 0) scale(1.0)");\r
           \r
           ele.parentNode.appendChild(ele.cloneNode(true));\r
           $animate.up("$a").numberOfList = -1;\r
+          ele.parentNode.__transformList = [];\r
           ele.parentNode.setAttribute("transform", "matrix(0 0 0 0 0 0)");\r
           $animate.$a.init(ele.parentNode.lastChild);\r
-          expect($animate.$a.numberOfList).toBe(2);\r
+          expect($animate.$a.numberOfList).toBe(0);\r
           expect($animate.$a.isDefault).toBeTruthy();\r
           expect($animate.$a.defaultValue).toBe("matrix(0 0 0 0 0 0)");\r
-          expect($animate.$a.tocall(0)).toBe("matrix(0 0 0 0 0 0) scale(1.0) scale(1.0) scale(0.0)");\r
-          expect($animate.$a.tocall(1)).toBe("matrix(0 0 0 0 0 0) scale(1.0) scale(1.0) scale(1.0)");\r
+          expect($animate.$a.tocall(0)).toBe("matrix(0 0 0 0 0 0) scale(0.0)");\r
+          expect($animate.$a.tocall(1)).toBe("matrix(0 0 0 0 0 0) scale(1.0)");\r
           $animate.defaultValue = $animate.$a.defaultValue;\r
-          expect($animate.tocall(0.1)).toBe("matrix(0 0 0 0 0 0) scale(1.0) scale(0.1) scale(1.0)");\r
+          expect($animate.tocall(0.1)).toBe("matrix(0 0 0 0 0 0) scale(0.1)");\r
         } );\r
         /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
         it("should be this for the value (the invalid partion )", function() {\r