svnno****@sourc*****
svnno****@sourc*****
2011年 1月 26日 (水) 22:39:54 JST
Revision: 2331 http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=2331 Author: dhrname Date: 2011-01-26 22:39:54 +0900 (Wed, 26 Jan 2011) Log Message: ----------- animate要素とanimateColor要素に関して、keyTimes属性を指定されていないときのバグ等を修正 Modified Paths: -------------- branches/06x/069/org/w3c/dom/svg.js Modified: branches/06x/069/org/w3c/dom/svg.js =================================================================== --- branches/06x/069/org/w3c/dom/svg.js 2011-01-25 10:48:47 UTC (rev 2330) +++ branches/06x/069/org/w3c/dom/svg.js 2011-01-26 13:39:54 UTC (rev 2331) @@ -4558,7 +4558,7 @@ this._begin = null; this._end = null; this._from = this._to = this._values = this._by = null; - this._keyTimes = [0, 1]; + this._keyTimes = null; this.addEventListener("beginEvent", function(evt) { var tar = evt.target; if (!tar.isRepeat) { @@ -4600,6 +4600,7 @@ tar._by = evt.newValue; } else if (name === "keyTimes") { var s = evt.newValue.split(";"); + tar._keyTimes = []; //_keyTimesプロパティを初期化 for (var i=0;i<s.length;++i) { tar._keyTimes[i] = parseFloat(s[i]); } @@ -4895,12 +4896,6 @@ vi = null; return; } - if ((tar._keyTimes[1] === 1) && (tar._valueList.length > 2)) { //keyTimesが設定されていない場合、均等に時間を割り振る - for (var i=0,n=0,tvli=tar._valueList.length-1;i<tvli;++i) { - n += 1 / tvli; - tar._keyTimes[i+1] = n; - } - } evt = tta = vir = vi = null; }, false); }, false); @@ -4909,9 +4904,12 @@ var attrName = tar.getAttributeNS(null, "attributeName"), newAttr = tar.targetElement.attributes.getNamedItemNS(null, attrName); var ttr = tar.targetElement, tta = ttr[attrName]; tar._frame = function() { - var d = tar.getSimpleDuration() * 0.8, n = tar._valueList.length - 1, tg = tar.getCurrentTime(); + var d = tar.getSimpleDuration() * 0.8, n = tar._valueList.length-1, tg = tar.getCurrentTime(); if ((n !== -1) && (d !== 0) && (tg <= d)) { var ii = Math.floor((tg*n) / d); + if (ii === n) { //iiが境い目のときは、n-2を適用 + ii -= 1; + } } else { return; } @@ -4923,6 +4921,13 @@ */ var evt = tar.ownerDocument.createEvent("MutationEvents"); evt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null); + if (tar._keyTimes) { + var di = (tar._keyTimes[ii+1] - tar._keyTimes[ii]) * d; + var ti = tar._keyTimes[ii]; + } else { + var di = d / n; //keyTimesがなければ均等に時間を配分しておく + var ti = ii / n; + } if (!!tta) { var base = tta.baseVal, tanim = tta.animVal; var v1 = tar._valueList[ii].value; @@ -4931,7 +4936,7 @@ *http://www.w3.org/TR/2005/REC-SMIL2-20050107/animation.html#animationNS-SpecifyingAnimationFunction */ if (!tar._isDiscrete) { - var v2 = tar._valueList[ii+1].value, di = (tar._keyTimes[ii+1] - tar._keyTimes[ii]) * d, v = v1 + (v2-v1) * (tg-tar._keyTimes[ii]*d) / di; + var v2 = tar._valueList[ii+1].value, v = v1 + (v2-v1) * (tg-ti*d) / di; } else { var v = v1; } @@ -4947,9 +4952,9 @@ di = null; } else if (!!CSS2Properties[attrName] || attrName.indexOf("-") > -1) { //スタイルシートのプロパティならば var base = null; - var v1 = tar._valueList[ii].value, v2 = tar._valueList[ii+1].value, di = (tar._keyTimes[ii+1] - tar._keyTimes[ii]) * d; + var v1 = tar._valueList[ii].value, v2 = tar._valueList[ii+1].value; if (!tar._isDiscrete) { - var v = v1 + (v2-v1) * (tg-tar._keyTimes[ii]*d) / di; + var v = v1 + (v2-v1) * (tg-ti*d) / di; } else { var v = v1; } @@ -5163,10 +5168,20 @@ var d = _tar.getSimpleDuration() * 0.8, n = _tar._valueList.length - 1, tg = _tar.getCurrentTime(); if ((n !== -1) && (d !== 0) && (tg <= d)) { var ii = Math.floor((tg*n) / d); + if (ii === n) { //iiが境い目のときは、n-2を適用 + ii -= 1; + } } else { return; } - var fc = _tar._valueList[ii].rgbColor, tc = _tar._valueList[ii+1].rgbColor, di = (_tar._keyTimes[ii+1] - _tar._keyTimes[ii]) * d, durd = (tg-tar._keyTimes[ii]*d) / di, num = CSSPrimitiveValue.CSS_NUMBER; + if (tar._keyTimes) { + var di = (tar._keyTimes[ii+1] - tar._keyTimes[ii]) * d; + var ti = tar._keyTimes[ii]; + } else { + var di = d / n; //keyTimesがなければ均等に時間を配分しておく + var ti = ii / n; + } + var fc = _tar._valueList[ii].rgbColor, tc = _tar._valueList[ii+1].rgbColor, durd = (tg-ti*d) / di, num = CSSPrimitiveValue.CSS_NUMBER; var fr = fc.red.getFloatValue(num), fg = fc.green.getFloatValue(num), fb = fc.blue.getFloatValue(num); var r = fr + (tc.red.getFloatValue(num) - fr) * durd; var g = fg + (tc.green.getFloatValue(num) - fg) * durd;