if( u !== 'px' ){
this.value =
u === 'em' ?
- v / this.xnode._getCharSize() :
+ v / X_Node_CSS_getCharSize( this.xnode ) :
v / ( X_Node_CSS__UNIT_RATIO[ u ] || 1 );
};
},
u === 'px' ?
v :
( u === 'em' || ( u === '' && this.name === 'lineHeight' ) ) ?
- v * this.xnode._getCharSize() :
+ v * X_Node_CSS_getCharSize( this.xnode ) :
// u === '%'
v / ( X_Node_CSS__UNIT_RATIO[ u ] || 1 );
},
* TODO
* body に css attr がセットされた場合には X_ViewPort_baseFontSize をクリア
*/
-
-Node.prototype._getCharSize =
+var
+X_Node_CSS_getCharSize =
window.getComputedStyle ?
- (function(){
- X_Node_body._updateTimerID && X_Node_startUpdate();
- if( this === X_Node_body && X_ViewPort_baseFontSize ) return X_ViewPort_baseFontSize;
- if( this._fontSize ) return this._fontSize;
- return this._fontSize = parseFloat( getComputedStyle( this._rawObject, null ).fontSize );
+ (function( that ){
+ X_Node_updateTimerID && X_Node_startUpdate();
+ if( that === X_Node_body && X_ViewPort_baseFontSize ) return X_ViewPort_baseFontSize;
+ if( that._fontSize ) return that._fontSize;
+ return that._fontSize = parseFloat( getComputedStyle( that._rawObject, null ).fontSize );
}) :
document.defaultView && document.defaultView.getComputedStyle ?
- (function(){
- X_Node_body._updateTimerID && X_Node_startUpdate();
- if( this === X_Node_body && X_ViewPort_baseFontSize ) return X_ViewPort_baseFontSize;
- if( this._fontSize ) return this._fontSize;
- return this._fontSize = parseFloat( document.defaultView.getComputedStyle( this._rawObject, null ).fontSize );
+ (function( that ){
+ X_Node_updateTimerID && X_Node_startUpdate();
+ if( that === X_Node_body && X_ViewPort_baseFontSize ) return X_ViewPort_baseFontSize;
+ if( that._fontSize ) return that._fontSize;
+ return that._fontSize = parseFloat( document.defaultView.getComputedStyle( that._rawObject, null ).fontSize );
}) :
5.5 <= X_UA.IE ?
- (function(){
+ (function( that ){
var font, vu, v, u, _v;
- X_Node_body._updateTimerID && X_Node_startUpdate();
- if( this === X_Node_body && X_ViewPort_baseFontSize ) return X_ViewPort_baseFontSize;
- if( this._fontSize ) return this._fontSize;
+ X_Node_updateTimerID && X_Node_startUpdate();
+ if( that === X_Node_body && X_ViewPort_baseFontSize ) return X_ViewPort_baseFontSize;
+ if( that._fontSize ) return that._fontSize;
- font = this._rawObject.currentStyle.fontSize;
- //font = this._css && this._css.fontSize || '1em';
+ font = that._rawObject.currentStyle.fontSize;
+ //font = that._css && that._css.fontSize || '1em';
vu = X_Node_CSS__splitValueAndUnit( font );
v = vu[ 0 ];
u = vu[ 1 ];
if( v === 0 ){
- if( v = X_Node_CSS__FONT_SIZE_RATIO[ font ] ) return this._fontSize = v;
+ if( v = X_Node_CSS__FONT_SIZE_RATIO[ font ] ) return that._fontSize = v;
} else {
- if( _v = X_Node_CSS__UNIT_RATIO[ u ] ) return this._fontSize = v / _v;
+ if( _v = X_Node_CSS__UNIT_RATIO[ u ] ) return that._fontSize = v / _v;
};
switch( u ){
case 'px' :
- return this._fontSize = v;
+ return that._fontSize = v;
case 'em' :
// body まで辿ってしまった場合は?
- if( this.parent ) return this._fontSize = this.parent._getCharSize() * v;
+ if( that.parent ) return that._fontSize = X_Node_CSS_getCharSize( that.parent ) * v;
break;
case '%' :
// body まで辿ってしまった場合は?
- if( this.parent ) return this._fontSize = this.parent._getCharSize() * v / 100;
+ if( that.parent ) return that._fontSize = X_Node_CSS_getCharSize( that.parent ) * v / 100;
};
return 0;
}) :
X_UA_DOM.W3C ?
- (function(){
+ (function( that ){
var elm, v;
- X_Node_body._updateTimerID && X_Node_startUpdate();
- if( this === X_Node_body && X_ViewPort_baseFontSize ) return X_ViewPort_baseFontSize;
- if( this._fontSize ) return this._fontSize;
+ X_Node_updateTimerID && X_Node_startUpdate();
+ if( that === X_Node_body && X_ViewPort_baseFontSize ) return X_ViewPort_baseFontSize;
+ if( that._fontSize ) return that._fontSize;
- this._rawObject.appendChild( elm = document.createElement( 'span' ) );
+ that._rawObject.appendChild( elm = document.createElement( 'span' ) );
elm.style.cssText = 'display:block;position:absolute;top:0;left:0;visivility:hidden;line-height:1;height:1em;';
elm.innerHTML = 'X';
v = elm.offsetHeight;
- this._rawObject.removeChild( elm );
- return this._fontSize = v;
+ that._rawObject.removeChild( elm );
+ return that._fontSize = v;
}) :
X_UA_DOM.IE4 ?
- (function(){
+ (function( that ){
var font, vu, v, u, _v;
- X_Node_body._updateTimerID && X_Node_startUpdate();
- if( this === X_Node_body && X_ViewPort_baseFontSize ) return X_ViewPort_baseFontSize;
- if( this._fontSize ) return this._fontSize;
+ X_Node_updateTimerID && X_Node_startUpdate();
+ if( that === X_Node_body && X_ViewPort_baseFontSize ) return X_ViewPort_baseFontSize;
+ if( that._fontSize ) return that._fontSize;
- if( this._css && ( font = this._css.fontSize ) ){
+ if( that._css && ( font = that._css.fontSize ) ){
vu = X_Node_CSS__splitValueAndUnit( font );
v = vu[ 0 ];
u = vu[ 1 ];
if( v === 0 ){
- if( _v = X_Node_CSS__FONT_SIZE_RATIO[ font ] ) return this._fontSize = _v;
+ if( _v = X_Node_CSS__FONT_SIZE_RATIO[ font ] ) return that._fontSize = _v;
} else {
- if( _v = X_Node_CSS__UNIT_RATIO[ u ] ) return this._fontSize = v / _v;
+ if( _v = X_Node_CSS__UNIT_RATIO[ u ] ) return that._fontSize = v / _v;
};
} else {
v = 1;
switch( u ){
case 'px' :
- return this._fontSize = v;
+ return that._fontSize = v;
case 'em' :
// body まで辿ってしまった場合は?
- if( this.parent ) return this._fontSize = this.parent._getCharSize() * v;
+ if( that.parent ) return that._fontSize = X_Node_CSS_getCharSize( that.parent ) * v;
break;
case '%' :
// body まで辿ってしまった場合は?
- if( this.parent ) return this._fontSize = this.parent._getCharSize() * v / 100;
+ if( that.parent ) return that._fontSize = X_Node_CSS_getCharSize( that.parent ) * v / 100;
};
return 0;
}) :
- // ie5?
- (function(){
- var elm, v;
- if( this === X_Node_body && X_ViewPort_baseFontSize ) return X_ViewPort_baseFontSize;
- X_Node_body._updateTimerID && X_Node_startUpdate();
- if( this._fontSize ) return this._fontSize;
-
- elm = this._rawObject;
- elm.insertAdjacentHTML( 'BeforeEnd', '<span style="visivility:hidden;line-height:1;">X</span>' );
- elm = elm.children[ elm.children.length - 1 ];
- v = elm.offsetHeight;
- elm.outerHTML = '';
- return this._fontSize = v * 0.75;
- });
+ 0;
X.CSS = {