OSDN Git Service

Version 0.6.106, bugfix for X.EventDispatcher, cleanup X.Node, Image JSONP for Opera1...
[pettanr/clientJs.git] / 0.6.x / js / 02_dom / 06_XNodeCSS.js
index 7fa9641..f0f3309 100644 (file)
@@ -367,7 +367,7 @@ X_Node_CSS_Property = X.Class.create(
                                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 );
                                };
                        },
@@ -392,7 +392,7 @@ X_Node_CSS_Property = X.Class.create(
                                        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 );
                        },
@@ -1067,85 +1067,85 @@ Node.prototype.cssText = function( v ){
  * 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;
@@ -1154,31 +1154,18 @@ Node.prototype._getCharSize =
 
                        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 = {