svnno****@sourc*****
svnno****@sourc*****
2010年 11月 30日 (火) 22:09:58 JST
Revision: 2187 http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=2187 Author: dhrname Date: 2010-11-30 22:09:58 +0900 (Tue, 30 Nov 2010) Log Message: ----------- 0.64統合 Modified Paths: -------------- trunk/sie.js Property Changed: ---------------- trunk/sie.js Modified: trunk/sie.js =================================================================== --- trunk/sie.js 2010-11-30 13:08:49 UTC (rev 2186) +++ trunk/sie.js 2010-11-30 13:09:58 UTC (rev 2187) @@ -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"); } @@ -4551,10 +4592,17 @@ if (stroke.paintType === /*SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR*/ 102) { /*再度、設定。css.jsのsetPropertyを参照*/ style.setProperty("color", style.getPropertyValue("color")); + tar._fillElement = fillElement; //キャッシュを作る + } else { + el.appendChild(fillElement); } 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"); } @@ -6747,8 +6795,6 @@ this.addEventListener("DOMAttrModified", function(evt){ if (evt.attrName === "type") { evt.target.type = evt.newValue; - } else if (!!tar.parentNode._tar){ - tar.parentNode._tar.appendChild(tar._tar); } evt = null; }, false); @@ -6781,6 +6827,7 @@ var evtt = tar.ownerDocument.createEvent("SVGEvents"); evtt.initEvent("SVGLoad", false, false); evt.currentTarget.dispatchEvent(evtt); + evtt = null; } tar = evt = null; }, false); @@ -6985,10 +7032,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を返す @@ -7059,6 +7106,7 @@ Max : 7000, start : function() { if (NAIBU.Clip.length > 0) { + screen.updateInterval = 42; //24fpsとして描画処理 NAIBU.stop = setInterval( (function() { /* try{*/ var ntc = NAIBU.Time.currentFrame++; @@ -7112,6 +7160,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; //強制終了させる @@ -7159,7 +7216,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; @@ -7189,12 +7246,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; @@ -7204,25 +7265,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); @@ -7286,12 +7351,6 @@ style.setProperty(attrName, tar.getAttributeNS(null, "to"), null); style = null; } - 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; - 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; } evt = tar = attrName = null; }, false); @@ -7393,6 +7452,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, ""); @@ -7401,30 +7480,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) { @@ -7696,6 +7765,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) {} @@ -7795,6 +7866,7 @@ s = null; } } + xmlhttp = null; }); NAIBU.addEvent("load", NAIBU._main); NAIBU.utf16 = function ( /*string*/ s) { Property changes on: trunk/sie.js ___________________________________________________________________ Modified: svn:mergeinfo - /branches/04x/040/sie.js:812-829 /branches/04x/041/sie.js:891-923 /branches/04x/042/sie.js:927-967 /branches/04x/043/sie.js:969-1013 /branches/04x/044/sie.js:1015-1067 /branches/04x/045/sie.js:1069-1078 /branches/04x/046/sie.js:1080-1129 /branches/04x/047/sie.js:1131-1164 /branches/04x/048/sie.js:1166-1180 /branches/04x/sie.js:830-1181 /branches/05x/050/sie.js:1183-1201 /branches/05x/051/sie.js:1207-1323 /branches/05x/052/sie.js:1325-1352 /branches/05x/053/sie.js:1354-1400 /branches/05x/054/sie.js:1403-1422 /branches/05x/055/sie.js:1424-1454 /branches/05x/056/sie.js:1456-1491 /branches/05x/057/sie.js:1496-1523 /branches/05x/058/sie.js:1526-1590 /branches/05x/sie.js:1183-1594 /branches/06x/060/sie.js:1603-1850 /branches/06x/sie.js:1599-2156 + /branches/04x/040/sie.js:812-829 /branches/04x/041/sie.js:891-923 /branches/04x/042/sie.js:927-967 /branches/04x/043/sie.js:969-1013 /branches/04x/044/sie.js:1015-1067 /branches/04x/045/sie.js:1069-1078 /branches/04x/046/sie.js:1080-1129 /branches/04x/047/sie.js:1131-1164 /branches/04x/048/sie.js:1166-1180 /branches/04x/sie.js:830-1181 /branches/05x/050/sie.js:1183-1201 /branches/05x/051/sie.js:1207-1323 /branches/05x/052/sie.js:1325-1352 /branches/05x/053/sie.js:1354-1400 /branches/05x/054/sie.js:1403-1422 /branches/05x/055/sie.js:1424-1454 /branches/05x/056/sie.js:1456-1491 /branches/05x/057/sie.js:1496-1523 /branches/05x/058/sie.js:1526-1590 /branches/05x/sie.js:1183-1594 /branches/06x/060/sie.js:1603-1850 /branches/06x/sie.js:1599-2185