OSDN Git Service

テキスト処理の高速化
authordhrname <dhrname@users.sourceforge.jp>
Fri, 3 May 2013 14:44:39 +0000 (23:44 +0900)
committerdhrname <dhrname@users.sourceforge.jp>
Fri, 3 May 2013 14:44:39 +0000 (23:44 +0900)
org/w3c/dom/svg.js

index 403b32b..d894b75 100644 (file)
@@ -4183,10 +4183,14 @@ SVGTextPositioningElement.prototype._texto = function(evt) {
       style = tar.ownerDocument.defaultView.getComputedStyle(tar, null),\r
       deter = Math.sqrt(Math.abs(tar.getScreenCTM()._determinant())),\r
       n = parseFloat(style.getPropertyValue("font-size")) * deter,\r
+      mt = -n-5+ "px",\r
+      lh = n+10+ "px",\r
       tod = tar.ownerDocument.documentElement,\r
       ttpc = ttp, //ttpcはttpのキャッシュ\r
       tlen = tar.getComputedTextLength(),\r
       anchor = style.getPropertyValue("text-anchor"),\r
+      isMiddle = (anchor === "middle"),\r
+      isEnd = (anchor === "end"),\r
       tedeco = style.getPropertyValue("text-decoration"), //text-decorationは継承しないので、個々に設定する\r
       ttps = ttp.style,\r
       ae = [],\r
@@ -4211,24 +4215,23 @@ SVGTextPositioningElement.prototype._texto = function(evt) {
             p = tar.getStartPositionOfChar(i);\r
         sty.position = "absolute";\r
         if (tar._isYokogaki) {\r
-          if (anchor === "middle") {\r
+          if (isMiddle) {\r
             p.x -= tlen / 2;\r
-          } else if (anchor === "end") {\r
+          } else if (isEnd) {\r
             p.x -= tlen;\r
           }\r
         } else {\r
-          if (anchor === "middle") {\r
+          if (isMiddle) {\r
             p.y -= tlen / 2;\r
-          } else if (anchor === "end") {\r
+          } else if (isEnd) {\r
             p.y -= tlen;\r
           }\r
         }\r
         sty.left = p.x + "px";\r
         sty.top = p.y + "px";\r
-        sty.width = "0px";\r
-        sty.height = "0px";\r
-        sty.marginTop = tar._isYokogaki ? -n-5+ "px" : "-5px";\r
-        sty.lineHeight = n+10+ "px";\r
+        sty.width = sty.height = "0px";\r
+        sty.marginTop = tar._isYokogaki ? mt : "-5px";\r
+        sty.lineHeight = lh;\r
         sty.textDecoration = tedeco;\r
         sty.display = "none";\r
         ttp.appendChild(ti._tars[ij]);\r
@@ -4358,7 +4361,7 @@ SVGTextPositioningElement.prototype._texto = function(evt) {
     ++j;\r
   }\r
   delete tar._cacheMatrix;\r
-  tftfunc = ae = isRect = evt = tar = style = tedeco = tpp = ttpc = style = color = cursor = disp = vis = ttps = backr = backrs = di = tft = jt = lts = deter = void 0;\r
+  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;\r
 };\r
 \r
 function SVGTextElement(_doc) {\r