svnno****@sourc*****
svnno****@sourc*****
2010年 11月 25日 (木) 20:44:41 JST
Revision: 2183 http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=2183 Author: dhrname Date: 2010-11-25 20:44:41 +0900 (Thu, 25 Nov 2010) Log Message: ----------- 0.64統合 Modified Paths: -------------- branches/06x/sie.js Modified: branches/06x/sie.js =================================================================== --- branches/06x/sie.js 2010-11-25 11:40:35 UTC (rev 2182) +++ branches/06x/sie.js 2010-11-25 11:44:41 UTC (rev 2183) @@ -1090,7 +1090,7 @@ * */ for (var i=0, n=1, d=0, tce = null, sli = s.length, slii = sli*2-1;i<slii;++i){ - d = sli - i - 1; + var d = sli - i - 1; if (d === 0){ //イベントのターゲットに到着(折り返し地点) n = -1; evt.eventPhase = 2;//Event.AT_TARGET; @@ -2186,21 +2186,43 @@ var style = this.defaultView.getComputedStyle(tar, "") s.setProperty = function(propertyName, value, priority) { var tar = elt, el = tar._tar, isFill = isStroke = false; + if ((tar.localName === "g") || (tar.localName === "a")) { + var sl = tar.getElementsByTagNameNS("http://www.w3.org/2000/svg", "*"); + if (sl) { + for (var i=0,sli=sl.length;i<sli;++i) { + var di = sl[i]; + NAIBU._setPaint(di, di.getScreenCTM()); + di = null; + } + sl = null; + } + el = null; + } + if (!el) { + setProp.call(s, propertyName, value, priority); + return; + } if (!!!tar._fillElement) { tar._fillElement = document.createElement("v:fill"); //キャッシュを作る } else { - /*あらかじめ消しおかないと、効果が出ない*/ - el.removeChild(tar._fillElement); + var tgebtfill = el.getElementsByTagName("fill"); + if (tgebtfill.length > 0) { + /*あらかじめ消しおかないと、効果が出ない*/ + el.removeChild(tgebtfill[0]); + } + tgebtfill = null; isFill = true; } if (!!!tar._strokeElement) { tar._strokeElement = document.createElement("v:stroke"); } else { - /*あらかじめ消しおかないと、効果が出ない*/ - el.removeChild(tar._strokeElement); + var tgebtstroke = el.getElementsByTagName("stroke") + if (tgebtstroke.length > 0) { + el.removeChild(tgebtstroke[0]); + } + tgebtstroke = null; isStroke = true; } - var fillElement = tar._fillElement, strokeElement = tar._strokeElement; setProp.call(s, propertyName, value, priority); if (propertyName === "fill-opacity") { @@ -3879,6 +3901,15 @@ NAIBU.doc.validateOnParse = false; NAIBU.doc.resolveExternals = false; NAIBU.doc.loadXML(str); + /*IE6-8のみで使えるupdateIntervalは、 + *描画間隔の調整が可能。デフォルトは0。 + *スクロール時にバグが起きるので、0に戻してやる必要がある。 + */ + screen.updateInterval = 999; + window.onscroll = function () { + screen.updateInterval = 0; + screen.updateInterval = 99; + } var objei = this._tar; if (/&[^;]+;/.test(str)) { /*以下の処理は、実体参照を使ったとき @@ -3900,6 +3931,9 @@ tar.viewport.left = 0; tar.viewport.width = objei.clientWidth; tar.viewport.height = objei.clientHeight; + if (tar.viewport.height < 24) { //IEの標準モードではclientHeightプロパティの値が小さくなることがある + tar.viewport.height = screen.width; + } var objw = objei.getAttribute("width"), objh = objei.getAttribute("height"); if (objw) { tar.setAttributeNS(null, "width", objw); @@ -4499,9 +4533,12 @@ /*以下では、スタイルシートを用いて、fill-とstroke-関連の *処理を行う。SVGPaintインターフェースをも用いる */ - var tod = tar.ownerDocument; + var tod = tar.ownerDocument, el = tar._tar; + if (!el) { + return; + } var style = tod.defaultView.getComputedStyle(tar, ""); - var el = tar._tar, fill = style.getPropertyCSSValue("fill"), stroke = style.getPropertyCSSValue("stroke"); + var fill = style.getPropertyCSSValue("fill"), stroke = style.getPropertyCSSValue("stroke"); if (fill.paintType === /*SVGPaint.SVG_PAINTTYPE_RGBCOLOR*/ 1 || fill.paintType === /*SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR*/ 102) { if (fill.paintType === /*SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR*/ 102) { /*再度、設定。css.jsのsetPropertyを参照*/ @@ -4509,8 +4546,12 @@ } if (!!tar._fillElement) { var fillElement = tar._fillElement; - /*あらかじめ消しおかないと、効果が出ない*/ - el.removeChild(fillElement); + var tgebtfill = el.getElementsByTagName("fill"); + if (tgebtfill.length > 0) { + /*あらかじめ消しおかないと、効果が出ない*/ + el.removeChild(tgebtfill[0]); + } + tgebtfill = null; } else { var fillElement = document.createElement("v:fill"); } @@ -4554,7 +4595,11 @@ } if (!!tar._strokeElement) { var strokeElement = tar._strokeElement; - el.removeChild(strokeElement); + var tgebtstroke = el.getElementsByTagName("stroke") + if (tgebtstroke.length > 0) { + el.removeChild(tgebtstroke[0]); + } + tgebtstroke = null; } else { var strokeElement = document.createElement("v:stroke"); } @@ -6983,10 +7028,10 @@ SVGAnimationElement.prototype._eventRegExp = /(mouse|activ|clic)[a-z]+/; SVGAnimationElement.prototype._timeRegExp = /[\-\d\.]+(h|min|s|ms)?/; SVGAnimationElement.prototype._unit = { - "h" : 2880000, + "h" : 2880000, "min" : 48000, - "s" : 800, - "ms" : 0.8 + "s" : 800, + "ms" : 0.8 }; /*どれだけズレの時間があるかを計測するメソッド *tに数値が使われていないときは0を返す @@ -7057,6 +7102,7 @@ Max : 7000, start : function() { if (NAIBU.Clip.length > 0) { + screen.updateInterval = 42; //24fpsとして描画処理 NAIBU.stop = setInterval( (function() { /* try{*/ var ntc = NAIBU.Time.currentFrame++; @@ -7110,6 +7156,15 @@ *機械が理解できる形で保管されているvalueの値の配列リスト */ this._valueList = []; + this._isDiscrete = false; + this.addEventListener("DOMAttrModified", function(evt){ + if (evt.eventPhase === Event.BUBBLING_PHASE) { + return; //強制終了させる + } + if ((evt.attrName === "calcMode") && (evt.newValue === "discrete")) { + evt.target._isDiscrete = true; + } + }, false); this.addEventListener("DOMNodeInserted", function(evt){ if (evt.eventPhase === Event.BUBBLING_PHASE) { return; //強制終了させる @@ -7157,7 +7212,7 @@ vi = null; return; } - if ((tar._keyTimes[1] === 1) && (tar._valueList.length > 2)) { + 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; @@ -7187,12 +7242,16 @@ evt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null); if (!!tta) { var base = tta.baseVal, tanim = tta.animVal; - 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; /*vを求める公式に関しては、SMIL2.0 Animation Moduleの単純アニメーション関数の項を参照 * 3.4.2 Specifying the simple animation function f(t) *http://www.w3.org/TR/2005/REC-SMIL2-20050107/animation.html#animationNS-SpecifyingAnimationFunction */ - var v = v1 + (v2-v1) * (tg-tar._keyTimes[ii]*d) / di; + 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; + } else { + var v = v1; + } tanim.newValueSpecifiedUnits(tanim.unitType, v); tta.baseVal = tanim; tanim = null; @@ -7202,25 +7261,29 @@ */ tta.animVal = tta.baseVal; tta.baseVal = base; + di = null; } else if (!!CSS2Properties[attrName] || attrName.indexOf("-") > -1) { //スタイルシートのプロパティならば var base = null; - var v1 = tar._valueList[ii], v2 = tar._valueList[ii+1]; - var v = v1 + (v2-v1) * (tg-tar._keyTimes[ii]*d) / d; - ttr.dispatchEvent(evt); + var v1 = tar._valueList[ii].value, v2 = tar._valueList[ii+1].value, di = (tar._keyTimes[ii+1] - tar._keyTimes[ii]) * d; + if (!tar._isDiscrete) { + var v = v1 + (v2-v1) * (tg-tar._keyTimes[ii]*d) / di; + } else { + var v = v1; + } } else if ("animatedPoints" in ttr) { var base = ttr.points; ttr.points = ttr.animatedPoints; ttr.dispatchEvent(evt); - tta.animatedPoints = tta.points; - tta.points = base; + ttr.animatedPoints = ttr.points; + ttr.points = base; } else if ("normalizedPathSegList" in ttr) { var base = ttr.normalizedPathSegList; ttr.normalizedPathSegList = ttr.animatedNormalizedPathSegList; ttr.dispatchEvent(evt); - tta.animatedNormalizedPathSegList = tta.normalizedPathSegList; - tta.normalizedPathSegList = base; + ttr.animatedNormalizedPathSegList = ttr.normalizedPathSegList; + ttr.normalizedPathSegList = base; } - evt = v1 = v2 = v = null; + evt = v1 = v2 = v = d = n = ii = tg = null; }; evt = vir = null; }, false); @@ -7385,6 +7448,26 @@ function SVGAnimateColorElement() { SVGAnimationElement.apply(this); NAIBU.Clip[NAIBU.Clip.length] = this; + this._valueList = []; + this.addEventListener("DOMNodeInserted", function(evt){ + if (evt.eventPhase === Event.BUBBLING_PHASE) { + return; //強制終了させる + } + var tar = evt.target; + tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){ + var tar = evt.target, attrName = tar.getAttributeNS(null, "attributeName"),ttr = tar.targetElement; + var fstyle = tar.ownerDocument.defaultView.getComputedStyle(ttr, ""); + if (!tar._values[0]) { + tar._values[0] = fstyle.getPropertyValue(attrName); + } + for (var i=0, tav=tar._values, tvli=tav.length;i<tvli;++i) { + var to = new SVGColor(); + to.setRGBColor(tar._values[i]); + tar._valueList[tar._valueList.length] = to; + to = null; + } + }, false); + }, false); this.addEventListener("beginEvent", function(evt) { var tar = evt.target, attrName = tar.getAttributeNS(null, "attributeName"); var style = tar.ownerDocument.getOverrideStyle(tar.targetElement, ""); @@ -7393,30 +7476,20 @@ style.setProperty(attrName, tar._values[0], null); } tar._frame = function() { - var _tar = tar, to = new SVGColor(), from = new SVGColor(); - var d = _tar.getSimpleDuration(); - if (d === 0) { - d = null; + var _tar = tar; + 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); + } else { return; } - var n = _tar._values.length - 1, t = _tar.getCurrentTime(), i = Math.floor((t*n) / d); - to.setRGBColor(_tar._values[i+1]); - from.setRGBColor(_tar._values[i]); - if (!!!_tar._keyTimes) { - var ti = d / n, ki =ti; - if (n === 1) { - ti = 0; - } - } else { - var ti = parseFloat(_tar._keyTimes[i]) * d; - var ki = parseFloat(_tar._keyTimes[i+1])*d - ti; - } - var tc = to.rgbColor, fc = from.rgbColor, num = CSSPrimitiveValue.CSS_NUMBER, di = (t - ti) / ki; - var r = fc.red.getFloatValue(num) + (tc.red.getFloatValue(num) - fc.red.getFloatValue(num)) * di; - var g = fc.green.getFloatValue(num) + (tc.green.getFloatValue(num) - fc.green.getFloatValue(num)) * di; - var b = fc.blue.getFloatValue(num) + (tc.blue.getFloatValue(num) - fc.blue.getFloatValue(num)) * di; + 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; + 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; + var b = fb + (tc.blue.getFloatValue(num) - fb) * durd; style.setProperty(attrName, "rgb(" +Math.ceil(r)+ "," +Math.ceil(g)+ "," +Math.ceil(b)+ ")", null); - _tar = t = to = from = fc = tc = num = r = g = b = null; + _tar = d = n = tg = fc = tc = fr = fg = fb = num = r = g = b = null; } }, false); this.addEventListener("endEvent", function(evt) { @@ -7688,6 +7761,8 @@ if ("stop" in NAIBU) { clearInterval(NAIBU.stop); } + window.dettachEvent("onload", NAIBU._main); + window.onscroll = NAIBU.emptyFunction; Element = SVGElement = Attr = NamedNodeMap = CSS2Properties = CSSValue = CSSPrimitiveValue = NAIBU.xmlhttp = Node = Event = NAIBU = stlog = STLog = document = null; Array = ActiveXObject = null; } catch(e) {} @@ -7787,6 +7862,7 @@ s = null; } } + xmlhttp = null; }); NAIBU.addEvent("load", NAIBU._main); NAIBU.utf16 = function ( /*string*/ s) {