[Sie-announce] SIEコード [2612] CSSPrimitiveValue. prototypeの設定について整理

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2011年 4月 19日 (火) 20:00:05 JST


Revision: 2612
          http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=2612
Author:   dhrname
Date:     2011-04-19 20:00:05 +0900 (Tue, 19 Apr 2011)

Log Message:
-----------
CSSPrimitiveValue.prototypeの設定について整理

Modified Paths:
--------------
    branches/07x/076/org/w3c/dom/css.js

Modified: branches/07x/076/org/w3c/dom/css.js
===================================================================
--- branches/07x/076/org/w3c/dom/css.js	2011-04-19 10:52:44 UTC (rev 2611)
+++ branches/07x/076/org/w3c/dom/css.js	2011-04-19 11:00:05 UTC (rev 2612)
@@ -404,113 +404,115 @@
 CSSPrimitiveValue.CSS_RGBCOLOR                   = 25;
 CSSPrimitiveValue.prototype = new CSSValue();
 CSSPrimitiveValue.constructor = CSSValue;
-CSSPrimitiveValue.prototype._n = [1, 0.01, 1, 1, 1, 35.43307, 3.543307, 90, 1.25, 15, 1, 180 / Math.PI, 90/100, 1, 1000, 1, 1000, 1]; //CSS_PX単位への変換値(なお、CSS_SはCSS_MSに、CSS_RADとCSS_GRADはCSS_DEGに、CSS_KHZはCSS_HZに統一)
-CSSPrimitiveValue.prototype.cssValueType = CSSValue.CSS_PRIMITIVE_VALUE;
-CSSPrimitiveValue.prototype.primitiveType = CSSPrimitiveValue.CSS_UNKNOWN;
-CSSPrimitiveValue.prototype._value = 1;
-CSSPrimitiveValue.prototype._percent = 0; //単位に%が使われていた場合、このプロパティの数値を1%として使う
-CSSPrimitiveValue.prototype._empercent = 0;
-/*void*/ CSSPrimitiveValue.prototype.setFloatValue = function(/*short*/ unitType, /*float*/ floatValue) {
-  if ((/*CSSPrimitiveValue.CSS_UNKNOWN*/ 0 >= unitType) && (unitType >= /*CSSPrimitiveValue.CSS_STRING*/ 19)) { //浮動小数点数単位型をサポートしないCSS単位である場合
-    throw new DOMException(DOMException.INVALID_ACCESS_ERR);
-  }
-  this.primitiveType = unitType;
-  this._value = floatValue * this._n[unitType-1];  //値はあらかじめ、利用しやすいように変換しておく
-};
-/*getFloatValueメソッド
- *別の単位に変換可能。
- */
-CSSPrimitiveValue.prototype._regD = /\D+$/;
-CSSPrimitiveValue.prototype._regd = /[\d\.]+/;
-/*float*/ CSSPrimitiveValue.prototype.getFloatValue = function(/*short*/ unitType) {
-  if ((/*CSSPrimitiveValue.CSS_UNKNOWN*/ 0 >= unitType) && (unitType >= /*CSSPrimitiveValue.CSS_STRING*/ 19)) { //浮動小数点数単位型をサポートしないCSS単位である場合
-    throw new DOMException(DOMException.INVALID_ACCESS_ERR);
-  }
-  var n = this.cssText.match(this._regD),
-      type = 0,
-      s = +(this.cssText.match(this._regd));
-  s = isNaN(s) ? 0 : s;
-  if (!!n) {
-    n = n[0];
-  }
-  if (!n) {
-    type = /*CSSPrimitiveValue.CSS_NUMBER*/ 1;
-  } else if (n === "%") {
-    s *= this._percent;
-    type = /*CSSPrimitiveValue.CSS_PERCENTAGE*/ 2;
-  } else if (n === "em") {
-    s *= this._empercent;
-    type = /*CSSPrimitiveValue.CSS_EMS*/ 3;
-  } else if (n === "ex") {
-    type = /*CSSPrimitiveValue.CSS_EXS*/ 4;
-  } else if (n === "px") {
-    type = /*CSSPrimitiveValue.CSS_PX*/ 5;
-  } else if (n === "cm") {
-    type = /*CSSPrimitiveValue.CSS_CM*/ 6;
-  } else if (n === "mm") {
-    type = /*CSSPrimitiveValue.CSS_MM*/ 7;
-  } else if (n === "in") {
-    type = /*CSSPrimitiveValue.CSS_IN*/ 8;
-  } else if (n === "pt") {
-    type = /*CSSPrimitiveValue.CSS_PT*/ 9;
-  } else if (n === "pc") {
-    type = /*CSSPrimitiveValue.CSS_PC*/ 10;
-  }
-  this._value = s * this._n[type-1];  //値はあらかじめ、利用しやすいように変換しておく
-  n = type = s = null;
-  return (this._value / this._n[unitType-1]);
-};
-/*void*/ CSSPrimitiveValue.prototype.setStringValue = function(/*short*/ stringType, /*string*/ stringValue) {
-  if (CSSPrimitiveValue.CSS_DIMENSION >= stringType && stringType >= CSSPrimitiveValue.CSS_COUNTER) { //文字列型をサポートしないCSS単位である場合
-    throw new DOMException(DOMException.INVALID_ACCESS_ERR);
-  }
-  this._value = stringValue;
-};
-/*string*/ CSSPrimitiveValue.prototype.getStringValue = function(/*short*/ stringType) {
-  if (CSSPrimitiveValue.CSS_DIMENSION >= stringType && stringType >= CSSPrimitiveValue.CSS_COUNTER) { //文字列型をサポートしないCSS単位である場合
-    throw new DOMException(DOMException.INVALID_ACCESS_ERR);
-  }
-  return (this._value);
-};
-/*Counter*/ CSSPrimitiveValue.prototype.getCounterValue = function() {
-  if (this.primitiveType !== CSSPrimitiveValue.CSS_COUNTER) { //Counter型ではないとき
-    throw new DOMException(DOMException.INVALID_ACCESS_ERR);
-  }
-  return (new Counter());
-};
-/*Rect*/ CSSPrimitiveValue.prototype.getRectValue = function() {
-  if (this.primitiveType !== CSSPrimitiveValue.CSS_RECT) { //Rect型ではないとき
-    throw new DOMException(DOMException.INVALID_ACCESS_ERR);
-  }
-  return (new Rect());
-};
-/*RGBColor*/ CSSPrimitiveValue.prototype.getRGBColorValue = function() {
-  if (this.primitiveType !== CSSPrimitiveValue.CSS_RGBCOLOR) { //RGBColor型ではないとき
-    throw new DOMException(DOMException.INVALID_ACCESS_ERR);
-  }
-  var s = new RGBColor();
-  var rgbColor = this.cssText;
-  var tkr = SVGColor.prototype._keywords[rgbColor];
-  if (tkr !== void 0) {
-    rgbColor = tkr;
-  }
-  if (rgbColor.indexOf("%", 5) > 0) {      // %を含むrgb形式の場合
-    rgbColor = rgbColor.replace(/[\d.]+%/g, function(t) {
-      return Math.round((2.55 * parseFloat(t)));
-    });
-  } else if (rgbColor.indexOf("#") > -1) {  //#を含む場合
-    rgbColor = rgbColor.replace(/[\da-f][\da-f]/gi, function(s) {
-      return parseInt(s, 16);
-    });
-  }
-  var n = rgbColor.match(/\d+/g);
-  s.red.setFloatValue(CSSPrimitiveValue.CSS_NUMBER, parseFloat(n[0]));
-  s.green.setFloatValue(CSSPrimitiveValue.CSS_NUMBER, parseFloat(n[1]));
-  s.blue.setFloatValue(CSSPrimitiveValue.CSS_NUMBER, parseFloat(n[2]));
-  n = rgbColor = null;
-  return (s);
-};
 
