From 1485fb5a69eaecc13348d03f8b308a5670367082 Mon Sep 17 00:00:00 2001 From: dhrname Date: Sat, 14 Feb 2015 21:08:33 +0900 Subject: [PATCH] Add a listener method --- org/w3c/dom/smil.js | 12 ++---------- tool/Spec/spec/SvgDomSpec.js | 39 +++++++++++++++++++++++++++++---------- 2 files changed, 31 insertions(+), 20 deletions(-) diff --git a/org/w3c/dom/smil.js b/org/w3c/dom/smil.js index 4f13e51..565bf46 100644 --- a/org/w3c/dom/smil.js +++ b/org/w3c/dom/smil.js @@ -276,11 +276,6 @@ base("$frame").mix ( { this.isResolved = true; } this.begin = Math.floor( this.begin * this.fpms); - var s = this.$activate.up(); - s.begin = this.begin; - s.dur = this.dur; - s.end = s.end.up(); - this.$$activate = s; if (event) { ele = event.id ? this.eventTarget.ownerDocument.getElementById(event.id) : this.eventTarget; @@ -292,15 +287,12 @@ base("$frame").mix ( { /*イベントのリスナーとして、parseメソッドで使う*/ listener: function(evt) { - var s = this.$activate.up(); + evt = evt || { timeStamp: 0 }; + var s = this.$activate; s.begin = this.begin; - s.dur = this.dur; - s.end = s.end.up(); - this.$$activate = s; s.timeStamp = evt.timeStamp; this.activeTime = s.call(); this.addLine(this); - return this; } /*$activate オブジェクト diff --git a/tool/Spec/spec/SvgDomSpec.js b/tool/Spec/spec/SvgDomSpec.js index 7ee9ce8..4c17cdf 100644 --- a/tool/Spec/spec/SvgDomSpec.js +++ b/tool/Spec/spec/SvgDomSpec.js @@ -2369,33 +2369,52 @@ describe("SMIL Animation Spec", function() { } ); describe("A listener method in $begin object", function() { + var obj = begin.up(); beforeEach( function() { begin.string = ""; /*配列は初期化しておく*/ begin.timelines.length = 0; + obj.$activate = begin.$activate.up(); } ); /*境界条件を調べておく (limit value analysis)*/ it("should be this for the value (limit value analysis)", function() { - var lis = begin.listener( { + obj.listener(); + expect(obj.$activate.timeStamp).toBe(0); + + obj.listener( { timeStamp: 0 } ); - expect(lis).toBe(begin); - expect(lis.begin).toBe(0); - expect(lis.activeTime).toBeNull(); - expect(lis.timelines.length).toBe(0); + expect(obj.begin).toBe(0); + expect(obj.activeTime).toBeNull(); + expect(obj.timelines.length).toBe(0); - lis = begin.up().mix( { - begin: 0, - dur: "12" + obj.up().mix( { + begin: 1, + $activate: begin.$activate.up().mix( { + dur: "12" + } ) }) .listener( { timeStamp: 0 } ); - expect(lis.begin).toBe(0); - expect(lis.activeTime).toEqual(Math.floor(12000*lis.fpms)); + expect(obj.$1.begin).toBe(1); + expect(obj.$1.activeTime).toEqual(Math.floor(12000*obj.fpms)); + expect(obj.$1.$activate.begin).toBe(obj.$1.begin); + expect(obj.timelines[0]).toBe(obj.$1); } ); /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/ it("should be this for the value (the valid partion)", function() { + obj.up().mix( { + begin: 1, + $activate: begin.$activate.up().mix( { + dur: "12" + } ) + }) + .listener( { + timeStamp: 0 + } ); + expect(obj.$1.begin).toBe(1); + expect(obj.$1.activeTime).toEqual(Math.floor(12000*obj.fpms)); } ); /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/ -- 2.11.0