svnno****@sourc*****
svnno****@sourc*****
2011年 7月 3日 (日) 23:19:09 JST
Revision: 2812 http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=2812 Author: dhrname Date: 2011-07-03 23:19:09 +0900 (Sun, 03 Jul 2011) Log Message: ----------- SVGRectElementのvar文を整理 Modified Paths: -------------- branches/08x/081/org/w3c/dom/svg.js Modified: branches/08x/081/org/w3c/dom/svg.js =================================================================== --- branches/08x/081/org/w3c/dom/svg.js 2011-07-03 14:10:13 UTC (rev 2811) +++ branches/08x/081/org/w3c/dom/svg.js 2011-07-03 14:19:09 UTC (rev 2812) @@ -3317,11 +3317,13 @@ /*readonly SVGAnimatedLength*/ this.rx = new SVGAnimatedLength(); /*readonly SVGAnimatedLength*/ this.ry = new SVGAnimatedLength(); this.addEventListener("DOMNodeInserted", function(evt){ - var tar = evt.target; if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) { return; //強制終了させる } - var tnext = tar.nextSibling, tpar = tar.parentNode, isLast = true; + var tar = evt.target, + tnext = tar.nextSibling, + tpar = tar.parentNode, + isLast = true; if (tnext && tnext._tar && tpar._tar && (tnext._tar.parentNode === tpar._tar)) { tpar._tar.insertBefore(tar._tar, tnext._tar); } else if (tnext && !tnext._tar && tpar._tar) { @@ -3343,57 +3345,73 @@ } tnext = tpar = isLast = null; tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) { - var tar = evt.target, style = tar.ownerDocument.defaultView.getComputedStyle(tar, ""); - var fontSize = parseFloat(style.getPropertyValue("font-size")); + var tar = evt.target, + style = tar.ownerDocument.defaultView.getComputedStyle(tar, ""), + fontSize = parseFloat(style.getPropertyValue("font-size")); tar.x.baseVal._emToUnit(fontSize); tar.y.baseVal._emToUnit(fontSize); tar.width.baseVal._emToUnit(fontSize); tar.height.baseVal._emToUnit(fontSize); - var rx = tar.getAttributeNS(null, "rx"), ry = tar.getAttributeNS(null, "ry"); - var x = tar.x.baseVal.value, y = tar.y.baseVal.value, xw = x + tar.width.baseVal.value, yh = y + tar.height.baseVal.value; - var list; + var rx = tar.getAttributeNS(null, "rx"), + ry = tar.getAttributeNS(null, "ry"), + x = tar.x.baseVal.value, + y = tar.y.baseVal.value, + xw = x + tar.width.baseVal.value, + yh = y + tar.height.baseVal.value, + list; if ((rx || ry) && (rx !== "0") && (ry !== "0")) { tar.rx.baseVal._emToUnit(fontSize); tar.ry.baseVal._emToUnit(fontSize); - var thrx = tar.rx.baseVal, thry = tar.ry.baseVal; + var thrx = tar.rx.baseVal, + thry = tar.ry.baseVal, + twidth = tar.width.baseVal.value, + theight = tar.height.baseVal.value; thrx.value = rx ? thrx.value : thry.value; thry.value = ry ? thry.value : thrx.value; //rx属性が幅より大きければ、幅の半分を属性に設定(ry属性は高さと比較する) - var twidth = tar.width.baseVal.value, theight = tar.height.baseVal.value; if (thrx.value > twidth / 2) { thrx.value = twidth / 2; } if (thry.value > theight / 2) { thry.value = theight / 2; } - var rxv = thrx.value, ryv = thry.value; - var rrx = rxv * 0.55228, rry = ryv * 0.55228; - var a = xw - rxv, b = x + rxv, c = y + ryv, d = yh - ryv; + var rxv = thrx.value, + ryv = thry.value, + rrx = rxv * 0.55228, + rry = ryv * 0.55228, + a = xw - rxv, + b = x + rxv, + c = y + ryv, + d = yh - ryv; list = ["m",b,y, "l",a,y, "c",a+rrx,y,xw,c-rry,xw,c, "l",xw,d, "c",xw,d+rry,a+rrx,yh,a,yh, "l",b,yh, "c",b-rrx,yh,x,d+rry,x,d, "l",x,c, "c",x,c-rry,b-rrx,y,b,y]; } else { list = ["m",x,y, "l",x,yh, xw,yh, xw,y, "x e"]; } //以下は、配列listそのものをCTMで座標変換していく処理 - var par = tar.ownerDocument.documentElement, ctm = tar.getScreenCTM(); + var par = tar.ownerDocument.documentElement, + ctm = tar.getScreenCTM(), + dat, p, pmt, + ele = tar._tar, + vi = tar.ownerDocument.documentElement, + w = vi.width.baseVal.value, + h = vi.height.baseVal.value; for (var i=0, lili=list.length;i<lili;) { if (isNaN(list[i])) { //コマンド文字は読み飛ばす ++i; continue; } - var p = par.createSVGPoint(); + p = par.createSVGPoint(); p.x = list[i]; p.y = list[i+1]; - var pmt = p.matrixTransform(ctm); + pmt = p.matrixTransform(ctm); list[i] = pmt.x; ++i; list[i] = pmt.y; ++i; p = pmt = null; } - var dat = list.join(" "); + dat = list.join(" "); //VMLに結び付けていく - var ele = tar._tar, vi = tar.ownerDocument.documentElement; - var w = vi.width.baseVal.value, h = vi.height.baseVal.value; ele.path = dat; ele.coordsize = w + " " + h; NAIBU._setPaint(tar, ctm);