From: itozyun Date: Sun, 25 Jan 2015 12:09:50 +0000 (+0900) Subject: Version 0.6.125, bugfix X.Node. X-Git-Url: http://git.osdn.jp/view?a=commitdiff_plain;h=d6670d07eb6589113c94af832862a93f2d010cdd;p=pettanr%2FclientJs.git Version 0.6.125, bugfix X.Node. --- diff --git a/0.6.x/js/02_dom/02_XNode.js b/0.6.x/js/02_dom/02_XNode.js index d526b36..58d523a 100644 --- a/0.6.x/js/02_dom/02_XNode.js +++ b/0.6.x/js/02_dom/02_XNode.js @@ -6,6 +6,7 @@ var IN_TREE : 0x2, // xnode が(仮想)ツリーに追加されている -> 描画の対象 ELM_NEED_INIT : 2 << 1, + ELM_HAS_PARENT : 2 << 1, STYLE_IS_DISPLAY_NONE : 2 << 2, // display : none STYLE_IS_INVISIBLE : 2 << 3, // visibility : hidden or opacity : 0 @@ -29,6 +30,8 @@ var OLD_ATTRTEXT : 2 << 18, OLD_CSSTEXT : 2 << 19, + IE_FILTER_NOW : 2 << 20, + GPU_WAITING : 2 << 20, // 1:子のGPU解除待 GPU_RESERVED : 2 << 21, // 2:GPU予約 GPU_NOW : 2 << 20 | 2 << 21, // 3:GPU now!() @@ -54,7 +57,7 @@ var X_Node_State.STYLE_IS_FONT_PCT ), X_Node_BitMask_IS_DIRTY = - X_Node_State.DIRTY_CHILD | X_Node_State.DIRTY_CONTENT | X_Node_State.DIRTY_ID | X_Node_State.DIRTY_CLASSNAME | + X_Node_State.DIRTY_CONTENT | X_Node_State.DIRTY_ID | X_Node_State.DIRTY_CLASSNAME | X_Node_State.DIRTY_ATTR | X_Node_State.DIRTY_CSS | X_Node_State.DIRTY_IE_FILTER, X_Node_BitMask_RESET_DIRTY = ( ( 2 << 29 ) - 1 + ( 2 << 29 ) ) ^ X_Node_BitMask_IS_DIRTY, @@ -622,12 +625,15 @@ function X_Node_remove(){ delete this.parent; parent._xnodes.splice( parent._xnodes.indexOf( this ), 1 ); + if( this._flags & X_Node_State.IN_TREE ){ - this._flags ^= X_Node_State.IN_TREE; + this._flags &= ~X_Node_State.IN_TREE & ~X_Node_State.IE4_TEXTNODE_EXIST; this._xnodes && X_Node_toggleInTreeFlag( this._xnodes, false ); - X_Node_reserveRemoval[ X_Node_reserveRemoval.length ] = this; - X_Node_reserveUpdate(); + //if( ( elm = this._rawObject ) && elm.parentNode && elm.parentNode.tagName ){ + X_Node_reserveRemoval[ X_Node_reserveRemoval.length ] = this; + X_Node_reserveUpdate(); + //}; }; return this; }; @@ -661,29 +667,28 @@ function X_Node_destroy( isChild ){ }; elm && this._listeners && this.unlisten(); // イベントの退避 - delete X_Node_CHASHE[ this._uid ]; - delete this._flags; - if( this._flags & X_Node_State.IN_TREE ){ !isChild && this.remove(); + delete this._flags; } else { this.parent && this.parent._xnodes.splice( this.parent._xnodes.indexOf( this ), 1 ); elm && !isChild && X_Node__actualRemove( this ); this.kill(); }; + + delete X_Node_CHASHE[ this._uid ]; }; -function X_Node_onKill( e ){ +function X_Node_onBeforeKill( e ){ var elm = this._rawObject || X_UA_DOM.IE4 && X_Node__ie4getRawNode( this ); delete X_Node_CHASHE[ this._uid ]; - delete this._flags; - if( this._flags & X_Node_State.IN_TREE ){ - this.remove(); - } else { - this.parent && this.parent._xnodes.splice( this.parent._xnodes.indexOf( this ), 1 ); - elm && X_Node__actualRemove( this ); + this.remove(); + + if( elm && elm.parentNode && elm.parentNode.tagName ){ + delete this._flags; + return X.Callback.PREVENT_DEFAULT; }; }; @@ -884,7 +889,7 @@ function X_Node_text( text ){ if( !this._tag ){ if( this._text !== text ){ - text ? ( this._text = text ) : delete this.text; + text ? ( this._text = text ) : delete this._text; this._flags |= X_Node_State.DIRTY_CONTENT; this._flags & X_Node_State.IN_TREE && X_Node_reserveUpdate(); }; @@ -1016,7 +1021,7 @@ function X_Node_startUpdate( time ){ for( ; i; ){ xnode = removal[ --i ]; X_Node__actualRemove( xnode ); - !X_Node_body._flags && xnode.kill(); + X_Node_body._flags && !xnode._flags && xnode.kill(); }; removal.length = 0; }; @@ -1040,13 +1045,15 @@ var X_Node__commitUpdate = X_UA_DOM.W3C ? ( function( that, parentElement, nextElement ){ var elm = that._rawObject, - xnodes, l, i, frg, next, k, v; - - if( X_Node_displayNoneFixForIE5 && that._flags & X_Node_State.STYLE_IS_DISPLAY_NONE ){ - // filter の効いている要素だけdisplay:none が無視される模様。filter を切ればよい? - // 親が、display:none の場合は? - elm && elm.parentNode && X_Node__actualRemove( that ); - return nextElement; + xnodes, l, next; + + if( X_Node_displayNoneFixForIE5 ){ + // filter の効いている要素を含む要素は display:none が無視される。 + // filter = '' で削除はできるが、再表示時に filter が消える。 -> filter な要素を削除してしまう。 + if( that._flags & X_Node_State.STYLE_IS_DISPLAY_NONE ){ + elm && elm.parentNode && X_Node__actualRemove( that ); + return nextElement; + }; }; if( !elm || ( parentElement && elm.parentNode !== parentElement ) || ( nextElement && elm.nextSibling !== nextElement ) ){ @@ -1054,7 +1061,6 @@ var X_Node__commitUpdate = parentElement.insertBefore( X_Node__actualCreate( that ), nextElement ) : parentElement.appendChild( X_Node__actualCreate( that ) ); X_Node__afterActualCreate( that ); - return elm || that._rawObject; } else if( ( xnodes = that._xnodes ) && ( l = xnodes.length ) ) { @@ -1065,14 +1071,12 @@ var X_Node__commitUpdate = delete that._fontSize; - if( that._flags & X_Node_BitMask_IS_DIRTY ){ - X_Node__updateRawNode( that, elm ); - } else - if( that._tag && X_Node_displayNoneFixForIE5 && elm.currentStyle.display === 'none' ){ - // TODO 親要素への変更で display:none が変わる場合もあるのでここで調べる - }; - - if( X_Node_displayNoneFixForIE5 && that._flags & X_Node_State.STYLE_IS_DISPLAY_NONE ){ + that._flags & X_Node_BitMask_IS_DIRTY && X_Node__updateRawNode( that, elm ); + + // ie5 only + // 親及び自身へのクラス・id指定で display : none になるケースもある + if( X_Node_displayNoneFixForIE5 && that._tag && elm.currentStyle.display === 'none' ){ + X_Node__actualRemove( that ); return nextElement; }; return elm; @@ -1150,20 +1154,9 @@ var X_Node__updateRawNode = that._className ? ( elm.className = that._className ) : ( elm.className && elm.removeAttribute( X_UA.IE5678 ? 'className' : 'class' ) ); // className は ie7-? }; - // ie5 only - // TODO 親へのクラス・id指定で display : none になるケースもある - if( X_Node_displayNoneFixForIE5 && elm.currentStyle.display === 'none' ){ - X_Node__actualRemove( that ); - that._flags |= X_Node_State.STYLE_IS_DISPLAY_NONE; - return; - }; - - if( that._flags & X_Node_State.DIRTY_IE_FILTER ){ - elm.style.filter = X_Node_CSS_objToIEFilterText( that );; - }; + // TODO display:none の場合、更新をスキップ // attr - // TODO display:none の場合、更新をスキップ if( that._flags & X_Node_State.DIRTY_ATTR && ( attrs = that._newAttrs || that._attrs ) ){ rename = X_Node_Attr_renameForDOM; @@ -1192,9 +1185,9 @@ var X_Node__updateRawNode = }; // style - // TODO display:none の場合、更新をスキップ if( that._flags & X_Node_State.DIRTY_CSS ){ if( that._flags & X_Node_State.OLD_CSSTEXT ? X_Node_CSS_objToCssText( that ) : that._cssText ){ + if( !elm.style ) alert(that.call('outerHTML')); X_UA.Opera78 || X_UA.NN6 ? elm.setAttribute( 'style', that._cssText ) : // opera8用 ( elm.style.cssText = that._cssText ); @@ -1203,6 +1196,15 @@ var X_Node__updateRawNode = elm.removeAttribute( 'style' ); delete that._cssText; }; + } else + if( that._flags & X_Node_State.DIRTY_IE_FILTER ){ + elm.style.filter = v = X_Node_CSS_objToIEFilterText( that ); + //alert( 'updateraw ' + that.call('outerHTML') ); + if( v ){ + that._flags |= X_Node_State.IE_FILTER_NOW; + } else { + that._flags &= ~X_Node_State.IE_FILTER_NOW; + }; }; that._flags &= X_Node_BitMask_RESET_DIRTY; @@ -1241,7 +1243,12 @@ var X_Node__updateRawNode = }; if( that._flags & X_Node_State.DIRTY_IE_FILTER ){ - that._rawObject.style.filter = X_Node_CSS_objToIEFilterText( that );; + that._rawObject.style.filter = v = X_Node_CSS_objToIEFilterText( that ); + if( v ){ + that._flags |= X_Node_State.IE_FILTER_NOW; + } else { + that._flags &= ~X_Node_State.IE_FILTER_NOW; + }; }; // attr @@ -1285,6 +1292,8 @@ var X_Node__actualCreate = if( !that._tag ){ if( elm ) return elm; that._flags &= X_Node_BitMask_RESET_DIRTY; + //console.log( 'create ' + that._text ); + console.log( document.createTextNode( X_String_chrReferanceTo( that._text ) ) ); return that._rawObject = document.createTextNode( X_String_chrReferanceTo( that._text ) ); }; @@ -1303,9 +1312,6 @@ var X_Node__actualCreate = that._cssText ? ' style="' + that._cssText + '"' : '', '>' ].join( '' ) ) : document.createElement( that._tag ); - - - console.log( '##' + that._attrText + '##' ); }; if( X_Node_useDocumentFragment ){ if( ( xnodes = that._xnodes ) && ( l = xnodes.length ) ){ @@ -1363,7 +1369,7 @@ var X_Node__actualCreate = var X_Node__afterActualCreate = X_UA_DOM.W3C ? (function( that ){ - var elm = that._rawObject, xnodes, l, i; + var elm = that._rawObject, xnodes, l, i, v; if( !that._tag ){ that._flags & X_Node_BitMask_IS_DIRTY && X_Node__updateRawNode( that, elm ); @@ -1373,21 +1379,32 @@ var X_Node__afterActualCreate = xnodes = that._xnodes; l = xnodes && xnodes.length; + + // src の onload があるので先ではないか? + // TODO ie の str から要素を作る場合、srcだけ イベント設定後ではないか? + X_EventDispatcher_toggleAllEvents( that, true );// イベントの復帰 + if( that._flags & X_Node_State.ELM_NEED_INIT ){ - if( !X_Node_useDocumentFragment ){// docFrg が使えない場合、doc 追加後に子を追加 + if( !X_Node_useDocumentFragment ){// docFrg が使えない場合、doc 追加後に子を追加 TODO ie の場合この順序(メモリリーク対策)、他のブラウザは 子が先が有利では? for( i = 0; i < l; ++i ){ elm.appendChild( X_Node__actualCreate( xnodes[ i ], true ) ); - X_Node__afterActualCreate( xnodes[ i ] ); + /* X_Node__afterActualCreate( xnodes[ i ] ); */ }; - } else { + /*} else { for( i = 0; i < l; ++i ){ X_Node__afterActualCreate( xnodes[ i ] ); - }; + }; */ }; if( X_Node_strictElmCreation ){ if( that._flags & X_Node_State.DIRTY_IE_FILTER ){ - elm.style.filter = X_Node_CSS_objToIEFilterText( that );; + // doc 追加後に filter を指定しないと有効にならない。 + elm.style.filter = v = X_Node_CSS_objToIEFilterText( that ); + if( v ){ + that._flags |= X_Node_State.IE_FILTER_NOW; + } else { + that._flags &= ~X_Node_State.IE_FILTER_NOW; + }; }; that._flags &= X_Node_BitMask_RESET_DIRTY; } else { @@ -1407,21 +1424,22 @@ var X_Node__afterActualCreate = that._flags ^= X_Node_State.ELM_NEED_INIT; } else { - + /* for( i = 0; i < l; ++i ){ X_Node__afterActualCreate( xnodes[ i ] ); - }; + }; */ // 親要素の updateRawNode 前に子要素の updateRawNode を行う - // 親要素が GPU レイヤーに転送されるケースがあるので、先に子要素の変更を済ませる + // 親要素が GPU レイヤーに転送されるケースがあるので、先に子要素の変更を済ませる <- コレ間違いでは? css 設定後の script 終了後ではないか? that._flags & X_Node_BitMask_IS_DIRTY && X_Node__updateRawNode( that, elm ); }; - // src の onload があるので先ではないか? - // TODO ie の str から要素を作る場合、srcだけ イベント設定後ではないか? - X_EventDispatcher_toggleAllEvents( that, true );// イベントの復帰 + for( i = 0; i < l; ++i ){ + X_Node__afterActualCreate( xnodes[ i ] ); + }; + }) : X_UA_DOM.IE4 ? (function( that ){ - var xnodes, i; + var xnodes, i, v; that._flags |= X_Node_State.IE4_TEXTNODE_EXIST; if( !that._tag ) return that; @@ -1432,7 +1450,12 @@ var X_Node__afterActualCreate = }; }; if( that._flags & X_Node_State.DIRTY_IE_FILTER ){ - X_Node__ie4getRawNode( that ).style.filter = X_Node_CSS_objToIEFilterText( that );; + X_Node__ie4getRawNode( that ).style.filter = v = X_Node_CSS_objToIEFilterText( that ); + if( v ){ + that._flags |= X_Node_State.IE_FILTER_NOW; + } else { + that._flags &= ~X_Node_State.IE_FILTER_NOW; + }; }; that._flags &= X_Node_BitMask_RESET_DIRTY; X_EventDispatcher_toggleAllEvents( that, true );// イベントの復帰 @@ -1455,7 +1478,18 @@ var X_Node__actualRemove = }; if( !elm ) return; + that._listeners && X_EventDispatcher_toggleAllEvents( that, false );// イベントの退避 + + // ie5では filter の効いている要素をremove時に破棄して、再度append 時に新規生成する + // ちなみに elm.filters に触ると ie8 でなぜかカラム落ちが発生、、、 + if( X_Node_displayNoneFixForIE5 ){ + if( elm.filters && elm.filters.length ){ + isChild = false; + delete that._rawObject; + }; + }; + if( !X_UA.MacIE ){ // elm.parentNode.tagName for ie7 !isChild && elm.parentNode && elm.parentNode.tagName && elm.parentNode.removeChild( elm ); diff --git a/0.6.x/js/02_dom/04_XBoxModel.js b/0.6.x/js/02_dom/04_XBoxModel.js index 7c4bf3e..d89ca64 100644 --- a/0.6.x/js/02_dom/04_XBoxModel.js +++ b/0.6.x/js/02_dom/04_XBoxModel.js @@ -64,16 +64,10 @@ X_ViewPort.listenOnce( X_TEMP.SYSTEM_EVENT_INIT, function(){ * getBoundingClientRect */ Node.prototype.width = function(){ - if( !this.parent ){// todo : _state で tree に所属しているか?判定 - console.log( 'xnode.width() : no parent' ); - return 0; - }; + if( ( this._flags & X_Node_State.IN_TREE ) === 0 || this._flags & X_Node_State.STYLE_IS_DISPLAY_NONE ) return 0; + X_Node_updateTimerID && X_Node_startUpdate(); - if( ( this._flags & X_Node_State.IN_TREE ) === 0 ){ - console.log( 'xnode.width() : not belong tree.' ); - return 0; - }; - if( this._flags & X_Node_State.STYLE_IS_DISPLAY_NONE ) return 0; + if( X_UA_DOM.W3C ){ // this.css( X_Node_CSS_Unit.px, 'width' ); return this._rawObject.offsetWidth; @@ -86,16 +80,10 @@ Node.prototype.width = function(){ }; Node.prototype.height = function(){ - if( !this.parent ){ - console.log( 'xnode.height() : no parent' ); - return 0; - }; + if( ( this._flags & X_Node_State.IN_TREE ) === 0 || this._flags & X_Node_State.STYLE_IS_DISPLAY_NONE ) return 0; + X_Node_updateTimerID && X_Node_startUpdate(); - if( ( this._flags & X_Node_State.IN_TREE ) === 0 ){ - console.log( 'xnode.height() : not belong tree.' ); - return 0; - }; - if( this._flags & X_Node_State.STYLE_IS_DISPLAY_NONE ) return 0; + if( X_UA_DOM.W3C ){ // this.css( X_Node_CSS_Unit.px, 'height' ); return this._rawObject.offsetHeight; @@ -108,16 +96,10 @@ Node.prototype.height = function(){ }; Node.prototype.clientWidth = function(){ - if( !this.parent ){// todo : _state で tree に所属しているか?判定 - console.log( 'xnode.width() : no parent' ); - return 0; - }; + if( ( this._flags & X_Node_State.IN_TREE ) === 0 || this._flags & X_Node_State.STYLE_IS_DISPLAY_NONE ) return 0; + X_Node_updateTimerID && X_Node_startUpdate(); - if( ( this._flags & X_Node_State.IN_TREE ) === 0 ){ - console.log( 'xnode.width() : not belong tree.' ); - return 0; - }; - if( this._flags & X_Node_State.STYLE_IS_DISPLAY_NONE ) return 0; + if( X_UA_DOM.W3C ){ // this.css( X_Node_CSS_Unit.px, 'width' ); return this._rawObject.clientWidth; @@ -130,16 +112,10 @@ Node.prototype.clientWidth = function(){ }; Node.prototype.clientHeight = function(){ - if( !this.parent ){ - console.log( 'xnode.height() : no parent' ); - return 0; - }; + if( ( this._flags & X_Node_State.IN_TREE ) === 0 || this._flags & X_Node_State.STYLE_IS_DISPLAY_NONE ) return 0; + X_Node_updateTimerID && X_Node_startUpdate(); - if( ( this._flags & X_Node_State.IN_TREE ) === 0 ){ - console.log( 'xnode.height() : not belong tree.' ); - return 0; - }; - if( this._flags & X_Node_State.STYLE_IS_DISPLAY_NONE ) return 0; + if( X_UA_DOM.W3C ){ // this.css( X_Node_CSS_Unit.px, 'height' ); return this._rawObject.clientHeight; @@ -152,16 +128,10 @@ Node.prototype.clientHeight = function(){ }; Node.prototype.scrollWidth = function(){ - if( !this.parent ){// todo : _state で tree に所属しているか?判定 - console.log( 'xnode.width() : no parent' ); - return 0; - }; + if( ( this._flags & X_Node_State.IN_TREE ) === 0 || this._flags & X_Node_State.STYLE_IS_DISPLAY_NONE ) return 0; + X_Node_updateTimerID && X_Node_startUpdate(); - if( ( this._flags & X_Node_State.IN_TREE ) === 0 ){ - console.log( 'xnode.width() : not belong tree.' ); - return 0; - }; - if( this._flags & X_Node_State.STYLE_IS_DISPLAY_NONE ) return 0; + if( X_UA_DOM.W3C ){ // this.css( X_Node_CSS_Unit.px, 'width' ); return this._rawObject.scrollWidth; @@ -174,18 +144,11 @@ Node.prototype.scrollWidth = function(){ }; Node.prototype.scrollHeight = function(){ - if( !this.parent ){ - console.log( 'xnode.height() : no parent' ); - return 0; - }; + if( ( this._flags & X_Node_State.IN_TREE ) === 0 || this._flags & X_Node_State.STYLE_IS_DISPLAY_NONE ) return 0; + X_Node_updateTimerID && X_Node_startUpdate(); - if( ( this._flags & X_Node_State.IN_TREE ) === 0 ){ - console.log( 'xnode.height() : not belong tree.' ); - return 0; - }; - if( this._flags & X_Node_State.STYLE_IS_DISPLAY_NONE ) return 0; + if( X_UA_DOM.W3C ){ - // this.css( X_Node_CSS_Unit.px, 'height' ); return this._rawObject.scrollHeight; } else if( X_UA_DOM.IE4 ){ @@ -196,16 +159,10 @@ Node.prototype.scrollHeight = function(){ }; Node.prototype.scrollLeft = function(){ - if( !this.parent ){// todo : _state で tree に所属しているか?判定 - console.log( 'xnode.scrollLeft() : no parent' ); - return 0; - }; + if( ( this._flags & X_Node_State.IN_TREE ) === 0 || this._flags & X_Node_State.STYLE_IS_DISPLAY_NONE ) return 0; + X_Node_updateTimerID && X_Node_startUpdate(); - if( ( this._flags & X_Node_State.IN_TREE ) === 0 ){ - console.log( 'xnode.scrollLeft() : not belong tree.' ); - return 0; - }; - if( this._flags & X_Node_State.STYLE_IS_DISPLAY_NONE ) return 0; + if( X_UA_DOM.W3C ){ // this.css( X_Node_CSS_Unit.px, 'width' ); return this._rawObject.scrollLeft; @@ -218,16 +175,10 @@ Node.prototype.scrollLeft = function(){ }; Node.prototype.scrollTop = function(){ - if( !this.parent ){// todo : _state で tree に所属しているか?判定 - console.log( 'xnode.scrollTop() : no parent' ); - return 0; - }; + if( ( this._flags & X_Node_State.IN_TREE ) === 0 || this._flags & X_Node_State.STYLE_IS_DISPLAY_NONE ) return 0; + X_Node_updateTimerID && X_Node_startUpdate(); - if( ( this._flags & X_Node_State.IN_TREE ) === 0 ){ - console.log( 'xnode.scrollTop() : not belong tree.' ); - return 0; - }; - if( this._flags & X_Node_State.STYLE_IS_DISPLAY_NONE ) return 0; + if( X_UA_DOM.W3C ){ // this.css( X_Node_CSS_Unit.px, 'width' ); return this._rawObject.scrollTop; @@ -248,22 +199,17 @@ Node.prototype.scrollTop = function(){ */ // X_Node_CSS_transform, Node.prototype.x = function(){ - if( !this.parent ){ - console.log( 'xnode.x() : no parent' ); - return 0; - }; + if( ( this._flags & X_Node_State.IN_TREE ) === 0 || this._flags & X_Node_State.STYLE_IS_DISPLAY_NONE ) return 0; + X_Node_updateTimerID && X_Node_startUpdate(); - if( ( this._flags & X_Node_State.IN_TREE ) === 0 ){ - console.log( 'xnode.x() : not belong tree.' ); - return 0; - }; - if( this._flags & X_Node_State.STYLE_IS_DISPLAY_NONE ) return 0; + if( X_UA_DOM.W3C ){ // this.css( X_Node_CSS_Unit.px, 'left' ); // this.css( X_Node_CSS_Unit.px, 'translateX' ); return this._rawObject.offsetLeft; } else if( X_UA_DOM.IE4 ){ + // pixelLeft http://www.din.or.jp/~hagi3/JavaScript/JSTips/DHTML/ProbIE5.htm return ( this._rawObject || X_Node__ie4getRawNode( this ) ).offsetLeft; } else { @@ -271,16 +217,10 @@ Node.prototype.x = function(){ }; Node.prototype.y = function(){ - if( !this.parent ){ - console.log( 'xnode.y() : no parent' ); - return 0; - }; + if( ( this._flags & X_Node_State.IN_TREE ) === 0 || this._flags & X_Node_State.STYLE_IS_DISPLAY_NONE ) return 0; + X_Node_updateTimerID && X_Node_startUpdate(); - if( ( this._flags & X_Node_State.IN_TREE ) === 0 ){ - console.log( 'xnode.y() : not belong tree.' ); - return 0; - }; - if( this._flags & X_Node_State.STYLE_IS_DISPLAY_NONE ) return 0; + if( X_UA_DOM.W3C ){ // this.css( X_Node_CSS_Unit.px, 'top' ); // this.css( X_Node_CSS_Unit.px, 'transisitonY' ); @@ -294,18 +234,8 @@ Node.prototype.y = function(){ }; Node.prototype.offset = function( /* xnodeParent */ ){ - var x = 0, y = 0, elm; - - if( !this.parent ){ - console.log( 'xnode.offset() : no parent' ); - return { x : 0, y : 0 }; - }; - - if( ( this._flags & X_Node_State.IN_TREE ) === 0 ){ - console.log( 'xnode.offset() : not belong tree.' ); - return { x : 0, y : 0 }; - }; - if( this._flags & X_Node_State.STYLE_IS_DISPLAY_NONE ) return { x : 0, y : 0 }; + + if( ( this._flags & X_Node_State.IN_TREE ) === 0 || this._flags & X_Node_State.STYLE_IS_DISPLAY_NONE ) return { x : 0, y : 0 }; if( X.Doc.body === this || X.Doc.html === this ){ return { x : 0, y : 0 }; @@ -314,15 +244,13 @@ Node.prototype.offset = function( /* xnodeParent */ ){ X_Node_updateTimerID && X_Node_startUpdate(); if( X_UA_DOM.W3C ){ - elm = this._rawObject; + return X_Node_getPosition( this._rawObject ); } else if( X_UA_DOM.IE4 ){ - elm = this._rawObject || X_Node__ie4getRawNode( this ); + return X_Node_getPosition( this._rawObject || X_Node__ie4getRawNode( this ) ); } else { }; - - return X_Node_getPosition( elm ); }; // エレメントの座標取得 ~スクロール要素~ diff --git a/0.6.x/js/02_dom/06_XNodeCSS.js b/0.6.x/js/02_dom/06_XNodeCSS.js index b185bdc..3f9f250 100644 --- a/0.6.x/js/02_dom/06_XNodeCSS.js +++ b/0.6.x/js/02_dom/06_XNodeCSS.js @@ -254,7 +254,7 @@ function X_Node_CSS_objToCssText( that ){ that._flags &= ~X_Node_State.OLD_CSSTEXT; if( !obj ){ // Opera7.5 未満? - delete that._cssText; + delete that._cssText;+65 return ''; }; @@ -492,21 +492,22 @@ function X_Node_CSS__splitValueAndUnit( v ){ Node.prototype.css = function( nameOrObj /* orUnitID, valuOrUnitOrName */ ){ var args = arguments, css = this._css, - p, name, v, plain, camelize; + p, name, v, plain, camelize, flags; if( !this._tag ) return this; // setter:object if( X.Type.isObject( nameOrObj ) ){ if( !css ) css = this._css = {}; plain = X_EMPTY_OBJECT; camelize = X_Node_CSS_camelize; + flags = this._flags; for( p in nameOrObj ){ if( plain[ p ] ) continue; name = camelize( p ); v = nameOrObj[ p ]; if( css[ name ] === v ) continue; - this._flags = X_Node_CSS_setStyle( css, this._flags, name, v ); + flags = X_Node_CSS_setStyle( css, flags, name, v ); }; - this._flags |= X_Node_State.DIRTY_CSS | X_Node_State.OLD_CSSTEXT; + this._flags = flags | X_Node_State.DIRTY_CSS | X_Node_State.OLD_CSSTEXT; this._flags & X_Node_State.IN_TREE && X_Node_reserveUpdate(); delete this._cssText; return this; @@ -604,7 +605,7 @@ Node.prototype.cssText = function( v ){ delete this._css; delete this._cssText; this._flags |= X_Node_State.DIRTY_CSS; - this._flags &= ~X_Node_State.OLD_CSSTEXT; // ~X_Node_State.DIRTY_IE_FILTER + this._flags &= ~X_Node_State.OLD_CSSTEXT | ~X_Node_State.DIRTY_IE_FILTER; this._flags &= X_Node_BITMASK_RESET_STYLE; this._flags & X_Node_State.IN_TREE && X_Node_reserveUpdate(); return this; @@ -706,7 +707,7 @@ X_Node_CSS_getCharSize = }; } else { // 要素を生成して測定! - ( that._rawObject || X_Node__ie4getRawNode( that ) ).insertAdjacentHTML( 'BeforeEnd', '
X
' ); + ( that._rawObject || X_Node__ie4getRawNode( that ) ).insertAdjacentHTML( 'BeforeEnd', '
X
' ); elm = document.all[ 'ie4charsize' ]; v = elm.offsetHeight; elm.removeAttribute( 'id' ); // ?