OSDN Git Service

Version 0.6.37, bugfix.
[pettanr/clientJs.git] / 0.6.x / js / dom / 15_XDomStyle.js
1
2
3 /*
4  * style 値の変更は、enterFrame 後にまとめて適用
5  * width(), height(), x(), y() 1em の取得時にも適用
6  * css3 の ie用 fix は X.UI レベルで行う
7  * 
8  * use X.Dom.Event
9  */
10 X.Dom.Style = {
11         
12         Type : {
13                 LENGTH            : 1,
14                 PERCENT           : 2,
15                 COLOR             : 2 < 2,
16                 U_DECIMAL         : 2 < 3,
17                 NUMERICAL         : 2 < 4,
18                 BOOLEAN           : 2 < 5,
19                 QUARTET           : 2 < 6,
20                 URL               : 2 < 7,
21                 FONT_NAME         : 2 < 8,
22                 TIME              : 2 < 9,
23                 CONTENT           : 2 < 10,
24                 LIST              : 2 < 11,
25                 AUTO              : 2 < 12,
26                 COMBI             : 2 < 13
27         },
28         
29         SPECIAL_VALUES : {
30                 AUTO : Number.POSITIVE_INFINITY,
31                 FULL : X.Dom // something unigue value; 100%
32         },
33         
34         PropNo : {},
35         
36         UNIT : {
37                 'px'   : 0,
38                 'em'   : 1,
39                 'cm'   : 2,
40                 'mm'   : 3,
41                 'in'   : 4,
42                 '%'    : 5,
43                 'pct'  : 5,
44                 'ms'   : 6,
45                 's'    : 7,
46                 '#'    : 8,
47                 'rgb'  : 9,
48                 'rgba' : 10
49         },
50         
51         /* font-size -> fontSize */
52         _DICTIONARY_CAMELIZE : {},
53         
54         camelize : function( cssProp ){
55                 var me  = X.Dom.Style,
56                         parts, l, i, camelized;
57                 
58                 if( camelized = me._DICTIONARY_CAMELIZE[ cssProp ] ) return camelized;
59                 parts = cssProp.split( ' ' ).join( '' ).split( '-' );
60                 l     = parts.length;
61                 if( l === 1 ) return parts[ 0 ];
62                 
63                 camelized = cssProp.charAt(0) === '-'
64                   ? parts[ 0 ].charAt( 0 ).toUpperCase() + parts[ 0 ].substring( 1 )
65                   : parts[ 0 ];
66                 
67                 for( i = 1; i < l; ++i ){
68                         camelized += parts[ i ].charAt( 0 ).toUpperCase() + parts[ i ].substring( 1 );
69                 };
70                 return me._DICTIONARY_CAMELIZE[ cssProp ] = camelized;
71         },
72         
73         /* fontSize -> font-size */
74         CHAR_CODE_A : 'A'.charCodeAt( 0 ),
75         
76         _DICTIONARY_UNCAMELIZE : {},
77         
78         uncamelize : function( str ){
79                 var me  = X.Dom.Style,
80                         A   = me.CHAR_CODE_A,
81                         Z   = A + 25,
82                         uncamelized, l, chr, code;
83                 str = str.split( ' ' ).join( '' );
84                 if( uncamelized = me._DICTIONARY_UNCAMELIZE[ str ] ) return uncamelized;
85                 uncamelized = '';
86                 for( i = 0, l = str.length; i < l; ++i ){
87                         chr = str.charAt( i );
88                         code = chr.charCodeAt( 0 );
89                         uncamelized += ( A <= code && code <= Z ) ? '-' + chr : chr;
90                 };
91                 return me._DICTIONARY_UNCAMELIZE[ str ] = uncamelized.toLowerCase();
92         },
93         
94 /*
95  * CSS における display, position, float プロパティの相互関係
96  * http://d.hatena.ne.jp/elm200/20080201/1201874740
97  * 
98  * CSS21:9.7 Relationships between ’display’, ’position’, and ’float’ 
99  * http://www.w3.org/TR/CSS21/visuren.html#dis-pos-flo
100  * 
101  *   display:none? -yes-> 非表示
102  *    ↓
103  *   position:absolute? -yes-> float:none,display:block;
104  *    ↓
105  *   float:none? -no-> display:block;
106  *    ↓
107  *   display:そのまま
108  * 
109  *
110 display         position                        float
111 block           static|relative         none
112 block           static|relative         right|left
113 block           absolute                        none
114 inline          static|relative         none
115
116 _DISPLAY_NONE
117 _ABSOLUTE_BOX
118 _FLOAT_BOX
119 _GRNERAL
120  */
121         objToCssText : function( obj ){
122                 var css           = [],
123                         me            = X.Dom.Style,
124                         uncamelize    = me.uncamelize,
125                         VENDER_PREFIX = me.VENDER_PREFIX,
126                         FIX_PROP      = me.SPECIAL_FIX_PROP,
127                         SPECIAL_FIX   = me.SPECIAL_FIX,
128                         n             = -1,
129                         p, name, sp;
130                 for( p in obj ){
131                         name = uncamelize( p );
132                         if( FIX_PROP[ name ] ){
133                                 sp = 1;
134                         } else {
135                                 css[ ++n ] = [ VENDER_PREFIX[ name ] || name, obj[ p ] ].join( ':' );
136                         };
137                 };
138                 sp && ( css[ ++n ] = 'filter:' + SPECIAL_FIX( obj ) );
139                 return css.join( ';' );
140         },
141         
142         IE_FILTER_FIX :
143                 X.UA.IE && X.UA.IE < 9 ?
144                         {
145                                 opacity : 1,
146                                 textShadow : 1
147                         } :
148                 9 <= X.UA.IE && X.UA.IE < 10 ? // == 9
149                         {} :
150                         {},
151         
152         _UNIT_RATIO      : null,
153         _FONT_SIZE_RATIO : null,
154
155         //  https://developer.mozilla.org/en-US/docs/Web/CSS/transform
156         //  Firefox 3.5, ie9, Opera 10.5, Safari 3.1, Chrome
157         //  3D support Firefox 10, ie10, Safari 4.0, Chrome 12.0
158         // transform : void 0,
159         
160         //  https://developer.mozilla.org/ja/docs/Web/Guide/CSS/Using_CSS_transitions
161         //  Chrome 1.0, Firefox 4.0, ie10, Opera 10.5, Safari 3.2
162         //  Android 2.1, Firefox Android 4.0, Opera Mobile 10, Safari Mobile 3.2        
163         // transition : void 0
164         
165         // ブラウザ毎の getComputedStyle の戻り値 http://d.hatena.ne.jp/uupaa/20080928/1222543331
166
167         COLOR : {
168                 BLACK         : 0x0,
169                 RED           : 0xFF0000,
170                 LIME          : 0x00FF00,
171                 BLUE          : 0x0000FF,
172                 YELLOW        : 0xFFFF00,
173                 AQUA          : 0x00FFFF,
174                 CYAN          : 0x00FFFF,
175                 MAGENTA       : 0xFF00FF,
176                 FUCHSIA       : 0xFF00FF,
177                 WHITE         : 0xFFFFFF,
178                 GREEN         : 0x008000,
179                 PURPLE        : 0x800080,
180                 MAROON        : 0x800000,
181                 NAVY          : 0x000080,
182                 OLIVE         : 0x808000,
183                 TEAL          : 0x008080,
184                 GRAY          : 0x808080,
185                 SILVER        : 0xC0C0C0,
186                 DIMGRAY       : 0x696969,
187                 SLATEGRAY     : 0x708090,
188                 DARKGRAY      : 0xA9A9A9,
189                 GAINSBORO     : 0xDCDCDC,
190                 MIDNIGHTBLUE  : 0x191970,
191                 SLATEBLUE     : 0x6A5ACD,
192                 MEDIUMBLUE    : 0x0000CD,
193                 ROYALBLUE     : 0x4169E1,
194                 DODGERBLUE    : 0x1E90FF,
195                 SKYBLUE       : 0x87CEEB,
196                 STEELBLUE     : 0x4682B4,
197                 LIGHTBLUE     : 0xADD8E6,
198                 PALETURQUOISE : 0xAFEEEE,
199                 TURQUOISE     : 0x40E0D0,
200                 LIGHTCYAN     : 0xE0FFFF,
201                 AQUAMARINE    : 0x7FFFD4,
202                 DARKGREEN     : 0x006400,
203                 SEAGREEN      : 0x2E8B57,
204                 LIGHTGREEN    : 0x90EE90,
205                 CHARTREUSE    : 0x7FFF00,
206                 GREENYELLOW   : 0xADFF2F,
207                 LIMEGREEN     : 0x32CD32,
208                 YELLOWGREEN   : 0x9ACD32,
209                 OLIVEDRAB     : 0x6B8E23,
210                 DARKKHAKI     : 0xBCB76B,
211                 PALEGOLDENROD : 0xEEE8AA,
212                 LIGHTYELLOW   : 0xFFFFE0,
213                 GOLD          : 0xFFD700,
214                 GOLDENROD     : 0xDAA520,
215                 DARKGOLDENROD : 0xB8860B,
216                 ROSYBROWN     : 0xBC8F8F,
217                 INDIANRED     : 0xCD5C5C,
218                 SADDLEBROWN   : 0x8B4513,
219                 SIENNA        : 0xA0522D,
220                 PERU          : 0xCD853F,
221                 BURLYWOOD     : 0xDEB887,
222                 BEIGE         : 0xF5F5DC,
223                 WHEAT         : 0xF5DEB3,
224                 SANDYBROWN    : 0xF4A460,
225                 TAN           : 0xD2B48C,
226                 CHOCOLATE     : 0xD2691E,
227                 FIREBRICK     : 0xB22222,
228                 BROWN         : 0xA52A2A,
229                 SALMON        : 0xFA8072,
230                 ORANGE        : 0xFFA500,
231                 CORAL         : 0xFF7F50,
232                 TOMATO        : 0xFF6347,
233                 HOTPINK       : 0xFF69B4,
234                 PINK          : 0xFFC0CB,
235                 DEEPPINK      : 0xFF1493,
236                 PALEVIOLETRED : 0xDB7093,
237                 VIOLET        : 0xEE82EE,
238                 PLUM          : 0xDDA0DD,
239                 ORCHILD       : 0xDA70D6,
240                 DARKVIOLET    : 0x9400D3,
241                 BLUEVIOLET    : 0x8A2BE2,
242                 MEDIUMPURPLE  : 0x9370DB,
243                 THISTLE       : 0xD8BFD8,
244                 LAVENDER      : 0xE6E6FA,
245                 MISTYROSE     : 0xFFE4E1,
246                 IVORY         : 0xFFFFF0,
247                 LEMONCHIFFON  : 0xFFFACD
248         },
249         
250         parseColor : function( x ){
251                 var rgb, r, g, b;
252                 
253                 if( X.Type.isNumber( x ) ){
254                         return ( 0x0 <= x && x <= 0xFFFFFF ) ? x : undefined;
255                 } else
256                 if( !X.Type.isString( x ) ) return;
257                 
258                 if( X.Type.isNumber( rgb = X.Dom.Style.COLOR[ x.toUpperCase() ] ) && 0x0 <= rgb && rgb <= 0xFFFFFF ){
259                         return rgb;
260                 } else
261                 if( x.charAt( 0 ) === '#' ){
262                         switch( x.length ){
263                                 case 7 :
264                                         r = parseInt( x.substr( 1, 2 ), 16 );
265                                         g = parseInt( x.substr( 3, 2 ), 16 );
266                                         b = parseInt( x.substr( 5, 2 ), 16 );
267                                         break;
268                                 case 4 :
269                                         r = parseInt( x.charAt( 1 ) + x.charAt( 1 ), 16 );
270                                         g = parseInt( x.charAt( 2 ) + x.charAt( 2 ), 16 );
271                                         b = parseInt( x.charAt( 3 ) + x.charAt( 3 ), 16 );
272                                         break;
273                                 case 2 :
274                                         r = g = b = parseInt( x.charAt( 1 ) + x.charAt( 1 ), 16 );
275                                         break;
276                                 default :
277                                         return;                                                                                 
278                         };
279                 } else
280                 if( x.indexOf( 'rgb(' ) === 0 ){
281                         rgb = x.substr( 4 ).split( ',' );
282                         r = parseFloat( rgb[ 0 ] );
283                         g = parseFloat( rgb[ 1 ] );
284                         b = parseFloat( rgb[ 2 ] );
285                         if( x.indexOf( '%' ) !== -1 ){
286                                 r *= 2.55;
287                                 g *= 2.55;
288                                 b *= 2.55;
289                         };
290                 } else
291                 if( x.indexOf( 'rgba(' ) === 0 ){
292                         rgb = x.substr( 5 ).split( ',' );
293                         r = parseFloat( rgb[ 0 ] );
294                         g = parseFloat( rgb[ 1 ] );
295                         b = parseFloat( rgb[ 2 ] );
296                         //a = parseFloat( rgb[ 3 ] );
297                         if( x.indexOf( '%' ) !== -1 ){
298                                 r *= 2.55;
299                                 g *= 2.55;
300                                 b *= 2.55;
301                         };
302                 } else {
303                         return undefined;
304                 };
305                 return isFinite( r + b + g ) ? ( r << 16 ) + ( g << 8 ) + b : undefined;
306         },
307         
308         PARAMS : ( function(){
309                 var ret = {};
310                 register( ret.percent = {},
311                         'marginBottom,marginLeft,marginRight,marginTop,paddingBottom,paddingLeft,paddingRight,paddingTop,fontSize,textIndent'
312                 );
313                 register( ret.offset = {},
314                         'height,width,bottom,left,right,top'
315                 );              
316                 register( ret.size = {},
317                         'borderBottomWidth,borderLeftWidth,borderRightWidth,borderTopWidth,letterSpacing,wordSpacing'
318                 );
319                 register( ret.color = {},
320                         'backgroundColor,borderBottomColor,borderLeftColor,borderRightColor,borderTopColor,color'
321                 );
322                 register( ret.region = {},
323                         'margin,padding,borderWidth,borderColor'
324                 );              
325                 register( ret.special = {},
326                         'clip,backgroundPosition,backgroundPositionX,backgroundPositionY,opacity,lineHeight,zIndex'
327                 );
328                 register( ret.unit = {}, 'px,cm,mm,in,pt,pc,em,%' );
329                 
330                 register( ret.margin = {}, 'marginBottom,marginLeft,marginRight,marginTop,paddingBottom' );
331                 register( ret.padding = {}, 'paddingBottom,paddingLeft,paddingRight,paddingTop' );
332                 register( ret.borderWidth = {}, 'borderBottomWidth,borderLeftWidth,borderRightWidth,borderTopWidth' );
333                 register( ret.borderColor = {}, 'borderBottomColor,borderLeftColor,borderRightColor,borderTopColor' );
334                 
335                 function register( obj, params ){
336                         params = params.split( ',' );
337                         for( var i = params.length; i; ) obj[ params[ --i ] ] = true;
338                 };
339                 return ret;
340         })(),
341         
342         _CLIP_SEPARATOR : X.UA.IE && X.UA.IE < 8 ? ' ' : ',',
343         
344         /*
345          * 
346          */
347         Property : X.Class.create(
348                 'Property',
349                 X.Class.POOL_OBJECT,
350                 {
351                         Constructor : function( name, value, unit, xnode ){
352                                 this.name  = name;
353                                 this.value = value;
354                                 this.unit  = unit;
355                                 this.xnode = xnode;
356                         },
357                         name    : '',
358                         value   : 0,
359                         unit    : '',
360                         xnode   : null,
361                         equal : function( prop ){
362                                 if( this.unit === prop.unit ){
363                                         return this.value === prop.value;
364                                 };
365                                 return Math.abs( this.toPx() - prop.toPx() ) < 1;
366                         },
367                         convert: function( prop ){
368                                 var u = prop.unit, v;
369                                 if( this.unit === u ) return;
370                                 this.value = v = this.toPx();
371                                 this.unit  = u;
372                                 // %
373                                 // bgpX, bgpY の場合 X.Dom.Image.getActualDimension( backgroundImage url を使用 )
374                                 if( u !== 'px' ){
375                                         this.value =
376                                                 u === 'em' ?
377                                                         v / this.xnode._getCharSize() :
378                                                         v / ( X.Dom.Style._UNIT_RATIO[ u ] || 1 );
379                                 };
380                         },
381                         setValue: function( v ){
382                                 this.value = v;
383                         },
384                         getValue: function(){
385                                 return this.value;
386                         },
387                         getOffset: function( prop ){
388                                 return prop.value - this.value;
389                         },
390                         getUnit: function(){
391                                 return this.unit;
392                         },
393                         getValueText: function(){
394                                 return this.value === 0 ? '0' : this.value + this.unit;
395                         },
396                         toPx: function(){
397                                 var v = this.value, u = this.unit;
398                                 return
399                                         u === 'px' ?
400                                                 v :
401                                         ( u === 'em' || ( u === '' && this.name === 'lineHeight' ) ) ?
402                                                 v * this.xnode._getCharSize() :
403                                         // u === '%'
404                                                 v / ( X.Dom.Style._UNIT_RATIO[ u ] || 1 );
405                         },
406                         isValid: function(){
407                                 var p = X.Dom.Style.PARAMS,
408                                         n = this.name,
409                                         v = this.value,
410                                         u = this.unit,
411                                         z = u !== '' ? true : v === 0;
412                                 if( p.percent[ n ] === true ) return z;
413                                 if( p.offset[ n ]  === true ) return z;
414                                 if( p.size[ n ]    === true ) return z && u !== '%';
415                                 if( p.special[ n ] === true ){
416                                         if( n === 'lineHeight' ) return true;
417                                         if( n === 'opacity' )    return 0 <= v && v <= 1 && u === '';
418                                         if( n === 'zIndex'  )    return u === '';
419                                 };
420                                 return false;
421                         }
422                 }
423         ),
424         
425         /**
426          * backgroundPosition, clip
427          */
428         PropertyGroup : X.Class.create(
429                 'PropertyGroup',
430                 X.Class.POOL_OBJECT,
431                 {
432                         Constructor : function( name ){
433                                 this.name  = name;
434                                 this.props = [];
435                                 for( var i = 1, l = arguments.length; i<l; ++i ){
436                                         this.props[ this.props.length ] = arguments[ i ];
437                                 };
438                         },
439                         name  : '',
440                         equal : function( prop ){
441                                 var ps = this.props, i = ps.length;
442                                 for( ; i; ){
443                                         --i;
444                                         if( ps[ i ].equal( prop[ i ] ) === false ) return false;
445                                 };
446                                 return true;
447                         },
448                         convert : function( prop ){
449                                 var ps = this.props, i = ps.length;
450                                 for( ; i; ){
451                                         --i;
452                                         ps[ i ].convert( prop[ i ] );
453                                 };
454                         },
455                         setValue : function( ary ){
456                                 var ps = this.props, i = 0, l = ps.length;
457                                 for( ; i<l; ++i ){
458                                         ps[ i ].setValue( ary[ i ] );
459                                 };
460                         },
461                         getValue : function(){
462                                 var ret = [], ps = this.props, i = 0, l = ps.length;
463                                 for( ; i<l; ++i ){
464                                         ret[ ret.length ] = ps[ i ].getValue();
465                                 };
466                                 return ret;
467                         },
468                         getOffset : function( prop ){
469                                 var ret = [],
470                                         ps  = this.props,
471                                         _ps = prop.props,
472                                         i   = 0,
473                                         l = ps.length;
474                                 for( ; i<l; ++i ){
475                                         ret[ ret.length ] = ps[ i ].getOffset( _ps[ i ] );
476                                 };
477                                 return ret;
478                         },
479                         getUnit : function(){
480                                 var ret = [], ps = this.props, i = 0, l = ps.length;
481                                 for( ; i<l; ++i ){
482                                         ret[ ret.length ] = ps[ i ].getUnit();
483                                 };
484                                 return ret;
485                         },
486                         getValueText : function(){
487                                 var ret = [], ps = this.props, i = 0, l = ps.length;
488                                 for( ; i<l; ++i ){
489                                         ret[ ret.length ] = ps[ i ].getValueText();
490                                 };
491                                 if( this.name === 'clip' ){
492                                         return 'rect(' + ret.join( X.Dom.Style._CLIP_SEPARATOR ) + ')';
493                                 };
494                                 return ret.join( ' ' );
495                         },
496                         onKill : function(){
497                                 var ps = this.props, i = ps.length;
498                                 for( ; i; ){
499                                         ps[ --i ].kill();
500                                 };
501                         },
502                         isValid : function( t ){
503                                 t = t || this;
504                                 var ps = t.props, i = ps.length;
505                                 for( ; i; ){
506                                         if( ps[ --i ].isValid() === false ) return false;
507                                 };
508                                 return true;
509                         }
510                 }
511         ),
512
513         /*
514          * http://css-eblog.com/ie-css-problems/rgba-pe.html
515          * ie67 では rgb() は background-color で反応しない、、、
516          */
517
518         ColorProperty : X.Class.create(
519                 'ColorProperty',
520                 X.Class.POOL_OBJECT, {
521                         Constructor : function( name, x ){
522                                 var pct = false,
523                                         r   = 0,
524                                         g   = 0,
525                                         b   = 0,
526                                         a   = 1,
527                                         rgb;
528                                 if( X.Type.isNumber( rgb = x ) || X.Type.isNumber( rgb = X.Dom.Style.COLOR[ x.toUpperCase() ] ) ){
529                                         r = ( rgb & 0xff0000 ) >> 16;
530                                         g = ( rgb & 0xff00 ) >> 8;
531                                         b = ( rgb & 0xff );
532                                 } else
533                                 if( x.charAt( 0 ) === '#' ){
534                                         if( x.length === 7 ){
535                                                 r = parseInt( x.charAt( 1 ) + x.charAt( 2 ), 16 );
536                                                 g = parseInt( x.charAt( 3 ) + x.charAt( 4 ), 16 );
537                                                 b = parseInt( x.charAt( 5 ) + x.charAt( 6 ), 16 );
538                                         } else                  
539                                         if( x.length === 4 ){
540                                                 r = parseInt( x.charAt( 1 ) + x.charAt( 1 ), 16 );
541                                                 g = parseInt( x.charAt( 2 ) + x.charAt( 2 ), 16 );
542                                                 b = parseInt( x.charAt( 3 ) + x.charAt( 3 ), 16 );
543                                         } else
544                                         if( x.length === 2 ){
545                                                 r = parseInt( x.charAt( 1 ) + x.charAt( 1 ), 16 );
546                                                 g = parseInt( x.charAt( 1 ) + x.charAt( 1 ), 16 );
547                                                 b = parseInt( x.charAt( 1 ) + x.charAt( 1 ), 16 );
548                                         };
549                                 } else
550                                 if( x.indexOf( 'rgb(' ) === 0 ){
551                                         rgb = x.substr( 4 ).split( ',' );
552                                         r = parseFloat( rgb[ 0 ] );
553                                         g = parseFloat( rgb[ 1 ] );
554                                         b = parseFloat( rgb[ 2 ] );
555                                         if( x.indexOf( '%' ) !== -1 ) pct = true;
556                                 } else
557                                 if( x.indexOf( 'rgba(' ) === 0 ){
558                                         rgb = x.substr( 5 ).split( ',' );
559                                         r = parseFloat( rgb[ 0 ] );
560                                         g = parseFloat( rgb[ 1 ] );
561                                         b = parseFloat( rgb[ 2 ] );
562                                         a = parseFloat( rgb[ 3 ] );
563                                         if( x.indexOf( '%' ) !== -1 ) pct = true;
564                                 } else {
565                                         r = 255;
566                                         g = 255;
567                                         b = 255;
568                                 };
569                                 
570                                 this.name = name;
571                                 this.r    = r;
572                                 this.g    = g;
573                                 this.b    = b;
574                                 this.a    = a;
575                                 this.pct  = pct;
576                         },
577                         name  : '',
578                         r     : 0,
579                         g     : 0,
580                         b     : 0,
581                         a     : 0,
582                         pct   : false,
583                         equal : function( prop ){
584                                 if( this.pct === prop.pct ){
585                                         return this.r === prop.r && this.g === prop.g && this.b === prop.b;
586                                 };
587                                 var rgb  = this._toPct(),
588                                         _rgb = prop._toPct(),
589                                         i    = rgb.length;
590                                 for( ; i; ){
591                                         --i;
592                                         if( Math.abs( rgb[ i ] - _rgb[ i ] ) > 1 ) return false;
593                                 };
594                                 return true;
595                         },
596                         convert : function( prop ){
597                                 var u = prop.pct, x;
598                                 if( this.pct === u ) return;
599                                 x = u === true ? 100 / 255 : 2.55;
600                                 this.r  *= x;
601                                 this.g  *= x;
602                                 this.b  *= x;
603                                 this.pct = u;
604                         },
605                         setValue : function( rgb ){
606                                 this.r = rgb[ 0 ];
607                                 this.g = rgb[ 1 ];
608                                 this.b = rgb[ 2 ];
609                         },
610                         getValue : function(){
611                                 return [ this.r, this.g, this.b ];
612                         },
613                         getOffset : function( prop ){
614                                 return [ prop.r - this.r, prop.g - this.g, prop.b - this.b ];
615                         },
616                         getUnit : function(){
617                                 return this.pct === true ? '%' : '';
618                         },
619                         getValueText : function(){
620                                 if( this.pct === true ){
621                                         return [ 'rgb(', this.r, '%,', this.g, '%,', this.b, '%)' ].join( '' );
622                                 };
623                                 var round = Math.round;
624                                 
625                                 var rgb   = '00000' + ( ( round( this.r ) << 16 ) + ( round( this.g ) << 8 ) + round( this.b ) ).toString( 16 );
626                                 return '#' + rgb.substr( rgb.length - 6 );
627                         },
628                         _toPct : function(){
629                                 if( this.pct === true ) return [ this.r, this.g, this.b ];
630                                 return [ this.r / 2.55, this.g / 2.55, this.b / 2.55 ];
631                         },
632                         isValid : function( t ){
633                                 var isFinite = window.isFinite;
634                                 if( !isFinite( this.r ) || !isFinite( this.g ) || !isFinite( this.b ) ) return false;
635                                 if( 0 > this.r || 0 > this.g || 0 > this.b ) return false;
636                                 if( this.pct === true ) return this.r <= 100 && this.g <= 100 && this.b <= 100;
637                                 return this.r <= 255 && this.g <= 255 && this.b <= 255;
638                         }
639                 }
640         ),
641         
642         _getProperty : function( xnode, css, unit, p ){
643                 
644                 var XDomStyle     = X.Dom.Style,
645                         me            = XDomStyle._getProperty,
646                         PARAMS        = XDomStyle.PARAMS,
647                         PropertyGroup = XDomStyle.PropertyGroup,
648                         Property      = XDomStyle.Property,
649                         ColorProperty = XDomStyle.ColorProperty,
650                         name, width;
651                 
652                 if( PARAMS.special[ p ] === true || PARAMS.region[ p ] === true ){
653                         switch( p ){
654                                 case 'clip' :
655                                         // rect(...)    クリップします。<top>, <bottom> は上端からの、 <right>, <left> は左端からのオフセットで指定します。Internet Explorer 4~7 では、カンマの代わりにスペースで区切る必要があります。
656                                         // position:absolute または position:fixed を適用した要素に対してのみ有効です。
657                                         var top    = me( p + 'Top' ),
658                                                 right  = me( p + 'Right' ),
659                                                 bottom = me( p + 'Bottom' ),
660                                                 left   = me( p + 'Left' ),
661                                                 ret    = new PropertyGroup( p, top, right, bottom, left ),
662                                     all;
663                                         if( ret.isValid() === true ) return ret;
664                                         ret.kill();
665                                         all = css[ p ].split( '(' )[ 1 ].split( ')' )[ 0 ].split( XDomStyle._CLIP_SEPARATOR );
666                                         return
667                                                 new PropertyGroup( 
668                                                         p,
669                                                         new Property( p + 'Top',    all[ 0 ], 'px', xnode ),
670                                                         new Property( p + 'Right',  all[ 1 ], 'px', xnode ),
671                                                         new Property( p + 'Bottom', all[ 2 ], 'px', xnode ),
672                                                         new Property( p + 'Left',   all[ 3 ], 'px', xnode )
673                                                 );
674
675                                 case 'margin' :
676                                 case 'padding' :
677                                         name  = p;
678                                         width = '';
679                                 case 'borderWidth' :
680                                         var props  = '$1Top$2,$1Right$2,$1Bottom$2,$1Left$2'.split( '$1' ).join( name || 'border' ).split( '$2' ).join( width || 'Width' ).split( ',' ),
681                                                 top    = me( props[ 0 ] ),
682                                                 right  = me( props[ 1 ] ),
683                                                 bottom = me( props[ 2 ] ),
684                                                 left   = me( props[ 3 ] ),
685                                                 ret    = new PropertyGroup( p, top, right, bottom, left ),
686                                                 all, _0, _1, _2, _3, vu, v, u;
687                                         if( ret.isValid() === true ) return ret;
688                                         ret.kill();
689                                         all = css[ p ].split( ' ' );
690                                         _0  = all[ 0 ];
691                                         _1  = all[ 1 ];
692                                         _2  = all[ 2 ];
693                                         _3  = all[ 3 ];
694                                         vu  = XDomStyle._splitValueAndUnit( _0 );
695                                         v   = vu[ 0 ];
696                                         u   = vu[ 1 ];
697                                         switch( all.length ){
698                                                 case 1 :
699                                                         top    = new Property( props[ 0 ], v, u, xnode );
700                                                         right  = new Property( props[ 1 ], v, u, xnode );
701                                                         bottom = new Property( props[ 2 ], v, u, xnode );
702                                                         left   = new Property( props[ 3 ], v, u, xnode );
703                                                         break;
704                                                 case 2 :
705                                                         top    = new Property( props[ 0 ], v, u, xnode );
706                                                         bottom = new Property( props[ 2 ], v, u, xnode );
707                                                         vu     = XDomStyle._splitValueAndUnit( _1 );
708                                                         v      = vu[ 0 ];
709                                                         u      = vu[ 1 ];
710                                                         right  = new Property( props[ 1 ], v, u, xnode );
711                                                         left   = new Property( props[ 3 ], v, u, xnode );
712                                                         break;
713                                                 case 3 :
714                                                         top    = new Property( props[ 0 ], v, u, xnode );
715                                                         vu     = XDomStyle._splitValueAndUnit( _1 );
716                                                         v      = vu[ 0 ];
717                                                         u      = vu[ 1 ];
718                                                         right  = new Property( props[ 1 ], v, u, xnode );
719                                                         left   = new Property( props[ 3 ], v, u, xnode );
720                                                         vu     = XDomStyle._splitValueAndUnit( _2 );
721                                                         v      = vu[ 0 ];
722                                                         u      = vu[ 1 ];
723                                                         bottom = new Property( props[ 2 ], v, u, xnode );
724                                                         break;
725                                                 case 4 :
726                                                         top    = new Property( props[ 0 ], v, u, xnode );
727                                                         vu     = XDomStyle._splitValueAndUnit( _1 );
728                                                         v      = vu[ 0 ];
729                                                         u      = vu[ 1 ];
730                                                         right  = new Property( props[ 1 ], v, u, xnode );
731                                                         vu     = XDomStyle._splitValueAndUnit( _2 );
732                                                         v      = vu[ 0 ];
733                                                         u      = vu[ 1 ];
734                                                         bottom = new Property( props[ 2 ], v,u, xnode );
735                                                         vu     = XDomStyle._splitValueAndUnit( _3 );
736                                                         v      = vu[ 0 ];
737                                                         u      = vu[ 1 ];
738                                                         left   = new Property( props[ 3 ], v, u, xnode );
739                                                         break;
740                                         };
741                                         return new PropertyGroup( p, top, right, bottom, left );
742
743                                 case 'borderColor' :
744                                         var props  = 'borderTopColor,borderRightColor,borderBottomColor,borderLeftColor'.split( ',' ),
745                                                 top    = me( props[ 0 ] ),
746                                                 right  = me( props[ 1 ] ),
747                                                 bottom = me( props[ 2 ] ),
748                                                 left   = me( props[ 3 ] ),
749                                                 ret    = new PropertyGroup( p, top, right, bottom, left ),
750                                                 all, _0, _1;
751                                         if( ret.isValid() === true ) return ret;
752                                         ret.kill();
753                                         all = css[ p ].split( ' ' );
754                                         _0  = all[ 0 ];
755                                         _1  = all[ 1 ];
756                                         switch( all.length ){
757                                                 case 1 :
758                                                         top    = new ColorProperty( props[ 0 ], _0 );
759                                                         right  = new ColorProperty( props[ 1 ], _0 );
760                                                         bottom = new ColorProperty( props[ 2 ], _0 );
761                                                         left   = new ColorProperty( props[ 3 ], _0 );
762                                                         break;
763                                                 case 2 :
764                                                         top    = new ColorProperty( props[ 0 ], _0 );
765                                                         right  = new ColorProperty( props[ 1 ], _1 );
766                                                         bottom = new ColorProperty( props[ 2 ], _0 );
767                                                         left   = new ColorProperty( props[ 3 ], _1 );
768                                                         break;
769                                                 case 3 :
770                                                         top    = new ColorProperty( props[ 0 ], _0 );
771                                                         right  = new ColorProperty( props[ 1 ], _1 );
772                                                         bottom = new ColorProperty( props[ 2 ], all[ 2 ] );
773                                                         left   = new ColorProperty( props[ 3 ], _1 );
774                                                         break;
775                                                 case 4 :
776                                                         top    = new ColorProperty( props[ 0 ], _0 );
777                                                         right  = new ColorProperty( props[ 1 ], _1 );
778                                                         bottom = new ColorProperty( props[ 2 ], all[ 2 ] );
779                                                         left   = new ColorProperty( props[ 3 ], all[ 3 ] );
780                                                         break;
781                                         };
782                                         return new PropertyGroup( p, top, right, bottom, left );
783                                         
784                                 case 'backgroundPosition' :
785                                         var x   = me( p + 'X' ),
786                                                 y   = me( p + 'Y' ),
787                                                 ret = new PropertyGroup( p, x, y ),
788                                                 xy;
789                                         if( ret.isValid() === true ) return ret;
790                                         ret.kill();
791                                         xy = css[ p ].split( ' ' );
792                                         x  = XDomStyle._splitValueAndUnit( xy[ 0 ] );
793                                         y  = XDomStyle._splitValueAndUnit( xy[ 1 ] );
794                                         return
795                                                 new PropertyGroup(
796                                                         p,
797                                                         new Property( p + 'X', x[ 0 ], x[ 1 ], xnode ),
798                                                         new Property( p + 'Y', y[ 0 ], y[ 1 ], xnode )
799                                                 );
800                         };
801                         // opacity, zindex, lineHeight
802                         vu = XDomStyle._splitValueAndUnit( css[ p ] );
803                         return new Property( p, vu[ 0 ], vu[ 1 ], xnode );
804                 };
805                 var x = css[ p ], e, v, u;
806                 /*
807                 if( PARAMS.offset[ p ] === true ){
808                         return new Property( p, vu[ 0 ], vu[ 1 ], xnode );
809
810                         e = this.elm;
811                         if( p === 'width'  ) v = e.offsetWidth;
812                         if( p === 'height' ) v = e.offsetHeight;
813                         if( p === 'top'    ) v = e.offsetTop;
814                         if( p === 'bottom' ) v = e.offsetBottom;
815                         if( p === 'left'   ) v = e.offsetLeft;
816                         if( p === 'right'  ) v = e.offsetRight;
817                         u = _getUnit( x, p );
818                         // alert( p + XDomStyle._Util.pxTo( v, u ) + u )
819                         return new Property( p, XDomStyle._Util.pxTo( v, u ), u, xnode );
820                 }; */
821                 if( p === 'fontSize' && ( v = XDomStyle._FONT_SIZE_RATIO[ x ] ) ){ // xx-small 等
822                         return new Property( p, v, 'px', xnode );
823                 };
824                 if( PARAMS.offset[ p ] || PARAMS.percent[ p ] || PARAMS.size[ p ] ){
825                         vu = XDomStyle._splitValueAndUnit( x );
826                         return new Property( p, vu[ 0 ], vu[ 1 ], xnode );
827                 };
828
829                 if( PARAMS.color[ p ] ) return new ColorProperty( p, x );
830         },
831         
832         _splitValueAndUnit : function( v ){
833                 var num, _num, u;
834                 if( X.Type.isNumber( v ) ) return [ v || 0, '' ];
835                 if( isNaN( num = parseFloat( v ) ) ) return [ 0, '' ];
836                 _num = '' + num;
837                 if( _num.indexOf( '0.' ) === 0 ) _num = _num.slice( 1 );
838                 u = v.substr( v.indexOf( _num ) + _num.length );
839                 return [ num, X.Dom.Style.UNIT[ u ] ? u : 'px' ];
840         }
841 };
842
843 X.Dom.Style._GET_VALUE_WITH_UNIT = {
844         borderWidth  : X.Dom.Style.Type.QUARTET | X.Dom.Style.Type.LENGTH,
845         //borderStyle  : X.Dom.Style.Type.QUARTET,
846         borderRadius : X.Dom.Style.Type.QUARTET | X.Dom.Style.Type.LENGTH,
847         margin       : X.Dom.Style.Type.QUARTET | X.Dom.Style.Type.LENGTH  | X.Dom.Style.Type.PERCENT,
848         padding      : X.Dom.Style.Type.QUARTET | X.Dom.Style.Type.LENGTH  | X.Dom.Style.Type.PERCENT,
849         clip         : X.Dom.Style.Type.QUARTET | X.Dom.Style.Type.LENGTH  | X.Dom.Style.Type.PERCENT,
850         
851         backgroundColor    : X.Dom.Style.Type.COLOR,
852         backgroundPosition : X.Dom.Style.Type.COMBI,
853         
854         // boxShadow
855         
856         fontSize      : X.Dom.Style.Type.LENGTH,
857         lineHeight    : X.Dom.Style.Type.LENGTH | X.Dom.Style.Type.PERCENT | X.Dom.Style.Type.NUMERICAL,
858         textIndent    : X.Dom.Style.Type.LENGTH,
859         letterSpacing : X.Dom.Style.Type.LENGTH,
860         wordSpacing   : X.Dom.Style.Type.LENGTH,
861         /*
862         textShadowColor   : X.Dom.Style.Type.COLOR,
863         textShadowOffsetX : X.Dom.Style.Type.LENGTH,
864         textShadowOffsetY : X.Dom.Style.Type.LENGTH,
865         textShadowBlur    : X.Dom.Style.Type.LENGTH, */
866         
867         width         : X.Dom.Style.Type.LENGTH | X.Dom.Style.Type.PERCENT,
868         height        : X.Dom.Style.Type.LENGTH | X.Dom.Style.Type.PERCENT,
869         
870         left          : X.Dom.Style.Type.LENGTH | X.Dom.Style.Type.PERCENT,
871         top           : X.Dom.Style.Type.LENGTH | X.Dom.Style.Type.PERCENT,
872         bottom        : X.Dom.Style.Type.LENGTH | X.Dom.Style.Type.PERCENT,
873         right         : X.Dom.Style.Type.LENGTH | X.Dom.Style.Type.PERCENT,
874         
875         // table
876         borderSpacing : X.Dom.Style.Type.LENGTH
877 };
878
879         
880 X.Dom.Style.SPECIAL_FIX =
881         // ~IE8
882         X.UA.IE && X.UA.IE < 9 ?
883                 (function( obj ){
884                         var test    = X.Dom.Style.SPECIAL_FIX_PROP,
885                                 filters = [],
886                                 n       = -1,
887                                 p, id, v, dir;
888                         for( p in obj ){
889                                 if( !( id = test[ p ] ) ) continue;
890                                 v = obj[ p ];
891                                 switch( id ){
892                                         case 1 : //'filter' :
893                                                 filters[ ++n ] = v;
894                                                 break;
895                                         case 2 : //'opacity' :
896                                                 filters[ ++n ] = 'alpha(opacity=' + v * 100 +')';
897                                                 break;
898                                         case 3 : //'boxShadow' :
899                                                 // box-shadow: 10px 10px 10px 10px rgba(0,0,0,0.4) inset;
900                                                 // スペース区切りで、水平方向の距離 垂直方向の距離 ぼかし距離 広がり距離 影の色 insetキーワードを指定する。 ぼかし距離 広がり距離 影の色 insetキーワードは省略可
901                                                 // shadow(color=#cccccc, strength=10, direction=135);
902                                                 v = X.Dom.Style._getProperty( this, css, 'px', 'boxShadow' );
903                                                 dir = Math.atan2( v[ 1 ], v[ 0 ] ) * 180 / Math.PI + 90;
904                                                 dir += dir < 0 ? 360 : 0;
905                                                 filters[ ++n ] = 'shadow(color=' + v[ 4 ] + ',strength=' + v[ 3 ] + ',direction=' + dir + ')';
906                                                 break;
907                                         case 4 : //'textShadow' :
908                                                 //text-shadow: 5px 5px 2px blue; 水平方向の距離 垂直方向の距離 影のぼかし半径 影の色 none
909                                                 //glow(Color=yellow,Strength=10);
910                                                 //どうやらCSSのbackgroundプロパティと同時に使えないようです。 
911                                                 
912                                                 
913                                                 break;
914                                         case 5 : //'backgroundImage' :
915                                                 //
916                                 };
917                         };
918                         return filters.join( ' ' );
919                 }) :
920         // IE9 textShadow に filter を使用
921         X.UA.IE && 9 <= X.UA.IE && X.UA.IE < 10 ?
922                 (function( obj ){
923                         var test    = X.Dom.Style.SPECIAL_FIX_PROP,
924                                 filters = [], p, id, v;
925                         for( p in obj ){
926                                 if( !( id = test[ p ] ) ) continue;
927                                 v = obj[ p ];
928                                 switch( id ){
929                                         case 1 : //'filter' :
930                                                 filters[ filters.length ] = v;
931                                                 break;
932                                 };
933                         };
934                         if( filters ) return filters.join( ' ' );
935                 }) :
936                 (function( obj ){
937                         var test    = X.Dom.Style.SPECIAL_FIX_PROP,
938                                 ret = [], p, id, v;
939                         for( p in obj ){
940                                 if( !( id = test[ p ] ) ) continue;
941                                 v = obj[ p ];
942                                 switch( id ){
943                                         case 1 : //'backgroundPositionX' :
944                                                 bgpX = v;
945                                                 break;
946                                         case 2 : //'backgroundPositionY' :
947                                                 bgpY = v;
948                                                 break;
949                                         case 3 : //'backgroundPositionX' :
950                                                 clipT = v;
951                                                 break;
952                                         case 4 : //'backgroundPositionX' :
953                                                 clipB = v;
954                                                 break;
955                                         case 5 : //'backgroundPositionX' :
956                                                 clipL = v;
957                                                 break;
958                                         case 6 : //'backgroundPositionX' :
959                                                 clipR = v;
960                                                 break;
961                                 };
962                         };
963                         if( bgpX || bgpY ) ret[ ret.length ] = 'background-position:';
964                         if( clipT || clipB || clipL || clipR ){
965                                 ret[ ret.length ] = 'clip:rect(';
966                         };
967                         return ret.join( ';' );
968                 });
969
970
971
972
973 // export
974 // name getter
975 // unitID, name 単位指定のプロパティ取得 geter
976 // obj setter
977 // name, value setter
978
979 X.Dom.Node.prototype.css = function( nameOrObj /* orUnitID, valuOrUnitOrName */ ){
980         var XDomStyle = X.Dom.Style,
981                 args = arguments,
982                 css  = this._css,
983                 p, name, v, camelize, unit, ieFix;
984         if( this._xnodeType !== 1 ) return this;
985 // setter:object
986         if( X.Type.isObject( nameOrObj ) ){
987                 if( !css ) css = this._css = {};
988                 camelize = XDomStyle.camelize;
989                 ieFix    = X.Dom.Style.IE_FILTER_FIX;
990                 for( p in nameOrObj ){
991                         if( ieFix[ p ] ){
992                                 this._dirty |= X.Dom.Dirty.IE_FILTER;
993                         };
994                         v = nameOrObj[ p ];
995                         v || v === 0 ? css[ camelize( p ) ] = v : delete css[ camelize( p ) ];
996                         if( p === 'display' ){
997                                 v === 'none' ? ( this._state |= X.Dom.State.IE5_DISPLAY_NONE_FIX ) : ( this._state &= ~X.Dom.State.IE5_DISPLAY_NONE_FIX );
998                                 v === 'none' ? ( this._state |= X.Dom.State.DISPLAY_NONE ) : ( this._state &= ~X.Dom.State.DISPLAY_NONE );
999                         };
1000                 };
1001                 this._dirty |= X.Dom.Dirty.CSS;
1002                 this.parent && this._reserveUpdate();
1003                 delete this._cssText;
1004                 return this;
1005         } else
1006         if( 1 < args.length ){
1007                 if( !XDomStyle.UNIT[ nameOrObj ] ){
1008 // setter name, value
1009                         if( !css ) css = this._css = {};
1010                         name = XDomStyle.camelize( nameOrObj );
1011                         v    = args[ 1 ];
1012                         if( css[ name ] === v ) return this;
1013                         if( X.Dom.Style.IE_FILTER_FIX[ name ] ){
1014                                 this._dirty |= X.Dom.Dirty.IE_FILTER;
1015                         };
1016                         if( !v && v !== 0 ){
1017                                 delete css[ name ];
1018                         } else {
1019                                 css[ name ] = v;
1020                         };
1021                         delete this._cssText;
1022                         this._dirty |= X.Dom.Dirty.CSS;
1023                         if( name === 'display' ){
1024                                 v === 'none' ? ( this._state |= X.Dom.State.IE5_DISPLAY_NONE_FIX ) : ( this._state &= ~X.Dom.State.IE5_DISPLAY_NONE_FIX );
1025                                 v === 'none' ? ( this._state |= X.Dom.State.DISPLAY_NONE ) : ( this._state &= ~X.Dom.State.DISPLAY_NONE );
1026                         };
1027                         // parent でなく this._root! でなくて this._state & in tree
1028                         this.parent && this._reserveUpdate();
1029                         return this;
1030                 };
1031 // getter unit
1032 // unit 付の値取得は fontSize と 画像サイズが確定していないと正確に取れない。内部のみにする?
1033                 if( !css ) return;
1034                 if( !XDomStyle._GET_VALUE_WITH_UNIT[ name = XDomStyle.camelize( args[ 1 ] ) ] ) return null;
1035                 p = XDomStyle._getProperty( this, css, nameOrObj, name );
1036                 v = p.pxTo( nameOrObj );
1037                 p.kill();
1038                 return v;
1039         };
1040 // getter
1041         if( !css ) return;
1042         // 集計 border, padding, margin, backgroundPosition, clip
1043         // border で正確なデータを返せない時は、null を返す
1044         return css[ XDomStyle.camelize( nameOrObj ) ];
1045 };
1046
1047 X.Dom.Node.prototype.cssText = function( v ){
1048         var obj, i, l, attr, name;
1049         if( v === '' ){
1050                 delete this._css;
1051                 this._state &= ~X.Dom.State.IE5_DISPLAY_NONE_FIX;
1052                 this._dirty |= X.Dom.Dirty.CSS;
1053                 this.parent && this._reserveUpdate();
1054                 delete this._cssText;
1055                 return this;
1056         } else
1057         if( X.Type.isString( v ) ){
1058                 delete this._css;
1059                 this._state &= ~X.Dom.State.IE5_DISPLAY_NONE_FIX;
1060                 obj = {};
1061                 v   = v.split( ';' );
1062                 for( i = 0, l = v.length; i < l; ++i ){
1063                         attr = v[ i ].split( ':' );
1064                         ( name = attr[ 0 ] ) && ( obj[ name ] = attr[ 1 ] || true );
1065                 };
1066                 return this.css( obj );
1067         };
1068         // getter
1069         if( this._dirty & X.Dom.Dirty.CSS && !( this._cssText = X.Dom.Style.objToCssText( this._css ) ) ){
1070                 delete this._cssText;
1071         };
1072         return this._cssText;
1073 };
1074
1075 /*
1076  * ここでは HTMLElement のチ1ェックは行わない!
1077  * TODO
1078  * body に css attr がセットされた場合には X.Dom.baseFontSize をクリア
1079  */
1080
1081 X.Dom.Node.prototype._getCharSize =
1082         window.getComputedStyle ?
1083                 (function(){
1084                         Node.root._updateTimerID && Node.root._startUpdate();
1085                         if( this === Node.root && X.Dom.baseFontSize ) return X.Dom.baseFontSize;
1086                         if( this._fontSize ) return this._fontSize;
1087                         return this._fontSize = parseFloat( getComputedStyle( this._rawNode, null ).fontSize );
1088                 }) :
1089         document.defaultView && document.defaultView.getComputedStyle ?
1090                 (function(){
1091                         Node.root._updateTimerID && Node.root._startUpdate();
1092                         if( this === Node.root && X.Dom.baseFontSize ) return X.Dom.baseFontSize;
1093                         if( this._fontSize ) return this._fontSize;
1094                         return this._fontSize = parseFloat( document.defaultView.getComputedStyle( this._rawNode, null ).fontSize );
1095                 }) :
1096         X.UA.IE && 5.5 <= X.UA.IE ?
1097                 (function(){
1098                         var font, vu, v, u, _v;
1099                         Node.root._updateTimerID && Node.root._startUpdate();
1100                         if( this === Node.root && X.Dom.baseFontSize ) return X.Dom.baseFontSize;
1101                         if( this._fontSize ) return this._fontSize;
1102                         
1103                         font = this._rawNode.currentStyle.fontSize;
1104                         //font = this._css && this._css.fontSize || '1em';
1105                         vu   = X.Dom.Style._splitValueAndUnit( font );
1106                         v    = vu[ 0 ];
1107                         u    = vu[ 1 ];
1108
1109                         if( v === 0 ){
1110                                 if( v = X.Dom.Style._FONT_SIZE_RATIO[ font ] ) return this._fontSize = v;
1111                         } else {
1112                                 if( _v = X.Dom.Style._UNIT_RATIO[ u ] ) return this._fontSize = v / _v;
1113                         };
1114                         switch( u ){
1115                                 case 'px' :
1116                                         return this._fontSize = v;
1117                                 case 'em' :
1118                                 // body まで辿ってしまった場合は?
1119                                         if( this.parent ) return this._fontSize = this.parent._getCharSize() * v;
1120                                         break;
1121                                 case '%' :
1122                                 // body まで辿ってしまった場合は?
1123                                         if( this.parent ) return this._fontSize = this.parent._getCharSize() * v / 100;
1124                         };
1125                         return 0;
1126                 }) :
1127         X.Dom.DOM_W3C ?
1128                 (function(){
1129                         var elm, v;
1130                         Node.root._updateTimerID && Node.root._startUpdate();
1131                         if( this === Node.root && X.Dom.baseFontSize ) return X.Dom.baseFontSize;
1132                         if( this._fontSize ) return this._fontSize;
1133
1134                         this._rawNode.appendChild( elm = document.createElement( 'span' ) );
1135                         elm.style.cssText = 'display:block;position:absolute;top:0;left:0;visivility:hidden;line-height:1;height:1em;';
1136                         elm.innerHTML = 'X';
1137                         v = elm.offsetHeight;
1138                         this._rawNode.removeChild( elm );
1139                         return this._fontSize = v;
1140                 }) :
1141         X.Dom.DOM_IE4 ?
1142                 (function(){
1143                         var font, vu, v, u, _v;
1144                         Node.root._updateTimerID && Node.root._startUpdate();
1145                         if( this === Node.root && X.Dom.baseFontSize ) return X.Dom.baseFontSize;
1146                         if( this._fontSize ) return this._fontSize;
1147                         
1148                         if( this._css && ( font = this._css.fontSize ) ){
1149                                 vu = X.Dom.Style._splitValueAndUnit( font );
1150                                 v  = vu[ 0 ];
1151                                 u  = vu[ 1 ];
1152                                 
1153                                 if( v === 0 ){
1154                                         if( _v = X.Dom.Style._FONT_SIZE_RATIO[ font ] ) return this._fontSize = _v;
1155                                 } else {
1156                                         if( _v = X.Dom.Style._UNIT_RATIO[ u ] ) return this._fontSize = v / _v;
1157                                 };
1158                         } else {
1159                                 v = 1;
1160                                 u = 'em';
1161                         };
1162
1163                         switch( u ){
1164                                 case 'px' :
1165                                         return this._fontSize = v;
1166                                 case 'em' :
1167                                 // body まで辿ってしまった場合は?
1168                                         if( this.parent ) return this._fontSize = this.parent._getCharSize() * v;
1169                                         break;
1170                                 case '%' :
1171                                 // body まで辿ってしまった場合は?
1172                                         if( this.parent ) return this._fontSize = this.parent._getCharSize() * v / 100;
1173                         };
1174                         return 0;
1175                 }) :
1176                 (function(){
1177                         var elm, v;
1178                         if( this === Node.root && X.Dom.baseFontSize ) return X.Dom.baseFontSize;
1179                         Node.root._updateTimerID && Node.root._startUpdate();
1180                         if( this._fontSize ) return this._fontSize;
1181                         
1182                         elm = this._rawNode || this._ie4getRawNode();
1183                         elm.insertAdjacentHTML( 'BeforeEnd', '<span style="visivility:hidden;line-height:1;">X</span>' );
1184                         elm = elm.children[ elm.children.length - 1 ];
1185                         v   = elm.offsetHeight;
1186                         elm.outerHTML = '';
1187                         return this._fontSize = v * 0.75;
1188                 });
1189
1190
1191 X.Dom.listenOnce( X.Dom.Event.DOM_PRE_INIT, function(){
1192         var testStyle = X.Dom._root.style;
1193         
1194         X.Dom.Style.VENDER_PREFIX = (function(){
1195                 var ret       = {},
1196                         vendors   = 'webkit,Webkit,Moz,moz,ms,Ms,O,o,khtml,Khtml'.split( ',' ),
1197                         searches  =
1198                                 'opacity,boxSizing,' +
1199                                 'transform,transformOrigin,perspective,' +
1200                                 'transisiton,transitionDelay,transitionProperty,transitionDuration,transitionTimingFunction,' +
1201                                 'userSelect,touchAction,touchCallout,contentZooming,userDrag,tapHighlightColor'.split( ',' ),
1202                         vendor, i, search, prop;
1203                 // 
1204                 vendors.unshift( '' );
1205                 
1206                 function findVenderPrefix( prop ){
1207                         var v, i = vendors.length;
1208                         vendor = null;
1209                         for( ; i; ){
1210                                 v = vendors[ --i ];
1211                                 if( testStyle[ v + prop ] !== undefined ){
1212                                         vendor = v;
1213                                         return v + prop;
1214                                 };
1215                         };      
1216                 };
1217                 
1218                 for( i = searches.length; i; ){
1219                         search = searches[ --i ];
1220                         prop = findVenderPrefix( search );
1221                         if( search === 'transform' ) ret.transVender = vendor;
1222                         if( prop ) ret[ search ] = prop;
1223                 };
1224                 return ret;
1225         })();
1226         
1227         X.Dom.Style.SPECIAL_FIX_PROP =
1228                 // ~IE8
1229                 X.UA.IE && X.UA.IE < 9 ?
1230                         {
1231                                 filter          : 1,
1232                                 opacity         : 2//, uinode ChromeNode で行う
1233                                 //boxShadow       : 3,
1234                                 //textShadow      : 4,
1235                                 //backgroundImage : 5
1236                         } :
1237                 // IE9
1238                 X.UA.IE && 9 <= X.UA.IE && X.UA.IE < 10 ?
1239                         {
1240                                 filter          : 1//,
1241                                 //textShadow      : 1
1242                         } :
1243                 {
1244                         backgroundPositionX : testStyle.backgroundPositionX === undefined ? 3 : 0,
1245                         backgroundPosiitonY : testStyle.backgroundPositionX === undefined ? 3 : 0,
1246                         clipTop             : testStyle.clipTop === undefined && testStyle[ 'clip-top' ] === undefined ? 3 : 0,
1247                         clipBottom          : testStyle.clipTop === undefined && testStyle[ 'clip-top' ] === undefined ? 4 : 0,
1248                         clipLeft            : testStyle.clipTop === undefined && testStyle[ 'clip-top' ] === undefined ? 5 : 0,
1249                         clipRight           : testStyle.clipTop === undefined && testStyle[ 'clip-top' ] === undefined ? 6 : 0
1250                 };
1251 } );
1252
1253 X.Dom.listenOnce( X.Dom.Event.DOM_INIT, function(){
1254         var xnode  = Node._systemNode,
1255                 output = X.Dom.Style._UNIT_RATIO = {},
1256                 list   = 'cm,mm,in,pt,pc'.split( ',' ),
1257                 unit,size, base, i;
1258         
1259         for( i = list.length; i; ){
1260                 unit = list[ --i ];
1261                 output[ unit ] = xnode.css( 'width', 100 + unit ).width() / 100;
1262         };
1263
1264         output = X.Dom.Style._FONT_SIZE_RATIO = {},
1265         list   = 'xx-large,x-large,large,larger,medium,small,smaller,x-small,xx-small'.split( ',' );
1266         xnode.css( { lineHeight : '100%', height : '1em' } ).text( 'X' );
1267         
1268         for( i = list.length; i; ){
1269                 size = list[ --i ];
1270                 output[ size ] = xnode.css( 'fontSize', size ).height();// / base;
1271         };
1272         
1273         // 以下解決、scroll 中に timer が無視される iOS の問題が原因(dom追加で起こったスクロール?)
1274         // ipod touch 1st で必要なんですけど、、、
1275         //xnode._rawNode.style.cssText = ''; 
1276         xnode.cssText( '' ).empty(); //._startUpdate();
1277 } );
1278