svnno****@sourc*****
svnno****@sourc*****
2010年 4月 23日 (金) 23:18:01 JST
Revision: 1801 http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=1801 Author: dhrname Date: 2010-04-23 23:18:01 +0900 (Fri, 23 Apr 2010) Log Message: ----------- Modified Paths: -------------- branches/ufltima/dom/svg.js Modified: branches/ufltima/dom/svg.js =================================================================== --- branches/ufltima/dom/svg.js 2010-04-21 14:32:23 UTC (rev 1800) +++ branches/ufltima/dom/svg.js 2010-04-23 14:18:01 UTC (rev 1801) @@ -2813,6 +2813,54 @@ function SVGTextElement() { SVGTextPositioningElement.apply(this, arguments); + this.addEventListener("DOMNodeInserted", function(evt){ + if (evt.eventPhase === Event.BUBBLING_PHASE) { + return; //強制終了させる + } + var tar = evt.target; + tar.parentNode._tar.appendChild(tar._tar); + tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) { + var tar = evt.target, ti = tar.firstChild; + var x = y = n = 0; //現在のテキスト位置と順番 + var tx = tar.x.baseVal, ty = tar.y.baseVal; + while (ti) { + if (ti.nodeType === Node.TEXT_NODE) { + var tt = ti._tar; + for (var i=0, tli=tt.length;i<tli;++i) { + if (n < tx.numberOfItems) { + x = tx.getItem(n).value; + } + if (n < ty.numberOfItems) { + y = ty.getItem(n).value; + } + var ts = tt[i].style; + ts.left = x+"px"; + ts.top = y+"px"; + ++n; + } + } else if (ti.localName === "tspan" && ti.namespaceURI === "http://www.w3.org/2000/svg"){ + var tt = ti._tar, ttx = tt.x.baseVal, tty = tt.y.baseVal; + for (var i=0, tli=tt.length;i<tli;++i) { + if (n < ttx.numberOfItems) { + x = ttx.getItem(n).value; + } else if (n < tx.numberOfItems) { + x = tx.getItem(n).value; + } + if (n < tty.numberOfItems) { + y = ttx.getItem(n).value; + } else if (n < ty.numberOfItems) { + y = ty.getItem(n).value; + } + var ts = tt[i].style; + ts.left = x+"px"; + ts.top = y+"px"; + ++n; + } + } + } + }, false); + evt = tar = null; + }, false); return this; }; SVGTextElement.constructor = SVGTextPositioningElement;