[Sie-announce] SIEコード [2491] SVGElementやSVGLengthのvar文を整理

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2011年 3月 21日 (月) 19:44:34 JST


Revision: 2491
          http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=2491
Author:   dhrname
Date:     2011-03-21 19:44:34 +0900 (Mon, 21 Mar 2011)

Log Message:
-----------
SVGElementやSVGLengthのvar文を整理

Modified Paths:
--------------
    branches/07x/073/org/w3c/dom/svg.js

Modified: branches/07x/073/org/w3c/dom/svg.js
===================================================================
--- branches/07x/073/org/w3c/dom/svg.js	2011-03-20 11:46:51 UTC (rev 2490)
+++ branches/07x/073/org/w3c/dom/svg.js	2011-03-21 10:44:34 UTC (rev 2491)
@@ -140,25 +140,36 @@
     if (evt.eventPhase === Event.BUBBLING_PHASE) {
       return;
     }
-    var name = evt.attrName, tar = evt.target;
+    var name = evt.attrName,
+        tar = evt.target;
     if (!!CSS2Properties[name] || name.indexOf("-") > -1) { //スタイルシートのプロパティならば
       tar._attributeStyle.setProperty(name, evt.newValue, "");
     }
     if (evt.relatedNode.localName === "id") { //xml:idあるいはid属性ならば
       tar.id = evt.newValue;
     } else if (name === "transform" && !!tar.transform) {
-      var tft = evt.newValue, degR = tar._degReg;
-      var coma = tft.match(tar._comaReg);   //コマンド文字にマッチ translate
-      var list = tft.match(tar._strReg);           //カッコ内のリストにマッチ (10 20 30...)
-      var a,b,c,d,e,f,lis,deg,rad,degli;
+      var tft = evt.newValue,
+          degR = tar._degReg,
+          coma = tft.match(tar._comaReg),   //コマンド文字にマッチ translate
+          list = tft.match(tar._strReg),    //カッコ内のリストにマッチ (10 20 30...)
+          a,b,c,d,e,f,
+          lis,
+          com,
+          deg,
+          rad,
+          degli,
+          s,
+          cm,
+          degz;
       //transform属性の値を、SVGTransformListであるtransformプロパティに結びつける
       for (var j=0,cli=coma.length;j<cli;j++) {
-        var s = evt.target.ownerDocument.documentElement.createSVGTransform();
-        lis = list[j], com = coma[j];
+        s = evt.target.ownerDocument.documentElement.createSVGTransform();
+        lis = list[j],
+        com = coma[j];
         deg = lis.match(degR);
         degli = deg.length;
         if (degli === 6) {
-          var cm = s.matrix;
+          cm = s.matrix;
           cm.a = +(deg[0]);
           cm.b = +(deg[1]);
           cm.c = +(deg[2]);
@@ -167,10 +178,10 @@
           cm.f = +(deg[5]);
         } else {
           if (degli === 3) {
-            var degz = +(deg[0]);
+            degz = +(deg[0]);
             s.setRotate(degz, +(deg[1]), +(deg[2]))
           } else if (degli <= 2) {
-            var degz = +(deg[0]);
+            degz = +(deg[0]);
             if (com === "translate") {
               s.setTranslate(degz, +(deg[1] || 0));
             } else if (com === "scale") {
@@ -185,27 +196,31 @@
           }
         }
         tar.transform.baseVal.appendItem(s);
-        lis = com = deg = rad = null;
       }
-      list = coma = mat = null;
+      tft = degR = coma = list = a = b = c = d = e = f = lis = com = deg = rad = degli = s = cm = degz = null;
     } else if (name === "style") {
-      var sc = evt.newValue, style = tar.style;
+      var sc = evt.newValue,
+          style = tar.style,
+          a,
+          ai,
+          m;
       style.cssText = sc;
       if (sc !== "") {
         //style属性値の解析
         sc = sc.replace(tar._shouReg, "")
                .replace(tar._conReg, ":")
                .replace(tar._bouReg, ";");
-        var a = sc.split(";");
+        a = sc.split(";");
         for (var i=0, ali=a.length;i<ali;++i) {
-          var ai = a[i], m = ai.split(":");
+          ai = a[i],
+          m = ai.split(":");
           if (ai !== "") {
             style.setProperty(m[0], m[1]);
           }
           ai = m = null;
         }
-        a = sc = null;
       }
+      a = sc = style = null;
     } else if (name === "class") {
       tar.className = evt.newValue;
     } else if (name.indexOf("on") === 0) {           //event属性ならば
@@ -241,9 +256,16 @@
       tar.xmlbase = evt.newValue;
     } else {
       if (!!tar[name]) {
-        var tea = tar[name], tod = tar.ownerDocument.documentElement;
+        var tea = tar[name],
+            tod = tar.ownerDocument.documentElement,
+            n,
+            type,
+            _parseFloat,
+            s;
         if (tea instanceof SVGAnimatedLength) {
-          var n = evt.newValue.match(tar._NaNReg), type = SVGLength.SVG_LENGTHTYPE_NUMBER, _parseFloat = parseFloat;
+          n = evt.newValue.match(tar._NaNReg);
+          type = /*SVGLength.SVG_LENGTHTYPE_NUMBER*/ 1;
+          _parseFloat = parseFloat;
           if (!!n) {
             n = n[0];
           }
@@ -253,28 +275,29 @@
             } else if ((name === "y") || (name === "height")) {
               tea.baseVal._percent *= tod.viewport.height;
             }
-            type = SVGLength.SVG_LENGTHTYPE_PERCENTAGE;
+            type = /*SVGLength.SVG_LENGTHTYPE_PERCENTAGE*/ 2;
           } else if (n === "em") {
-            type = SVGLength.SVG_LENGTHTYPE_EMS;
+            type = /*SVGLength.SVG_LENGTHTYPE_EMS*/ 3;
           } else if (n === "ex") {
-            type = SVGLength.SVG_LENGTHTYPE_EXS;
+            type = /*SVGLength.SVG_LENGTHTYPE_EXS*/ 4;
           } else if (n === "px") {
-            type = SVGLength.SVG_LENGTHTYPE_PX;
+            type = /*SVGLength.SVG_LENGTHTYPE_PX*/ 5;
           } else if (n === "cm") {
-            type = SVGLength.SVG_LENGTHTYPE_CM;
+            type = /*SVGLength.SVG_LENGTHTYPE_CM*/ 6;
           } else if (n === "mm") {
-            type = SVGLength.SVG_LENGTHTYPE_MM;
+            type = /*SVGLength.SVG_LENGTHTYPE_MM*/ 7;
           } else if (n === "in") {
-            type = SVGLength.SVG_LENGTHTYPE_IN;
+            type = /*SVGLength.SVG_LENGTHTYPE_IN*/ 8;
           } else if (n === "pt") {
-            type = SVGLength.SVG_LENGTHTYPE_PT;
+            type = /*SVGLength.SVG_LENGTHTYPE_PT*/ 9;
           } else if (n === "pc") {
-            type = SVGLength.SVG_LENGTHTYPE_PC;
+            type = /*SVGLength.SVG_LENGTHTYPE_PC*/ 10;
           }
-          var s = _parseFloat(evt.newValue);
+          s = _parseFloat(evt.newValue);
           s = isNaN(s) ? 0 : s;
           tea.baseVal.newValueSpecifiedUnits(type, s);
         }
+        tea = tod = n = type = _parseFloat = s = null;
       }
     }
     evt = _parseFloat = name = tar = null;
