svnno****@sourc*****
svnno****@sourc*****
2010年 9月 30日 (木) 19:33:58 JST
Revision: 2029 http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=2029 Author: dhrname Date: 2010-09-30 19:33:58 +0900 (Thu, 30 Sep 2010) Log Message: ----------- Modified Paths: -------------- branches/06x/061/org/w3c/dom/svg.js Modified: branches/06x/061/org/w3c/dom/svg.js =================================================================== --- branches/06x/061/org/w3c/dom/svg.js 2010-09-29 14:13:27 UTC (rev 2028) +++ branches/06x/061/org/w3c/dom/svg.js 2010-09-30 10:33:58 UTC (rev 2029) @@ -3247,40 +3247,31 @@ function SVGTextContentElement() { SVGElement.apply(this); - this._list = []; //文字の位置を格納しておくリスト + this._list = []; //文字の位置を格納しておくリスト + this._length = 0; //全文字数 /*readonly SVGAnimatedLength*/ this.textLength = new SVGAnimatedLength(); /*readonly SVGAnimatedEnumeration*/ this.lengthAdjust = new SVGAnimatedEnumeration(SVGTextContentElement.LENGTHADJUST_UNKNOWN); this._isYokogaki = true; this.addEventListener("DOMNodeInserted", function(evt){ var tar = evt.target, cur = evt.currentTarget; if ((evt.eventPhase === Event.CAPTURING_PHASE) && (tar.nodeType === Node.TEXT_NODE) && !!!tar._tar) { - /*Textノードにdiv要素を格納したリストをプロパティとして蓄えておく*/ - tar._tar = []; - for (var i=0, tdli=tar.data.length;i<tdli;++i) { - var d = document.createElement("div"), dstyle = d.style; - dstyle.position = "absolute"; - dstyle.marginLeft = "0px"; - dstyle.marginTop = "0px"; - dstyle.paddingTop = "0px"; - dstyle.paddingLeft = "0px"; - dstyle.whiteSpace = "nowrap"; - dstyle.textIndent = "0px"; - d.appendChild(document.createTextNode(tar.data.charAt(i))); - tar._tar[tar._tar.length] = d; - } - if (cur.parentNode) { - var evtt = cur.ownerDocument.createEvent("MutationEvents"); - evtt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null); - evtt.target = cur; - evtt.eventPhase = Event.AT_TARGET; - var tce = cur._capter; //tceは登録しておいたリスナーのリスト - for (var j=0,tcli=tce.length;j<tcli;++j){ - if (tce[j]) { - tce[j].handleEvent(evtt); - } - } - evtt = null; - } + /*Textノードにdiv要素を格納したリストをプロパティとして蓄えておく*/ + tar._tar = []; + for (var i=0, tdli=tar.data.length;i<tdli;++i) { + var d = document.createElement("div"), dstyle = d.style; + dstyle.position = "absolute"; + dstyle.marginLeft = "0px"; + dstyle.marginTop = "0px"; + dstyle.paddingTop = "0px"; + dstyle.paddingLeft = "0px"; + dstyle.whiteSpace = "nowrap"; + dstyle.textIndent = "0px"; + d.appendChild(document.createTextNode(tar.data.charAt(i))); + tar._tar[tar._tar.length] = d; + } + this._length += tar._tar.length; + } else if ((evt.eventPhase === Event.CAPTURING_PHASE) && (tar.localName === "tspan")) { + cur._length += tar.getNumberOfChars(); } evt = tar = null; }, true); @@ -3293,7 +3284,7 @@ /*unsigned short*/ SVGTextContentElement.LENGTHADJUST_SPACING = 1; /*unsigned short*/ SVGTextContentElement.LENGTHADJUST_SPACINGANDGLYPHS = 2; /*long*/ SVGTextContentElement.prototype.getNumberOfChars = function() { - return (this._list.length/3); + return (this._list.length / 3); }; /*float*/ SVGTextContentElement.prototype.getComputedTextLength = function() { var l = this.textLength.baseVal; @@ -3441,25 +3432,6 @@ } else { var ptx = pty = ptdx = ptdy = {numberOfItems : 0}; } - if (tar.localName === "tspan") { - /*現在のテキスト位置を、前のノードによって、 - *変更する(tspan要素のみ) - */ - var d = 0, tpre = tar.previousSibling; - while (tpre) { - if (tpre.nodeType === Node.TEXT_NODE) { - d += tpre.length; - } else if (tpre.localName === "tspan") { - d += tpre.getNumberOfChars(); - } - tpre = tpre.previousSibling; - } - if (isYokogaki) { - x = tp.getSubStringLength(0, d); - } else { - y = tp.getSubStringLength(0, d); - } - } var kern = "f ijltIr.,:;'-\"()", akern = "1234567890abcdeghknopquvxyz"; if (isYokogaki) { y += fontSize * 0.2;