OSDN Git Service

Version 0.6.25, bugfix.
[pettanr/clientJs.git] / 0.6.x / js / dom / 13_XDomBoxModel.js
index 6d488a1..94336e9 100644 (file)
@@ -10,7 +10,7 @@ X.Dom.BoxModel = {
 
 X.Dom.listenOnce( X.Dom.Event.DOM_INIT, function(){
 
-       var elm = Node._systemNode._rawNode;
+       var elm = Node._systemNode._rawNode || Node._systemNode._ie4getRawNode();
        elm.style.cssText = 'width:10px;padding:1px;border:2px solid #0;margin:4px;';
        
        X.Dom.BoxModel.defaultBoxModel = elm.offsetWidth === 10 ?
@@ -22,8 +22,6 @@ X.Dom.listenOnce( X.Dom.Event.DOM_INIT, function(){
                
                X.Dom.BoxModel.boxSizingEnabled = elm.offsetWidth === 10;
        };
-       
-
        // padding
        // border
        // margin
@@ -33,36 +31,39 @@ X.Dom.listenOnce( X.Dom.Event.DOM_INIT, function(){
 });
 
 /* --------------------------------------
- *  Width, Height
- *  overflow:hidden かつ width か height が設定されていたら、再描画しないでその値を返す
+ * Width, Height
+ *  display:blobk かつ overflow:hidden かつ size(px,em)が設定されていたら、再描画しないでその値を返す
+ *  display:none なら 0
  */
 Node.prototype.width = function(){
-       var elm;
-       if( !this.parent ) return 0;
+       if( !this.parent ){
+               console.log( 'xnode.width() : no parent' );
+               return 0;
+       };
+       Node.root._updateTimerID && Node.root._startUpdate();
        if( document.getElementById ){
                // this.css( X.Dom.Style.Unit.px, 'width' );
-               return ( elm = this._rawNode ) ? elm.offsetWidth : 0;
+               return this._rawNode.offsetWidth;
        } else
        if( document.all ){
-               if( !( elm = this._ie4getRawNode() ) ) return 0;
-               Node.root._ie4reserved === true && Node.root._ie4startUpdate();
-               return elm.offsetWidth;
+               return ( this._rawNode || this._ie4getRawNode() ).offsetWidth;
        } else {
                
        };
 };
 
 Node.prototype.height = function(){
-       var elm;
-       if( !this.parent ) return 0;
+       if( !this.parent ){
+               console.log( 'xnode.height() : no parent' );
+               return 0;
+       };
+       Node.root._updateTimerID && Node.root._startUpdate();
        if( document.getElementById ){
                // this.css( X.Dom.Style.Unit.px, 'height' );
-               return ( elm = this._rawNode ) ? elm.offsetHeight : 0;
+               return this._rawNode.offsetHeight;
        } else
        if( document.all ){
-               if( !( elm = this._ie4getRawNode() ) ) return 0;
-               Node.root._ie4reserved === true && Node.root._ie4startUpdate();
-               return elm.offsetHeight;                
+               return ( this._rawNode || this._ie4getRawNode() ).offsetHeight;
        } else {
                
        };
@@ -70,42 +71,45 @@ Node.prototype.height = function(){
 
 /* --------------------------------------
  *  x, y
- *  position:absolute かつ x か y が設定されていたら、再描画しないでその値を返す。
- *  position:absolute の指定で自動で top,left を補う必要あり?
+ *  position:absolute かつ x か y が設定されていたら、再描画しないで css オブジェクトから計算した値を返す。 float は?
+ *  position:absolute の指定で自動で top,left を補う必要あり? -> X.Dom.Style
  *  親要素 border 外側からの値。 IE, Firefox, Safari, Chrome の offsetLeft/Topでは、border 内側なので補正する。
  * transformX, Y は加える? アニメーション中は?
  */
 // X.Dom.Style.transform,
 Node.prototype.x = function(){
-       var elm;
-       if( !this.parent ) return 0;
+       if( !this.parent ){
+               console.log( 'xnode.x() : no parent' );
+               return 0;
+       };
+       Node.root._updateTimerID && Node.root._startUpdate();
        if( document.getElementById ){
                // this.css( X.Dom.Style.Unit.px, 'left' );
                // this.css( X.Dom.Style.Unit.px, 'translateX' );
-               return ( elm = this._rawNode ) ? elm.offsetLeft : 0;
+               return this._rawNode.offsetLeft;
        } else
        if( document.all ){
-               if( !( elm = this._ie4getRawNode() ) ) return 0;
-               Node.root._ie4reserved === true && Node.root._ie4startUpdate();
-               return elm.offsetLeft;          
+               return ( this._rawNode || this._ie4getRawNode() ).offsetLeft;
        } else {
                
        };
 };
 
 Node.prototype.y = function(){
-       var elm;
-       if( !this.parent ) return 0;
+       if( !this.parent ){
+               console.log( 'xnode.y() : no parent' );
+               return 0;
+       };
+       Node.root._updateTimerID && Node.root._startUpdate();
        if( document.getElementById ){
                // this.css( X.Dom.Style.Unit.px, 'top' );
                // this.css( X.Dom.Style.Unit.px, 'transisitonY' );
-               return ( elm = this._rawNode ) ? elm.offsetTop : 0;
+               return this._rawNode.offsetTop;
        } else
        if( document.all ){
-               if( !( elm = this._ie4getRawNode() ) ) return 0;
-               Node.root._ie4reserved === true && Node.root._ie4startUpdate();
-               return elm.offsetTop;           
+               return ( this._rawNode || this._ie4getRawNode() ).offsetTop;            
        } else {
                
        };
-};
\ No newline at end of file
+};
+