[Sie-announce] SIEコード [2287] createSVGLengthメソッドにおいて、unitTypeプロパティ設定に仕様と矛盾するミスがあったので、修正。

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2011年 1月 10日 (月) 22:30:04 JST


Revision: 2287
          http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=2287
Author:   dhrname
Date:     2011-01-10 22:30:03 +0900 (Mon, 10 Jan 2011)

Log Message:
-----------
createSVGLengthメソッドにおいて、unitTypeプロパティ設定に仕様と矛盾するミスがあったので、修正。
SVGLengthも修正を開始

Modified Paths:
--------------
    branches/06x/068/org/w3c/dom/svg.js

Modified: branches/06x/068/org/w3c/dom/svg.js
===================================================================
--- branches/06x/068/org/w3c/dom/svg.js	2011-01-09 13:34:59 UTC (rev 2286)
+++ branches/06x/068/org/w3c/dom/svg.js	2011-01-10 13:30:03 UTC (rev 2287)
@@ -497,6 +497,7 @@
   /*attribute float*/          this.valueInSpecifiedUnits = SVGLength.SVG_LENGTHTYPE_UNKNOWN;  //unitTypeにおける値
   /*attribute DOMString*/      this.valueAsString;
   this._percent = 0.01; //単位に%が使われていた場合、このプロパティの数値を1%として使う
+  return this;
 };
     // Length Unit Types
   /*const unsigned short*/ SVGLength.SVG_LENGTHTYPE_UNKNOWN    = 0;
@@ -511,43 +512,44 @@
   /*const unsigned short*/ SVGLength.SVG_LENGTHTYPE_PT         = 9;
   /*const unsigned short*/ SVGLength.SVG_LENGTHTYPE_PC         = 10;
 
+SVGLength.prototype = {
 /*newValueSpedifiedUnitsメソッド
  *新しくunitTypeにおける値を設定する
  *例:2pxならば、x.newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_PX, 2);となる
  */
-SVGLength.prototype.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_PERCENTAGE) {
-    n = this._percent;
-    _s = "%"
-  } else if (unitType === SVGLength.SVG_LENGTHTYPE_EMS) {
-    n = this._percent * 100;
-    _s = "em";
-  } else if (unitType === SVGLength.SVG_LENGTHTYPE_EXS) {
-    _s = "ex";
-  } else if (unitType === SVGLength.SVG_LENGTHTYPE_CM) {
-    n = 35.43307;
-    _s = "cm";
-  } else if (unitType === SVGLength.SVG_LENGTHTYPE_MM) {
-    n = 3.543307;
-    _s = "mm";
-  } else if (unitType === SVGLength.SVG_LENGTHTYPE_IN) {
-    n = 90;
-    _s = "in";
-  } else if (unitType === SVGLength.SVG_LENGTHTYPE_PT) {
-    n = 1.25;
-    _s = "pt";
-  } else if (unitType === SVGLength.SVG_LENGTHTYPE_PC) {
-    n = 15;
-    _s = "pc";
-  }
-  this.unitType = unitType;
-  this.value = valueInSpecifiedUnits * n;
-  this.valueInSpecifiedUnits = valueInSpecifiedUnits;
-  this.valuAsString = valueInSpecifiedUnits + _s;
-  n = _s = null;
-};
+  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_PERCENTAGE) {
+      n = this._percent;
+      _s = "%"
+    } else if (unitType === SVGLength.SVG_LENGTHTYPE_EMS) {
+      n = this._percent * 100;
+      _s = "em";
+    } else if (unitType === SVGLength.SVG_LENGTHTYPE_EXS) {
+      _s = "ex";
+    } else if (unitType === SVGLength.SVG_LENGTHTYPE_CM) {
+      n = 35.43307;
+      _s = "cm";
+    } else if (unitType === SVGLength.SVG_LENGTHTYPE_MM) {
+      n = 3.543307;
+      _s = "mm";
+    } else if (unitType === SVGLength.SVG_LENGTHTYPE_IN) {
+      n = 90;
+      _s = "in";
+    } else if (unitType === SVGLength.SVG_LENGTHTYPE_PT) {
+      n = 1.25;
+      _s = "pt";
+    } else if (unitType === SVGLength.SVG_LENGTHTYPE_PC) {
+      n = 15;
+      _s = "pc";
+    }
+    this.unitType = unitType;
+    this.value = valueInSpecifiedUnits * n;
+    this.valueInSpecifiedUnits = valueInSpecifiedUnits;
+    this.valuAsString = valueInSpecifiedUnits + _s;
+    n = _s = null;
+  },
 /*convertToSpecifiedUnitsメソッド
  *valueプロパティを書き換えずに、単位だけを変換する
  *例:2cmをmmに変換したい場合
@@ -555,10 +557,10 @@
  * x.convertToSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_MM);
  * alert(x.valueAsString); //20mm
  */
-SVGLength.prototype.convertToSpecifiedUnits = function (/*unsigned short*/ unitType) {
-  this.newValueSpecifiedUnits(unitType, this.valueInSpecifiedUnits);
+  convertToSpecifiedUnits : function (/*unsigned short*/ unitType) {
+    this.newValueSpecifiedUnits(unitType, this.valueInSpecifiedUnits);
+  }
 };
-
 function SVGAnimatedLength() {
   /*readonly SVGLength*/ this.animVal;
   this.baseVal = new SVGLength();
@@ -1159,6 +1161,7 @@
 };
 /*SVGLength*/     SVGSVGElement.prototype.createSVGLength = function(){
   var s = new SVGLength();
+  s.unitType = /*SVG_LENGTHTYPE_NUMBER*/ 1;
   return s;
 };
 /*SVGPoint*/      SVGSVGElement.prototype.createSVGPoint = function(){




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