From: dhrname Date: Sat, 21 Feb 2015 11:09:19 +0000 (+0900) Subject: Modify the object X-Git-Tag: version22~299 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=47f21d087ef8afbc604fd8ad12b533edfa991423;p=sie%2Fsie.git Modify the object --- diff --git a/org/w3c/dom/smil.js b/org/w3c/dom/smil.js index fb81d57..3765d1f 100644 --- a/org/w3c/dom/smil.js +++ b/org/w3c/dom/smil.js @@ -350,43 +350,47 @@ base("$frame").mix ( { isIndefRepeatCount = (this.repeatCount === ind), isIndefRepeatDur = (this.repeatDur === ind), isIndefEnd = (this.end === ind), + isDur = dur || (dur === 0), + isEnd = this.end || (this.end === 0), + isRepeatCount = this.repeatCount || (this.repeatCount === 0), + isRepeatDur = this.repeatDur || (this.repeatDur === 0), actList = [], min = Math.floor(this.offset(this.min) * this.fpms), max = (this.max === ind) ? null : Math.floor(this.offset(this.max) * this.fpms), s; - if (indef(this)) { + if (indef()) { return null; } - if (dur && this.repeatCount && !isIndefRepeatCount) { + if (isDur && this.repeatCount && !isIndefRepeatCount) { actList.push( dur * this.repeatCount ); } - if (this.repeatDur && !isIndefRepeatDur) { + if (isRepeatDur && !isIndefRepeatDur) { actList.push( Math.floor( this.offset(this.repeatDur) * this.fpms) ); } - if (this.end && !isIndefEnd) { + if (isEnd && !isIndefEnd) { actList.push( this.end - this.begin ); } - if (dur && !this.repeatCount && !this.repeatDur) { + if (isDur && !isRepeatCount && !isRepeatDur) { /*repeatCountやrepeatDur属性が指定されていない場合*/ actList.push( dur ); } /*長くなるため、インライン関数を活用 * indef関数は活動持続時間が不定かどうか、もし、不定なら真を返す*/ - function indef(obj) { + function indef() { if(isIndefEnd) { return true; - } else if (obj.end) { + } else if (isEnd) { return false; } - return !!( (!dur && !obj.repeatDur) - || (isIndefRepeatCount && !obj.repeatDur) - || (isIndefRepeatDur && !obj.repeatCount) + return !!( (!isDur && !isRepeatDur) + || (isIndefRepeatCount && !isRepeatDur) + || (isIndefRepeatDur && !isRepeatCount) || (isIndefRepeatCount && isIndefRepeatDur) ); }; - ind = dur = isIndefRepeatCount = isIndefRepeatDurindef = indef = void 0; + ind = dur = isIndefRepeatCount = isIndefRepeatDurindef = isDur = isEnd = isRepeatDur = isRepeatCount = indef = void 0; if (actList.length === 1) { s = actList[0]; @@ -417,11 +421,19 @@ base("$frame").mix ( { } ).mix( { /*イベントリスナー用の関数*/ listener: function(evt) { - var offset = this.begin; - if (offset > 0) { - } else { + evt = evt || { timeStamp: 0 }; + if (!evt.timeStamp && (evt.timeStamp !== 0)) { + throw new Error(); + } + if (this.begin <= 0) { + /*強制的に終了させる*/ this.removeLine(this.$begin); } + this.begin += Math.floor( (evt.timeStamp - this.startTime ) * this.fpms ); + var s = this.$begin.$activate; + s.end = this.begin; + this.$begin.activeTime = s.call(); + s = void 0; } } ); } ); diff --git a/tool/Spec/spec/SvgDomSpec.js b/tool/Spec/spec/SvgDomSpec.js index 1a6c79d..8bf0f95 100644 --- a/tool/Spec/spec/SvgDomSpec.js +++ b/tool/Spec/spec/SvgDomSpec.js @@ -2498,8 +2498,11 @@ describe("SMIL Animation Spec", function() { /*配列は初期化しておく*/ end.timelines.length = 0; obj = end.up(); - obj.$begin = begin.up(); - obj.$activate = begin.$activate.up(); + obj.$begin = begin.up().mix( { + begin: 12, + activeTime: 120 + } ); + obj.$begin.$activate = begin.$activate.up(); obj.addLine(obj.$begin); } ); /*境界条件を調べておく (limit value analysis)*/ @@ -2509,28 +2512,48 @@ describe("SMIL Animation Spec", function() { obj.listener(); expect(obj.timelines[0]).not.toBe(obj.$begin); - obj.addLine(obj.$begin); + obj.addLine(obj.$begin.mix( { + begin: 12, + activeTime: 120 + } ) ); obj.listener({ timeStamp: 12 } ); expect(obj.timelines[0]).not.toBe(obj.$begin); + } ); + /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/ + it("should be this for the value (the valid partion)", function() { + obj.$begin.$activate.begin = 0; + obj.mix( { + string: "event" + } ).parse(); + obj.listener({ + timeStamp: 120 + } ); + expect(obj.timelines[0]).not.toBe(obj.$begin); + expect(obj.begin).toEqual(Math.floor(120*obj.fpms)); + expect(obj.$begin.activeTime).toEqual(Math.floor(120*obj.fpms)); - obj.addLine(obj.$begin); + obj.addLine(obj.$begin.mix( { + begin: 12, + activeTime: 120 + } ) ); + obj.$begin.$activate.begin = 0; obj.mix( { - string: "event+100ms" + string: "event+1000ms" } ).parse(); obj.listener({ timeStamp: 12 } ); expect(obj.timelines[0]).toBe(obj.$begin); - } ); - /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/ - it("should be this for the value (the valid partion)", function() { + expect(obj.begin).toEqual(Math.floor(1012*obj.fpms)); + expect(obj.$begin.activeTime).toEqual(Math.floor(1012*obj.fpms)); } ); /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/ it("should be this for the value (the invalid partion)", function() { - obj.listener({}); - expect(obj.timelines[0]).not.toBe(obj.$begin); + expect(function() { + obj.listener({}); + } ).toThrow(); } ); } ) } ); @@ -2743,6 +2766,22 @@ describe("SMIL Animation Spec", function() { simpleDur: act.simpleDur } ); expect(act.$d.call()).toEqual(Math.floor(2000*act.fpms)); + + /*endで0が指定されている場合*/ + act.begin = 0; + act.end = 0; + act.repeatDur = null; + act.repeatCount = "indefinite"; + act.dur = "1"; + expect(act.call()).toEqual(0); + act.repeatCount = null; + act.repeatDur = "indefinite"; + act.dur = "1"; + expect(act.call()).toEqual(0); + act.repeatDur = "indefinite"; + act.repeatCount = "indefinite"; + act.dur = "1"; + expect(act.call()).toEqual(0); } ); /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/ it("should be this for the value (the invalid partion)", function() {