@@ -307,28 +330,33 @@
   
   /*interface SVGLocatable*/
   /*SVGRect*/     this.getBBox = function(){
-    var s = new SVGRect();
-    var data = this._tar.path.value, vi = this.ownerDocument.documentElement.viewport;
-    var el = vi.width, et = vi.height, er = 0, eb = 0;
+    var s = new SVGRect(),
+        data = this._tar.path.value,
+        vi = this.ownerDocument.documentElement.viewport,
+        el = vi.width,
+        et = vi.height,
+        er = 0,
+        eb = 0,
+        degis = data.match(/[0-9\-]+/g),
+        nx,
+        ny;
     /*要素の境界領域を求める(四隅の座標を求める)
      *etは境界領域の上からビューポート(例えばsvg要素)の上端までの距離であり、ebは境界領域の下からビューポートの下端までの距離
      *elは境界領域の左からビューポートの左端までの距離であり、erは境界領域の右からビューポートの右端までの距離
      */
-    var degis = data.match(/[0-9\-]+/g);
     for (var i=0,degisli=degis.length;i<degisli;i+=2) {
-      var nx = +(degis[i]), ny = +(degis[i+1]);
+      nx = +(degis[i]),
+      ny = +(degis[i+1]);
       el = el > nx ? nx : el;
       et = et > ny ? ny : et;
       er = er > nx ? er : nx;
       eb = eb > ny ? eb : ny;
-      nx = ny = null;
     }
-    data = degis = null;
     s.x      = el;
     s.y      = et;
     s.width  = er - el;
     s.height = eb - et;
-    el = et = er = eb = vi = null;
+    nx = ny = data = degis =el = et = er = eb = vi = null;
     return s;
   };
 
