From 55486e7ecf22117969b0a4a2fa6374a0165f7ac2 Mon Sep 17 00:00:00 2001 From: dhrname Date: Tue, 1 Dec 2015 23:11:11 +0900 Subject: [PATCH] Modify the accumulate attribute problem --- org/w3c/dom/smil.js | 10 ++++++---- tool/Spec/spec/SvgDomSpec.js | 21 +++++++++++---------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/org/w3c/dom/smil.js b/org/w3c/dom/smil.js index ac9d7a9..d670973 100644 --- a/org/w3c/dom/smil.js +++ b/org/w3c/dom/smil.js @@ -767,9 +767,10 @@ base("$from").of( { return f(Ay*t*t*t + By*t*t + Cy*t); }; } else if (this.mode === "discrete") { + this.to.call(); return function (t) { return isNaN(t) ? this.string - : this.to.from.string; + : this.to.advance(0); }.bind(this); } } @@ -1037,7 +1038,7 @@ base("$calcMode").up("$attribute").mix( { call: function() { return function (t) { return isNaN(t) ? this.string - : this.to.string; + : this.to.advance(1); }.bind(this); } } ) ); @@ -1279,11 +1280,12 @@ base("$calcMode").up("$attribute").mix( { /*additive属性がsum (加法アニメーション)の場合*/ if (ele.getAttributeNS(null, "additive") === "sum") { + var attrValue = ele.parentNode.getAttributeNS(null, this.attrName); ele.addEventListener("beginEvent", function(evt) { to.forEach( function(x) { - x.to.setAdditive(evt.target.parentNode.getAttributeNS(null, this.attrName)); + x.to.setAdditive(attrValue); } ) - }.bind(this), false); + }, false); } /*acuumulate属性がsum (蓄積アニメーション)の場合*/ if (ele.getAttributeNS(null, "accumulate") === "sum") { diff --git a/tool/Spec/spec/SvgDomSpec.js b/tool/Spec/spec/SvgDomSpec.js index 844b211..5359e3a 100644 --- a/tool/Spec/spec/SvgDomSpec.js +++ b/tool/Spec/spec/SvgDomSpec.js @@ -3381,6 +3381,7 @@ describe("SMIL Animation Spec", function() { calc.mode = "discrete"; calc.keyTime = 0.5; calc.to.degit = 1; + calc.to.string = "1"; calc.to.from.string = "0.5"; expect(calc.call()(0.2)).toBe("0.5"); expect(calc.call()(0.3)).toBe("0.5"); @@ -4013,10 +4014,10 @@ describe("SMIL Animation Spec", function() { ele.setAttributeNS(null, "calcMode", "discrete"); $animate.init(ele); expect($animate.mode).toBe("discrete"); - f(24, "M20 0 L20 30"); - f(25, "M20 0 L20 30"); - f(37, "M20 20 L10 30"); - f(48, "M20 20 L10 30"); + f(24, "M20.0 0.0 L20.0 30.0"); + f(25, "M20.0 0.0 L20.0 30.0"); + f(37, "M20.0 20.0 L10.0 30.0"); + f(48, "M20.0 20.0 L10.0 30.0"); } ); /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/ it("should be this for the value (the valid partion )", function() { @@ -4111,12 +4112,12 @@ describe("SMIL Animation Spec", function() { ele.setAttributeNS(null, "calcMode", "discrete"); ele.setAttributeNS(null, "keyTimes", "0.1;0.5;0.4"); $animate.init(ele); - f(1, "M20 0 L20 30"); - f(4, "M20 0 L20 30"); - f(5, "M20 24 L20 30"); - f(25, "M20 24 L20 30"); - f(29, "M20 26.4 L20 30"); - f(48, "M20 26.4 L20 30"); + f(1, "M20.0 0.0 L20.0 30.0"); + f(4, "M20.0 0.0 L20.0 30.0"); + f(5, "M20.0 24.0 L20.0 30.0"); + f(25, "M20.0 24.0 L20.0 30.0"); + f(29, "M20.0 26.4 L20.0 30.0"); + f(48, "M20.0 26.4 L20.0 30.0"); frame.timelines.length = 0; ele.setAttributeNS(null, "calcMode", "spline"); -- 2.11.0