+(function(){
+  this._n = [1, 0.01, 1, 1, 1, 35.43307, 3.543307, 90, 1.25, 15, 1, 180 / Math.PI, 90/100, 1, 1000, 1, 1000, 1]; //CSS_PX単位への変換値(なお、CSS_SはCSS_MSに、CSS_RADとCSS_GRADはCSS_DEGに、CSS_KHZはCSS_HZに統一)
+  this.cssValueType = CSSValue.CSS_PRIMITIVE_VALUE;
+  this.primitiveType = CSSPrimitiveValue.CSS_UNKNOWN;
+  this._value = 1;
+  this._percent = 0; //単位に%が使われていた場合、このプロパティの数値を1%として使う
+  this._empercent = 0;
+  /*void*/ this.setFloatValue = function(/*short*/ unitType, /*float*/ floatValue) {
+    if ((/*CSSPrimitiveValue.CSS_UNKNOWN*/ 0 >= unitType) && (unitType >= /*CSSPrimitiveValue.CSS_STRING*/ 19)) { //浮動小数点数単位型をサポートしないCSS単位である場合
+      throw new DOMException(DOMException.INVALID_ACCESS_ERR);
+    }
+    this.primitiveType = unitType;
+    this._value = floatValue * this._n[unitType-1];  //値はあらかじめ、利用しやすいように変換しておく
+  };
+  /*getFloatValueメソッド
+   *別の単位に変換可能。
+   */
+  this._regD = /\D+$/;
+  this._regd = /[\d\.]+/;
+  /*float*/ this.getFloatValue = function(/*short*/ unitType) {
+    if ((/*CSSPrimitiveValue.CSS_UNKNOWN*/ 0 >= unitType) && (unitType >= /*CSSPrimitiveValue.CSS_STRING*/ 19)) { //浮動小数点数単位型をサポートしないCSS単位である場合
+      throw new DOMException(DOMException.INVALID_ACCESS_ERR);
+    }
+    var n = this.cssText.match(this._regD),
+        type = 0,
+        s = +(this.cssText.match(this._regd));
+    s = isNaN(s) ? 0 : s;
+    if (!!n) {
+      n = n[0];
+    }
+    if (!n) {
+      type = /*CSSPrimitiveValue.CSS_NUMBER*/ 1;
+    } else if (n === "%") {
+      s *= this._percent;
+      type = /*CSSPrimitiveValue.CSS_PERCENTAGE*/ 2;
+    } else if (n === "em") {
+      s *= this._empercent;
+      type = /*CSSPrimitiveValue.CSS_EMS*/ 3;
+    } else if (n === "ex") {
+      type = /*CSSPrimitiveValue.CSS_EXS*/ 4;
+    } else if (n === "px") {
+      type = /*CSSPrimitiveValue.CSS_PX*/ 5;
+    } else if (n === "cm") {
+      type = /*CSSPrimitiveValue.CSS_CM*/ 6;
+    } else if (n === "mm") {
+      type = /*CSSPrimitiveValue.CSS_MM*/ 7;
+    } else if (n === "in") {
+      type = /*CSSPrimitiveValue.CSS_IN*/ 8;
+    } else if (n === "pt") {
+      type = /*CSSPrimitiveValue.CSS_PT*/ 9;
+    } else if (n === "pc") {
+      type = /*CSSPrimitiveValue.CSS_PC*/ 10;
+    }
+    this._value = s * this._n[type-1];  //値はあらかじめ、利用しやすいように変換しておく
+    n = type = s = null;
+    return (this._value / this._n[unitType-1]);
+  };
+  /*void*/ this.setStringValue = function(/*short*/ stringType, /*string*/ stringValue) {
+    if (CSSPrimitiveValue.CSS_DIMENSION >= stringType && stringType >= CSSPrimitiveValue.CSS_COUNTER) { //文字列型をサポートしないCSS単位である場合
+      throw new DOMException(DOMException.INVALID_ACCESS_ERR);
+    }
+    this._value = stringValue;
+  };
+  /*string*/ this.getStringValue = function(/*short*/ stringType) {
+    if (CSSPrimitiveValue.CSS_DIMENSION >= stringType && stringType >= CSSPrimitiveValue.CSS_COUNTER) { //文字列型をサポートしないCSS単位である場合
+      throw new DOMException(DOMException.INVALID_ACCESS_ERR);
+    }
+    return (this._value);
+  };
+  /*Counter*/ this.getCounterValue = function() {
+    if (this.primitiveType !== CSSPrimitiveValue.CSS_COUNTER) { //Counter型ではないとき
+      throw new DOMException(DOMException.INVALID_ACCESS_ERR);
+    }
+    return (new Counter());
+  };
+  /*Rect*/ this.getRectValue = function() {
+    if (this.primitiveType !== CSSPrimitiveValue.CSS_RECT) { //Rect型ではないとき
+      throw new DOMException(DOMException.INVALID_ACCESS_ERR);
+    }
+    return (new Rect());
+  };
+  /*RGBColor*/ this.getRGBColorValue = function() {
+    if (this.primitiveType !== CSSPrimitiveValue.CSS_RGBCOLOR) { //RGBColor型ではないとき
+      throw new DOMException(DOMException.INVALID_ACCESS_ERR);
+    }
+    var s = new RGBColor();
+    var rgbColor = this.cssText;
+    var tkr = SVGColor.prototype._keywords[rgbColor];
+    if (tkr !== void 0) {
+      rgbColor = tkr;
+    }
+    if (rgbColor.indexOf("%", 5) > 0) {      // %を含むrgb形式の場合
+      rgbColor = rgbColor.replace(/[\d.]+%/g, function(t) {
+        return Math.round((2.55 * parseFloat(t)));
+      });
+    } else if (rgbColor.indexOf("#") > -1) {  //#を含む場合
+      rgbColor = rgbColor.replace(/[\da-f][\da-f]/gi, function(s) {
+        return parseInt(s, 16);
+      });
+    }
+    var n = rgbColor.match(/\d+/g);
+    s.red.setFloatValue(CSSPrimitiveValue.CSS_NUMBER, parseFloat(n[0]));
+    s.green.setFloatValue(CSSPrimitiveValue.CSS_NUMBER, parseFloat(n[1]));
+    s.blue.setFloatValue(CSSPrimitiveValue.CSS_NUMBER, parseFloat(n[2]));
+    n = rgbColor = null;
+    return (s);
+  };
+}).apply(CSSPrimitiveValue.prototype);
 /*CSSValueList
  *Arrayで代用する
  */




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