OSDN Git Service

base.jsを使って、CSSValue系統のインターフェースをすべてオブジェクトに変更
authordhrname <sie-developers@lists.sourceforge.jp>
Tue, 26 Aug 2014 13:25:58 +0000 (22:25 +0900)
committerdhrname <sie-developers@lists.sourceforge.jp>
Tue, 26 Aug 2014 13:25:58 +0000 (22:25 +0900)
org/w3c/dom/css.js
org/w3c/dom/svg.js

index 15a3eb9..5fca9cd 100644 (file)
@@ -250,7 +250,7 @@ base("$CSSStyleDeclaration").mix( {
       /*fill、strokeプロパティは別途、SVGPaintで処理(JavaScriptでは、型キャストを使えないため)\r
        *CSSPrimitiveValueオブジェクトとSVGPaintオブジェクトを最後に置き換える\r
        */\r
-      ti = tg ? tg : new SVGPaint();\r
+      ti = tg ? tg : base("$CSSValue").$SVGColor.$SVGPaint._new$();\r
       paintType =\r
         (this._isRS[value.charAt(0)] || ti._keywords[value]) ?\r
           /*SVGPaint.SVG_PAINTTYPE_RGBCOLOR*/ 1\r
@@ -269,7 +269,7 @@ base("$CSSStyleDeclaration").mix( {
       ti.setPaint(paintType, uri, color, null);\r
       paintType = uri = color = void 0;\r
     } else if (this._isStop[propertyName]) {\r
-      ti = tg ? tg : new SVGColor();\r
+      ti = tg ? tg : base("$CSSValue").$SVGColor._new$();\r
       if (value === "currentColor") {\r
         ti.colorType = /*SVGColor.SVG_COLORTYPE_CURRENTCOLOR*/ 3;\r
       } else {\r
@@ -277,7 +277,7 @@ base("$CSSStyleDeclaration").mix( {
         ti.setRGBColor(value);\r
       }\r
     } else {\r
-      ti = tg ? tg : new CSSPrimitiveValue();\r
+      ti = tg ? tg : base("$CSSValue").$CSSPrimitiveValue.up("$1");\r
     }\r
     ti._priority = priority;\r
     ti.cssText = cssText;\r
@@ -316,24 +316,20 @@ base("$CSSStyleDeclaration").mix( {
   }\r
 });\r
 \r
-function CSSValue() {\r
-};\r
+base("$CSSValue").mix( {\r
 /*    // UnitTypes\r
 CSSValue.CSS_INHERIT                    = 0;\r
 CSSValue.CSS_PRIMITIVE_VALUE            = 1;\r
 CSSValue.CSS_VALUE_LIST                 = 2;\r
 CSSValue.CSS_CUSTOM                     = 3;*/\r
-CSSValue.prototype = {\r
   cssText : "",\r
   cssValueType : /*CSSValue.CSS_CUSTOM*/ 3,\r
   _isDefault : 0 //デフォルトであるかどうか(独自のプロパティ)\r
-};\r
-\r
-function CSSPrimitiveValue() {\r
-};\r
+} );\r
+base("$CSSValue").up("$CSSPrimitiveValue").mix( {\r
 \r
-(function(t) {\r
-/*t.CSS_UNKNOWN                    = 0;\r
+/* var t = CSSPrimitiveValue;\r
+t.CSS_UNKNOWN                    = 0;\r
 t.CSS_NUMBER                     = 1;\r
 t.CSS_PERCENTAGE                 = 2;\r
 t.CSS_EMS                        = 3;\r
@@ -359,29 +355,44 @@ t.CSS_ATTR                       = 22;
 t.CSS_COUNTER                    = 23;\r
 t.CSS_RECT                       = 24;\r
 t.CSS_RGBCOLOR                   = 25;*/\r
-t.prototype = Object._create(CSSValue);\r
-})(CSSPrimitiveValue);\r
 \r
-(function(){\r
-  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に統一)\r
-  this.cssValueType = /*CSSValue.CSS_PRIMITIVE_VALUE*/ 1;\r
-  this.primitiveType = /*CSSPrimitiveValue.CSS_UNKNOWN*/ 0;\r
-  this._value = null;\r
-  this._percent = 0; //単位に%が使われていた場合、このプロパティの数値を1%として使う\r
-  this._empercent = 0;\r
-  this._em = this._ex = this["_%"] = null; //emが単位の場合、getComputedStyleメソッドなどで使う\r
-  /*void*/ this.setFloatValue = function(/*short*/ unitType, /*float*/ floatValue) {\r
+  _n: [1, \r
+        0.01,\r
+        1,\r
+        1,\r
+        1,\r
+        35.43307,\r
+        3.543307,\r
+        90,\r
+        1.25,\r
+        15,\r
+        1,\r
+        180 / Math.PI, 90/100,\r
+        1,\r
+        1000,\r
+        1,\r
+        1000,\r
+        1], //CSS_PX単位への変換値(なお、CSS_SはCSS_MSに、CSS_RADとCSS_GRADはCSS_DEGに、CSS_KHZはCSS_HZに統一)\r
+  cssValueType: /*CSSValue.CSS_PRIMITIVE_VALUE*/ 1,\r
+  primitiveType: /*CSSPrimitiveValue.CSS_UNKNOWN*/ 0,\r
+  _value: null,\r
+  _percent: 0, //単位に%が使われていた場合、このプロパティの数値を1%として使う\r
+  _empercent: 0,\r
+  _em: null,\r
+  _ex: null,\r
+  "_%": null, //emが単位の場合、getComputedStyleメソッドなどで使う\r
+  /*void*/ setFloatValue: function(/*short*/ unitType, /*float*/ floatValue) {\r
     if ((/*CSSPrimitiveValue.CSS_UNKNOWN*/ 0 >= unitType) && (unitType >= /*CSSPrimitiveValue.CSS_STRING*/ 19)) { //浮動小数点数単位型をサポートしないCSS単位である場合\r
       throw new DOMException(/*DOMException.INVALID_ACCESS_ERR*/ 15);\r
     }\r
     this.primitiveType = unitType;\r
     this._value = floatValue * this._n[unitType-1];  //値はあらかじめ、利用しやすいように変換しておく\r
-  };\r
+  },\r
   /*getFloatValueメソッド\r
    *別の単位に変換可能。\r
    */\r
-  this._regd = /[\d\.]+/;\r
-  /*float*/ this.getFloatValue = function(/*short*/ unitType) {\r
+  _regd: /[\d\.]+/,\r
+  /*float*/ getFloatValue: function(/*short*/ unitType) {\r
     if ((/*CSSPrimitiveValue.CSS_UNKNOWN*/ 0 >= unitType) && (unitType >= /*CSSPrimitiveValue.CSS_STRING*/ 19)) { //浮動小数点数単位型をサポートしないCSS単位である場合\r
       throw new DOMException(/*DOMException.INVALID_ACCESS_ERR*/ 15);\r
     }\r
@@ -424,38 +435,38 @@ t.prototype = Object._create(CSSValue);
       tc = n = type = unitType = void 0;\r
       return s;\r
     }\r
-  };\r
-  /*void*/ this.setStringValue = function(/*short*/ stringType, /*string*/ stringValue) {\r
+  },\r
+  /*void*/ setStringValue: function(/*short*/ stringType, /*string*/ stringValue) {\r
     if (/*CSSPrimitiveValue.CSS_DIMENSION*/ 18 >= stringType && stringType >= /*CSSPrimitiveValue.CSS_COUNTER*/ 23) { //文字列型をサポートしないCSS単位である場合\r
       throw new DOMException(/*DOMException.INVALID_ACCESS_ERR*/ 15);\r
     }\r
     this._value = stringValue;\r
-  };\r
-  /*string*/ this.getStringValue = function(/*short*/ stringType) {\r
+  },\r
+  /*string*/ getStringValue: function(/*short*/ stringType) {\r
     if (/*CSSPrimitiveValue.CSS_DIMENSION*/ 18 >= stringType && stringType >= /*CSSPrimitiveValue.CSS_COUNTER*/ 23) { //文字列型をサポートしないCSS単位である場合\r
       throw new DOMException(/*DOMException.INVALID_ACCESS_ERR*/ 15);\r
     }\r
     return (this._value);\r
-  };\r
-  /*Counter*/ this.getCounterValue = function() {\r
+  },\r
+  /*Counter*/ getCounterValue: function() {\r
     if (this.primitiveType !== /*CSSPrimitiveValue.CSS_COUNTER*/ 23) { //Counter型ではないとき\r
       throw new DOMException(/*DOMException.INVALID_ACCESS_ERR*/ 15);\r
     }\r
     return (new Counter());\r
-  };\r
-  /*Rect*/ this.getRectValue = function() {\r
+  },\r
+  /*Rect*/ getRectValue: function() {\r
     if (this.primitiveType !== /*CSSPrimitiveValue.CSS_RECT*/ 24) { //Rect型ではないとき\r
       throw new DOMException(/*DOMException.INVALID_ACCESS_ERR*/ 15);\r
     }\r
     return (new Rect());\r
-  };\r
-  /*RGBColor*/ this.getRGBColorValue = function() {\r
+  },\r
+  /*RGBColor*/ getRGBColorValue: function() {\r
     if (this.primitiveType !== /*CSSPrimitiveValue.CSS_RGBCOLOR*/ 25) { //RGBColor型ではないとき\r
       throw new DOMException(/*DOMException.INVALID_ACCESS_ERR*/ 15);\r
     }\r
     var s = new RGBColor(),\r
         rgbColor = this.cssText,\r
-        n = SVGColor.prototype._keywords[rgbColor];\r
+        n = base("$CSSValue").$SVGColor._keywords[rgbColor];\r
     if (rgbColor.indexOf("%", 5) > 0) {      // %を含むrgb形式の場合\r
       rgbColor = rgbColor.replace(/[\d.]+%/g, function(t) {\r
         return Math.round((2.55 * parseFloat(t)));\r
@@ -471,35 +482,34 @@ t.prototype = Object._create(CSSValue);
     s.blue.setFloatValue(/*CSSPrimitiveValue.CSS_NUMBER*/ 1, parseFloat(n[2]));\r
     n = rgbColor = void 0;\r
     return (s);\r
-  };\r
-}).apply(CSSPrimitiveValue.prototype);\r
+  }\r
+} );\r
 /*CSSValueList\r
  *Arrayで代用する\r
  */\r
-function CSSValueList() {\r
-  this.cssValueType = /*CSSValue.CSS_VALUE_LIST*/ 2;\r
-  this.length = 0;\r
-};\r
-CSSValueList.prototype = Object._create(CSSValue);\r
-/*CSSValue*/ CSSValueList.prototype.item = function( /*long*/ index) {\r
+base("$CSSValue").$CSSPrimitiveValue.up("$CSSValueList").mix( {\r
+  cssValueType: /*CSSValue.CSS_VALUE_LIST*/ 2,\r
+  length: 0,\r
+/*CSSValue*/ item: function( /*long*/ index) {\r
   return (this[index]);\r
-};\r
+}\r
+} );\r
 \r
 function RGBColor() {\r
-  var cs = CSSPrimitiveValue;\r
-  this.red = new cs();\r
-  this.green = new cs();\r
-  this.blue = new cs();\r
+  var cs = base("$CSSValue").$CSSPrimitiveValue;\r
+  this.red = cs.up("$1");\r
+  this.green = cs.up("$1");\r
+  this.blue = cs.up("$1");\r
   cs = void 0;\r
   this.red.primitiveType = this.green.primitiveType = this.blue.primitiveType = /*CSSPrimitiveValue.CSS_NUMBER*/ 1;\r
 };\r
 \r
 function Rect() {\r
-  var cs = CSSPrimitiveValue;\r
-  this.top = new cs();\r
-  this.right = new cs();\r
-  this.bottom = new cs();\r
-  this.left = new cs();\r
+  var cs = base("$CSSValue").$CSSPrimitiveValue;\r
+  this.top = cs.up("$1");\r
+  this.right = cs.up("$1");\r
+  this.bottom = cs.up("$1");\r
+  this.left = cs.up("$1");\r
   cs = void 0;\r
 };\r
 \r
index 898f7fb..1539bb0 100644 (file)
@@ -691,25 +691,23 @@ function SVGAnimatedAngle() {
   /*readonly attribute SVGAngle*/ this.baseVal = new SVGAngle();\r
   /*readonly attribute SVGAngle*/ this.animVal = this.baseVal;\r
 };\r
-function SVGColor() {\r
-  CSSValue.apply(this);\r
-  /*readonly css::RGBColor*/  this.rgbColor  = new RGBColor();\r
-};\r
 \r
+base("$CSSValue").up("$SVGColor").mix( {\r
+  _new$: function() {\r
+    /*readonly css::RGBColor*/  this.up("$1").rgbColor  = new RGBColor();\r
+    return this.$1;\r
+  },\r
   // Color Types\r
 /*unsigned short SVGColor.SVG_COLORTYPE_UNKNOWN           = 0;\r
 /*unsigned short SVGColor.SVG_COLORTYPE_RGBCOLOR          = 1;\r
 /*unsigned short SVGColor.SVG_COLORTYPE_RGBCOLOR_ICCCOLOR = 2;\r
 /*unsigned short SVGColor.SVG_COLORTYPE_CURRENTCOLOR      = 3;*/\r
-SVGColor.prototype = Object._create(CSSValue);  //ノードのプロトタイプチェーンを作って、継承\r
-\r
-(function(){\r
-  /*readonly unsigned short*/ this.colorType = /*SVGColor.SVG_COLORTYPE_UNKNOWN*/ 0;\r
-  /*readonly SVGICCColor*/    this.iccColor = null;\r
-  this._regD = /\d+/g;\r
-  this._regDP = /[\d.]+%/g;\r
-  this._exceptionsvg = /*SVGException.SVG_INVALID_VALUE_ERR*/ 1;\r
-  /*void*/ this.setRGBColor = function(/*DOMString*/ rgbColor ){\r
+  /*readonly unsigned short*/ colorType: /*SVGColor.SVG_COLORTYPE_UNKNOWN*/ 0,\r
+  /*readonly SVGICCColor*/    iccColor: null,\r
+  _regD: /\d+/g,\r
+  _regDP: /[\d.]+%/g,\r
+  _exceptionsvg: /*SVGException.SVG_INVALID_VALUE_ERR*/ 1,\r
+  /*void*/ setRGBColor: function(/*DOMString*/ rgbColor ){\r
   var s,\r
       _parseInt,\r
       r, g, b;\r
@@ -748,10 +746,10 @@ SVGColor.prototype = Object._create(CSSValue);  //ノードのプロトタイプ
   rgbColor.green.setFloatValue(1, s[1]);\r
   rgbColor.blue.setFloatValue(1, s[2]);\r
   rgbColor = s = _parseInt = void 0;\r
-};\r
+},\r
 \r
 //                    raises( SVGException );\r
-/*void*/ this.setColor =function(/*unsigned short*/ colorType, /*DOMString*/ rgbColor, /*DOMString*/ iccColor ){\r
+/*void*/ setColor: function(/*unsigned short*/ colorType, /*DOMString*/ rgbColor, /*DOMString*/ iccColor ){\r
   this.colorType = colorType;\r
   if ((colorType === /*SVGColor.SVG_COLORTYPE_RGBCOLOR*/ 1) && iccColor) {\r
     throw new SVGException(this._exceptionsvg);\r
@@ -765,10 +763,10 @@ SVGColor.prototype = Object._create(CSSValue);  //ノードのプロトタイプ
     throw new SVGException(this._exceptionsvg);\r
   }\r
   colorType = rgbColor = void 0;\r
-};\r
+},\r
 //                    raises( SVGException );\r
 //色キーワード\r
-this._keywords = {\r
+_keywords: {\r
     aliceblue:    [240,248,255],\r
     antiquewhite: [250,235,215],\r
     aqua:         [0,255,255],\r
@@ -916,8 +914,8 @@ this._keywords = {
     whitesmoke:    [245,245,245],\r
     yellow:        [255,255,0],\r
     yellowgreen:   [154,205,50]\r
-};\r
-}).apply(SVGColor.prototype);\r
+}\r
+} );\r
 \r
 function SVGRect() {\r
   /*float*/ this.x      = 0;\r
@@ -4492,13 +4490,7 @@ SVGTextPathElement.prototype = Object._create(SVGTextContentElement);
 })(SVGTextPathElement);\r
 \r
 \r
-function SVGPaint() {\r
-  SVGColor.apply(this);\r
-};\r
-\r
-(function(t){\r
-  var tproto;\r
-  tproto = t.prototype = Object._create(SVGColor);\r
+base("$CSSValue").$SVGColor.up("$SVGPaint").mix( {\r
     // Paint Types\r
   /*unsigned short t.SVG_PAINTTYPE_UNKNOWN               = 0;\r
   /*unsigned short t.SVG_PAINTTYPE_RGBCOLOR              = 1;\r
@@ -4510,12 +4502,13 @@ function SVGPaint() {
   /*unsigned short t.SVG_PAINTTYPE_URI_RGBCOLOR          = 105;\r
   /*unsigned short t.SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR = 106;\r
   /*unsigned short t.SVG_PAINTTYPE_URI                   = 107;*/\r
-  /*readonly unsigned short*/ tproto.paintType = /*t.SVG_PAINTTYPE_UNKNOWN*/ 0;\r
-  /*readonly DOMString*/      tproto.uri = null;\r
-/*void*/ tproto.setUri = function(/*DOMString*/ uri ) {\r
+\r
+  /*readonly unsigned short*/ paintType: /*t.SVG_PAINTTYPE_UNKNOWN*/ 0,\r
+  /*readonly DOMString*/      uri: null,\r
+/*void*/ setUri: function(/*DOMString*/ uri ) {\r
   this.setPaint(/*SVGPaint.SVG_PAINTTYPE_URI_NONE*/ 103, uri, null, null);\r
-};\r
-/*void*/ tproto.setPaint = function(/*unsigned short*/ paintType, /*DOMString*/ uri, /*DOMString*/ rgbColor, /*DOMString*/ iccColor ) {\r
+},\r
+/*void*/ setPaint: function(/*unsigned short*/ paintType, /*DOMString*/ uri, /*DOMString*/ rgbColor, /*DOMString*/ iccColor ) {\r
   if ((paintType < 101 && uri) || (paintType > 102 && !uri)) {\r
     throw new SVGException(/*SVGException.SVG_INVALID_VALUE_ERR*/ 1);\r
   }\r
@@ -4525,10 +4518,9 @@ function SVGPaint() {
     paintType = /*SVGColor.SVG_COLORTYPE_CURRENTCOLOR*/ 3;\r
   }\r
   this.setColor(paintType, rgbColor, iccColor); //SVGColorのsetColorメソッドを用いる\r
-};\r
+}\r
 //                    raises( SVGException );\r
-t = tproto = void 0;\r
-})(SVGPaint);\r
+} ) ;\r
 \r
 function SVGMarkerElement(_doc) {\r
   _doc = void 0;\r
@@ -5802,7 +5794,7 @@ function SVGAnimateElement(){
       } else if (!!CSS2Properties[attrName] || attrName.indexOf("-") > -1) { //スタイルシートのプロパティならば\r
         for (var i=0, tav=tar._values, tvli=tav.length;i<tvli;++i) {\r
           if ((attrName === "fill") || (attrName === "stroke") || (attrName === "stop-color")) {\r
-            tar._valueList[i] = new SVGPaint();\r
+            tar._valueList[i] = base("$CSSValue").$SVGColor.$SVGPaint._new$();\r
             tar._valueList[i].setPaint(1, null, tav[i], null);\r
           } else {\r
             tar._valueList[i] = parseFloat(tav[i]);\r
@@ -6161,7 +6153,7 @@ function SVGAnimateColorElement() {
         tar._values[0] = fstyle.getPropertyValue(attrName);\r
       }\r
       for (var i=0, tav=tar._values, tvli=tav.length;i<tvli;++i) {\r
-        var to = new SVGColor();\r
+        var to = base("$CSSValue").$SVGColor._new$();\r
         if (tar._values[i] === "currentColor") {\r
           to.setRGBColor(fstyle.getPropertyValue("color") || "black");\r
         } else if (tar._values[i] === "inherit") {\r
@@ -6755,7 +6747,7 @@ function unsvgtovml() {
     window.onscroll = NAIBU.emptyFunction;\r
     window.detachEvent("onload", NAIBU._main);\r
     NAIBU.freeArg();\r
-    base = Object._create = SVGElement = CSS2Properties = CSSValue = CSSPrimitiveValue = NAIBU.xmlhttp = NAIBU = STLog = SVGColor = SVGPaint = void 0;\r
+    base = Object._create = SVGElement = CSS2Properties = NAIBU.xmlhttp = NAIBU = STLog =  void 0;\r
     Array = ActiveXObject = void 0;\r
   } catch(e) {}\r
 }\r