From dad4215398716c9913e80ec902c76db6762c1dce Mon Sep 17 00:00:00 2001 From: itozyun Date: Fri, 23 Jan 2015 11:33:53 +0900 Subject: [PATCH] Version 0.6.124, remove xnode._root. --- 0.6.x/js/01_core/16_XViewPort.js | 6 +- 0.6.x/js/02_dom/02_XNode.js | 305 +++++++++++++++++++++---------------- 0.6.x/js/02_dom/04_XBoxModel.js | 22 +-- 0.6.x/js/02_dom/05_XNodeAttr.js | 51 ++++--- 0.6.x/js/02_dom/06_XNodeCSS.js | 155 +++++++++++++------ 0.6.x/js/02_dom/22_XTreeBuilder.js | 17 +-- 6 files changed, 332 insertions(+), 224 deletions(-) diff --git a/0.6.x/js/01_core/16_XViewPort.js b/0.6.x/js/01_core/16_XViewPort.js index 5627a85..a290fea 100644 --- a/0.6.x/js/01_core/16_XViewPort.js +++ b/0.6.x/js/01_core/16_XViewPort.js @@ -287,12 +287,12 @@ X.ViewPort = { X_ViewPort_rootElement = document.compatMode !== 'CSS1Compat' ? elmBody : elmHtml || elmBody; html = X.Doc.html = X_Node_html = elmHtml && new Node( elmHtml ); - + html._flags |= X_Node_State.IN_TREE; + head = X.Doc.head = X_Node_head = elmHead && new Node( elmHead ); body = X.Doc.body = X_Node_body = new Node( elmBody ); - - body._root = html._root = head._root = body;// _root は html だろ + body.parent = head.parent = html; html._xnodes = [ head, body ]; diff --git a/0.6.x/js/02_dom/02_XNode.js b/0.6.x/js/02_dom/02_XNode.js index 9f5fa99..d526b36 100644 --- a/0.6.x/js/02_dom/02_XNode.js +++ b/0.6.x/js/02_dom/02_XNode.js @@ -1,48 +1,63 @@ var X_Node_State = { - DESTROYED : 0, - EXIST : 1, - IN_TREE : 2, + DESTROYED : 0x0, + EXIST : 0x1, + IN_TREE : 0x2, // xnode が(仮想)ツリーに追加されている -> 描画の対象 - ELM_EXIST : 2 << 1, - ELM_IN_TREE : 2 << 2, + ELM_NEED_INIT : 2 << 1, - STYLE_IS_DISPLAY_NONE : 2 << 4, // display:none - STYLE_IS_HIDDEN : 2 << 5, // visibility:hidden opacity:0 - STYLE_IS_POS_ABSOLUTE : 2 << 6, // position:absolute - STYLE_IS_NO_OVERFLOW : 2 << 7, // overflow:hidden - STYLE_IS_WIDTH_LENGTH : 2 << 8, // width : width() のための commitUpdate が不要 - STYLE_IS_WIDTH_PCT : 2 << 9, // width : width() のための commitUpdate が不要かもしれない。(親で LENGTH が指定されているなら) - STYLE_IS_HEIGHT_LENGTH : 2 << 10, // height : - STYLE_IS_HEIGHT_PCT : 2 << 11, // height : - STYLE_IS_FONT_LENGTH : 2 << 12, // fontSize : - STYLE_IS_FONT_PCT : 2 << 13, // fontSize : + STYLE_IS_DISPLAY_NONE : 2 << 2, // display : none + STYLE_IS_INVISIBLE : 2 << 3, // visibility : hidden or opacity : 0 + STYLE_IS_POS_ABSOLUTE : 2 << 4, // position : absolute + STYLE_IS_NO_OVERFLOW : 2 << 5, // overflow : hidden + STYLE_IS_WIDTH_LENGTH : 2 << 6, // width : width() のための commitUpdate が不要 + STYLE_IS_WIDTH_PCT : 2 << 7, // width : width() のための commitUpdate が不要かもしれない。(親で LENGTH が指定されているなら) + STYLE_IS_HEIGHT_LENGTH : 2 << 8, // height : + STYLE_IS_HEIGHT_PCT : 2 << 9, // height : + STYLE_IS_FONT_LENGTH : 2 << 10, // fontSize : + STYLE_IS_FONT_PCT : 2 << 11, // fontSize : + + //DIRTY_CHILD : 2 << 18, // 使っていない + DIRTY_CONTENT : 2 << 12, // width, height, x, y textNode の内容 TODO html と排他なので ID と共通でいい + DIRTY_ID : 2 << 13, // width, height, x, y + DIRTY_CLASSNAME : 2 << 14, // X_Node_CSS_getCharSize, width, height, x, y + DIRTY_ATTR : 2 << 15, // X_Node_CSS_getCharSize, width, height, x, y + DIRTY_CSS : 2 << 16, // X_Node_CSS_getCharSize, width, height, x, y + DIRTY_IE_FILTER : X_UA.IE < 10 && X_UA.ActiveX ? 2 << 17 : 0, // + + OLD_ATTRTEXT : 2 << 18, + OLD_CSSTEXT : 2 << 19, + + GPU_WAITING : 2 << 20, // 1:子のGPU解除待 + GPU_RESERVED : 2 << 21, // 2:GPU予約 + GPU_NOW : 2 << 20 | 2 << 21, // 3:GPU now!() + GPU_RELEASE_RESERVED : 2 << 20 | 2 << 21 | 2 << 22, // 4:GPU解除予約 - IE4_ONLY_TEXT : 2 << 14, - IE5_DISPLAY_NONE_FIX : X_UA.IE5 && X_UA.ActiveX ? 2 << 15 : 0, // filterがかかっていると不可ってことかも? MacIE5.2- は ? - UNKNOWN_TAG_FIX : 2 << 16, // 使っていない - IE4_TEXTNODE_FIX : 2 << 17, - - DIRTY_CHILD : 2 << 18, // 使っていない - DIRTY_CONTENT : 2 << 19, // width, height, x, y textNode の内容 - DIRTY_ID : 2 << 20, // width, height, x, y - DIRTY_CLASSNAME : 2 << 21, // X_Node_CSS_getCharSize, width, height, x, y - DIRTY_ATTR : 2 << 22, // X_Node_CSS_getCharSize, width, height, x, y - DIRTY_CSS : 2 << 23, // X_Node_CSS_getCharSize, width, height, x, y - DIRTY_IE_FILTER : X_UA.IE < 10 && X_UA.ActiveX ? 2 << 24 : 0, // - - GPU_WAITING : 2 << 25, // 1:子のGPU解除待 - GPU_RESERVED : 2 << 26, // 2:GPU予約 - GPU_NOW : 2 << 25 | 2 << 26, // 3:GPU now!() - GPU_RELEASE_RESERVED : 2 << 27 // 4:GPU解除予約 + /* 子要素は一つのテキストノード */ + IE4_ONLY_TEXT : 2 << 23, + /* 子要素に html要素とテキストノードが混在する */ + IE4_TEXTNODE_FIX : 2 << 24, + IE4_TEXTNODE_EXIST : 2 << 25 }, - X_Node_DIRTY_MASK = + X_Node_BITMASK_RESET_STYLE = ( ( 2 << 29 ) - 1 + ( 2 << 29 ) ) ^ ( + X_Node_State.STYLE_IS_DISPLAY_NONE | + X_Node_State.STYLE_IS_INVISIBLE | + X_Node_State.STYLE_IS_POS_ABSOLUTE | + X_Node_State.STYLE_IS_NO_OVERFLOW | + X_Node_State.STYLE_IS_WIDTH_LENGTH | + X_Node_State.STYLE_IS_WIDTH_PCT | + X_Node_State.STYLE_IS_HEIGHT_LENGTH | + X_Node_State.STYLE_IS_HEIGHT_PCT | + X_Node_State.STYLE_IS_FONT_LENGTH | + 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_ATTR | X_Node_State.DIRTY_CSS | X_Node_State.DIRTY_IE_FILTER, - X_Node_DIRTY_MASK_RESET = ( ( 2 << 29 ) - 1 ) ^ X_Node_DIRTY_MASK, + X_Node_BitMask_RESET_DIRTY = ( ( 2 << 29 ) - 1 + ( 2 << 29 ) ) ^ X_Node_BitMask_IS_DIRTY, X_Node_TYPE = { XNODE : 1, @@ -61,6 +76,8 @@ var X_Node_useDocumentFragment = document.createDocumentFragment && ( !X_UA.IE || 5.5 <= X_UA.IE ) && document.createDocumentFragment(), + X_Node_displayNoneFixForIE5 = X_UA.IE5 && X_UA.ActiveX, + X_Node_newByTag = false, X_Node_newByText = false, @@ -77,30 +94,25 @@ var { _uid : 0, _flags : X_Node_State.DESTROYED, - - _isNew : false, // state にまとめる - _root : null, // xnode が文書ツリーに属しているか?はこれを見る -> state - _xnodeType : 0, // state へ - + _rawObject : null, _rect : null, // + _fontSize : 0, parent : null, // remove された枝も親子構造は維持している。 _xnodes : null, // Array. _tag : '', - _text : null, - _id : null, + _text : '', + _id : '', _className : '', _attrs : null, // see X_Node_Attr _newAttrs : null, - _attrText : '', // X_Node_Attr_objToAttrText が必要な場合は false が入っている + _attrText : '', _css : null, // see X_Node_CSS - _cssText : null, // String | null - - _fontSize : 0, + _cssText : '', _anime : null, // Hash see X_Node_Anime @@ -113,7 +125,7 @@ var if( X_Node_newByTag ){ X_Node_newByTag = false; this._tag = v.toUpperCase(); - this._flags |= X_Node_State.EXIST; + this._flags |= X_Node_State.EXIST; arguments[ 1 ] && this.attr( arguments[ 1 ] ); css = arguments[ 2 ]; css && this[ X.Type.isString( css ) ? 'cssText' : 'css' ]( css ); @@ -121,7 +133,7 @@ var if( X_Node_newByText ){ X_Node_newByText = false; this._text = v; - this._flags |= X_Node_State.EXIST; + this._flags |= X_Node_State.EXIST; } else { if( 1 < arguments.length ) return new X_NodeList( arguments ); if( X.Type.isArray( v ) && v.length ) return new X_NodeList( v ); @@ -135,19 +147,18 @@ var if( xnode = X_Node_getXNode( v ) ) return xnode; // v.parentNode || v.parentElement : dom1 || dom0 this.parent = ( parent = v.parentNode || v.parentElement ) && parent.tagName /* ie7- */ && X_Node_getXNode( parent ); - if( this.parent && this.parent._root ){ - this._root = this.parent._root; - this._flags |= X_Node_State.IN_TREE | X_Node_State.ELM_IN_TREE; + if( this.parent && ( this.parent._flags & X_Node_State.IN_TREE ) ){ + this._flags |= X_Node_State.IN_TREE; }; this._rawObject = v; - this._flags |= X_Node_State.EXIST | X_Node_State.ELM_EXIST; + this._flags |= X_Node_State.EXIST; this._tag = v.tagName.toUpperCase(); this._id = v.id; this._className = v.className; + this.cssText( v.style.cssText ); - // X_Node_State.DIRTY_CSS を落とす - //this._flags = 0; - this._flags &= X_Node_DIRTY_MASK_RESET; + this._flags &= X_Node_BitMask_RESET_DIRTY; // X_Node_State.DIRTY_CSS を落とす + // TODO attr の回収は不可能、、、 if( X_UA_DOM.IE4 ){ v.setAttribute( 'UID', '' + uid ); @@ -160,9 +171,11 @@ var case X_Node_TYPE.RAW_TEXT : if( xnode = X_Node_getXNode( v ) ) return xnode; this.parent = X_Node_getXNode( v.parentNode ); - if( this.parent && this.parent._root ) this._root = this.parent._root; + if( this.parent && ( this.parent._flags & X_Node_State.IN_TREE ) ){ + this._flags |= X_Node_State.IN_TREE; + }; this._rawObject = v; - this._flags |= X_Node_State.EXIST; + this._flags |= X_Node_State.EXIST; this._text = v.data; v.UID = uid; break; @@ -324,6 +337,15 @@ var X_Node__ie4getRawNode = X_UA_DOM.IE4 && function ( that ){ }; +function X_Node_toggleInTreeFlag( xnodes, flag ){ + var i = xnodes.length, xnode; + for( ; i; ){ + xnode = xnodes[ --i ]; + flag ? ( xnode._flags |= X_Node_State.IN_TREE ) : ( xnode._flags &= ~X_Node_State.IN_TREE ); + xnode._xnodes && X_Node_toggleInTreeFlag( xnode._xnodes, flag ); + }; +}; + /* -------------------------------------- * Create */ @@ -336,7 +358,11 @@ function X_Node_create( tag, opt_attrs, opt_css ){ xnode.parent = this; this._xnodes[ this._xnodes.length ] = xnode; - this._root && X_Node_reserveUpdate(); + if( this._flags & X_Node_State.IN_TREE ){ + xnode._flags |= X_Node_State.IN_TREE; + xnode._xnodes && X_Node_toggleInTreeFlag( xnode._xnodes, true ); + X_Node_reserveUpdate(); + }; return xnode; }; function X_Node_createAt( index, tag, opt_attrs, opt_css ){ @@ -356,9 +382,13 @@ function X_Node_createText( text ){ X_Node_newByText = true; xnode = new Node( text ); xnode.parent = this; - - this._root && X_Node_reserveUpdate(); this._xnodes[ this._xnodes.length ] = xnode; + + if( this._flags & X_Node_State.IN_TREE ){ + xnode._flags |= X_Node_State.IN_TREE; + xnode._xnodes && X_Node_toggleInTreeFlag( xnode._xnodes, true ); + X_Node_reserveUpdate(); + }; return xnode; }; function X_Node_createTextAt( index, text ){ @@ -428,7 +458,11 @@ function X_Node_append( v ){ v.parent = this; xnodes[ xnodes.length ] = v; - this._root && X_Node_reserveUpdate(); + if( this._flags & X_Node_State.IN_TREE ){ + v._flags |= X_Node_State.IN_TREE; + v._xnodes && X_Node_toggleInTreeFlag( v._xnodes, true ); + X_Node_reserveUpdate(); + }; return this; }; @@ -480,7 +514,11 @@ function X_Node_appendAt( start, v ){ v.parent = this; this._xnodes.splice( start, 0, v ); - this._root && X_Node_reserveUpdate(); + if( this._flags & X_Node_State.IN_TREE ){ + v._flags |= X_Node_State.IN_TREE; + v._xnodes && X_Node_toggleInTreeFlag( v._xnodes, true ); + X_Node_reserveUpdate(); + }; return this; }; @@ -582,13 +620,15 @@ function X_Node_remove(){ if( !parent ) return this; + delete this.parent; parent._xnodes.splice( parent._xnodes.indexOf( this ), 1 ); - if( this._root ){ + if( this._flags & X_Node_State.IN_TREE ){ + this._flags ^= X_Node_State.IN_TREE; + this._xnodes && X_Node_toggleInTreeFlag( this._xnodes, false ); + X_Node_reserveRemoval[ X_Node_reserveRemoval.length ] = this; X_Node_reserveUpdate(); }; - delete this.parent; - delete this._root; return this; }; @@ -606,7 +646,6 @@ function X_Node_empty(){ /* -------------------------------------- * TODO destory -> kill */ -// Node._destroyChildFlag = false; // TODO function X_Node_destroy( isChild ){ var xnodes = this._xnodes, i, elm; @@ -625,7 +664,7 @@ function X_Node_destroy( isChild ){ delete X_Node_CHASHE[ this._uid ]; delete this._flags; - if( this._root ){ + if( this._flags & X_Node_State.IN_TREE ){ !isChild && this.remove(); } else { this.parent && this.parent._xnodes.splice( this.parent._xnodes.indexOf( this ), 1 ); @@ -634,6 +673,19 @@ function X_Node_destroy( isChild ){ }; }; +function X_Node_onKill( 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 ); + }; +}; /* -------------------------------------- @@ -715,7 +767,7 @@ function X_Node_className( v ){ v ? ( this._className = v ) : delete this._className; }; this._flags |= X_Node_State.DIRTY_CLASSNAME; - this._root && X_Node_reserveUpdate(); + this._flags & X_Node_State.IN_TREE && X_Node_reserveUpdate(); return this; }; function X_Node_addClass( v ){ @@ -797,14 +849,13 @@ function X_Node_html( html ){ return this._text; }; - if( this._flags & X_Node_State.DIRTY_CSS && !( this._cssText = X_Node_CSS_objToCssText( this ) ) ){ - delete this._cssText; - }; + this._flags & X_Node_State.OLD_CSSTEXT && X_Node_CSS_objToCssText( this ); + html = !X_Node_outerXNode ? [] : [ '<', this._tag, this._id ? ' id="' + this._id + q : _, this._className ? ' class="' + this._className + q : _, - this._attrText === false ? ( this._attrText = X_Node_Attr_objToAttrText( this._attrs ) ) : this._attrText, + this._flags & X_Node_State.OLD_ATTRTEXT ? X_Node_Attr_objToAttrText( this ) : this._attrText, this._cssText ? ' style="' + this._cssText + q : _, '>' ]; @@ -815,7 +866,7 @@ function X_Node_html( html ){ html[ n ] = xnodes[ i ].html(); ++n; }; - if( X_Node_outerXNode === this ) X_Node_outerXNode = null; + if( X_Node_outerXNode === this ) X_Node_outerXNode = null; }; !X_Node_outerXNode || X_Dom_DTD_EMPTY[ this._tag ] || ( html[ n ] = '<\/' + this._tag + '>' ); return html.join( _ ); @@ -834,8 +885,8 @@ function X_Node_text( text ){ if( !this._tag ){ if( this._text !== text ){ text ? ( this._text = text ) : delete this.text; - this._root && X_Node_reserveUpdate(); - this._flags |= X_Node_State.DIRTY_CONTENT; + this._flags |= X_Node_State.DIRTY_CONTENT; + this._flags & X_Node_State.IN_TREE && X_Node_reserveUpdate(); }; return this; }; @@ -970,7 +1021,7 @@ function X_Node_startUpdate( time ){ removal.length = 0; }; - if( X_Node_html._flags & X_Node_DIRTY_MASK ){ + if( X_Node_html._flags & X_Node_BitMask_IS_DIRTY ){ X_Node__commitUpdate( X_Node_html ); } else { X_Node__commitUpdate( X_Node_head ); @@ -991,7 +1042,7 @@ var X_Node__commitUpdate = var elm = that._rawObject, xnodes, l, i, frg, next, k, v; - if( that._flags & X_Node_State.IE5_DISPLAY_NONE_FIX ){ + 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 ); @@ -1014,14 +1065,14 @@ var X_Node__commitUpdate = delete that._fontSize; - if( that._flags & X_Node_DIRTY_MASK ){ + if( that._flags & X_Node_BitMask_IS_DIRTY ){ X_Node__updateRawNode( that, elm ); } else - if( X_Node_State.IE5_DISPLAY_NONE_FIX ){ + if( that._tag && X_Node_displayNoneFixForIE5 && elm.currentStyle.display === 'none' ){ // TODO 親要素への変更で display:none が変わる場合もあるのでここで調べる }; - if( that._flags & X_Node_State.IE5_DISPLAY_NONE_FIX ){ + if( X_Node_displayNoneFixForIE5 && that._flags & X_Node_State.STYLE_IS_DISPLAY_NONE ){ return nextElement; }; return elm; @@ -1042,7 +1093,7 @@ var X_Node__commitUpdate = xnodes = that._xnodes; l = xnodes ? xnodes.length : 0; - if( that._flags & X_Node_State.IE4_TEXTNODE_FIX || ( that._flags & X_Node_State.IE4_ONLY_TEXT && ( l !== 1 || xnodes[ 0 ]._tag ) ) ){ // 1 < l && elm.children.length === 0 + if( ( that._flags & X_Node_State.IE4_ONLY_TEXT && ( l !== 1 || xnodes[ 0 ]._tag ) ) || that._flags & X_Node_State.IE4_TEXTNODE_FIX ){ html = []; for( i = 0; i < l; ++i ){ html[ i ] = X_Node__actualCreate( xnodes[ i ] ); @@ -1051,16 +1102,16 @@ var X_Node__commitUpdate = for( i = 0; i < l; ++i ){ X_Node__afterActualCreate( xnodes[ i ] ); }; + that._flags &= ~X_Node_State.IE4_TEXTNODE_FIX; that._flags &= ~X_Node_State.IE4_ONLY_TEXT; } else - if( that._flags & X_Node_State.IE4_ONLY_TEXT ){ // textNode が swap した場合の検出は、_root で行う + // TODO textNode だけが 2つ以上ある場合 + if( that._flags & X_Node_State.IE4_ONLY_TEXT ){ text = xnodes[ 0 ]; - //if( text._flags || !text._root ){ - if( text._flags & X_Node_State.DIRTY_CONTENT || !text._root ){ + if( text._flags & X_Node_State.DIRTY_CONTENT || ( text._flags & X_Node_State.IE4_TEXTNODE_EXIST ) === 0 ){ elm.innerHTML = text._text; - //delete text._flags; - text._flags &= X_Node_DIRTY_MASK_RESET; - text._root = that._root; + text._flags &= X_Node_BitMask_RESET_DIRTY; + /* if( taht._flags & X_Node_State.IN_TREE ) */ text._flags |= X_Node_State.IE4_TEXTNODE_EXIST; }; } else if( l ){ @@ -1070,8 +1121,7 @@ var X_Node__commitUpdate = }; delete that._fontSize; - //that._flags && X_Node__updateRawNode( that, elm ); - that._flags & X_Node_DIRTY_MASK && X_Node__updateRawNode( that, elm ); + that._flags & X_Node_BitMask_IS_DIRTY && X_Node__updateRawNode( that, elm ); return elm; }) : (function(){}); @@ -1088,8 +1138,7 @@ var X_Node__updateRawNode = // textNode if( !that._tag ){ elm.data = X_String_chrReferanceTo( that._text ); - //delete that._flags; - that._flags &= X_Node_DIRTY_MASK_RESET; + that._flags &= X_Node_BitMask_RESET_DIRTY; return; }; // id @@ -1099,16 +1148,16 @@ var X_Node__updateRawNode = // className if( that._flags & X_Node_State.DIRTY_CLASSNAME ){ 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_State.IE5_DISPLAY_NONE_FIX && elm.currentStyle.display === 'none' ){ - X_Node__actualRemove( that ); - that._flags |= X_Node_State.IE5_DISPLAY_NONE_FIX; - return; - }; }; + // 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 );; }; @@ -1145,7 +1194,7 @@ var X_Node__updateRawNode = // style // TODO display:none の場合、更新をスキップ if( that._flags & X_Node_State.DIRTY_CSS ){ - if( that._cssText !== null || ( that._cssText = X_Node_CSS_objToCssText( that ) ) ){ + if( that._flags & X_Node_State.OLD_CSSTEXT ? X_Node_CSS_objToCssText( that ) : that._cssText ){ X_UA.Opera78 || X_UA.NN6 ? elm.setAttribute( 'style', that._cssText ) : // opera8用 ( elm.style.cssText = that._cssText ); @@ -1156,8 +1205,7 @@ var X_Node__updateRawNode = }; }; - //delete that._flags; - that._flags &= X_Node_DIRTY_MASK_RESET; + that._flags &= X_Node_BitMask_RESET_DIRTY; }) : X_UA_DOM.IE4 ? ( function( that, elm ){ @@ -1166,8 +1214,7 @@ var X_Node__updateRawNode = // fake textNode if( !that._tag ){ elm.innerText = that._text; - //delete that._flags; - that._flags &= X_Node_DIRTY_MASK_RESET; + that._flags &= X_Node_BitMask_RESET_DIRTY; return; }; @@ -1184,7 +1231,7 @@ var X_Node__updateRawNode = }; // style if( that._flags & X_Node_State.DIRTY_CSS ){ - if( that._cssText !== null || ( that._cssText = X_Node_CSS_objToCssText( that ) ) ){ + if( that._flags & X_Node_State.OLD_CSSTEXT ? X_Node_CSS_objToCssText( that ) : that._cssText ){ elm.style.cssText = that._cssText; } else { elm.style.cssText = ''; @@ -1208,9 +1255,8 @@ var X_Node__updateRawNode = }; delete that._newAttrs; }; - - //delete that._flags; - that._flags &= X_Node_DIRTY_MASK_RESET; + + that._flags &= X_Node_BitMask_RESET_DIRTY; }) : (function(){}); @@ -1238,16 +1284,14 @@ var X_Node__actualCreate = if( !that._tag ){ if( elm ) return elm; - //delete that._flags; - that._flags &= X_Node_DIRTY_MASK_RESET; + that._flags &= X_Node_BitMask_RESET_DIRTY; return that._rawObject = document.createTextNode( X_String_chrReferanceTo( that._text ) ); }; if( !elm ){ - if( that._flags & X_Node_State.DIRTY_CSS && !( that._cssText = X_Node_CSS_objToCssText( that ) ) ){ - delete that._cssText; - }; - that._isNew = true; + that._flags & X_Node_State.DIRTY_CSS && X_Node_CSS_objToCssText( that ); + + that._flags |= X_Node_State.ELM_NEED_INIT; that._rawObject = elm = X_Node_strictElmCreation ? document.createElement( [ @@ -1255,10 +1299,13 @@ var X_Node__actualCreate = ' UID="', that._uid, '"', that._id ? ' id="' + that._id + '"' : '', that._className ? ' class="' + that._className + '"' : '', - that._attrText === false ? ( that._attrText = X_Node_Attr_objToAttrText( that._attrs ) ) : that._attrText, + that._flags & X_Node_State.OLD_ATTRTEXT ? X_Node_Attr_objToAttrText( that ) : that._attrText, 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 ) ){ @@ -1282,14 +1329,12 @@ var X_Node__actualCreate = } else { if( that._rawObject && !isChild ) X_Node__actualRemove( that, true ); - if( that._flags & X_Node_State.DIRTY_CSS && !( that._cssText = X_Node_CSS_objToCssText( that ) ) ){ - delete that._cssText; - }; + that._flags & X_Node_State.DIRTY_CSS && X_Node_CSS_objToCssText( that ); html = [ '<', that._tag, ' id=', ( that._id || ( 'ie4uid' + uid ) ), ' UID="', uid, '"', that._className ? ' class="' + that._className + '"' : '', - that._attrText === false ? ( that._attrText = X_Node_Attr_objToAttrText( that._attrs ) ) : that._attrText, + that._flags & X_Node_State.OLD_ATTRTEXT ? X_Node_Attr_objToAttrText( that ) : that._attrText, that._cssText ? ' style="' + that._cssText + '"' : '', '>' ]; @@ -1319,20 +1364,17 @@ var X_Node__actualCreate = var X_Node__afterActualCreate = X_UA_DOM.W3C ? (function( that ){ var elm = that._rawObject, xnodes, l, i; - - that._root = that.parent._root; if( !that._tag ){ - // that._flags && X_Node__updateRawNode( that, elm ); - that._flags & X_Node_DIRTY_MASK && X_Node__updateRawNode( that, elm ); + that._flags & X_Node_BitMask_IS_DIRTY && X_Node__updateRawNode( that, elm ); return that; }; xnodes = that._xnodes; l = xnodes && xnodes.length; - if( that._isNew ){ - if( !X_Node_useDocumentFragment /*&& l*/ ){// docFrg が使えない場合、doc 追加後に子を追加 + if( that._flags & X_Node_State.ELM_NEED_INIT ){ + if( !X_Node_useDocumentFragment ){// docFrg が使えない場合、doc 追加後に子を追加 for( i = 0; i < l; ++i ){ elm.appendChild( X_Node__actualCreate( xnodes[ i ], true ) ); X_Node__afterActualCreate( xnodes[ i ] ); @@ -1347,8 +1389,7 @@ var X_Node__afterActualCreate = if( that._flags & X_Node_State.DIRTY_IE_FILTER ){ elm.style.filter = X_Node_CSS_objToIEFilterText( that );; }; - //delete that._flags; - that._flags &= X_Node_DIRTY_MASK_RESET; + that._flags &= X_Node_BitMask_RESET_DIRTY; } else { elm.UID = that._uid; that._newAttrs = that._attrs; @@ -1364,7 +1405,7 @@ var X_Node__afterActualCreate = }; }; - delete that._isNew; + that._flags ^= X_Node_State.ELM_NEED_INIT; } else { for( i = 0; i < l; ++i ){ @@ -1372,8 +1413,7 @@ var X_Node__afterActualCreate = }; // 親要素の updateRawNode 前に子要素の updateRawNode を行う // 親要素が GPU レイヤーに転送されるケースがあるので、先に子要素の変更を済ませる - //that._flags && X_Node__updateRawNode( that, elm ); - that._flags & X_Node_DIRTY_MASK && X_Node__updateRawNode( that, elm ); + that._flags & X_Node_BitMask_IS_DIRTY && X_Node__updateRawNode( that, elm ); }; // src の onload があるので先ではないか? @@ -1382,7 +1422,7 @@ var X_Node__afterActualCreate = }) : X_UA_DOM.IE4 ? (function( that ){ var xnodes, i; - that._root = that.parent._root; + that._flags |= X_Node_State.IE4_TEXTNODE_EXIST; if( !that._tag ) return that; @@ -1394,8 +1434,7 @@ var X_Node__afterActualCreate = if( that._flags & X_Node_State.DIRTY_IE_FILTER ){ X_Node__ie4getRawNode( that ).style.filter = X_Node_CSS_objToIEFilterText( that );; }; - //delete that._flags; - that._flags &= X_Node_DIRTY_MASK_RESET; + that._flags &= X_Node_BitMask_RESET_DIRTY; X_EventDispatcher_toggleAllEvents( that, true );// イベントの復帰 }) : (function(){}); @@ -1418,7 +1457,7 @@ var X_Node__actualRemove = if( !elm ) return; that._listeners && X_EventDispatcher_toggleAllEvents( that, false );// イベントの退避 if( !X_UA.MacIE ){ - // elm.parentNode.tagName for ie7 -> that.state & ELM_IN_TREE + // elm.parentNode.tagName for ie7 !isChild && elm.parentNode && elm.parentNode.tagName && elm.parentNode.removeChild( elm ); } else { !isChild && elm.parentNode && elm.parentNode.tagName && X_TEMP._fixed_remove( elm, that ); diff --git a/0.6.x/js/02_dom/04_XBoxModel.js b/0.6.x/js/02_dom/04_XBoxModel.js index 4dc8d66..7c4bf3e 100644 --- a/0.6.x/js/02_dom/04_XBoxModel.js +++ b/0.6.x/js/02_dom/04_XBoxModel.js @@ -69,7 +69,7 @@ Node.prototype.width = function(){ return 0; }; X_Node_updateTimerID && X_Node_startUpdate(); - if( !this._root ){ + if( ( this._flags & X_Node_State.IN_TREE ) === 0 ){ console.log( 'xnode.width() : not belong tree.' ); return 0; }; @@ -91,7 +91,7 @@ Node.prototype.height = function(){ return 0; }; X_Node_updateTimerID && X_Node_startUpdate(); - if( !this._root ){ + if( ( this._flags & X_Node_State.IN_TREE ) === 0 ){ console.log( 'xnode.height() : not belong tree.' ); return 0; }; @@ -113,7 +113,7 @@ Node.prototype.clientWidth = function(){ return 0; }; X_Node_updateTimerID && X_Node_startUpdate(); - if( !this._root ){ + if( ( this._flags & X_Node_State.IN_TREE ) === 0 ){ console.log( 'xnode.width() : not belong tree.' ); return 0; }; @@ -135,7 +135,7 @@ Node.prototype.clientHeight = function(){ return 0; }; X_Node_updateTimerID && X_Node_startUpdate(); - if( !this._root ){ + if( ( this._flags & X_Node_State.IN_TREE ) === 0 ){ console.log( 'xnode.height() : not belong tree.' ); return 0; }; @@ -157,7 +157,7 @@ Node.prototype.scrollWidth = function(){ return 0; }; X_Node_updateTimerID && X_Node_startUpdate(); - if( !this._root ){ + if( ( this._flags & X_Node_State.IN_TREE ) === 0 ){ console.log( 'xnode.width() : not belong tree.' ); return 0; }; @@ -179,7 +179,7 @@ Node.prototype.scrollHeight = function(){ return 0; }; X_Node_updateTimerID && X_Node_startUpdate(); - if( !this._root ){ + if( ( this._flags & X_Node_State.IN_TREE ) === 0 ){ console.log( 'xnode.height() : not belong tree.' ); return 0; }; @@ -201,7 +201,7 @@ Node.prototype.scrollLeft = function(){ return 0; }; X_Node_updateTimerID && X_Node_startUpdate(); - if( !this._root ){ + if( ( this._flags & X_Node_State.IN_TREE ) === 0 ){ console.log( 'xnode.scrollLeft() : not belong tree.' ); return 0; }; @@ -223,7 +223,7 @@ Node.prototype.scrollTop = function(){ return 0; }; X_Node_updateTimerID && X_Node_startUpdate(); - if( !this._root ){ + if( ( this._flags & X_Node_State.IN_TREE ) === 0 ){ console.log( 'xnode.scrollTop() : not belong tree.' ); return 0; }; @@ -253,7 +253,7 @@ Node.prototype.x = function(){ return 0; }; X_Node_updateTimerID && X_Node_startUpdate(); - if( !this._root ){ + if( ( this._flags & X_Node_State.IN_TREE ) === 0 ){ console.log( 'xnode.x() : not belong tree.' ); return 0; }; @@ -276,7 +276,7 @@ Node.prototype.y = function(){ return 0; }; X_Node_updateTimerID && X_Node_startUpdate(); - if( !this._root ){ + if( ( this._flags & X_Node_State.IN_TREE ) === 0 ){ console.log( 'xnode.y() : not belong tree.' ); return 0; }; @@ -301,7 +301,7 @@ Node.prototype.offset = function( /* xnodeParent */ ){ return { x : 0, y : 0 }; }; - if( !this._root ){ + if( ( this._flags & X_Node_State.IN_TREE ) === 0 ){ console.log( 'xnode.offset() : not belong tree.' ); return { x : 0, y : 0 }; }; diff --git a/0.6.x/js/02_dom/05_XNodeAttr.js b/0.6.x/js/02_dom/05_XNodeAttr.js index cd96a45..2e306bf 100644 --- a/0.6.x/js/02_dom/05_XNodeAttr.js +++ b/0.6.x/js/02_dom/05_XNodeAttr.js @@ -66,19 +66,32 @@ X_Node_Attr_renameForTag = {}; // checked -> defaultChecked // 動的に生成した input 要素を文書ツリーに挿入する前に設定した checked 属性は反映されず、defaultChecked だと反映される // 先頭にスペース -function X_Node_Attr_objToAttrText( obj ){ - var noValue = X_Node_Attr_noValue, - attrs = [ '' ], n = 0, k, v; - if( !obj ) return ''; // Opera7 - for( k in obj ){ - //if( X_EMPTY_OBJECT[ k ] ) continue; - v = obj[ k ]; - if( k === 'value' ){ - v = v.split( '"' ).join( '"' ).split( '>' ).join( '>' ).split( '<' ).join( '<' ); - }; - attrs[ ++n ] = noValue[ k ] ? k : [ k, '="', v, '"' ].join( '' ); +function X_Node_Attr_objToAttrText( that ){ + var obj = that._attrs, + noValue = X_Node_Attr_noValue, + attrs = [ '' ], + plain = X_EMPTY_OBJECT, + n = 0, k, v; + + that._flags &= ~X_Node_State.OLD_ATTRTEXT; + + if( !obj ){ // Opera7 + delete that._attrText; + return ''; + }; + for( k in obj ){ + if( plain[ k ] ) continue; + v = obj[ k ]; + if( k === 'value' ){ + v = v.split( '"' ).join( '"' ).split( '>' ).join( '>' ).split( '<' ).join( '<' ); }; - return 0 < n ? attrs.join( ' ' ) : ''; + attrs[ ++n ] = noValue[ k ] ? k : [ k, '="', v, '"' ].join( '' ); + }; + if( 0 < n ){ + return that._attrText = attrs.join( ' ' ); + }; + delete that._attrText; + return ''; }; (function( renameForDOM, renameForTag ){ @@ -112,18 +125,18 @@ Node.prototype.attr = function( nameOrObj /* v */ ){ if( X_Node_Attr_setAttr( this, attrs, newAttrs, k, nameOrObj[ k ] ) === true ) f = true; }; if( f ){ - this._attrText = false; - this._flags |= X_Node_State.DIRTY_ATTR; - this._root && X_Node_reserveUpdate(); + delete this._attrText; + this._flags |= X_Node_State.DIRTY_ATTR | X_Node_State.OLD_ATTRTEXT; + this._flags & X_Node_State.IN_TREE && X_Node_reserveUpdate(); }; return this; } else if( 1 < arguments.length ){ // setter if( X_Node_Attr_setAttr( this, attrs || ( this._attrs = {} ), this._newAttrs || ( this._newAttrs = {} ), nameOrObj, arguments[ 1 ] ) === true ){ - this._attrText = false; - this._flags |= X_Node_State.DIRTY_ATTR; - this._root && X_Node_reserveUpdate(); + delete this._attrText; + this._flags |= X_Node_State.DIRTY_ATTR | X_Node_State.OLD_ATTRTEXT; + this._flags & X_Node_State.IN_TREE && X_Node_reserveUpdate(); }; return this; } else @@ -177,7 +190,7 @@ function X_Node_Attr_setAttr( that, attrs, newAttrs, name, v ){ if( v !== that._id ){ that._id = v; that._flags |= X_Node_State.DIRTY_ID; - that._root && X_Node_reserveUpdate(); + that._flags & X_Node_State.IN_TREE && X_Node_reserveUpdate(); }; return; case 'class' : diff --git a/0.6.x/js/02_dom/06_XNodeCSS.js b/0.6.x/js/02_dom/06_XNodeCSS.js index a3b6db6..b185bdc 100644 --- a/0.6.x/js/02_dom/06_XNodeCSS.js +++ b/0.6.x/js/02_dom/06_XNodeCSS.js @@ -250,8 +250,13 @@ function X_Node_CSS_objToCssText( that ){ css = [], n = -1, p, v, specialFix, filterFix; - - if( !obj ) return ''; // Opera7.5 未満? + + that._flags &= ~X_Node_State.OLD_CSSTEXT; + + if( !obj ){ // Opera7.5 未満? + delete that._cssText; + return ''; + }; for( p in obj ){ // object の拡張に備えて plain なオブジェクトを用意し、そのメンバーと一致するものは処理の対象外。 @@ -263,11 +268,9 @@ function X_Node_CSS_objToCssText( that ){ if( specialFix = X_Node_CSS_SPECIAL_FIX_PROP[ p ] ){ css[ ++n ] = p + ':' + specialFix( v ); - } else if( X_Node_CSS_FILTER_FIX_PROPS && X_Node_CSS_FILTER_FIX_PROPS[ p ] ){ ( filterFix || ( filterFix = {} ) )[ p ] = v; - } else { css[ ++n ] = p + ':' + v; }; @@ -275,7 +278,11 @@ function X_Node_CSS_objToCssText( that ){ filterFix && ( css[ ++n ] = 'filter:' + X_Node_CSS_objToIEFilterText( that, filterFix ) ); - return css.join( ';' ); + if( 0 <= n ){ + return that._cssText = css.join( ';' ); + }; + delete that._cssText; + return ''; }; var @@ -393,7 +400,7 @@ function X_Node_CSS_objToIEFilterText( that, opt_css ){ }; function X_Node_CSS_onAfterUpdateForIEFilterFix(){ - if( this._root ){ // 要素があり、要素がツリーに属している + if( this._flags & X_Node_State.IN_TREE ){ // 要素があり、要素がツリーに属している this._flags |= X_Node_State.DIRTY_IE_FILTER; X_Node_reserveUpdate(); }; @@ -483,31 +490,24 @@ function X_Node_CSS__splitValueAndUnit( v ){ // name, value setter Node.prototype.css = function( nameOrObj /* orUnitID, valuOrUnitOrName */ ){ - var plain = X_EMPTY_OBJECT, - args = arguments, - css = this._css, - p, name, v, camelize, unit, ieFix; + var args = arguments, + css = this._css, + p, name, v, plain, camelize; 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; - ieFix = X_Node_CSS_FILTER_FIX_PROPS; for( p in nameOrObj ){ if( plain[ p ] ) continue; - - if( ieFix && ieFix[ p ] ){ - this._flags |= X_Node_State.DIRTY_IE_FILTER; - }; - v = nameOrObj[ p ]; - v || v === 0 ? css[ camelize( p ) ] = v : delete css[ camelize( p ) ]; - if( p === 'display' ){ - v === 'none' ? ( this._flags |= X_Node_State.IE5_DISPLAY_NONE_FIX ) : ( this._flags &= ~X_Node_State.IE5_DISPLAY_NONE_FIX ); - v === 'none' ? ( this._flags |= X_Node_State.STYLE_IS_DISPLAY_NONE ) : ( this._flags &= ~X_Node_State.STYLE_IS_DISPLAY_NONE ); - }; + name = camelize( p ); + v = nameOrObj[ p ]; + if( css[ name ] === v ) continue; + this._flags = X_Node_CSS_setStyle( css, this._flags, name, v ); }; - this._flags |= X_Node_State.DIRTY_CSS; - this.parent && X_Node_reserveUpdate(); + this._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; } else @@ -517,44 +517,100 @@ Node.prototype.css = function( nameOrObj /* orUnitID, valuOrUnitOrName */ ){ name = X_Node_CSS_camelize( nameOrObj ); v = args[ 1 ]; if( css[ name ] === v ) return this; - if( X_Node_CSS_FILTER_FIX_PROPS && X_Node_CSS_FILTER_FIX_PROPS[ name ] ){ - this._flags |= X_Node_State.DIRTY_IE_FILTER; - }; - if( !v && v !== 0 ){ - delete css[ name ]; - } else { - css[ name ] = v; - }; + this._flags = X_Node_CSS_setStyle( css, this._flags, name, v ) | X_Node_State.DIRTY_CSS | X_Node_State.OLD_CSSTEXT; + this._flags & X_Node_State.IN_TREE && X_Node_reserveUpdate(); delete this._cssText; - this._flags |= X_Node_State.DIRTY_CSS; - if( name === 'display' ){ - v === 'none' ? ( this._flags |= X_Node_State.IE5_DISPLAY_NONE_FIX ) : ( this._flags &= ~X_Node_State.IE5_DISPLAY_NONE_FIX ); - v === 'none' ? ( this._flags |= X_Node_State.STYLE_IS_DISPLAY_NONE ) : ( this._flags &= ~X_Node_State.STYLE_IS_DISPLAY_NONE ); - }; - // TODO this._flags & in tree - this.parent && X_Node_reserveUpdate(); return this; }; // getter if( !css ) return; // 集計 border, padding, margin, backgroundPosition, clip - // border で正確なデータを返せない時は、null を返す + // TODO border で正確なデータを返せない時は、null を返す return css[ X_Node_CSS_camelize( nameOrObj ) ]; }; +function X_Node_CSS_setStyle( css, flags, name, newValue ){ + + if( X_Node_CSS_FILTER_FIX_PROPS && X_Node_CSS_FILTER_FIX_PROPS[ name ] ){ + flags |= X_Node_State.DIRTY_IE_FILTER; + }; + if( !newValue && newValue !== 0 ){ + delete css[ name ]; + } else { + css[ name ] = newValue; + }; + + switch( name ){ + case 'display' : + newValue === 'none' ? ( flags |= X_Node_State.STYLE_IS_DISPLAY_NONE ) : ( flags &= ~X_Node_State.STYLE_IS_DISPLAY_NONE ); + return flags; + + case 'visibility' : + // すでに opacity:0 で invisible + if( flags & X_Node_State.STYLE_IS_INVISIBLE && css[ 'opacity' ] == 0 ) return flags; + newValue === 'hidden' ? ( flags |= X_Node_State.STYLE_IS_INVISIBLE ) : ( flags &= ~X_Node_State.STYLE_IS_INVISIBLE ); + return flags; + + case 'opacity' : + // すでに visibility:hidden で invisible + if( flags & X_Node_State.STYLE_IS_INVISIBLE && css[ 'visibility' ] === 'hidden' ) return flags; + newValue == 0 ? ( flags |= X_Node_State.STYLE_IS_INVISIBLE ) : ( flags &= ~X_Node_State.STYLE_IS_INVISIBLE ); + return flags; + + case 'overflow' : + newValue === 'hidden' ? ( flags |= X_Node_State.STYLE_IS_NO_OVERFLOW ) : ( flags &= ~X_Node_State.STYLE_IS_NO_OVERFLOW ); + return flags; + + case 'position' : + newValue === 'absolute' ? ( flags |= X_Node_State.STYLE_IS_POS_ABSOLUTE ) : ( flags &= ~X_Node_State.STYLE_IS_POS_ABSOLUTE ); + return flags; + + case 'width' : + newValue = X_Node_CSS__splitValueAndUnit( newValue ); + if( newValue[ 1 ] !== '%' ){ + flags |= X_Node_State.STYLE_IS_WIDTH_LENGTH; + flags &= ~X_Node_State.STYLE_IS_WIDTH_PCT; + } else { + flags &= ~X_Node_State.STYLE_IS_WIDTH_LENGTH; + flags |= X_Node_State.STYLE_IS_WIDTH_PCT; + }; + return flags; + + case 'height' : + newValue = X_Node_CSS__splitValueAndUnit( newValue ); + if( newValue[ 1 ] !== '%' ){ + flags |= X_Node_State.STYLE_IS_HEIGHT_LENGTH; + flags &= ~X_Node_State.STYLE_IS_HEIGHT_PCT; + } else { + flags &= ~X_Node_State.STYLE_IS_HEIGHT_LENGTH; + flags |= X_Node_State.STYLE_IS_HEIGHT_PCT; + }; + return flags; + + case 'fontSize' : + + }; + return flags; +}; + Node.prototype.cssText = function( v ){ var obj, i, l, attr, name; + + if( v === this._cssText && ( this._flags & X_Node_State.OLD_CSSTEXT ) === 0 ){ + return this; + }; + if( v === '' ){ delete this._css; - this._flags &= ~X_Node_State.IE5_DISPLAY_NONE_FIX; - this._flags |= X_Node_State.DIRTY_CSS; - this.parent && X_Node_reserveUpdate(); 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_BITMASK_RESET_STYLE; + this._flags & X_Node_State.IN_TREE && X_Node_reserveUpdate(); return this; } else if( X.Type.isString( v ) ){ delete this._css; - this._flags &= ~X_Node_State.IE5_DISPLAY_NONE_FIX; obj = {}; v = v.split( ';' ); // TODO content ";" などにも対応 for( i = 0, l = v.length; i < l; ++i ){ @@ -564,9 +620,7 @@ Node.prototype.cssText = function( v ){ return this.css( obj ); }; // getter - if( this._flags & X_Node_State.DIRTY_CSS && !( this._cssText = X_Node_CSS_objToCssText( this ) ) ){ - delete this._cssText; - }; + this._flags & X_Node_State.OLD_CSSTEXT && X_Node_CSS_objToCssText( this ); return this._cssText; }; @@ -651,8 +705,13 @@ X_Node_CSS_getCharSize = if( _v = X_Node_CSS__UNIT_RATIO[ u ] ) return that._fontSize = v / _v; }; } else { - v = 1; - u = 'em'; + // 要素を生成して測定! + ( that._rawObject || X_Node__ie4getRawNode( that ) ).insertAdjacentHTML( 'BeforeEnd', '
X
' ); + elm = document.all[ 'ie4charsize' ]; + v = elm.offsetHeight; + elm.removeAttribute( 'id' ); // ? + elm.outerHTML = ''; + return that._fontSize = v; }; switch( u ){ diff --git a/0.6.x/js/02_dom/22_XTreeBuilder.js b/0.6.x/js/02_dom/22_XTreeBuilder.js index 533f6d9..3ba6c19 100644 --- a/0.6.x/js/02_dom/22_XTreeBuilder.js +++ b/0.6.x/js/02_dom/22_XTreeBuilder.js @@ -367,8 +367,8 @@ X_TEMP.bindElementToXnode = if( tag.charAt( 0 ) === '/' ) tag = tag.slice( 1 ); xnode._tag = tag; //}; - xnode._root = parent._root; - xnode._flags &= X_Node_DIRTY_MASK_RESET; + xnode._flags |= X_Node_State.IN_TREE; + xnode._flags &= X_Node_BitMask_RESET_DIRTY; elm.UID = xnode._uid; current.xtext = null; @@ -376,10 +376,6 @@ X_TEMP.bindElementToXnode = xnode.attr( 'value', xnode.html() ).empty(); } else - //if( X_TEMP._isCleanupTarget( elm ) ){// !xnode.hasClass( 'skip-cleanup' ) && ( X_Dom_DTD_CLEANUP_TAGS[ tag ] || xnode.hasClass( 'cleanup-target' ) ) ){ // ie で body 内の script が2度よばれるのに対処 - //alert( '[' +parent._tag + '>' + xnode._tag + '] remove ... ' ); - //xnode.destroy(); - //} else if( elm.childNodes && elm.childNodes.length ){ //alert( '[' +parent._tag + '>' + xnode._tag + ' ' + (xnode._xnodes ? xnode._xnodes.length : '' ) + '] === ' + tag + ' ' + (elm.childNodes ? elm.childNodes.length : '' ) + ' Hit\n' + elm.outerHTML ); //current.xtext = null; @@ -419,9 +415,10 @@ X_TEMP.bindElementToXnode = ++current.j; xnode._rawObject = elm; - xnode._flags &= X_Node_DIRTY_MASK_RESET; + xnode._flags |= X_Node_State.IN_TREE; + xnode._flags &= X_Node_BitMask_RESET_DIRTY; xnode._text = elm.data; // 正確 - xnode._root = parent._root; + if( !skipCleanup ){ if( !( text = xnode._text ) || ( text = X_String_cleanupWhiteSpace( text ) ) === ' ' ){ console.log( '[' +parent._tag + '>' + xnode._uid + '] destroy ... ' ); @@ -500,8 +497,8 @@ X_TEMP.bindElementToXnode = ++current.j; xnode._rawObject = elm; - xnode._flags &= X_Node_DIRTY_MASK_RESET; - xnode._root = parent._root; + xnode._flags |= X_Node_State.IN_TREE; + xnode._flags &= X_Node_BitMask_RESET_DIRTY; //xnode._tag = X_Dom_DTD_TAG_FIX[ tag ] || tag; if( X_TEMP._isCleanupTarget( elm ) ){ //!xnode.hasClass( 'skip-cleanup' ) && ( X_Dom_DTD_CLEANUP_TAGS[ tag ] || xnode.hasClass( 'cleanup-target' ) ) ){ xnode.destroy(); -- 2.11.0