[Sie-announce] SIEコード [1255]

アーカイブの一覧に戻る

svnno****@sourc***** svnno****@sourc*****
2009年 9月 16日 (水) 20:53:59 JST


Revision: 1255
          http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=1255
Author:   dhrname
Date:     2009-09-16 20:53:59 +0900 (Wed, 16 Sep 2009)

Log Message:
-----------


Modified Paths:
--------------
    branches/DOM/org/w3c/dom/svg.js

Modified: branches/DOM/org/w3c/dom/svg.js
===================================================================
--- branches/DOM/org/w3c/dom/svg.js	2009-09-16 09:36:07 UTC (rev 1254)
+++ branches/DOM/org/w3c/dom/svg.js	2009-09-16 11:53:59 UTC (rev 1255)
@@ -1446,48 +1446,6 @@
   }
 }
 
-//SVGLengthを参照
-function STLength( /*string or number*/ d, /*boolean*/ wort, /*float*/ f) {
-  d += "";
-  this.unitType = 0;//unknown
-  this.wort = wort;
-  this.fontSize = f;
-  try {
-  var v = parseFloat(d);
-  var tani = d.match(/\D+$/);
-  this.newValueSpecifiedUnits(tani,v);
-  }  catch(e) {stlog.add(e,1133); this.value = 1000;}
-  return this;
-}
-STLength.prototype.newValueSpecifiedUnits = function stlengthnvsu( /*string or number*/ tani, /*number*/ value) {
-  var n = 1,  ut;
-  switch (tani+"") {
-    case "pt":  n = 1.25; ut = 9;
-    break;
-    case "pc":  n = 15; ut = 10;
-    break;
-    case "mm":  n = 3.543307; ut = 7;
-    break;
-    case "cm":  n = 35.43307; ut = 6;
-    break;
-    case "in":  n = 90; ut = 8;
-    break;
-    case "em":  n = this.fontSize; ut = 3;
-    break;
-    case "ex":  ut = 4;
-    break;
-    case "px":  ut = 5;
-    break;
-    case "%":  n = 0.01 * this.wort; ut = 2;
-    break;
-    default:  ut = 1;
-    break;
-  }
-  this.unitType = ut;
-  this.value = value * n;
-  this.valueInSpecifiedUnits = value;
-}
-
 //XLink言語を処理
 NAIBU.XLink = function( /*element*/ ele) {
   this.tar = ele;
@@ -1683,7 +1641,7 @@
 try{if (sieb_s) {svgtovml();}} catch(e) {}
 
 if((typeof SVGElement) === "function" && /*@cc_on!@*/false){//IE7以降
-
+/*
 // File: svg.idl
 #ifndef _SVG_IDL_
 #define _SVG_IDL_
@@ -1733,6 +1691,7 @@
   exception SVGException {
     unsigned short   code;
   };
+*/
   // SVGExceptionCode
 /*const unsigned short*/ SVG_WRONG_TYPE_ERR           = 0;
 /*const unsigned short*/ SVG_INVALID_VALUE_ERR        = 1;
@@ -1758,7 +1717,7 @@
   /*readonly String*/ this.animVal;
   return this;
 };
-  interface SVGStringList { 
+function SVGStringList() { /*
     readonly attribute unsigned long numberOfItems;
     void   clear (  )
                     raises( DOMException );
@@ -1774,7 +1733,9 @@
                     raises( DOMException );
     DOMString appendItem ( in DOMString newItem )
                     raises( DOMException, SVGException );
-  };
+*/return this;
+};
+/*
   interface SVGAnimatedEnumeration { 
              attribute unsigned short baseVal;
                          // raises DOMException on setting
@@ -1794,7 +1755,8 @@
                          // raises DOMException on setting
     readonly attribute float animVal;
   };
-  interface SVGNumberList { 
+*/
+function SVGNumberList() { /*
     readonly attribute unsigned long numberOfItems;
     void   clear (  )
                     raises( DOMException );
@@ -1810,13 +1772,21 @@
                     raises( DOMException );
     SVGNumber appendItem ( in SVGNumber newItem )
                     raises( DOMException, SVGException );
-  };
-  interface SVGAnimatedNumberList { 
-    readonly attribute SVGNumberList baseVal;
-    readonly attribute SVGNumberList animVal;
-  };
-  interface SVGLength { 
+*/
+  return this;
+};
+function SVGAnimatedNumberList() { 
+  /*readonly SVGNumberList*/ this.baseVal = new SVGNumberList();
+  /*readonly SVGNumberList*/ this.animVal;
+  return this;
+};
+/*SVGLengthクラス
+ *長さを設定する(単位pxに統一する方便として使う)
+ *valueInSpecifiedUnitsプロパティはpxに統一する前の数値。valueプロパティはpxに統一した後の数値
+ */
+function SVGLength( /*string or number*/ d, /*float*/ wort, /*float*/ f) { 
     // Length Unit Types
+/*
     const unsigned short SVG_LENGTHTYPE_UNKNOWN    = 0;
     const unsigned short SVG_LENGTHTYPE_NUMBER     = 1;
     const unsigned short SVG_LENGTHTYPE_PERCENTAGE = 2;
@@ -1828,21 +1798,64 @@
     const unsigned short SVG_LENGTHTYPE_IN         = 8;
     const unsigned short SVG_LENGTHTYPE_PT         = 9;
     const unsigned short SVG_LENGTHTYPE_PC         = 10;
-    readonly attribute unsigned short unitType;
-             attribute float          value;
-                         // raises DOMException on setting
-             attribute float          valueInSpecifiedUnits;
-                         // raises DOMException on setting
-             attribute DOMString      valueAsString;
-                         // raises DOMException on setting
-    void newValueSpecifiedUnits ( in unsigned short unitType, in float valueInSpecifiedUnits );
-    void convertToSpecifiedUnits ( in unsigned short unitType );
-  };
-  interface SVGAnimatedLength { 
-    readonly attribute SVGLength baseVal;
-    readonly attribute SVGLength animVal;
-  };
-  interface SVGLengthList { 
+*/
+  d += "";
+  /*readonly unsigned short*/ this.unitType = 0; //unknown
+  if (wort === void 0) { //void 0 = undefined
+    wort = 1;
+  }
+  if (f === void 0) {
+    f = 12;
+  }
+  try {
+  this._n[1] *= wort;
+  this._n[2] = this._n[3] = f;
+  var v = parseFloat(d);
+  var tani = d.match(this._dR);
+  var ut = 1;
+  if(tani) {
+    ut = this._tani[tani];
+  }
+  this.newValueSpecifiedUnits(ut,v);
+  /*DOMString*/ this.valueAsString = d;
+  wort = f = v = tani = ut = null; //解放
+  }  catch(e) {stlog.add(e,1133); this.value = 1000;}
+  return this;
+};
+
+SVGLength.prototype._dR = /\D+$/; //RegExpオブジェクトをあらかじめ生成
+SVGLength.prototype._n = [1, 0.01, 1, 1, 1, 35.43307, 3.543307, 90, 1.25, 15]; //利用単位への変換値
+SVGLength.prototype._tani = { //単位に番号を振る
+  "pt": 9,
+  "pc": 10,
+  "mm": 7,
+  "cm": 6,
+  "in": 8,
+  "em": 3,
+  "ex": 4,
+  "px": 5,
+  "%":  2
+}
+
+SVGLength.prototype.newValueSpecifiedUnits = function (/*unsigned short*/ unitType, /*float*/ valueInSpecifiedUnits) {
+  this.unitType = unitType;
+  /*float*/ this.value = valueInSpecifiedUnits * this._n[unitType-1];
+  /*float*/ this.valueInSpecifiedUnits = valueInSpecifiedUnits;
+  this._n[1] = 0.01; //初期化
+}
+SVGLength.prototype.convertToSpecifiedUnits = function (/*unsigned short*/ unitType) {
+  this.unitType = unitType;
+  this.valueInSpecifiedUnits = this.value / this._n[unitType-1];
+};
+
+function SVGAnimatedLength( /*string or number*/ d, /*float*/ wort, /*float*/ f) { 
+  /*readonly SVGLength*/ this.baseVal = new SVGLength(d, wort, f);
+  /*readonly SVGLength*/ this.animVal;
+  return this;
+};
+
+function SVGLengthList() {
+/*
     readonly attribute unsigned long numberOfItems;
     void   clear (  )
                     raises( DOMException );
@@ -1858,7 +1871,9 @@
                     raises( DOMException );
     SVGLength appendItem ( in SVGLength newItem )
                     raises( DOMException, SVGException );
-  };
+*/
+  return this;
+};
   interface SVGAnimatedLengthList { 
     readonly attribute SVGLengthList baseVal;
     readonly attribute SVGLengthList animVal;




Sie-announce メーリングリストの案内
アーカイブの一覧に戻る