[Sie-announce] SIEコード [2918] SVGElementの変数とif文の整理をして、軽量化

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2011年 9月 3日 (土) 21:19:04 JST


Revision: 2918
          http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=2918
Author:   dhrname
Date:     2011-09-03 21:19:04 +0900 (Sat, 03 Sep 2011)

Log Message:
-----------
SVGElementの変数とif文の整理をして、軽量化

Modified Paths:
--------------
    branches/08x/085/org/w3c/dom/svg.js

Modified: branches/08x/085/org/w3c/dom/svg.js
===================================================================
--- branches/08x/085/org/w3c/dom/svg.js	2011-09-03 11:30:28 UTC (rev 2917)
+++ branches/08x/085/org/w3c/dom/svg.js	2011-09-03 12:19:04 UTC (rev 2918)
@@ -256,52 +256,47 @@
       tar.addEventListener(v, document._s, false);
     } else if (evt.relatedNode.nodeName === "xml:base") { //xml:base属性ならば
       tar.xmlbase = evt.newValue;
-    } else if (!!tar[name]) {
+    } else if (!!tar[name] && (tar[name] instanceof SVGAnimatedLength)) {
       var tea = tar[name],
-      tod = tar.ownerDocument.documentElement,
-      tvw = tod.viewport.width,
-      tvh = tod.viewport.height,
-      n,
-      type,
-      _parseFloat,
-      s;
-      if (tea instanceof SVGAnimatedLength) {
-        n = evt.newValue.match(tar._NaNReg);
-        type = /*SVGLength.SVG_LENGTHTYPE_NUMBER*/ 1;
-        _parseFloat = parseFloat;
-        if (!!n) {
-          n = n[0];
+          tod = tar.ownerDocument.documentElement,
+          tvw = tod.viewport.width,
+          tvh = tod.viewport.height,
+          s,
+          n = evt.newValue.match(tar._NaNReg),
+          type = /*SVGLength.SVG_LENGTHTYPE_NUMBER*/ 1,
+          _parseFloat = parseFloat;
+      if (!!n) {
+        n = n[0];
+      }
+      if (n === "%") {
+        if (tar._x1width[name]) {
+          tea.baseVal._percent = tvw * 0.01;
+        } else if (tar._y1height[name]) {
+          tea.baseVal._percent = tvh * 0.01;
+        } else {
+          tea.baseVal._percent = Math.sqrt((tvw*tvw + tvh*tvh) / 2) * 0.01;
         }
-        if (n === "%") {
-          if (tar._x1width[name]) {
-            tea.baseVal._percent = tvw * 0.01;
-          } else if (tar._y1height[name]) {
-            tea.baseVal._percent = tvh * 0.01;
-          } else {
-            tea.baseVal._percent = Math.sqrt((tvw*tvw + tvh*tvh) / 2) * 0.01;
-          }
-          type = /*SVGLength.SVG_LENGTHTYPE_PERCENTAGE*/ 2;
-        } else if (n === "em") {
-          type = /*SVGLength.SVG_LENGTHTYPE_EMS*/ 3;
-        } else if (n === "ex") {
-          type = /*SVGLength.SVG_LENGTHTYPE_EXS*/ 4;
-        } else if (n === "px") {
-          type = /*SVGLength.SVG_LENGTHTYPE_PX*/ 5;
-        } else if (n === "cm") {
-          type = /*SVGLength.SVG_LENGTHTYPE_CM*/ 6;
-        } else if (n === "mm") {
-          type = /*SVGLength.SVG_LENGTHTYPE_MM*/ 7;
-        } else if (n === "in") {
-          type = /*SVGLength.SVG_LENGTHTYPE_IN*/ 8;
-        } else if (n === "pt") {
-          type = /*SVGLength.SVG_LENGTHTYPE_PT*/ 9;
-        } else if (n === "pc") {
-          type = /*SVGLength.SVG_LENGTHTYPE_PC*/ 10;
-        }
-        s = _parseFloat(evt.newValue);
-        s = isNaN(s) ? 0 : s;
-        tea.baseVal.newValueSpecifiedUnits(type, s);
+        type = /*SVGLength.SVG_LENGTHTYPE_PERCENTAGE*/ 2;
+      } else if (n === "em") {
+        type = /*SVGLength.SVG_LENGTHTYPE_EMS*/ 3;
+      } else if (n === "ex") {
+        type = /*SVGLength.SVG_LENGTHTYPE_EXS*/ 4;
+      } else if (n === "px") {
+        type = /*SVGLength.SVG_LENGTHTYPE_PX*/ 5;
+      } else if (n === "cm") {
+        type = /*SVGLength.SVG_LENGTHTYPE_CM*/ 6;
+      } else if (n === "mm") {
+        type = /*SVGLength.SVG_LENGTHTYPE_MM*/ 7;
+      } else if (n === "in") {
+        type = /*SVGLength.SVG_LENGTHTYPE_IN*/ 8;
+      } else if (n === "pt") {
+        type = /*SVGLength.SVG_LENGTHTYPE_PT*/ 9;
+      } else if (n === "pc") {
+        type = /*SVGLength.SVG_LENGTHTYPE_PC*/ 10;
       }
+      s = _parseFloat(evt.newValue);
+      s = isNaN(s) ? 0 : s;
+      tea.baseVal.newValueSpecifiedUnits(type, s);
       tea = tod = tvw = tvh = n = type = _parseFloat = s = null;
     }
     evt = _parseFloat = name = tar = null;




Sie-announce メーリングリストの案内
Back to archive index