X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=0.6.x%2Fjs%2F02_dom%2F02_XNode.js;h=d71a866b54b15c35502387ed486fc6d1f2c9cc8c;hb=6c4c72f7e862c9f950bfb3562adda24c39498abd;hp=7da12887c1aa6a44c92db61c4006a62f32d544ce;hpb=42e0982b02a99c71702ce8cd8740645aefdc8097;p=pettanr%2FclientJs.git diff --git a/0.6.x/js/02_dom/02_XNode.js b/0.6.x/js/02_dom/02_XNode.js index 7da1288..d71a866 100644 --- a/0.6.x/js/02_dom/02_XNode.js +++ b/0.6.x/js/02_dom/02_XNode.js @@ -68,7 +68,7 @@ var X_Node_BITMASK_RESET_STYLE = ( ( 2 << 29 ) - 1 + ( 2 << 29 ) ) ^ ( X_Node_BitMask_IE4_IS_MIX = X_Node_State.IE4_HAS_TEXTNODE | X_Node_State.IE4_HAS_ELEMENT, - /** @enum {number} */ + /* @enum {number} */ X_Node_TYPE = { XNODE : 1, RAW_HTML : 2, @@ -109,7 +109,7 @@ var X_Node_BITMASK_RESET_STYLE = ( ( 2 << 29 ) - 1 + ( 2 << 29 ) ) ^ ( */ var Node = X[ 'Node' ] = X_EventDispatcher[ 'inherits' ]( 'X.Node', - X.Class.POOL_OBJECT, // X.Class.FINAL + X_Class.POOL_OBJECT, { /** @@ -142,7 +142,6 @@ var Node = X[ 'Node' ] = X_EventDispatcher[ 'inherits' ]( /** * NodeList と動作を一致させるためのプロパティ。常に 1。 * @type {number} - * @private * @alias Node.prototype.length */ length : 1, @@ -150,7 +149,6 @@ var Node = X[ 'Node' ] = X_EventDispatcher[ 'inherits' ]( /** * 親 Node。 * @type {Node} - * @private * @alias Node.prototype.parent */ parent : null, // remove された枝も親子構造は維持している。 @@ -261,7 +259,7 @@ var Node = X[ 'Node' ] = X_EventDispatcher[ 'inherits' ]( if( X_Node_newByTag ){ X_Node_newByTag = false; this[ '_tag' ] = v.toUpperCase(); - arguments[ 1 ] && this.attr( arguments[ 1 ] ); + arguments[ 1 ] && this[ 'attr' ]( arguments[ 1 ] ); css = arguments[ 2 ]; css && this[ X_Type_isString( css ) ? 'cssText' : 'css' ]( css ); } else @@ -313,8 +311,8 @@ var Node = X[ 'Node' ] = X_EventDispatcher[ 'inherits' ]( return X_Node_none; default : - this.length = 0; if( X_Node_none ) return X_Node_none; + this.length = 0; return; }; }; @@ -324,6 +322,8 @@ var Node = X[ 'Node' ] = X_EventDispatcher[ 'inherits' ]( }; this[ '_flags' ] |= X_Node_State.EXIST; X_Node_CHASHE[ this[ '_uid' ] = uid ] = this; + + X_EventDispatcher_systemListen( this, X_EVENT_BEFORE_KILL_INSTANCE, X_Node_onBeforeKill ); }, // attr @@ -347,9 +347,9 @@ var Node = X[ 'Node' ] = X_EventDispatcher[ 'inherits' ]( 'appendTo' : X_Node_appendTo, - 'prev' : X_Node_before, + 'prev' : X_Node_prev, - 'next' : X_Node_after, + 'next' : X_Node_next, 'swap' : X_Node_swap, @@ -357,13 +357,11 @@ var Node = X[ 'Node' ] = X_EventDispatcher[ 'inherits' ]( 'empty' : X_Node_empty, - destroy : X_Node_destroy, // -> kill && kill event - 'contains' : X_Node_contains, 'getChildAt' : X_Node_getChildAt, - 'numChildren' : X_Node_length, + 'numChildren' : X_Node_numChildren, 'firstChild' : X_Node_firstChild, @@ -397,6 +395,7 @@ function X_Node_getType( v ){ if( X_Type_isString( v ) ){ return '<' === v.charAt( 0 ) && v.charAt( v.length - 1 ) === '>' ? X_Node_TYPE.HTML_STRING : X_Node_TYPE.STRING; }; + if( v[ 'instanceOf' ] && v[ 'instanceOf' ]( Node ) ) return X_Node_TYPE.XNODE; return 0; }; function X_Node_getXNode( v ){ @@ -437,7 +436,7 @@ var X_Node_isXmlDocument = return root.isXML = root[ '_rawObject' ].createElement( 'p' ).tagName !== root[ '_rawObject' ].createElement( 'P' ).tagName; }), X_Node_CHASHE = [], - X_Node_none = X_Node_CHASHE[ 0 ] = new Node(), + X_Node_none = X_Node_CHASHE[ 0 ] = Node(), X_Node_html, // = X_Node_CHASHE[ 1 ] X_Node_head, // = X_Node_CHASHE[ 2 ] X_Node_body, // = X_Node_CHASHE[ 3 ] @@ -562,8 +561,8 @@ function X_Node_clone( opt_clone_children ){ var xnode, xnodes, i, l; if( this[ '_tag' ] ){ X_Node_newByTag = true; - xnode = new Node( this[ '_tag' ], X_Object_clone( this[ '_attrs' ] ), X_Object_clone( this[ '_css' ] ) ) - .attr( { 'id' : this[ '_id' ] } ) + xnode = Node( this[ '_tag' ], X_Object_clone( this[ '_attrs' ] ), X_Object_clone( this[ '_css' ] ) ) + [ 'attr' ]( { 'id' : this[ '_id' ] } ) [ 'className' ]( this[ '_className' ] ); if( opt_clone_children && ( xnodes = this[ '_xnodes' ] ) && ( l = xnodes.length ) ){ for( i = 0; i < l; ++i ){ @@ -573,12 +572,12 @@ function X_Node_clone( opt_clone_children ){ return xnode; }; X_Node_newByText = true; - return new Node( this[ '_text' ] ); + return Node( this[ '_text' ] ); }; /** * ノードを子配列の最後に追加する。文字列が渡された場合、HTMLパーサーによって Node ツリーを作成して追加する。HtmlElement, TextNode の場合は内部使用専用。 - * @alias Node.prototype.clone + * @alias Node.prototype.append * @param {Node|string|HTMLElement|TextNode} [v] HTMLElement と TextNode は内部のみ。 * @return {Node} 自身。チェインメソッド * @example myNode.append( node ); @@ -600,11 +599,11 @@ function X_Node_append( v ){ switch( X_Node_getType( v ) ){ case X_Node_TYPE.RAW_HTML : case X_Node_TYPE.RAW_TEXT : - v = new Node( v ); + v = Node( v ); break; case X_Node_TYPE.HTML_STRING : case X_Node_TYPE.STRING : - return this.append.apply( this, X_HtmlParser_parse( v, true ) ); + return X_Node_append.apply( this, X_HtmlParser_parse( v, true ) ); case X_Node_TYPE.XNODE : // 親の xnodes から v を消す v.parent && v[ 'remove' ](); @@ -627,7 +626,7 @@ function X_Node_append( v ){ /** * ノードを挿入位置に追加する。 - * @alias Node.prototype.clone + * @alias Node.prototype.appendAt * @param {number} index 挿入位置 0以上 * @param {Node|string|HTMLElement|TextNode} [v] HTMLElement と TextNode は内部のみ。 * @return {Node} 自身。チェインメソッド @@ -659,7 +658,7 @@ function X_Node_appendAt( start, v ){ switch( X_Node_getType( v ) ){ case X_Node_TYPE.RAW_HTML : case X_Node_TYPE.RAW_TEXT : - v = new Node( v ); + v = Node( v ); break; case X_Node_TYPE.HTML_STRING : case X_Node_TYPE.STRING : @@ -670,7 +669,14 @@ function X_Node_appendAt( start, v ){ return this; case X_Node_TYPE.XNODE : // 親の xnodes から v を消す - v.parent && v[ 'remove' ](); + if( v.parent ){ + if( v.parent === this ){ + i = v[ 'getOrder' ](); + if( i === start ) return this; + if( i < start ) --start; + }; + v[ 'remove' ](); + }; // IE4 でテキストノードの追加、FIXED 済でない場合、親に要素の追加を通知 if( X_UA[ 'IE4' ] && !v[ '_tag' ] && ( this[ '_flags' ] & X_Node_State.IE4_FIXED ) === 0 ) this[ '_flags' ] |= X_Node_State.IE4_DIRTY_CHILDREN; break; @@ -688,10 +694,18 @@ function X_Node_appendAt( start, v ){ return this; }; +/** + * ノードを親に追加する。戻り値は子ノードなので、続けて操作が出来る。 + * @alias Node.prototype.appendTo + * @param {Node|string|HTMLElement} [parent] HTMLElement は内部のみ。 + * @param {number} [opt_index=-1] 挿入位置。省略した場合は最後に追加する。 + * @return {Node} 自身。チェインメソッド + * @example childNode.appendTo( parentNode, 1 ); + */ function X_Node_appendTo( parent, opt_index ){ switch( X_Node_getType( parent ) ){ case X_Node_TYPE.RAW_HTML : - parent = new Node( parent ); + parent = Node( parent ); break; case X_Node_TYPE.HTML_STRING : parent = X_HtmlParser_parse( parent, true ); @@ -701,15 +715,20 @@ function X_Node_appendTo( parent, opt_index ){ default : return this; }; - opt_index === undefined ? parent[ 'append' ]( this ) : parent[ 'appendAt' ]( opt_index, this ); + X_Type_isFinite( opt_index ) ? parent[ 'appendAt' ]( opt_index, this ) : parent[ 'append' ]( this ); return this; }; -/* -------------------------------------- - * Before , After, Replace + +/** + * ノードの直前の要素を取得。または直前に挿入。挿入する要素が先にいる兄弟でも正しく動作する。 + * @alias Node.prototype.prev + * @param {Node|string|HTMLElement|TextNode} [...v] HTMLElement と TextNode は内部のみ。 + * @return {Node} 自身。チェインメソッド + * @example childNode.prev( prevNode ); */ -function X_Node_before( v ){ - var parent = this.parent, xnodes, i, l, start; +function X_Node_prev( v ){ + var parent = this.parent, xnodes, i, l; // getter if( v === undefined ){ @@ -722,18 +741,24 @@ function X_Node_before( v ){ if( !parent ) return this; l = arguments.length; - start = this[ 'getOrder' ](); if( 1 < l ){ - for( ; l; ){ - parent[ 'appendAt' ]( start, arguments[ --l ] ); + for( i = 0; l; ++i ){ + parent[ 'appendAt' ]( this[ 'getOrder' ]() - i, arguments[ --l ] ); }; return this; }; - parent[ 'appendAt' ]( start, v ); + parent[ 'appendAt' ]( this[ 'getOrder' ](), v ); return this; }; -function X_Node_after( v ){ +/** + * ノードの直後の要素を取得。または直後に挿入。挿入する要素が先にいる兄弟でも正しく動作する。 + * @alias Node.prototype.next + * @param {Node|string|HTMLElement|TextNode} [v] HTMLElement と TextNode は内部のみ。 + * @return {Node} 自身。チェインメソッド + * @example childNode.next( prevNode ); + */ +function X_Node_next( v ){ var parent = this.parent, xnodes, i, l, start; // getter @@ -748,33 +773,39 @@ function X_Node_after( v ){ l = arguments.length; start = this[ 'getOrder' ]() + 1; + if( parent[ '_xnodes' ].length <= start ){ - if( 1 < l ){ - for( i = 0; i < l; ++i ){ - parent[ 'append' ]( arguments[ i ] ); - }; - return this; + for( i = 0; i < l; ++i ){ + parent[ 'append' ]( arguments[ i ] ); }; - parent[ 'append' ]( v ); - return this; - }; + } else if( 1 < l ){ for( ; l; ){ - parent[ 'appendAt' ]( start, arguments[ --l ] ); + parent[ 'appendAt' ]( this[ 'getOrder' ]() + 1, arguments[ --l ] ); }; - return this; + } else { + parent[ 'appendAt' ]( start, v ); }; - parent[ 'appendAt' ]( start, v ); return this; }; +/** + * 要素の入れ替え。自身は remove() される。 + * @alias Node.prototype.swap + * @param {Node|string|HTMLElement|TextNode} [v] HTMLElement と TextNode は内部のみ。 + * @return {Node} 自身。チェインメソッド + * @example node.swap( newNode ); + */ function X_Node_swap( v ){ if( !this.parent ) return this; - return arguments.length === 1 ? this[ 'prev' ]( v )[ 'remove' ]() : X_Node_before.apply( this, arguments )[ 'remove' ](); + return arguments.length === 1 ? this[ 'prev' ]( v )[ 'remove' ]() : X_Node_prev.apply( this, arguments )[ 'remove' ](); }; -/* -------------------------------------- - * Remove +/** + * 要素を抜く。 + * @alias Node.prototype.remove + * @return {Node} 自身。チェインメソッド + * @example node.remove(); */ function X_Node_remove(){ var parent = this.parent, @@ -809,54 +840,30 @@ function X_Node_remove(){ return this; }; +/** + * 子要素を破棄する。子要素は kill() されます。 + * @alias Node.prototype.empty + * @return {Node} 自身。チェインメソッド + * @example node.empty(); + */ function X_Node_empty(){ var xnodes = this[ '_xnodes' ], i; if( xnodes && ( i = xnodes.length ) ){ for( ; i; ){ - xnodes[ --i ].destroy(); + xnodes[ --i ][ 'kill' ](); }; xnodes.length = 0; }; return this; }; -/* -------------------------------------- - * TODO destory -> kill - */ - -function X_Node_destroy( isChild ){ - var xnodes = this[ '_xnodes' ], i, elm; - - if( ( this[ '_flags' ] & X_Node_State.EXIST ) === 0 ) return; - - elm = this[ '_rawObject' ] || X_UA_DOM.IE4 && X_Node__ie4getRawNode( this ); - - if( xnodes && ( i = xnodes.length ) ){ - //for( ; i; ){ - // xnodes[ --i ].destroy( true ); - //}; - }; - elm && this._listeners && this[ 'unlisten' ](); // イベントの退避 - - if( this[ '_flags' ] & X_Node_State.IN_TREE ){ - !isChild && this[ 'remove' ](); - this[ '_flags' ] &= ~X_Node_State.EXIST; - } 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_onBeforeKill( e ){ var xnodes = this[ '_xnodes' ], i, elm; if( ( this[ '_flags' ] & X_Node_State.EXIST ) === 0 ) return X_Callback_NONE; elm = this[ '_rawObject' ] || X_UA_DOM.IE4 && X_Node__ie4getRawNode( this ); - elm && this._listeners && this[ 'unlisten' ](); // イベントの退避 + elm && this[ '_listeners' ] && X_EventDispatcher_unlistenAll( this ); // イベントの退避 if( xnodes && ( i = xnodes.length ) ){ for( ; i; ){ @@ -877,64 +884,100 @@ function X_Node_onBeforeKill( e ){ }; -/* -------------------------------------- - * contains +/** + * 要素を子以下に持つか?調べる。 + * @alias Node.prototype.contains + * @param {Node|string|HTMLElement|TextNode} [v] HTMLElement と TextNode は内部のみ。 + * @return {boolean} + * @example node.contains( testNode ); */ function X_Node_contains( v ){ var elm, type, xnodes, i; if( !v || !this[ '_tag' ] || this === v ) return false; // contains ie4+ if( ( elm = this[ '_rawObject' ] || X_UA_DOM.IE4 && X_Node__ie4getRawNode( this ) ) && document.contains && ( type = X_Node_getType( v ) ) && ( type === X_Node_TYPE.RAW_HTML || type === X_Node_TYPE.RAW_TEXT ) ){ - return elm[ 'contains' ]( v ); + return elm.contains( v ); }; + //if( document.compareDocumentPosition ){ // //}; xnodes = this[ '_xnodes' ]; if( !xnodes || !xnodes.length ) return false; if( xnodes.indexOf( v ) !== -1 ) return true; // fast - if( elm === v.parentNode ) return true; for( i = xnodes.length; i; ){ if( xnodes[ --i ][ 'contains' ]( v ) ) return true; }; return false; }; -/* -------------------------------------- - * getChild +/** + * index の子要素を取得する。 + * @alias Node.prototype.getChildAt + * @param {number} index 取得する子ノードの位置。0~ + * @return {Node} 子要素 + * @example child1 = parent.getChildAt(1); */ function X_Node_getChildAt( i ){ var xnodes = this[ '_xnodes' ]; return xnodes && 0 <= i && i < xnodes.length && xnodes[ i ]; }; -function X_Node_length(){ +/** + * 子要素の数を取得する。 + * @alias Node.prototype.numChildren + * @return {number} 子要素の数。 + * @example n = parent.numChildren(); + */ +function X_Node_numChildren(){ var xnodes = this[ '_xnodes' ]; return xnodes ? xnodes.length : 0; }; -/* -------------------------------------- - * firstChild, lastChild +/** + * 最初の子要素を取得する。 + * @alias Node.prototype.firstChild + * @return {Node} 最初の子要素 + * @example child0 = parent.firstChild(); */ function X_Node_firstChild(){ return this[ '_xnodes' ] && this[ '_xnodes' ][ 0 ]; }; + +/** + * 最後の子要素を取得する。 + * @alias Node.prototype.lastChild + * @return {Node} 最後の子要素 + * @example lastChild = parent.lastChild(); + */ function X_Node_lastChild(){ var xnodes = this[ '_xnodes' ]; return xnodes && xnodes[ xnodes.length - 1 ]; }; -/* -------------------------------------- - * getOrder +/** + * 要素の index 位置を取得する。 + * @alias Node.prototype.getOrder + * @return {number} index -1 の場合、親を持たない。 + * @example index = node.getOrder(); */ function X_Node_getOrder(){ var parent = this.parent; - if( !parent ) return -1; - return parent[ '_xnodes' ].indexOf( this ); + return this === X_Node_html ? + 0 : + parent ? + parent[ '_xnodes' ].indexOf( this ) : + -1; }; -/* -------------------------------------- - * className, addClass, removeClass, hasClass +/** + * className の取得と設定。 + * @alias Node.prototype.className + * @return {string|Node} getter の場合 class 文字列、setter の場合自身。 + * @example // getter + * className = node.className(); + * // setter + * node.className( 'myClass myClass_new' ); */ function X_Node_className( v ){ var node, _, __; @@ -960,9 +1003,18 @@ function X_Node_className( v ){ this[ '_flags' ] & X_Node_State.IN_TREE && X_Node_reserveUpdate(); return this; }; + +/** + * className の追加。 + * @alias Node.prototype.addClass + * @param {string} className スペース区切りで複数のクラスを追加できる。 + * @return {Node} 自身。 + * @example node.addClass( 'myClass myClass_new' ); + */ function X_Node_addClass( v ){ - var names = v.split( ' ' ), - i = names.length, + var names = v.split( ' ' ), + i = names.length, + _class = this[ '_className' ], name; v = ''; for( ; i; ){ @@ -970,18 +1022,27 @@ function X_Node_addClass( v ){ if( !name ) continue; !this[ 'hasClass' ]( name ) && ( v += ( v ? ' ' : '' ) + name ); }; - return v ? this[ 'className' ]( this[ '_className' ] + ( this[ '_className' ] ? ' ' : '' ) + v ) : this; + return v ? this[ 'className' ]( ( _class ? _class + ' ' : '' ) + v ) : this; }; + +/** + * className の削除。 + * @alias Node.prototype.removeClass + * @param {string} className スペース区切りで複数のクラスを削除できる。 + * @return {Node} 自身。 + * @example node.removeClass( 'myClass myClass_new' ); + */ function X_Node_removeClass( v ){ - var _ = ' ', - className = this[ '_className' ], - names = v.split( _ ), + var _ = ' ', + _class = this[ '_className' ], + names = v.split( _ ), classNames, i, f, j; - if( !className ) return this; - for( classNames = className.split( _ ), i = classNames.length; i; ){ - className = classNames[ --i ]; + + if( !_class ) return this; + for( classNames = _class.split( _ ), i = classNames.length; i; ){ + _class = classNames[ --i ]; for( j = names.length; j; ){ - if( className === names[ --j ] ){ + if( _class === names[ --j ] ){ classNames.splice( i, 1 ); names.splice( j, 1 ); f = true; @@ -991,10 +1052,19 @@ function X_Node_removeClass( v ){ }; return f ? this[ 'className' ]( classNames.join( _ ) ) : this; }; + +/** + * className の更新。 + * @alias Node.prototype.toggleClass + * @param {string} className スペース区切りで複数のクラスを削除できる。 + * @param {boolean} [opt_toggle=] true はクラスの追加。false はクラスの削除。undefined はクラスのトグル。 + * @return {Node} 自身。 + * @example node.toggleClass( 'myClass myClass_new', !!n ); + */ function X_Node_toggleClass( v, opt_toggle ){ var names, i, name; if( opt_toggle !== undefined ){ - return !!opt_toggle ? this[ 'addClass' ]( v ) : this[ 'removeClass' ]( v ); + return !opt_toggle ? this[ 'removeClass' ]( v ) : this[ 'addClass' ]( v ); }; names = v.split( ' ' ); for( i = names.length; i; ){ @@ -1003,35 +1073,45 @@ function X_Node_toggleClass( v, opt_toggle ){ }; return this; }; + +/** + * className を持つか。 + * @alias Node.prototype.hasClass + * @param {string} className スペース区切りで複数のクラスを削除できる。 + * @return {boolean} + * @example node.hasClass( 'myClass myClass_new' ); + */ function X_Node_hasClass( v ){ var _ = ' ', - className = this[ '_className' ], + _class = this[ '_className' ], i, name; - if( className === v ) return true; - if( !className ) return false; + if( _class === v ) return true; + if( !_class ) return false; - className = _ + className + _; - if( className.indexOf( _ + v + _ ) !== -1 ) return true; // lucky hit + _class = _ + _class + _; + if( _class.indexOf( _ + v + _ ) !== -1 ) return true; // lucky hit for( v = v.split( _ ), i = v.length; i; ){ name = v[ --i ]; if( name === '' ) continue; - if( className.indexOf( _ + name + _ ) === -1 ) return false; + if( _class.indexOf( _ + name + _ ) === -1 ) return false; }; return true; }; -/* -------------------------------------- - * html, text - * - * outerHTML が欲しい場合は、xnode.call('outerHTML') とできる。 +/** + * innerHTML 取得・設定。outerHTML が欲しい場合は、xnode.call('outerHTML') とできる。 + * @alias Node.prototype.html + * @param {string} [html=] html文字列 + * @return {string|Node} + * @example node.html( '' ); */ function X_Node_html( html ){ var _ = '', q = '"', xnodes, n, i, l; // setter if( html !== undefined ){ // String 以外に Number や false null なども許可 if( !this[ '_tag' ] ) return this[ 'text' ]( html ); - return html ? this[ 'empty' ]().append.apply( this, X_HtmlParser_parse( html, true ) ) : this[ 'empty' ](); + return html ? this[ 'empty' ]()[ 'append' ].apply( this, X_HtmlParser_parse( html, true ) ) : this[ 'empty' ](); }; // getter @@ -1065,6 +1145,13 @@ function X_Node_html( html ){ /* * null が来たら '', 数値等が来たら文字列化 */ +/** + * textContent 取得・設定。null が来たら '', 数値等が来たら文字列化 + * @alias Node.prototype.text + * @param {string} [text=] + * @return {string|Node} + * @example node.text( 'Hello, world!' ); + */ function X_Node_text( text ){ var xnodes, texts, i, l; // setter @@ -1108,28 +1195,25 @@ function X_Node_text( text ){ function X_Node_call( name /*, opt_args... */ ){ var l = arguments.length - 1, raw, func, args, params, i; - - X_Node_updateTimerID && X_Node_startUpdate(); - + switch( name ){ case 'nodeType' : return this[ '_tag' ] ? 1 : 3; - case 'text' : - return this[ 'text' ](); - case 'html' : - case 'innerHTML' : - return this[ 'html' ](); case 'outerHTML' : X_Node_outerXNode = X_Node_body; // == true ならなんでもよい。型を合わすために xbody にしている v = this[ 'html' ](); X_Node_outerXNode = null; return v; + case 'treeIsDirty' : + return !!X_Node_updateTimerID; case 'fontSize' : return X_Node_CSS_getCharSize( this ); case 'inGPU' : return !!( this[ '_flags' ] & ( X_Node_State.GPU_NOW | X_Node_State.GPU_RELEASE_RESERVED ) ); }; + X_Node_updateTimerID && X_Node_startUpdate(); + raw = this[ '_rawObject' ] || X_UA_DOM.IE4 && X_Node__ie4getRawNode( this ); if( !raw ) return; @@ -1210,7 +1294,7 @@ function X_Node_startUpdate( time ){ if( time ){ // X.Timer 経由でないと発火しない このイベントでサイズを取ると無限ループに - X_System._listeners && X_System._listeners[ X_EVENT_BEFORE_UPDATE ] && X_System[ 'dispatch' ]( X_EVENT_BEFORE_UPDATE ); + X_System[ '_listeners' ] && X_System[ '_listeners' ][ X_EVENT_BEFORE_UPDATE ] && X_System[ 'dispatch' ]( X_EVENT_BEFORE_UPDATE ); }; removal = X_Node_reserveRemoval; @@ -1239,10 +1323,12 @@ function X_Node_startUpdate( time ){ if( time ){ // X.Timer 経由でないと発火しない このイベントでサイズを取ると無限ループに - X_System._listeners && X_System._listeners[ X_EVENT_UPDATED ] && X_System[ 'dispatch' ]( X_EVENT_UPDATED ); + X_System[ '_listeners' ] && X_System[ '_listeners' ][ X_EVENT_UPDATED ] && X_System[ 'dispatch' ]( X_EVENT_UPDATED ); + } else { + X_System[ '_listeners' ] && X_System[ '_listeners' ][ X_EVENT_UPDATED ] && X_System[ 'asyncDispatch' ]( X_EVENT_UPDATED ); }; - X_ViewPort._listeners && X_ViewPort._listeners[ X_EVENT_AFTER_UPDATE ] && X_ViewPort[ 'asyncDispatch' ]( X_EVENT_AFTER_UPDATE ); + X_ViewPort[ '_listeners' ] && X_ViewPort[ '_listeners' ][ X_EVENT_AFTER_UPDATE ] && X_ViewPort[ 'asyncDispatch' ]( X_EVENT_AFTER_UPDATE ); }; /* @@ -1272,13 +1358,12 @@ var X_Node__commitUpdate = }; // 2. GPU解放予約 - // TODO もしかしたらこのタイミングで更新できるかも。 if( that[ '_flags' ] & X_Node_State.GPU_RELEASE_RESERVED ){ - console.log( 'GPU 解放 ' ); + // console.log( 'GPU 解放 ' ); //X_Node_updateReservedByReleaseGPU = true; //X_Node__updateRawNode( that, elm ); that[ '_flags' ] &= X_Node_BitMask_RESET_GPU; - //return elm; + //return elm;// TODO もしかしたらこのタイミングで更新できるかも。 }; // 3. GPU予約 -> GPU @@ -1367,7 +1452,7 @@ var X_Node__commitUpdate = if( X_UA[ 'Gecko' ] ){ if( that[ '_tag' ] === 'IFRAME' && ( !that[ '_attrs' ] || !that[ '_attrs' ][ 'src' ] ) ){ //elm.contentWindow.location.replace = elm.src = 'about:blank'; - that.attr( 'src', 'about:blank' ); + that[ 'attr' ]( 'src', 'about:blank' ); }; }; }; @@ -1382,7 +1467,7 @@ var X_Node__commitUpdate = parentElement.appendChild( elm ); }; - if( that._listeners && ( that[ '_flags' ] & X_Node_State.ACTUAL_LISTENING ) === 0 ){ + if( that[ '_listeners' ] && ( that[ '_flags' ] & X_Node_State.ACTUAL_LISTENING ) === 0 ){ X_EventDispatcher_toggleAllEvents( that, true );// イベントの退避 that[ '_flags' ] |= X_Node_State.ACTUAL_LISTENING; }; @@ -1779,7 +1864,7 @@ var X_Node__actualRemove = if( !elm ) return; if( that[ '_flags' ] & X_Node_State.ACTUAL_LISTENING ){ - that._listeners && X_EventDispatcher_toggleAllEvents( that, false );// イベントの退避 + that[ '_listeners' ] && X_EventDispatcher_toggleAllEvents( that, false );// イベントの退避 that[ '_flags' ] &= ~X_Node_State.ACTUAL_LISTENING; }; @@ -1830,7 +1915,7 @@ var X_Node__actualRemove = }; if( !elm ) return; - that._listeners && X_EventDispatcher_toggleAllEvents( that, false );// イベントの退避 + that[ '_listeners' ] && X_EventDispatcher_toggleAllEvents( that, false );// イベントの退避 // 破棄前にインタラクティブな属性値を控える if( X_Node_Attr_HAS_VALUE[ that[ '_tag' ] ] && ( !that[ '_newAttrs' ] || !X_Object_inObject( 'value', that[ '_newAttrs' ] ) ) ){