4 * style 値の変更は、enterFrame 後にまとめて適用
5 * width(), height(), x(), y() 1em の取得時にも適用
6 * css3 の ie用 fix は X.UI レベルで行う
44 /* font-size -> fontSize */
45 _DICTIONARY_CAMELIZE : {},
47 camelize : function( cssProp ){
49 parts, l, i, camelized;
51 if( camelized = me._DICTIONARY_CAMELIZE[ cssProp ] ) return camelized;
52 parts = cssProp.split( ' ' ).join( '' ).split( '-' );
54 if( l === 1 ) return parts[ 0 ];
56 camelized = cssProp.charAt(0) === '-'
57 ? parts[ 0 ].charAt( 0 ).toUpperCase() + parts[ 0 ].substring( 1 )
60 for( i = 1; i < l; ++i ){
61 camelized += parts[ i ].charAt( 0 ).toUpperCase() + parts[ i ].substring( 1 );
63 return me._DICTIONARY_CAMELIZE[ cssProp ] = camelized;
66 /* fontSize -> font-size */
67 CHAR_CODE_A : 'A'.charCodeAt( 0 ),
69 _DICTIONARY_UNCAMELIZE : {},
71 uncamelize : function( str ){
75 uncamelized, l, chr, code;
76 str = str.split( ' ' ).join( '' );
77 if( uncamelized = me._DICTIONARY_UNCAMELIZE[ str ] ) return uncamelized;
79 for( i = 0, l = str.length; i < l; ++i ){
80 chr = str.charAt( i );
81 code = chr.charCodeAt( 0 );
82 uncamelized += ( A <= code && code <= Z ) ? '-' + chr : chr;
84 return me._DICTIONARY_UNCAMELIZE[ str ] = uncamelized.toLowerCase();
88 * CSS における display, position, float プロパティの相互関係
89 * http://d.hatena.ne.jp/elm200/20080201/1201874740
91 * CSS21:9.7 Relationships between ’display’, ’position’, and ’float’
92 * http://www.w3.org/TR/CSS21/visuren.html#dis-pos-flo
94 * display:none? -yes-> 非表示
96 * position:absolute? -yes-> float:none,display:block;
98 * float:none? -no-> display:block;
103 display position float
104 block static|relative none
105 block static|relative right|left
107 inline static|relative none
114 objToCssText : function( obj ){
117 uncamelize = me.uncamelize,
118 VENDER_PREFIX = me.VENDER_PREFIX,
119 FIX_PROP = me.SPECIAL_FIX_PROP,
120 SPECIAL_FIX = me.SPECIAL_FIX,
123 if( !obj ) return ''; // Opera7.5 未満?
125 name = uncamelize( p );
126 if( FIX_PROP[ name ] ){
129 css[ ++n ] = [ VENDER_PREFIX[ name ] || name, obj[ p ] ].join( ':' );
132 sp && ( css[ ++n ] = 'filter:' + SPECIAL_FIX( obj ) );
133 return css.join( ';' );
137 X.UA.IE && X.UA.IE < 9 && !X.UA.MacIE ?
142 9 <= X.UA.IE && X.UA.IE < 10 ? // == 9
147 _FONT_SIZE_RATIO : null,
149 // https://developer.mozilla.org/en-US/docs/Web/CSS/transform
150 // Firefox 3.5, ie9, Opera 10.5, Safari 3.1, Chrome
151 // 3D support Firefox 10, ie10, Safari 4.0, Chrome 12.0
152 // transform : void 0,
154 // https://developer.mozilla.org/ja/docs/Web/Guide/CSS/Using_CSS_transitions
155 // Chrome 1.0, Firefox 4.0, ie10, Opera 10.5, Safari 3.2
156 // Android 2.1, Firefox Android 4.0, Opera Mobile 10, Safari Mobile 3.2
157 // transition : void 0
159 // ブラウザ毎の getComputedStyle の戻り値 http://d.hatena.ne.jp/uupaa/20080928/1222543331
181 SLATEGRAY : 0x708090,
183 GAINSBORO : 0xDCDCDC,
184 MIDNIGHTBLUE : 0x191970,
185 SLATEBLUE : 0x6A5ACD,
186 MEDIUMBLUE : 0x0000CD,
187 ROYALBLUE : 0x4169E1,
188 DODGERBLUE : 0x1E90FF,
190 STEELBLUE : 0x4682B4,
191 LIGHTBLUE : 0xADD8E6,
192 PALETURQUOISE : 0xAFEEEE,
193 TURQUOISE : 0x40E0D0,
194 LIGHTCYAN : 0xE0FFFF,
195 AQUAMARINE : 0x7FFFD4,
196 DARKGREEN : 0x006400,
198 LIGHTGREEN : 0x90EE90,
199 CHARTREUSE : 0x7FFF00,
200 GREENYELLOW : 0xADFF2F,
201 LIMEGREEN : 0x32CD32,
202 YELLOWGREEN : 0x9ACD32,
203 OLIVEDRAB : 0x6B8E23,
204 DARKKHAKI : 0xBCB76B,
205 PALEGOLDENROD : 0xEEE8AA,
206 LIGHTYELLOW : 0xFFFFE0,
208 GOLDENROD : 0xDAA520,
209 DARKGOLDENROD : 0xB8860B,
210 ROSYBROWN : 0xBC8F8F,
211 INDIANRED : 0xCD5C5C,
212 SADDLEBROWN : 0x8B4513,
215 BURLYWOOD : 0xDEB887,
218 SANDYBROWN : 0xF4A460,
220 CHOCOLATE : 0xD2691E,
221 FIREBRICK : 0xB22222,
230 PALEVIOLETRED : 0xDB7093,
234 DARKVIOLET : 0x9400D3,
235 BLUEVIOLET : 0x8A2BE2,
236 MEDIUMPURPLE : 0x9370DB,
239 MISTYROSE : 0xFFE4E1,
241 LEMONCHIFFON : 0xFFFACD
244 parseColor : function( x ){
247 if( X.Type.isNumber( x ) ){
248 return ( 0x0 <= x && x <= 0xFFFFFF ) ? x : undefined;
250 if( !X.Type.isString( x ) ) return;
252 if( X.Type.isNumber( rgb = X.Dom.Style.COLOR[ x.toUpperCase() ] ) && 0x0 <= rgb && rgb <= 0xFFFFFF ){
255 if( x.charAt( 0 ) === '#' ){
258 r = parseInt( x.substr( 1, 2 ), 16 );
259 g = parseInt( x.substr( 3, 2 ), 16 );
260 b = parseInt( x.substr( 5, 2 ), 16 );
263 r = parseInt( x.charAt( 1 ) + x.charAt( 1 ), 16 );
264 g = parseInt( x.charAt( 2 ) + x.charAt( 2 ), 16 );
265 b = parseInt( x.charAt( 3 ) + x.charAt( 3 ), 16 );
268 r = g = b = parseInt( x.charAt( 1 ) + x.charAt( 1 ), 16 );
274 if( x.indexOf( 'rgb(' ) === 0 ){
275 rgb = x.substr( 4 ).split( ',' );
276 r = parseFloat( rgb[ 0 ] );
277 g = parseFloat( rgb[ 1 ] );
278 b = parseFloat( rgb[ 2 ] );
279 if( x.indexOf( '%' ) !== -1 ){
285 if( x.indexOf( 'rgba(' ) === 0 ){
286 rgb = x.substr( 5 ).split( ',' );
287 r = parseFloat( rgb[ 0 ] );
288 g = parseFloat( rgb[ 1 ] );
289 b = parseFloat( rgb[ 2 ] );
290 //a = parseFloat( rgb[ 3 ] );
291 if( x.indexOf( '%' ) !== -1 ){
299 return isFinite( r + b + g ) ? ( r << 16 ) + ( g << 8 ) + b : undefined;
302 PARAMS : ( function(){
304 register( ret.percent = {},
305 'marginBottom,marginLeft,marginRight,marginTop,paddingBottom,paddingLeft,paddingRight,paddingTop,fontSize,textIndent'
307 register( ret.offset = {},
308 'height,width,bottom,left,right,top'
310 register( ret.size = {},
311 'borderBottomWidth,borderLeftWidth,borderRightWidth,borderTopWidth,letterSpacing,wordSpacing'
313 register( ret.color = {},
314 'backgroundColor,borderBottomColor,borderLeftColor,borderRightColor,borderTopColor,color'
316 register( ret.region = {},
317 'margin,padding,borderWidth,borderColor'
319 register( ret.special = {},
320 'clip,backgroundPosition,backgroundPositionX,backgroundPositionY,opacity,lineHeight,zIndex'
322 register( ret.unit = {}, 'px,cm,mm,in,pt,pc,em,%' );
324 register( ret.margin = {}, 'marginBottom,marginLeft,marginRight,marginTop,paddingBottom' );
325 register( ret.padding = {}, 'paddingBottom,paddingLeft,paddingRight,paddingTop' );
326 register( ret.borderWidth = {}, 'borderBottomWidth,borderLeftWidth,borderRightWidth,borderTopWidth' );
327 register( ret.borderColor = {}, 'borderBottomColor,borderLeftColor,borderRightColor,borderTopColor' );
329 function register( obj, params ){
330 params = params.split( ',' );
331 for( var i = params.length; i; ) obj[ params[ --i ] ] = true;
336 _CLIP_SEPARATOR : X.UA.IE && X.UA.IE < 8 ? ' ' : ',',
341 Property : X.Class.create(
345 Constructor : function( name, value, unit, xnode ){
355 equal : function( prop ){
356 if( this.unit === prop.unit ){
357 return this.value === prop.value;
359 return Math.abs( this.toPx() - prop.toPx() ) < 1;
361 convert: function( prop ){
362 var u = prop.unit, v;
363 if( this.unit === u ) return;
364 this.value = v = this.toPx();
367 // bgpX, bgpY の場合 X.Dom.Image.getActualDimension( backgroundImage url を使用 )
371 v / this.xnode._getCharSize() :
372 v / ( X.Dom.Style._UNIT_RATIO[ u ] || 1 );
375 setValue: function( v ){
378 getValue: function(){
381 getOffset: function( prop ){
382 return prop.value - this.value;
387 getValueText: function(){
388 return this.value === 0 ? '0' : this.value + this.unit;
391 var v = this.value, u = this.unit;
395 ( u === 'em' || ( u === '' && this.name === 'lineHeight' ) ) ?
396 v * this.xnode._getCharSize() :
398 v / ( X.Dom.Style._UNIT_RATIO[ u ] || 1 );
401 var p = X.Dom.Style.PARAMS,
405 z = u !== '' ? true : v === 0;
406 if( p.percent[ n ] === true ) return z;
407 if( p.offset[ n ] === true ) return z;
408 if( p.size[ n ] === true ) return z && u !== '%';
409 if( p.special[ n ] === true ){
410 if( n === 'lineHeight' ) return true;
411 if( n === 'opacity' ) return 0 <= v && v <= 1 && u === '';
412 if( n === 'zIndex' ) return u === '';
420 * backgroundPosition, clip
422 PropertyGroup : X.Class.create(
426 Constructor : function( name ){
429 for( var i = 1, l = arguments.length; i<l; ++i ){
430 this.props[ this.props.length ] = arguments[ i ];
434 equal : function( prop ){
435 var ps = this.props, i = ps.length;
438 if( ps[ i ].equal( prop[ i ] ) === false ) return false;
442 convert : function( prop ){
443 var ps = this.props, i = ps.length;
446 ps[ i ].convert( prop[ i ] );
449 setValue : function( ary ){
450 var ps = this.props, i = 0, l = ps.length;
452 ps[ i ].setValue( ary[ i ] );
455 getValue : function(){
456 var ret = [], ps = this.props, i = 0, l = ps.length;
458 ret[ ret.length ] = ps[ i ].getValue();
462 getOffset : function( prop ){
469 ret[ ret.length ] = ps[ i ].getOffset( _ps[ i ] );
473 getUnit : function(){
474 var ret = [], ps = this.props, i = 0, l = ps.length;
476 ret[ ret.length ] = ps[ i ].getUnit();
480 getValueText : function(){
481 var ret = [], ps = this.props, i = 0, l = ps.length;
483 ret[ ret.length ] = ps[ i ].getValueText();
485 if( this.name === 'clip' ){
486 return 'rect(' + ret.join( X.Dom.Style._CLIP_SEPARATOR ) + ')';
488 return ret.join( ' ' );
491 var ps = this.props, i = ps.length;
496 isValid : function( t ){
498 var ps = t.props, i = ps.length;
500 if( ps[ --i ].isValid() === false ) return false;
508 * http://css-eblog.com/ie-css-problems/rgba-pe.html
509 * ie67 では rgb() は background-color で反応しない、、、
512 ColorProperty : X.Class.create(
514 X.Class.POOL_OBJECT, {
515 Constructor : function( name, x ){
522 if( X.Type.isNumber( rgb = x ) || X.Type.isNumber( rgb = X.Dom.Style.COLOR[ x.toUpperCase() ] ) ){
523 r = ( rgb & 0xff0000 ) >> 16;
524 g = ( rgb & 0xff00 ) >> 8;
527 if( x.charAt( 0 ) === '#' ){
528 if( x.length === 7 ){
529 r = parseInt( x.charAt( 1 ) + x.charAt( 2 ), 16 );
530 g = parseInt( x.charAt( 3 ) + x.charAt( 4 ), 16 );
531 b = parseInt( x.charAt( 5 ) + x.charAt( 6 ), 16 );
533 if( x.length === 4 ){
534 r = parseInt( x.charAt( 1 ) + x.charAt( 1 ), 16 );
535 g = parseInt( x.charAt( 2 ) + x.charAt( 2 ), 16 );
536 b = parseInt( x.charAt( 3 ) + x.charAt( 3 ), 16 );
538 if( x.length === 2 ){
539 r = parseInt( x.charAt( 1 ) + x.charAt( 1 ), 16 );
540 g = parseInt( x.charAt( 1 ) + x.charAt( 1 ), 16 );
541 b = parseInt( x.charAt( 1 ) + x.charAt( 1 ), 16 );
544 if( x.indexOf( 'rgb(' ) === 0 ){
545 rgb = x.substr( 4 ).split( ',' );
546 r = parseFloat( rgb[ 0 ] );
547 g = parseFloat( rgb[ 1 ] );
548 b = parseFloat( rgb[ 2 ] );
549 if( x.indexOf( '%' ) !== -1 ) pct = true;
551 if( x.indexOf( 'rgba(' ) === 0 ){
552 rgb = x.substr( 5 ).split( ',' );
553 r = parseFloat( rgb[ 0 ] );
554 g = parseFloat( rgb[ 1 ] );
555 b = parseFloat( rgb[ 2 ] );
556 a = parseFloat( rgb[ 3 ] );
557 if( x.indexOf( '%' ) !== -1 ) pct = true;
577 equal : function( prop ){
578 if( this.pct === prop.pct ){
579 return this.r === prop.r && this.g === prop.g && this.b === prop.b;
581 var rgb = this._toPct(),
582 _rgb = prop._toPct(),
586 if( Math.abs( rgb[ i ] - _rgb[ i ] ) > 1 ) return false;
590 convert : function( prop ){
592 if( this.pct === u ) return;
593 x = u === true ? 100 / 255 : 2.55;
599 setValue : function( rgb ){
604 getValue : function(){
605 return [ this.r, this.g, this.b ];
607 getOffset : function( prop ){
608 return [ prop.r - this.r, prop.g - this.g, prop.b - this.b ];
610 getUnit : function(){
611 return this.pct === true ? '%' : '';
613 getValueText : function(){
614 if( this.pct === true ){
615 return [ 'rgb(', this.r, '%,', this.g, '%,', this.b, '%)' ].join( '' );
617 var round = Math.round;
619 var rgb = '00000' + ( ( round( this.r ) << 16 ) + ( round( this.g ) << 8 ) + round( this.b ) ).toString( 16 );
620 return '#' + rgb.substr( rgb.length - 6 );
623 if( this.pct === true ) return [ this.r, this.g, this.b ];
624 return [ this.r / 2.55, this.g / 2.55, this.b / 2.55 ];
626 isValid : function( t ){
627 var isFinite = window.isFinite;
628 if( !isFinite( this.r ) || !isFinite( this.g ) || !isFinite( this.b ) ) return false;
629 if( 0 > this.r || 0 > this.g || 0 > this.b ) return false;
630 if( this.pct === true ) return this.r <= 100 && this.g <= 100 && this.b <= 100;
631 return this.r <= 255 && this.g <= 255 && this.b <= 255;
636 _getProperty : function( xnode, css, unit, p ){
638 var XDomStyle = X.Dom.Style,
639 me = XDomStyle._getProperty,
640 PARAMS = XDomStyle.PARAMS,
641 PropertyGroup = XDomStyle.PropertyGroup,
642 Property = XDomStyle.Property,
643 ColorProperty = XDomStyle.ColorProperty,
646 if( PARAMS.special[ p ] === true || PARAMS.region[ p ] === true ){
649 // rect(...) クリップします。<top>, <bottom> は上端からの、 <right>, <left> は左端からのオフセットで指定します。Internet Explorer 4~7 では、カンマの代わりにスペースで区切る必要があります。
650 // position:absolute または position:fixed を適用した要素に対してのみ有効です。
651 var top = me( p + 'Top' ),
652 right = me( p + 'Right' ),
653 bottom = me( p + 'Bottom' ),
654 left = me( p + 'Left' ),
655 ret = new PropertyGroup( p, top, right, bottom, left ),
657 if( ret.isValid() === true ) return ret;
659 all = css[ p ].split( '(' )[ 1 ].split( ')' )[ 0 ].split( XDomStyle._CLIP_SEPARATOR );
663 new Property( p + 'Top', all[ 0 ], 'px', xnode ),
664 new Property( p + 'Right', all[ 1 ], 'px', xnode ),
665 new Property( p + 'Bottom', all[ 2 ], 'px', xnode ),
666 new Property( p + 'Left', all[ 3 ], 'px', xnode )
674 var props = '$1Top$2,$1Right$2,$1Bottom$2,$1Left$2'.split( '$1' ).join( name || 'border' ).split( '$2' ).join( width || 'Width' ).split( ',' ),
675 top = me( props[ 0 ] ),
676 right = me( props[ 1 ] ),
677 bottom = me( props[ 2 ] ),
678 left = me( props[ 3 ] ),
679 ret = new PropertyGroup( p, top, right, bottom, left ),
680 all, _0, _1, _2, _3, vu, v, u;
681 if( ret.isValid() === true ) return ret;
683 all = css[ p ].split( ' ' );
688 vu = XDomStyle._splitValueAndUnit( _0 );
691 switch( all.length ){
693 top = new Property( props[ 0 ], v, u, xnode );
694 right = new Property( props[ 1 ], v, u, xnode );
695 bottom = new Property( props[ 2 ], v, u, xnode );
696 left = new Property( props[ 3 ], v, u, xnode );
699 top = new Property( props[ 0 ], v, u, xnode );
700 bottom = new Property( props[ 2 ], v, u, xnode );
701 vu = XDomStyle._splitValueAndUnit( _1 );
704 right = new Property( props[ 1 ], v, u, xnode );
705 left = new Property( props[ 3 ], v, u, xnode );
708 top = new Property( props[ 0 ], v, u, xnode );
709 vu = XDomStyle._splitValueAndUnit( _1 );
712 right = new Property( props[ 1 ], v, u, xnode );
713 left = new Property( props[ 3 ], v, u, xnode );
714 vu = XDomStyle._splitValueAndUnit( _2 );
717 bottom = new Property( props[ 2 ], v, u, xnode );
720 top = new Property( props[ 0 ], v, u, xnode );
721 vu = XDomStyle._splitValueAndUnit( _1 );
724 right = new Property( props[ 1 ], v, u, xnode );
725 vu = XDomStyle._splitValueAndUnit( _2 );
728 bottom = new Property( props[ 2 ], v,u, xnode );
729 vu = XDomStyle._splitValueAndUnit( _3 );
732 left = new Property( props[ 3 ], v, u, xnode );
735 return new PropertyGroup( p, top, right, bottom, left );
738 var props = 'borderTopColor,borderRightColor,borderBottomColor,borderLeftColor'.split( ',' ),
739 top = me( props[ 0 ] ),
740 right = me( props[ 1 ] ),
741 bottom = me( props[ 2 ] ),
742 left = me( props[ 3 ] ),
743 ret = new PropertyGroup( p, top, right, bottom, left ),
745 if( ret.isValid() === true ) return ret;
747 all = css[ p ].split( ' ' );
750 switch( all.length ){
752 top = new ColorProperty( props[ 0 ], _0 );
753 right = new ColorProperty( props[ 1 ], _0 );
754 bottom = new ColorProperty( props[ 2 ], _0 );
755 left = new ColorProperty( props[ 3 ], _0 );
758 top = new ColorProperty( props[ 0 ], _0 );
759 right = new ColorProperty( props[ 1 ], _1 );
760 bottom = new ColorProperty( props[ 2 ], _0 );
761 left = new ColorProperty( props[ 3 ], _1 );
764 top = new ColorProperty( props[ 0 ], _0 );
765 right = new ColorProperty( props[ 1 ], _1 );
766 bottom = new ColorProperty( props[ 2 ], all[ 2 ] );
767 left = new ColorProperty( props[ 3 ], _1 );
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 ], all[ 3 ] );
776 return new PropertyGroup( p, top, right, bottom, left );
778 case 'backgroundPosition' :
779 var x = me( p + 'X' ),
781 ret = new PropertyGroup( p, x, y ),
783 if( ret.isValid() === true ) return ret;
785 xy = css[ p ].split( ' ' );
786 x = XDomStyle._splitValueAndUnit( xy[ 0 ] );
787 y = XDomStyle._splitValueAndUnit( xy[ 1 ] );
791 new Property( p + 'X', x[ 0 ], x[ 1 ], xnode ),
792 new Property( p + 'Y', y[ 0 ], y[ 1 ], xnode )
795 // opacity, zindex, lineHeight
796 vu = XDomStyle._splitValueAndUnit( css[ p ] );
797 return new Property( p, vu[ 0 ], vu[ 1 ], xnode );
799 var x = css[ p ], e, v, u;
801 if( PARAMS.offset[ p ] === true ){
802 return new Property( p, vu[ 0 ], vu[ 1 ], xnode );
805 if( p === 'width' ) v = e.offsetWidth;
806 if( p === 'height' ) v = e.offsetHeight;
807 if( p === 'top' ) v = e.offsetTop;
808 if( p === 'bottom' ) v = e.offsetBottom;
809 if( p === 'left' ) v = e.offsetLeft;
810 if( p === 'right' ) v = e.offsetRight;
811 u = _getUnit( x, p );
812 // alert( p + XDomStyle._Util.pxTo( v, u ) + u )
813 return new Property( p, XDomStyle._Util.pxTo( v, u ), u, xnode );
815 if( p === 'fontSize' && ( v = XDomStyle._FONT_SIZE_RATIO[ x ] ) ){ // xx-small 等
816 return new Property( p, v, 'px', xnode );
818 if( PARAMS.offset[ p ] || PARAMS.percent[ p ] || PARAMS.size[ p ] ){
819 vu = XDomStyle._splitValueAndUnit( x );
820 return new Property( p, vu[ 0 ], vu[ 1 ], xnode );
823 if( PARAMS.color[ p ] ) return new ColorProperty( p, x );
826 _splitValueAndUnit : function( v ){
828 if( X.Type.isNumber( v ) ) return [ v || 0, '' ];
829 if( isNaN( num = parseFloat( v ) ) ) return [ 0, '' ];
831 if( _num.indexOf( '0.' ) === 0 ) _num = _num.slice( 1 );
832 u = v.substr( v.indexOf( _num ) + _num.length );
833 return [ num, X.Dom.Style.UNIT[ u ] ? u : 'px' ];
837 X.Dom.Style._GET_VALUE_WITH_UNIT = {
838 borderWidth : X.Dom.Style.Type.QUARTET | X.Dom.Style.Type.LENGTH,
839 //borderStyle : X.Dom.Style.Type.QUARTET,
840 borderRadius : X.Dom.Style.Type.QUARTET | X.Dom.Style.Type.LENGTH,
841 margin : X.Dom.Style.Type.QUARTET | X.Dom.Style.Type.LENGTH | X.Dom.Style.Type.PERCENT,
842 padding : X.Dom.Style.Type.QUARTET | X.Dom.Style.Type.LENGTH | X.Dom.Style.Type.PERCENT,
843 clip : X.Dom.Style.Type.QUARTET | X.Dom.Style.Type.LENGTH | X.Dom.Style.Type.PERCENT,
845 backgroundColor : X.Dom.Style.Type.COLOR,
846 backgroundPosition : X.Dom.Style.Type.COMBI,
850 fontSize : X.Dom.Style.Type.LENGTH,
851 lineHeight : X.Dom.Style.Type.LENGTH | X.Dom.Style.Type.PERCENT | X.Dom.Style.Type.NUMERICAL,
852 textIndent : X.Dom.Style.Type.LENGTH,
853 letterSpacing : X.Dom.Style.Type.LENGTH,
854 wordSpacing : X.Dom.Style.Type.LENGTH,
856 textShadowColor : X.Dom.Style.Type.COLOR,
857 textShadowOffsetX : X.Dom.Style.Type.LENGTH,
858 textShadowOffsetY : X.Dom.Style.Type.LENGTH,
859 textShadowBlur : X.Dom.Style.Type.LENGTH, */
861 width : X.Dom.Style.Type.LENGTH | X.Dom.Style.Type.PERCENT,
862 height : X.Dom.Style.Type.LENGTH | X.Dom.Style.Type.PERCENT,
864 left : X.Dom.Style.Type.LENGTH | X.Dom.Style.Type.PERCENT,
865 top : X.Dom.Style.Type.LENGTH | X.Dom.Style.Type.PERCENT,
866 bottom : X.Dom.Style.Type.LENGTH | X.Dom.Style.Type.PERCENT,
867 right : X.Dom.Style.Type.LENGTH | X.Dom.Style.Type.PERCENT,
870 borderSpacing : X.Dom.Style.Type.LENGTH
874 X.Dom.Style.SPECIAL_FIX =
876 X.UA.IE && X.UA.IE < 9 && !X.UA.MacIE?
878 var test = X.Dom.Style.SPECIAL_FIX_PROP,
883 if( !( id = test[ p ] ) ) continue;
886 case 1 : //'filter' :
889 case 2 : //'opacity' :
890 filters[ ++n ] = 'alpha(opacity=' + v * 100 +')';
892 case 3 : //'boxShadow' :
893 // box-shadow: 10px 10px 10px 10px rgba(0,0,0,0.4) inset;
894 // スペース区切りで、水平方向の距離 垂直方向の距離 ぼかし距離 広がり距離 影の色 insetキーワードを指定する。 ぼかし距離 広がり距離 影の色 insetキーワードは省略可
895 // shadow(color=#cccccc, strength=10, direction=135);
896 v = X.Dom.Style._getProperty( this, css, 'px', 'boxShadow' );
897 dir = Math.atan2( v[ 1 ], v[ 0 ] ) * 180 / Math.PI + 90;
898 dir += dir < 0 ? 360 : 0;
899 filters[ ++n ] = 'shadow(color=' + v[ 4 ] + ',strength=' + v[ 3 ] + ',direction=' + dir + ')';
901 case 4 : //'textShadow' :
902 //text-shadow: 5px 5px 2px blue; 水平方向の距離 垂直方向の距離 影のぼかし半径 影の色 none
903 //glow(Color=yellow,Strength=10);
904 //どうやらCSSのbackgroundプロパティと同時に使えないようです。
908 case 5 : //'backgroundImage' :
912 return filters.join( ' ' );
914 // IE9 textShadow に filter を使用
915 X.UA.IE && 9 <= X.UA.IE && X.UA.IE < 10 ?
917 var test = X.Dom.Style.SPECIAL_FIX_PROP,
918 filters = [], p, id, v;
920 if( !( id = test[ p ] ) ) continue;
923 case 1 : //'filter' :
924 filters[ filters.length ] = v;
928 if( filters ) return filters.join( ' ' );
931 var test = X.Dom.Style.SPECIAL_FIX_PROP,
934 if( !( id = test[ p ] ) ) continue;
937 case 1 : //'backgroundPositionX' :
940 case 2 : //'backgroundPositionY' :
943 case 3 : //'backgroundPositionX' :
946 case 4 : //'backgroundPositionX' :
949 case 5 : //'backgroundPositionX' :
952 case 6 : //'backgroundPositionX' :
957 if( bgpX || bgpY ) ret[ ret.length ] = 'background-position:';
958 if( clipT || clipB || clipL || clipR ){
959 ret[ ret.length ] = 'clip:rect(';
961 return ret.join( ';' );
969 // unitID, name 単位指定のプロパティ取得 geter
971 // name, value setter
973 X.Dom.Node.prototype.css = function( nameOrObj /* orUnitID, valuOrUnitOrName */ ){
974 var XDomStyle = X.Dom.Style,
977 p, name, v, camelize, unit, ieFix;
978 if( this._xnodeType !== 1 ) return this;
980 if( X.Type.isObject( nameOrObj ) ){
981 if( !css ) css = this._css = {};
982 camelize = XDomStyle.camelize;
983 ieFix = X.Dom.Style.IE_FILTER_FIX;
984 for( p in nameOrObj ){
986 this._dirty |= X.Dom.Dirty.IE_FILTER;
989 v || v === 0 ? css[ camelize( p ) ] = v : delete css[ camelize( p ) ];
990 if( p === 'display' ){
991 v === 'none' ? ( this._state |= X.Dom.State.IE5_DISPLAY_NONE_FIX ) : ( this._state &= ~X.Dom.State.IE5_DISPLAY_NONE_FIX );
992 v === 'none' ? ( this._state |= X.Dom.State.DISPLAY_NONE ) : ( this._state &= ~X.Dom.State.DISPLAY_NONE );
995 this._dirty |= X.Dom.Dirty.CSS;
996 this.parent && this._reserveUpdate();
997 delete this._cssText;
1000 if( 1 < args.length ){
1001 if( !XDomStyle.UNIT[ nameOrObj ] ){
1002 // setter name, value
1003 if( !css ) css = this._css = {};
1004 name = XDomStyle.camelize( nameOrObj );
1006 if( css[ name ] === v ) return this;
1007 if( X.Dom.Style.IE_FILTER_FIX[ name ] ){
1008 this._dirty |= X.Dom.Dirty.IE_FILTER;
1010 if( !v && v !== 0 ){
1015 delete this._cssText;
1016 this._dirty |= X.Dom.Dirty.CSS;
1017 if( name === 'display' ){
1018 v === 'none' ? ( this._state |= X.Dom.State.IE5_DISPLAY_NONE_FIX ) : ( this._state &= ~X.Dom.State.IE5_DISPLAY_NONE_FIX );
1019 v === 'none' ? ( this._state |= X.Dom.State.DISPLAY_NONE ) : ( this._state &= ~X.Dom.State.DISPLAY_NONE );
1021 // parent でなく this._root! でなくて this._state & in tree
1022 this.parent && this._reserveUpdate();
1026 // unit 付の値取得は fontSize と 画像サイズが確定していないと正確に取れない。内部のみにする?
1028 if( !XDomStyle._GET_VALUE_WITH_UNIT[ name = XDomStyle.camelize( args[ 1 ] ) ] ) return null;
1029 p = XDomStyle._getProperty( this, css, nameOrObj, name );
1030 v = p.pxTo( nameOrObj );
1036 // 集計 border, padding, margin, backgroundPosition, clip
1037 // border で正確なデータを返せない時は、null を返す
1038 return css[ XDomStyle.camelize( nameOrObj ) ];
1041 X.Dom.Node.prototype.cssText = function( v ){
1042 var obj, i, l, attr, name;
1045 this._state &= ~X.Dom.State.IE5_DISPLAY_NONE_FIX;
1046 this._dirty |= X.Dom.Dirty.CSS;
1047 this.parent && this._reserveUpdate();
1048 delete this._cssText;
1051 if( X.Type.isString( v ) ){
1053 this._state &= ~X.Dom.State.IE5_DISPLAY_NONE_FIX;
1056 for( i = 0, l = v.length; i < l; ++i ){
1057 attr = v[ i ].split( ':' );
1058 ( name = attr[ 0 ] ) && ( obj[ name ] = attr[ 1 ] || true );
1060 return this.css( obj );
1063 if( this._dirty & X.Dom.Dirty.CSS && !( this._cssText = X.Dom.Style.objToCssText( this._css ) ) ){
1064 delete this._cssText;
1066 return this._cssText;
1070 * ここでは HTMLElement のチ1ェックは行わない!
1072 * body に css attr がセットされた場合には X.Dom.baseFontSize をクリア
1075 X.Dom.Node.prototype._getCharSize =
1076 window.getComputedStyle ?
1078 Node.root._updateTimerID && Node.root._startUpdate();
1079 if( this === Node.root && X.Dom.baseFontSize ) return X.Dom.baseFontSize;
1080 if( this._fontSize ) return this._fontSize;
1081 return this._fontSize = parseFloat( getComputedStyle( this._rawNode, null ).fontSize );
1083 document.defaultView && document.defaultView.getComputedStyle ?
1085 Node.root._updateTimerID && Node.root._startUpdate();
1086 if( this === Node.root && X.Dom.baseFontSize ) return X.Dom.baseFontSize;
1087 if( this._fontSize ) return this._fontSize;
1088 return this._fontSize = parseFloat( document.defaultView.getComputedStyle( this._rawNode, null ).fontSize );
1090 X.UA.IE && 5.5 <= X.UA.IE ?
1092 var font, vu, v, u, _v;
1093 Node.root._updateTimerID && Node.root._startUpdate();
1094 if( this === Node.root && X.Dom.baseFontSize ) return X.Dom.baseFontSize;
1095 if( this._fontSize ) return this._fontSize;
1097 font = this._rawNode.currentStyle.fontSize;
1098 //font = this._css && this._css.fontSize || '1em';
1099 vu = X.Dom.Style._splitValueAndUnit( font );
1104 if( v = X.Dom.Style._FONT_SIZE_RATIO[ font ] ) return this._fontSize = v;
1106 if( _v = X.Dom.Style._UNIT_RATIO[ u ] ) return this._fontSize = v / _v;
1110 return this._fontSize = v;
1112 // body まで辿ってしまった場合は?
1113 if( this.parent ) return this._fontSize = this.parent._getCharSize() * v;
1116 // body まで辿ってしまった場合は?
1117 if( this.parent ) return this._fontSize = this.parent._getCharSize() * v / 100;
1124 Node.root._updateTimerID && Node.root._startUpdate();
1125 if( this === Node.root && X.Dom.baseFontSize ) return X.Dom.baseFontSize;
1126 if( this._fontSize ) return this._fontSize;
1128 this._rawNode.appendChild( elm = document.createElement( 'span' ) );
1129 elm.style.cssText = 'display:block;position:absolute;top:0;left:0;visivility:hidden;line-height:1;height:1em;';
1130 elm.innerHTML = 'X';
1131 v = elm.offsetHeight;
1132 this._rawNode.removeChild( elm );
1133 return this._fontSize = v;
1137 var font, vu, v, u, _v;
1138 Node.root._updateTimerID && Node.root._startUpdate();
1139 if( this === Node.root && X.Dom.baseFontSize ) return X.Dom.baseFontSize;
1140 if( this._fontSize ) return this._fontSize;
1142 if( this._css && ( font = this._css.fontSize ) ){
1143 vu = X.Dom.Style._splitValueAndUnit( font );
1148 if( _v = X.Dom.Style._FONT_SIZE_RATIO[ font ] ) return this._fontSize = _v;
1150 if( _v = X.Dom.Style._UNIT_RATIO[ u ] ) return this._fontSize = v / _v;
1159 return this._fontSize = v;
1161 // body まで辿ってしまった場合は?
1162 if( this.parent ) return this._fontSize = this.parent._getCharSize() * v;
1165 // body まで辿ってしまった場合は?
1166 if( this.parent ) return this._fontSize = this.parent._getCharSize() * v / 100;
1172 if( this === Node.root && X.Dom.baseFontSize ) return X.Dom.baseFontSize;
1173 Node.root._updateTimerID && Node.root._startUpdate();
1174 if( this._fontSize ) return this._fontSize;
1176 elm = this._rawNode || this._ie4getRawNode();
1177 elm.insertAdjacentHTML( 'BeforeEnd', '<span style="visivility:hidden;line-height:1;">X</span>' );
1178 elm = elm.children[ elm.children.length - 1 ];
1179 v = elm.offsetHeight;
1181 return this._fontSize = v * 0.75;
1185 X.Dom.listenOnce( X.Dom.Event.DOM_PRE_INIT, function(){
1186 var testStyle = X.Dom._root.style;
1188 X.Dom.Style.VENDER_PREFIX = (function(){
1190 vendors = 'webkit,Webkit,Moz,moz,ms,Ms,O,o,khtml,Khtml'.split( ',' ),
1192 'opacity,boxSizing,' +
1193 'transform,transformOrigin,perspective,' +
1194 'transisiton,transitionDelay,transitionProperty,transitionDuration,transitionTimingFunction,' +
1195 'userSelect,touchAction,touchCallout,contentZooming,userDrag,tapHighlightColor'.split( ',' ),
1196 vendor, i, search, prop;
1198 vendors.unshift( '' );
1200 function findVenderPrefix( prop ){
1201 var v, i = vendors.length;
1205 if( testStyle[ v + prop ] !== undefined ){
1212 for( i = searches.length; i; ){
1213 search = searches[ --i ];
1214 prop = findVenderPrefix( search );
1215 if( search === 'transform' ) ret.transVender = vendor;
1216 if( prop ) ret[ search ] = prop;
1221 X.Dom.Style.SPECIAL_FIX_PROP =
1223 X.UA.IE && X.UA.IE < 9 && !X.UA.MacIE ?
1226 opacity : 2//, uinode ChromeNode で行う
1229 //backgroundImage : 5
1232 X.UA.IE && 9 <= X.UA.IE && X.UA.IE < 10 ?
1238 backgroundPositionX : testStyle.backgroundPositionX === undefined ? 3 : 0,
1239 backgroundPosiitonY : testStyle.backgroundPositionX === undefined ? 3 : 0,
1240 clipTop : testStyle.clipTop === undefined && testStyle[ 'clip-top' ] === undefined ? 3 : 0,
1241 clipBottom : testStyle.clipTop === undefined && testStyle[ 'clip-top' ] === undefined ? 4 : 0,
1242 clipLeft : testStyle.clipTop === undefined && testStyle[ 'clip-top' ] === undefined ? 5 : 0,
1243 clipRight : testStyle.clipTop === undefined && testStyle[ 'clip-top' ] === undefined ? 6 : 0
1247 X.Dom.listenOnce( X.Dom.Event.DOM_INIT, function(){
1248 var xnode = Node._systemNode,
1249 output = X.Dom.Style._UNIT_RATIO = {},
1250 list = 'cm,mm,in,pt,pc'.split( ',' ),
1253 for( i = list.length; i; ){
1255 output[ unit ] = xnode.css( 'width', 10 + unit ).width() / 10;
1258 output = X.Dom.Style._FONT_SIZE_RATIO = {},
1259 list = 'xx-large,x-large,large,larger,medium,small,smaller,x-small,xx-small'.split( ',' );
1260 xnode.css( { lineHeight : '100%', height : '1em' } ).text( 'X' );
1262 for( i = list.length; i; ){
1264 output[ size ] = xnode.css( 'fontSize', size ).height();// / base;
1267 xnode.cssText( '' ).empty();