@@ -339,11 +367,11 @@
    *もし、要素の中心座標を取得したい人がいれば、transformプロパティのconsolidateメソッドを使うこと
    */
   /*SVGMatrix*/   this.getCTM = function() {
-    var s;
+    var s, m;
     if (!!this._cacheMatrix) { //キャッシュがあれば
       s = this._cacheMatrix;
     } else {
-      var m = this.transform.baseVal.consolidate();
+      m = this.transform.baseVal.consolidate();
       if (m) {
         m = m.matrix;
       } else {
@@ -366,6 +394,7 @@
     }
     var view = this.nearestViewportElement || this.ownerDocument.documentElement;
     var s = view.getScreenCTM().multiply(this.getCTM());
+    view = null;
     return s;
   };
 
@@ -511,32 +540,33 @@
  *例:2pxならば、x.newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_PX, 2);となる
  */
   newValueSpecifiedUnits : function (/*unsigned short*/ unitType, /*float*/ valueInSpecifiedUnits) {
-    var n = 1, _s = ""; //nは各単位から利用単位への変換数値。_sは単位の文字列を表す
-    if (unitType === SVGLength.SVG_LENGTHTYPE_NUMBER) {
-    } else if (unitType === SVGLength.SVG_LENGTHTYPE_PX) {
+    var n = 1,
+       _s = ""; //nは各単位から利用単位への変換数値。_sは単位の文字列を表す
+    if (unitType === /*SVGLength.SVG_LENGTHTYPE_NUMBER*/ 1) {
+    } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_PX*/ 5) {
       _s = "px";
-    } else if (unitType === SVGLength.SVG_LENGTHTYPE_PERCENTAGE) {
+    } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_PERCENTAGE*/ 2) {
       n = this._percent;
       _s = "%"
-    } else if (unitType === SVGLength.SVG_LENGTHTYPE_EMS) {
+    } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_EMS*/ 3) {
       n = this._fontSize;
       _s = "em";
-    } else if (unitType === SVGLength.SVG_LENGTHTYPE_EXS) {
+    } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_EXS*/ 4) {
       n = this._fontSize * 0.5;
       _s = "ex";
-    } else if (unitType === SVGLength.SVG_LENGTHTYPE_CM) {
+    } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_CM*/ 6) {
       n = 35.43307;
       _s = "cm";
-    } else if (unitType === SVGLength.SVG_LENGTHTYPE_MM) {
+    } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_MM*/ 7) {
       n = 3.543307;
       _s = "mm";
-    } else if (unitType === SVGLength.SVG_LENGTHTYPE_IN) {
+    } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_IN*/ 8) {
       n = 90;
       _s = "in";
-    } else if (unitType === SVGLength.SVG_LENGTHTYPE_PT) {
+    } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_PT*/ 9) {
       n = 1.25;
       _s = "pt";
-    } else if (unitType === SVGLength.SVG_LENGTHTYPE_PC) {
+    } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_PC*/ 10) {
       n = 15;
       _s = "pc";
     } else {
@@ -546,7 +576,7 @@
     this.value = valueInSpecifiedUnits * n;
     this.valueInSpecifiedUnits = valueInSpecifiedUnits;
     this.valueAsString = valueInSpecifiedUnits + _s;
-    n = _s = null;
+    valueInSpecifiedUnits = unitType = n = _s = null;
   },
 /*convertToSpecifiedUnitsメソッド
  *valueプロパティを書き換えずに、単位だけを変換する
@@ -603,7 +633,8 @@
 };
 SVGAngle.prototype = {
   /*void*/ newValueSpecifiedUnits : function (/*in unsigned short*/ unitType, /*in float*/ valueInSpecifiedUnits ) {
-    var n = 1, _s = ""; //nは各単位から利用単位への変換数値。_sは単位の文字列を表す
+    var n = 1,
+        _s = ""; //nは各単位から利用単位への変換数値。_sは単位の文字列を表す
     if (unitType === SVGAngle.SVG_ANGLETYPE_DEG) {
       _s = "deg"
     } else if (unitType === SVGAngle.SVG_ANGLETYPE_RAD) {
@@ -638,7 +669,7 @@
 };
 function SVGColor() {
   CSSValue.call(this, arguments);
-  /*readonly unsigned short*/ this.colorType = SVGColor.SVG_COLORTYPE_UNKNOWN;
+  /*readonly unsigned short*/ this.colorType = /*SVGColor.SVG_COLORTYPE_UNKNOWN*/ 0;
   /*readonly css::RGBColor*/  this.rgbColor  = new RGBColor();
   /*readonly SVGICCColor*/    this.iccColor;
   return this;




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