From: dhrname Date: Fri, 3 May 2013 14:44:39 +0000 (+0900) Subject: テキスト処理の高速化 X-Git-Tag: v16beta~307 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=421058b0aafc7b20fc3aa9f11a73f378467d8f64;p=sie%2Fsie.git テキスト処理の高速化 --- diff --git a/org/w3c/dom/svg.js b/org/w3c/dom/svg.js index 403b32b..d894b75 100644 --- a/org/w3c/dom/svg.js +++ b/org/w3c/dom/svg.js @@ -4183,10 +4183,14 @@ SVGTextPositioningElement.prototype._texto = function(evt) { style = tar.ownerDocument.defaultView.getComputedStyle(tar, null), deter = Math.sqrt(Math.abs(tar.getScreenCTM()._determinant())), n = parseFloat(style.getPropertyValue("font-size")) * deter, + mt = -n-5+ "px", + lh = n+10+ "px", tod = tar.ownerDocument.documentElement, ttpc = ttp, //ttpcはttpのキャッシュ tlen = tar.getComputedTextLength(), anchor = style.getPropertyValue("text-anchor"), + isMiddle = (anchor === "middle"), + isEnd = (anchor === "end"), tedeco = style.getPropertyValue("text-decoration"), //text-decorationは継承しないので、個々に設定する ttps = ttp.style, ae = [], @@ -4211,24 +4215,23 @@ SVGTextPositioningElement.prototype._texto = function(evt) { p = tar.getStartPositionOfChar(i); sty.position = "absolute"; if (tar._isYokogaki) { - if (anchor === "middle") { + if (isMiddle) { p.x -= tlen / 2; - } else if (anchor === "end") { + } else if (isEnd) { p.x -= tlen; } } else { - if (anchor === "middle") { + if (isMiddle) { p.y -= tlen / 2; - } else if (anchor === "end") { + } else if (isEnd) { p.y -= tlen; } } sty.left = p.x + "px"; sty.top = p.y + "px"; - sty.width = "0px"; - sty.height = "0px"; - sty.marginTop = tar._isYokogaki ? -n-5+ "px" : "-5px"; - sty.lineHeight = n+10+ "px"; + sty.width = sty.height = "0px"; + sty.marginTop = tar._isYokogaki ? mt : "-5px"; + sty.lineHeight = lh; sty.textDecoration = tedeco; sty.display = "none"; ttp.appendChild(ti._tars[ij]); @@ -4358,7 +4361,7 @@ SVGTextPositioningElement.prototype._texto = function(evt) { ++j; } delete tar._cacheMatrix; - tftfunc = ae = isRect = evt = tar = style = tedeco = tpp = ttpc = style = color = cursor = disp = vis = ttps = backr = backrs = di = tft = jt = lts = deter = void 0; + anchor = isEnd = isMiddle = mt = lh = tftfunc = ae = isRect = evt = tar = style = tedeco = tpp = ttpc = style = color = cursor = disp = vis = ttps = backr = backrs = di = tft = jt = lts = deter = void 0; }; function SVGTextElement(_doc) {