X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=0.6.x%2Fjs%2F02_dom%2F02_XNode.js;h=451ea0eab0bccade77f61fab1ecf0f6a3f4df124;hb=36f999435e807f3d04f899b2a84eb1dc31df34b7;hp=22c8f03a6658d0e9425ba05078fa245613e61370;hpb=dd02887497fa95f13d112b7fc2e5e7aefd0ffb08;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 22c8f03..451ea0e 100644
--- a/0.6.x/js/02_dom/02_XNode.js
+++ b/0.6.x/js/02_dom/02_XNode.js
@@ -1,34 +1,74 @@
var
- X_Node_Dirty = {
- CLEAN : 0,
- CHILD_IS_DIRTY : 1,
- ID : 2, // width, height, x, y
- CONTENT : 4, // width, height, x, y textNode ã®å
容
- CLASSNAME : 8, // X_Node_CSS_getCharSize, width, height, x, y
- ATTR : 16, // X_Node_CSS_getCharSize, width, height, x, y
- CSS : 32, // X_Node_CSS_getCharSize, width, height, x, y
- IE_FILTER : X_UA.IE < 9 && !X_UA.MacIE ? 64 : 0,
- UNKNOWN_TAG_FIX : 128,
- IE4_TEXTNODE_FIX : 256
- },
-
+ /** @enum {number}
+ * @const */
X_Node_State = {
- DESTROYED : 0,
- EXIST : 1, // XNODE_EXIDT, ELEMENT_EXIST
- BELONG_TREE : 2, // HAS_PARENT, HAS_PARENT_ACTUAL, BELONG_TREE, BELONG_TREE_ACTUAL
- DISPLAY_NONE : 4, // VISIVILITY_HIDDEN(opacity0), DISPALY_NONE
- DISPLAY_BLOCK : 8, // remove
- DISPLAY_INLINE : 16,// remove
- POSITION_ABSOLUTE : 32,
- OVERFLOW_HIDDEN : 64,
- HAS_WIDTH_LENGTH : 128,
- HAS_WIDTH_PERCENT : 256,
- HAS_HEIGHT_LENGTH : 512,
- HAS_HEIGHT_PERCENT : 1024,
- IE4_ONLY_TEXT : 2048,
- IE5_DISPLAY_NONE_FIX : !X_UA.MacIE && X_UA.IE5 ? 4096 : 0 // filterãããã£ã¦ããã¨ä¸å¯? MacIE5.2- 㯠ï¼
- },
+ DESTROYED : 0x0,
+ EXIST : 0x1,
+ IN_TREE : 0x2, // xnode ã(ä»®æ³)ããªã¼ã«è¿½å ããã¦ãã -> æç»ã®å¯¾è±¡
+
+ STYLE_IS_DISPLAY_NONE : 2 << 1, // display : none
+ STYLE_IS_INVISIBLE : 2 << 2, // visibility : hidden or opacity : 0
+ STYLE_IS_POS_ABSOLUTE : 2 << 3, // position : absolute
+ STYLE_IS_NO_OVERFLOW : 2 << 4, // overflow : hidden
+ STYLE_IS_WIDTH_LENGTH : 2 << 5, // width : overflow:hidden,è¦ç´ ç¡ããã¾ãã¯è¦ç´ ãé表示ãªãã width() ã®ããã® commitUpdate ãä¸è¦
+ STYLE_IS_WIDTH_PCT : 2 << 6, // width : width() ã®ããã® commitUpdate ãä¸è¦ãããããªãã(親㧠LENGTH ãæå®ããã¦ãããªã)
+ STYLE_IS_HEIGHT_LENGTH : 2 << 7, // height :
+ STYLE_IS_HEIGHT_PCT : 2 << 8, // height :
+ STYLE_IS_FONT_LENGTH : 2 << 9, // fontSize :
+ STYLE_IS_FONT_PCT : 2 << 10, // fontSize :
+
+ DIRTY_POSITION : 2 << 11, // è¦ç´ ä½ç½®ã®å¤æ´ãèµ·ãã£ãã
+ DIRTY_CONTENT : 2 << 12, // width, height, x, y textNode ã®å
容 TODO html ã¨æä»ãªã®ã§ ID ã¨å
±éã§ãã
+ DIRTY_ID : 2 << 12, // width, height, x, y
+ DIRTY_CLASSNAME : 2 << 13, // X_Node_CSS_getCharSize, width, height, x, y
+ DIRTY_ATTR : 2 << 14, // X_Node_CSS_getCharSize, width, height, x, y
+ DIRTY_CSS : 2 << 15, // X_Node_CSS_getCharSize, width, height, x, y
+ DIRTY_IE_FILTER : X_UA[ 'IE' ] < 10 && X_UA[ 'ActiveX' ] ? 2 << 16 : 0, //
+
+ ACTUAL_LISTENING : 2 << 17,
+ OLD_ATTRTEXT : 2 << 18,
+ OLD_CSSTEXT : 2 << 19,
+
+ // filter è¦ç´ ã親åã«ãªãã¨ä¸å
·åãåºãã®ãæ¤åº
+ IE_FILTER_NOW : 2 << 20,
+
+ //GPU_WAITING : 2 << 20, // 1:åã®GPU解é¤å¾
+ GPU_RESERVED : 2 << 21, // 2:GPUäºç´
+ GPU_NOW : 2 << 22, // 3:GPU now!
+ GPU_RELEASE_RESERVED : 2 << 23, // 4:GPU解é¤äºç´
+ GPU_CHILD : 2 << 24,
+
+ IE4_HAS_TEXTNODE : X_UA[ 'IE4' ] ? 2 << 21 : 0,
+ IE4_HAS_ELEMENT : X_UA[ 'IE4' ] ? 2 << 22 : 0,
+ IE4_DIRTY_CHILDREN : X_UA[ 'IE4' ] ? 2 << 23 : 0,
+ IE4_FIXED : X_UA[ 'IE4' ] ? 2 << 24 : 0,
+
+ IE5_DISPLAY_NONE_FIX : X_UA[ 'IE5' ] && X_UA[ 'ActiveX' ] ? 2 << 24 : 0
+ };
+
+var 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_POSITION |
+ 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,
+
+ X_Node_BitMask_RESET_GPU = ( ( 2 << 29 ) - 1 + ( 2 << 29 ) ) ^ ( X_Node_State.GPU_RESERVED | X_Node_State.GPU_NOW | X_Node_State.GPU_RELEASE_RESERVED ),
+ X_Node_BitMask_IE4_IS_MIX = X_Node_State.IE4_HAS_TEXTNODE | X_Node_State.IE4_HAS_ELEMENT,
+
+ /** @enum {number} */
X_Node_TYPE = {
XNODE : 1,
RAW_HTML : 2,
@@ -42,9 +82,14 @@ var
IMAGE : 10
},
- X_Node_strictElmCreation = !X_UA.MacIE && X_UA.IE5678,// && !X_UA.MacIE;
+ X_Node_strictElmCreation = !X_UA[ 'MacIE' ] && X_UA[ 'IE' ] <= 8,
+
+ X_Node_documentFragment = document.createDocumentFragment && ( !X_UA[ 'IE' ] || 5.5 <= X_UA[ 'IE' ] ) && document.createDocumentFragment(),
+
+ // åã®çæå¾ã« ãªã¢ã«ææ¸ tree ã«è¿½å ãã
+ X_Node_addTreeAfterChildren = !( X_UA[ 'IE' ] < 9 ),
- X_Node_useDocumentFragment = document.createDocumentFragment && ( !X_UA.IE || 5.5 <= X_UA.IE ) && document.createDocumentFragment(),
+ X_Node_displayNoneFixForIE5 = !!X_Node_State.IE5_DISPLAY_NONE_FIX,
X_Node_newByTag = false,
@@ -52,191 +97,288 @@ var
X_Node_outerXNode = null,
- X_Node_updateTimerID = 0,
-/*
+ X_Node_updateTimerID = 0;
+
+/**
* Node( rawElement | rawTextnode | htmlString | textString )
- */
- Node = X.Node = X.EventDispatcher.inherits(
- 'XDomNode',
- X.Class.POOL_OBJECT,
+ *
+ * @alias X.Node
+ * @class Node HTMLElementãTextNode ãã©ããã jQuery 風㪠API ã§æä½ã§ãã¾ãã
+ * @constructs Node
+ * @extends {EventDispatcher}
+ */
+var Node = X[ 'Node' ] = X_EventDispatcher[ 'inherits' ](
+ 'X.Node',
+ X_Class.POOL_OBJECT,
+
{
- _uid : 0,
- _state : 0,
- _dirty : 0,
+ /**
+ * è¦ç´ ã«æ¯ãããã¦ãã¼ã¯ID
+ * @type {number}
+ * @private
+ * @alias Node.prototype._uid
+ */
+ '_uid' : 0,
- _isNew : false, // state ã«ã¾ã¨ãã
+ /**
+ * Node ã®ç¶æ
ã表ããã©ã°ã
+ * @type {number}
+ * @private
+ * @alias Node.prototype._flags
+ */
+ '_flags' : X_Node_State.DESTROYED,
+
+ // _rawObject : null,
+ '_rect' : null, //
- _rawObject : null,
- _rect : null, //
+ /**
+ * æå¾ã«è¨æ¸¬ãããã©ã³ããµã¤ãºãä¿æãã¦ãããããªã¼ãå¤æ´ãããã¨åé¤ãããã
+ * @type {number}
+ * @private
+ * @alias Node.prototype._fontSize
+ */
+ '_fontSize' : 0,
- _root : null, // xnode ãææ¸ããªã¼ã«å±ãã¦ãããï¼ã¯ãããè¦ã -> state
- parent : null, // remove ãããæã親åæ§é ã¯ç¶æãã¦ããã
- _xnodes : null,
-
- _xnodeType : 0,
- _tag : null,
- _text : null,
- _id : null,
- _className : '',
-
- _attrs : null, // see X_Node_Attr
- _newAttrs : null,
- _attrText : '', // X_Node_Attr_objToAttrText ãå¿
è¦ãªå ´å㯠false ãå
¥ã£ã¦ãã
+ /**
+ * NodeList ã¨åä½ãä¸è´ãããããã®ããããã£ã常㫠1ã
+ * @type {number}
+ * @alias Node.prototype.length
+ */
+ length : 1,
+
+ /**
+ * 親 Nodeã
+ * @type {Node}
+ * @alias Node.prototype.parent
+ */
+ parent : null, // remove ãããæã親åæ§é ã¯ç¶æãã¦ããã
+
+ /**
+ * å Node ãªã¹ã
+ * @type {Array}
+ * @private
+ * @alias Node.prototype._xnodes
+ */
+ '_xnodes' : null,
+
+ /**
+ * GPU ã¬ã¤ã¤ã¼ã«è»¢éããã¦ããå ´åããã®ä¸çªè¦ªã¨ãªã£ã¦ãã Nodeãæªå®è£
ã
+ * @type {Node}
+ * @private
+ * @alias Node.prototype._gpuParent
+ */
+ '_gpuParent' : null,
+
+ /**
+ * ã¿ã°åãããã¹ããã¼ãã®å ´åã¯ç©ºæååã
+ * @type {string}
+ * @private
+ * @alias Node.prototype._tag
+ */
+ '_tag' : '',
+
+ /**
+ * ããã¹ãã³ã³ãã³ããããã¹ããã¼ãã§ä½¿ç¨ã
+ * @type {string}
+ * @private
+ * @alias Node.prototype._text
+ */
+ '_text' : '',
+
+ /**
+ * id
+ * @type {string}
+ * @private
+ * @alias Node.prototype._id
+ */
+ '_id' : '',
- _css : null, // see X_Node_CSS
- _cssText : null,
+ /**
+ * ã¯ã©ã¹åãè¤æ°ã®ã¯ã©ã¹ãè¨å®ããã¦ããå ´åãã¹ãã¼ã¹åºåãã
+ * @type {string}
+ * @private
+ * @alias Node.prototype._className
+ */
+ '_className' : '', //
+
+ /**
+ * å±æ§ã
+ * @type {object}
+ * @private
+ * @alias Node.prototype._attrs
+ */
+ '_attrs' : null, // see X_Node_Attr
- _fontSize : 0,
+ /**
+ * ã¾ã ã³ãããããã¦ããªãå±æ§ã
+ * @type {object}
+ * @private
+ * @alias Node.prototype._newAttrs
+ */
+ '_newAttrs' : null,
- _anime : null,
+ /**
+ * å±æ§ãæååã«ãããã®ã color="red" size="8"
+ * @type {object}
+ * @private
+ * @alias Node.prototype._attrText
+ */
+ '_attrText' : '',
+
+ /**
+ * ã¹ã¿ã¤ã«ã
+ * @type {object}
+ * @private
+ * @alias Node.prototype._css
+ */
+ '_css' : null,
+
+ /**
+ * cssText
+ * @type {string}
+ * @private
+ * @alias Node.prototype._cssText
+ */
+ '_cssText' : '',
+
+ /**
+ * ã¢ãã¡ã¼ã·ã§ã³ç¨ãªãã¸ã§ã¯ãã
+ * @type {object}
+ * @private
+ * @alias Node.prototype._anime
+ */
+ '_anime' : null,
/*
* TODO Node ã®ç¶æ¿ãã§ããªãï¼
*/
- Constructor : function( v ){
- var css, xnodes, xnode, parent, uid = X_Node_CHASHE.length;
+ 'Constructor' : function( v ){
+ var uid = X_Node_CHASHE.length,
+ css, xnodes, xnode, parent;
if( X_Node_newByTag ){
X_Node_newByTag = false;
- this._tag = v.toUpperCase();
- this._xnodeType = 1;
- this._state = X_Node_State.DISPLAY_INLINE; // TODO
- arguments[ 1 ] && this.attr( arguments[ 1 ] );
+ this[ '_tag' ] = v.toUpperCase();
+ arguments[ 1 ] && this[ 'attr' ]( arguments[ 1 ] );
css = arguments[ 2 ];
- css && this[ X.Type.isString( css ) ? 'cssText' : 'css' ]( css );
+ css && this[ X_Type_isString( css ) ? 'cssText' : 'css' ]( css );
} else
if( X_Node_newByText ){
X_Node_newByText = false;
- this._text = v;
- this._xnodeType = 3;
- this._state = X_Node_State.DISPLAY_INLINE;
+ this[ '_text' ] = v;
} else {
if( 1 < arguments.length ) return new X_NodeList( arguments );
- if( X.Type.isArray( v ) && v.length ) return new X_NodeList( v );
- //if( !this || this.append !== X_Node_append ){
- // return new Node( v );
- //};
+ if( X_Type_isArray( v ) && v.length ) return new X_NodeList( v );
+
switch( X_Node_getType( v ) ){
case X_Node_TYPE.XNODE :
case X_Node_TYPE.XNODE_LIST :
return v;
+
case X_Node_TYPE.RAW_HTML :
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._rawObject = v;
- this._xnodeType = 1;
- this._state = X_Node_State.DISPLAY_BLOCK; // TODO
- this._tag = v.tagName.toUpperCase();
- this._id = v.id;
- this._className = v.className;
- this.cssText( v.style.cssText );
- // X_Node_Dirty.CSS ãè½ã¨ã
- this._dirty = 0;
- // TODO attr ã®ååã¯ä¸å¯è½ããã
+ this[ '_rawObject' ] = v;
+ this[ '_tag' ] = v.tagName.toUpperCase();
+ this[ '_id' ] = v.id;
+ this[ '_className' ] = v.className;
+
+ this[ 'cssText' ]( v.style.cssText );
+ this[ '_flags' ] &= X_Node_BitMask_RESET_DIRTY; // X_Node_State.DIRTY_CSS ãè½ã¨ã
+
+ // TODO attr ã®ååã¯ä¸å¯è½ããã?
if( X_UA_DOM.IE4 ){
v.setAttribute( 'UID', '' + uid );
} else {
- v.UID = uid;
+ v[ 'UID' ] = uid;
};
// childNodes...
break;
+
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;
- this._rawObject = v;
- this._xnodeType = 3;
- this._state = X_Node_State.DISPLAY_INLINE;
- this._text = v.data;
- v.UID = uid;
+ this[ '_rawObject' ] = v;
+ this[ '_text' ] = v.data;
+ v[ 'UID' ] = uid;
break;
+
case X_Node_TYPE.HTML_STRING :
case X_Node_TYPE.STRING :
if( xnodes = X_HtmlParser_parse( v, true ) && 1 < xnodes.length ) return new X_NodeList( xnodes );
if( xnodes.length ) return xnodes[ 0 ];
return X_Node_none;
- case X_Node_TYPE.IMAGE :
- if( xnode = X_Node_getXNode( v ) ) return xnode;
- this._rawObject = v;
- this._xnodeType = 4;
- v.UID = uid;
- this._state = X_Node_State.EXIST;
- break;
- /*
- case X_Node_TYPE.WINDOW :
- case X_Node_TYPE.DOCUMENT :
- if( xnode = X_Node_getXNode( v ) ) return xnode;
- this._rawObject = v;
- this._xnodeType = 2;
- this._state = X_Node_State.DISPLAY_BLOCK;
- break; */
+
default :
if( X_Node_none ) return X_Node_none;
+ this.length = 0;
return;
};
};
- X_Node_CHASHE[ this._uid = uid ] = this;
+ if( this.parent && ( this.parent[ '_flags' ] & X_Node_State.IN_TREE ) ){
+ this[ '_flags' ] |= X_Node_State.IN_TREE;
+ };
+ 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 );
},
- create : X_Node_create,
-
- createAt : X_Node_createAt,
+ // attr
+ // css, cssText
+ // find
+ // animate, stop
- createText : X_Node_createText,
+ 'create' : X_Node_create,
- createTextAt : X_Node_createTextAt,
+ 'createAt' : X_Node_createAt,
- clone : X_Node_clone,
+ 'createText' : X_Node_createText,
- append : X_Node_append,
+ 'createTextAt' : X_Node_createTextAt,
- appendAt : X_Node_appendAt,
+ 'clone' : X_Node_clone,
- appendTo : X_Node_appendTo,
+ 'append' : X_Node_append,
- appendToRoot : X_Node_appendToRoot,
+ 'appendAt' : X_Node_appendAt,
- before : X_Node_before, // remove
+ 'appendTo' : X_Node_appendTo,
- prevNode : X_Node_before, // -> prev
+ 'prev' : X_Node_prev,
- after : X_Node_after, // remove
+ 'next' : X_Node_next,
- nextNode : X_Node_after, // -> next
+ 'swap' : X_Node_swap,
- replace : X_Node_replace, // remove
+ 'remove' : X_Node_remove,
- swap : X_Node_replace,
+ 'empty' : X_Node_empty,
- remove : X_Node_remove,
+ 'contains' : X_Node_contains,
- empty : X_Node_empty,
+ 'getChildAt' : X_Node_getChildAt,
- destroy : X_Node_destroy, // -> kill && kill event
+ 'numChildren' : X_Node_numChildren,
- contains : X_Node_contains,
+ 'firstChild' : X_Node_firstChild,
- getChildAt : X_Node_getChildAt,
+ 'lastChild' : X_Node_lastChild,
- firstChild : X_Node_firstChild,
+ 'getOrder' : X_Node_getOrder,
- lastChild : X_Node_lastChild,
+ 'className' : X_Node_className,
+ 'addClass' : X_Node_addClass,
+ 'removeClass' : X_Node_removeClass,
+ 'toggleClass' : X_Node_toggleClass,
+ 'hasClass' : X_Node_hasClass,
- getOrder : X_Node_getOrder,
-
- className : X_Node_className,
- addClass : X_Node_addClass,
- removeClass : X_Node_removeClass,
- toggleClass : X_Node_toggleClass,
- hasClass : X_Node_hasClass,
-
- html : X_Node_html,
- text : X_Node_text,
- call : X_Node_call,
- each : X_Node_each
+ 'html' : X_Node_html,
+ 'text' : X_Node_text,
+ 'call' : X_Node_call,
+ 'each' : X_Node_each
}
);
@@ -248,13 +390,12 @@ function X_Node_getType( v ){
if( v === document ) return X_Node_TYPE.DOCUMENT;
if( v.constructor === Node ) return X_Node_TYPE.XNODE;
if( v.constructor === X_NodeList ) return X_Node_TYPE.XNODE_LIST;
- if( X.Type.isHTMLElement( v ) ) return X_Node_TYPE.RAW_HTML;
+ if( X_Type_isHTMLElement( v ) ) return X_Node_TYPE.RAW_HTML;
if( v.nodeType === 3 ) return X_Node_TYPE.RAW_TEXT;
- if( X.Type.isImage( v ) ) return X_Node_TYPE.IMAGE;
- if( X.Type.isString( 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.nodeType === 11 ) return X_Node_TYPE.DOC_FRAG;
+ if( v[ 'instanceOf' ] && v[ 'instanceOf' ]( Node ) ) return X_Node_TYPE.XNODE;
return 0;
};
function X_Node_getXNode( v ){
@@ -264,192 +405,210 @@ function X_Node_getXNode( v ){
case X_Node_TYPE.XNODE_LIST :
return v;
case X_Node_TYPE.RAW_HTML :
- case X_Node_TYPE.IMAGE :
// fake TextNode too.
if( X_UA_DOM.IE4 ){
uid = v.getAttribute( 'UID' );
return uid && X_Node_CHASHE[ uid ];
};
- return v.UID && X_Node_CHASHE[ v.UID ];
+ return v[ 'UID' ] && X_Node_CHASHE[ v[ 'UID' ] ];
case X_Node_TYPE.WINDOW :
- return X.ViewPort;
+ return X_ViewPort;
case X_Node_TYPE.DOCUMENT :
return X_ViewPort_document;
case X_Node_TYPE.RAW_TEXT :
- if( v.UID ) return X_Node_CHASHE[ v.UID ];
+ if( v[ 'UID' ] ) return X_Node_CHASHE[ v[ 'UID' ] ];
for( chashe = X_Node_CHASHE, i = chashe.length; i; ){
- if( ( xnode = X_Node_CHASHE[ --i ] ) && ( xnode._rawObject === v ) ) return xnode;
+ if( ( xnode = X_Node_CHASHE[ --i ] ) && ( xnode[ '_rawObject' ] === v ) ) return xnode;
};
};
};
-
-X.Doc.create = Node.create = function( tag, opt_attrs, opt_css ){
- var list, i;
- switch( X_Node_getType( tag ) ){
- case X_Node_TYPE.STRING :
- X_Node_newByTag = true;
- return new Node( tag, opt_attrs, opt_css );
- case X_Node_TYPE.HTML_STRING :
- list = X_HtmlParser_parse( tag, true );
- for( i = list.length; 1 < i; ){
- list[ --i ].destroy();
- };
- return list[ 0 ];
- };
-};
-X.Doc.createText = Node.createText = function( text ){
- X_Node_newByText = true;
- return new Node( text );
-};
-
-
function X_Node_getRoot( xnode ){
return X_ViewPort_document;
- //return X_Node_body._rawObject.documentElement ? node : node.ownerDocument || node.document;
+ //return X_Node_body[ '_rawObject' ].documentElement ? node : node.ownerDocument || node.document;
};
// XMLãã©ãããå¤å¥ãã
var X_Node_isXmlDocument =
- X_UA_DOM.IE4 ?
- X.emptyFunction :
- (function( root ){
- if( X.Type.isBoolean( root.isXML ) ) return root.isXML;
- return root.isXML = root._rawObject.createElement( 'p' ).tagName !== root._rawObject.createElement( 'P' ).tagName;
- }),
+ X_UA_DOM.IE4 ?
+ X_emptyFunction :
+ (function( root ){
+ if( X_Type_isBoolean( root.isXML ) ) return root.isXML;
+ 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 ]
X_Node_systemNode, // = X_Node_CHASHE[ ? ]
X_Node_fontSizeNode,
+/*
+ * remove :
+ * X_Node_reserveRemoval = [] ã«è¿½å ãcommitUpdate 㧠remove
+ * add :
+ * X_Node_reserveRemoval ã«ãããæ¶ã, new_parent[ '_xnodes' ] ã«æ¿å
¥
+ */
X_Node_reserveRemoval = [];
var X_Node__ie4getRawNode = X_UA_DOM.IE4 && function ( that ){
- var elm = that._rawObject;
- return elm ||
- ( ( elm = document.all[ 'ie4uid' + that._uid ] ) && ( that._rawObject = elm ) ) ||
- ( that._id && ( elm = document.all[ that._id ] ) ) && ( that._rawObject = elm );
+ return that[ '_rawObject' ] ||
+ ( that[ '_rawObject' ] = document.all[ 'ie4uid' + that[ '_uid' ] ] ) ||
+ ( that[ '_id' ] && ( that[ '_rawObject' ] = document.all[ that[ '_id' ] ] ) );
};
-/* --------------------------------------
- * Create
+function X_Node_toggleInTreeFlag( xnodes, flag ){
+ var i = xnodes.length, xnode;
+ for( ; i; ){
+ xnode = xnodes[ --i ];
+ flag ? ( xnode[ '_flags' ] |= X_Node_State.IN_TREE | X_Node_State.DIRTY_POSITION ) : ( xnode[ '_flags' ] &= ~X_Node_State.IN_TREE & ~X_Node_State.IE5_DISPLAY_NONE_FIX );
+ xnode[ '_xnodes' ] && X_Node_toggleInTreeFlag( xnode[ '_xnodes' ], flag );
+ };
+};
+
+function X_Node_toggleInGPUFlag( gpuRoot, xnodes, flag ){
+ var i = xnodes.length, xnode;
+
+ if( flag ){
+ for( ; i; ){
+ xnode = xnodes[ --i ];
+ if( !xnode[ '_gpuParent' ] ){
+ xnode[ '_flags' ] |= X_Node_State.GPU_CHILD;
+ xnode[ '_gpuParent' ] = gpuRoot;
+ xnode[ '_xnodes' ] && X_Node_toggleInTreeFlag( gpuRoot, xnode[ '_xnodes' ], flag );
+ };
+ };
+ } else {
+ for( ; i; ){
+ xnode = xnodes[ --i ];
+ if( xnode[ '_gpuParent' ] === gpuRoot ){
+ xnode[ '_flags' ] &= ~X_Node_State.GPU_CHILD;
+ delete xnode[ '_gpuParent' ];
+ xnode[ '_xnodes' ] && X_Node_toggleInTreeFlag( gpuRoot, xnode[ '_xnodes' ], flag );
+ };
+ };
+ };
+};
+
+/**
+ * ã¿ã°åçãæå®ãã¦æ°è¦ã«åãã¼ããä½æããç¾å¨ã®ãã¼ãã«è¿½å ããã
+ * @alias Node.prototype.create
+ * @param {string} [tag] ã¿ã°å
+ * @param {object} [opt_attrs=] å±æ§
+ * @param {object|string}ã[opt_css=] css
+ * @return {Node} æ°è¦ä½æããããã¼ã
+ * @example var child = parent.create( 'div' );
*/
function X_Node_create( tag, opt_attrs, opt_css ){
var xnode;
- if( this._xnodeType !== 1 ) return;
- if( !this._xnodes ) this._xnodes = [];
-
- xnode = Node.create( tag, opt_attrs, opt_css );
-
- xnode.parent = this;
- this._xnodes[ this._xnodes.length ] = xnode;
- this._root && X_Node_reserveUpdate();
+ if( !this[ '_tag' ] ) return;
+ this[ 'append' ]( xnode = X_Doc_create( tag, opt_attrs, opt_css ) );
return xnode;
};
+/**
+ * æ¿å
¥ä½ç½®ã¨ã¿ã°åçãæå®ãã¦æ°è¦ã«åãã¼ããä½æããç¾å¨ã®ãã¼ãã«æ¿å
¥ããã
+ * @alias Node.prototype.createAt
+ * @param {number} [index] æ¿å
¥ä½ç½®
+ * @param {string} [tag] ã¿ã°å
+ * @param {object} [opt_attrs=] å±æ§
+ * @param {object|string}ã[opt_css=] css
+ * @return {Node} æ°è¦ä½æããããã¼ã
+ * @example var child = parent.create( 2, 'div' );
+ */
function X_Node_createAt( index, tag, opt_attrs, opt_css ){
- var xnode = Node.create( tag, opt_attrs, opt_css );
- this.appendAt( index, xnode );
+ var xnode;
+ if( !this[ '_tag' ] ) return;
+ this[ 'appendAt' ]( index, xnode = X_Doc_create( tag, opt_attrs, opt_css ) );
return xnode;
};
-/* --------------------------------------
- * CreateText
+/**
+ * ããã¹ããæå®ãã¦æ°è¦ã«ããã¹ããã¼ããä½æããç¾å¨ã®ãã¼ãã«æ¿å
¥ããã
+ * @alias Node.prototype.createText
+ * @param {string} [tag] ããã¹ã
+ * @return {Node} æ°è¦ä½æããããã¼ã
*/
function X_Node_createText( text ){
var xnode;
- if( this._xnodeType !== 1 ) return;
- if( !this._xnodes ) this._xnodes = [];
-
- X_Node_newByText = true;
- xnode = new Node( text );
- xnode.parent = this;
-
- this._root && X_Node_reserveUpdate();
- this._xnodes[ this._xnodes.length ] = xnode;
+ if( !this[ '_tag' ] ) return;
+ this[ 'append' ]( xnode = X_Doc_createText( text ) );
return xnode;
};
+/**
+ * æ¿å
¥ä½ç½®ã¨ããã¹ããæå®ãã¦æ°è¦ã«åãã¼ããä½æããç¾å¨ã®ãã¼ãã«æ¿å
¥ããã
+ * @alias Node.prototype.createTextAt
+ * @param {number} [index] æ¿å
¥ä½ç½®
+ * @param {string} [tag] ããã¹ã
+ * @return {Node} æ°è¦ä½æããããã¼ã
+ */
function X_Node_createTextAt( index, text ){
- var xtext = Node.createText( text );
- this.appendAt( index, xtext );
- return xtext;
+ var xnode;
+ if( !this[ '_tag' ] ) return;
+ this[ 'appendAt' ]( index, xnode = X_Doc_createText( text ) );
+ return xnode;
};
-/* --------------------------------------
- * Clone
+/**
+ * Node ã®ã¯ãã¼ã³ãä½æãè¿ããid ãã¯ãã¼ã³ãããç¹ã«æ³¨æãã¤ãã³ããªã¹ãã¯ã¯ãã¼ã³ãããªãã
* http://d.hatena.ne.jp/think49/20110724/1311472811
* http://d.hatena.ne.jp/uupaa/20100508/1273299874
+ * @alias Node.prototype.clone
+ * @param {boolean} [opt_clone_children] åè¦ç´ ã®ã¯ãã¼ã³ãè¡ããï¼
+ * @return {Node}
*/
function X_Node_clone( opt_clone_children ){
var xnode, xnodes, i, l;
- switch( this._xnodeType ){
- case 1 :
- X_Node_newByTag = true;
- xnode = new 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 ){
- xnode.append( xnodes[ i ].clone( true ) );
- };
+ if( this[ '_tag' ] ){
+ X_Node_newByTag = true;
+ 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 ){
+ xnode[ 'append' ]( xnodes[ i ][ 'clone' ]( true ) );
};
- return xnode;
- case 3 :
- X_Node_newByText = true;
- xnode = new Node( this._text );
- return xnode;
-
- //case 0 :
- //case 2 :
+ };
+ return xnode;
};
- return this;
+ X_Node_newByText = true;
+ return Node( this[ '_text' ] );
};
-/* --------------------------------------
- * Add
- * Node
- * HtmlElement ã®å ´åã¯å
é¨ä½¿ç¨å°ç¨ ãã®ãã event ã®ç ´æ£çããªã
+/**
+ * ãã¼ããåé
åã®æå¾ã«è¿½å ãããæååã渡ãããå ´åãHTMLãã¼ãµã¼ã«ãã£ã¦ Node ããªã¼ãä½æãã¦è¿½å ãããHtmlElement, TextNode ã®å ´åã¯å
é¨ä½¿ç¨å°ç¨ã
+ * @alias Node.prototype.append
+ * @param {Node|string|HTMLElement|TextNode} [v] HTMLElement 㨠TextNode ã¯å
é¨ã®ã¿ã
+ * @return {Node} èªèº«ããã§ã¤ã³ã¡ã½ãã
+ * @example myNode.append( node );
+ * myNode.append( nodeSprite, 'A
', 'B' );
*/
function X_Node_append( v ){
var i, l, xnodes, frg;
- if( this._xnodeType !== 1 ) return;
+ if( !this[ '_tag' ] ) return;
if( 1 < ( l = arguments.length ) ){
for( i = 0; i < l; ++i ){
- this.append( arguments[ i ] );
+ this[ 'append' ]( arguments[ i ] );
};
return this;
};
- if( !( xnodes = this._xnodes ) ) this._xnodes = xnodes = [];
+ if( !( xnodes = this[ '_xnodes' ] ) ) this[ '_xnodes' ] = xnodes = [];
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 :
- if( v._xnodeType !== 1 && v._xnodeType !== 3 ) return this;
// 親㮠xnodes ãã v ãæ¶ã
- if( v.parent ){
- //if( X_UA_DOM.W3C ){
- // v.parent._xnodes.splice( v.parent._xnodes.indexOf( v ), 1 );
- //} else
- //if( X_UA_DOM.IE4 ){
- v.remove();
- //} else {
-
- //};
- };// else
- //if( ( i = X_Node_reserveRemoval.indexOf( v ) ) !== -1 ){
- // if( !this._state ) alert( 'xnode already destroyed!' );
- // X_Node_reserveRemoval.splice( i, 1 );
- //};
+ v.parent && 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;
default :
return this;
@@ -457,30 +616,41 @@ 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;
};
-
+/**
+ * ãã¼ããæ¿å
¥ä½ç½®ã«è¿½å ããã
+ * @alias Node.prototype.appendAt
+ * @param {number} index æ¿å
¥ä½ç½® 0以ä¸
+ * @param {Node|string|HTMLElement|TextNode} [v] HTMLElement 㨠TextNode ã¯å
é¨ã®ã¿ã
+ * @return {Node} èªèº«ããã§ã¤ã³ã¡ã½ãã
+ * @example myNode.appendAt( 1, node );
+ */
function X_Node_appendAt( start, v ){
var xnodes, l, i;
- if( this._xnodeType !== 1 ) return this;
+ if( !this[ '_tag' ] ) return this;
l = arguments.length;
- if( !( xnodes = this._xnodes ) ) xnodes = this._xnodes = [];
+ if( !( xnodes = this[ '_xnodes' ] ) ) xnodes = this[ '_xnodes' ] = [];
if( xnodes.length <= start ){
- if( l === 2 ) return this.append( v );
+ if( l === 2 ) return this[ 'append' ]( v );
for( i = 1; i < l; ++i ){
- this.append( arguments[ i ] );
+ this[ 'append' ]( arguments[ i ] );
};
return this;
};
if( start < 0 ) start = 0;
if( 2 < l ){
for( ; l; ){
- this.appendAt( start, arguments[ --l ] );
+ this[ 'appendAt' ]( start, arguments[ --l ] );
};
return this;
};
@@ -488,47 +658,54 @@ 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 :
v = X_HtmlParser_parse( v, true );
for( i = v.length; i; ){
- this.appendAt( start, v[ --i ] );
+ this[ 'appendAt' ]( start, v[ --i ] );
};
return this;
case X_Node_TYPE.XNODE :
- if( v._xnodeType !== 1 && v._xnodeType !== 3 ) return this;
// 親㮠xnodes ãã v ãæ¶ã
if( v.parent ){
- //if( X_UA_DOM.W3C ){
- // v.parent._xnodes.splice( v.parent._xnodes.indexOf( v ), 1 );
- //} else
- //if( X_UA_DOM.IE4 ){
- v.remove();
- //} else {
-
- //};
- };// else
- //if( ( i = X_Node_reserveRemoval.indexOf( v ) ) !== -1 ){
- // if( !this._state ) alert( 'xnode already destroyed!' );
- // X_Node_reserveRemoval.splice( i, 1 );
- //};
+ 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;
default :
return this;
};
v.parent = this;
- this._xnodes.splice( start, 0, v );
- this._root && X_Node_reserveUpdate();
+ this[ '_xnodes' ].splice( start, 0, v );
+ 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;
};
+/**
+ * ãã¼ãã親ã«è¿½å ãããæ»ãå¤ã¯åãã¼ããªã®ã§ãç¶ãã¦æä½ãåºæ¥ãã
+ * @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 );
@@ -538,25 +715,25 @@ 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;
};
-function X_Node_appendToRoot( opt_index ){
- opt_index === undefined ? X_Node_body.append( this ) : X_Node_body.appendAt( opt_index, 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 ){
if( !parent ) return;
- xnodes = parent._xnodes;
+ xnodes = parent[ '_xnodes' ];
i = xnodes.indexOf( this );
return 0 < i ? xnodes[ i - 1 ] : v;
};
@@ -564,24 +741,30 @@ 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
if( v === undefined ){
if( !parent ) return;
- xnodes = parent._xnodes;
+ xnodes = parent[ '_xnodes' ];
i = xnodes.indexOf( this );
return ++i < xnodes.length ? xnodes[ i ] : v;
};
@@ -589,157 +772,222 @@ function X_Node_after( v ){
if( !parent ) return this;
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;
+ start = this[ 'getOrder' ]() + 1;
+
+ if( parent[ '_xnodes' ].length <= start ){
+ 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;
};
-function X_Node_replace( v ){
+/**
+ * è¦ç´ ã®å
¥ãæ¿ããèªèº«ã¯ 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.before( v ).remove() : this.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;
+ var parent = this.parent,
+ elm;
if( !parent ) return this;
- parent._xnodes.splice( parent._xnodes.indexOf( this ), 1 );
- if( this._root ){
- X_Node_reserveRemoval[ X_Node_reserveRemoval.length ] = this;
- X_Node_reserveUpdate();
- };
delete this.parent;
- delete this._root;
+ parent[ '_xnodes' ].splice( parent[ '_xnodes' ].indexOf( this ), 1 );
+
+ if( this[ '_flags' ] & X_Node_State.IN_TREE ){
+ this[ '_flags' ] &= ~X_Node_State.IN_TREE & ~X_Node_State.IE5_DISPLAY_NONE_FIX;
+ this[ '_xnodes' ] && X_Node_toggleInTreeFlag( this[ '_xnodes' ], false );
+
+ if( X_UA_DOM.IE4 ){
+ elm = this[ '_rawObject' ] || X_Node__ie4getRawNode( this );
+ if( elm ){
+ X_Node_reserveRemoval[ X_Node_reserveRemoval.length ] = this;
+ X_Node_reserveUpdate();
+ } else
+ if( !this[ '_tag' ] && ( parent[ '_flags' ] & X_Node_State.IE4_FIXED ) === 0 ){
+ parent[ '_flags' ] |= X_Node_State.IE4_DIRTY_CHILDREN;
+ };
+ } else {
+ elm = this[ '_rawObject' ];
+ if( elm && elm.parentNode && elm.parentNode.tagName ){
+ X_Node_reserveRemoval[ X_Node_reserveRemoval.length ] = this;
+ X_Node_reserveUpdate();
+ };
+ };
+ };
return this;
};
+/**
+ * åè¦ç´ ãç ´æ£ãããåè¦ç´ 㯠kill() ããã¾ãã
+ * @alias Node.prototype.empty
+ * @return {Node} èªèº«ããã§ã¤ã³ã¡ã½ãã
+ * @example node.empty();
+ */
function X_Node_empty(){
- var xnodes = this._xnodes, i;
+ var xnodes = this[ '_xnodes' ], i;
if( xnodes && ( i = xnodes.length ) ){
for( ; i; ){
- xnodes[ --i ].destroy();
+ xnodes[ --i ][ 'kill' ]();
};
xnodes.length = 0;
};
return this;
};
-/* --------------------------------------
- * destory
- */
-// Node._destroyChildFlag = false; // TODO
-
-function X_Node_destroy( isChild ){
- var xnodes = this._xnodes, i, elm;
-
- if( !this._state ) return;
+function X_Node_onBeforeKill( e ){
+ var xnodes = this[ '_xnodes' ], i, elm;
- elm = this._rawObject || X_UA_DOM.IE4 && X_Node__ie4getRawNode( this );
+ 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' ] && X_EventDispatcher_unlistenAll( this ); // ã¤ãã³ãã®éé¿
+
if( xnodes && ( i = xnodes.length ) ){
- //for( ; i; ){
- // xnodes[ --i ].destroy( true );
- //};
+ for( ; i; ){
+ X_Node_onBeforeKill.call( xnodes[ --i ] );
+ };
};
- elm && this._listeners && this.unlisten(); // ã¤ãã³ãã®éé¿
- delete X_Node_CHASHE[ this._uid ];
- delete this._state;
-
- if( this._root ){
- !isChild && this.remove();
- } 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' ] ];
+
+ if( e ){
+ this[ 'remove' ]();
+ if( X_Node_reserveRemoval[ X_Node_reserveRemoval.length - 1 ] === this ){
+ this[ '_flags' ] &= ~X_Node_State.EXIST;
+ return X_Callback_PREVENT_DEFAULT;
+ };
};
+ return X_Callback_NONE;
};
-
-/* --------------------------------------
- * 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._xnodeType !== 1 ) return false;
+ 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 );
+ 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 );
};
+
//if( document.compareDocumentPosition ){
//
//};
- xnodes = this._xnodes;
+ xnodes = this[ '_xnodes' ];
if( !xnodes || !xnodes.length ) return false;
if( xnodes.indexOf( v ) !== -1 ) return true; // fast
- if( elm === v.parentNode ) return false;
for( i = xnodes.length; i; ){
- if( xnodes[ --i ].contains( v ) ) return true;
+ 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._xnodeType === 1 && this._xnodes;
+ var xnodes = this[ '_xnodes' ];
return xnodes && 0 <= i && i < xnodes.length && xnodes[ i ];
};
+/**
+ * åè¦ç´ ã®æ°ãåå¾ããã
+ * @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.getChildAt( 0 );
+ return this[ '_xnodes' ] && this[ '_xnodes' ][ 0 ];
};
+
+/**
+ * æå¾ã®åè¦ç´ ãåå¾ããã
+ * @alias Node.prototype.lastChild
+ * @return {Node} æå¾ã®åè¦ç´
+ * @example lastChild = parent.lastChild();
+ */
function X_Node_lastChild(){
- return this.getChildAt( this._xnodes.length - 1 );
+ 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, _, __;
// getter
- if( v === undefined ) return this._className;
+ if( v === undefined ) return this[ '_className' ];
// setter
- if( this._className === v ) return this;
- if( !v || typeof v !== 'string' ){
- delete this._className;
+ if( this[ '_className' ] === v ) return this;
+ if( !v || !X_Type_isString( v ) ){
+ delete this[ '_className' ];
} else {
// cleanup
_ = ' ';
@@ -748,35 +996,53 @@ function X_Node_className( v ){
v.charAt( 0 ) === _ && ( v = v.substr( 1 ) );
v.lastIndexOf( _ ) === 0 && ( v = v.substr( 0, v.length - 1 ) );
- if( this._className === v ) return this;
- v ? ( this._className = v ) : delete this._className;
+ if( this[ '_className' ] === v ) return this;
+ v ? ( this[ '_className' ] = v ) : delete this[ '_className' ];
};
- this._dirty |= X_Node_Dirty.CLASSNAME;
- this._root && X_Node_reserveUpdate();
+ this[ '_flags' ] |= X_Node_State.DIRTY_CLASSNAME;
+ 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; ){
name = names[ --i ];
if( !name ) continue;
- !this.hasClass( name ) && ( v += ( v ? ' ' : '' ) + name );
+ !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;
@@ -784,122 +1050,181 @@ function X_Node_removeClass( v ){
};
};
};
- return f ? this.className( classNames.join( _ ) ) : this;
+ 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; ){
name = names[ --i ];
- this.hassClass( name ) ? this.removeClass( name ) : this.addClass( name );
+ this[ 'hasClass' ]( name ) ? this[ 'removeClass' ]( name ) : this[ 'addClass' ]( name );
};
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
+/**
+ * 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._xnodeType === 3 ) return this.text( html );
- return html ? this.empty().append.apply( this, X_HtmlParser_parse( html, true ) ) : this.empty();
+ if( !this[ '_tag' ] ) return this[ 'text' ]( html );
+ return html ? this[ 'empty' ]()[ 'append' ].apply( this, X_HtmlParser_parse( html, true ) ) : this[ 'empty' ]();
};
// getter
- if( this._xnodeType === 3 ){
- return this._text;
+ if( !this[ '_tag' ] ){
+ return this[ '_text' ];
};
- if( this._dirty & X_Node_Dirty.CSS && !( this._cssText = X_Node_CSS_objToCssText( this._css ) ) ){
- 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._cssText ? ' style="' + this._cssText + q : _,
+ '<', this[ '_tag' ],
+ this[ '_id' ] ? ' id="' + this[ '_id' ] + q : _,
+ this[ '_className' ] ? ' class="' + this[ '_className' ] + q : _,
+ this[ '_flags' ] & X_Node_State.OLD_ATTRTEXT ? X_Node_Attr_objToAttrText( this ) : this[ '_attrText' ],
+ this[ '_cssText' ] ? ' style="' + this[ '_cssText' ] + q : _,
'>' ];
n = html.length;
- if( ( xnodes = this._xnodes ) && ( l = xnodes.length ) ){
+ if( ( xnodes = this[ '_xnodes' ] ) && ( l = xnodes.length ) ){
if( !X_Node_outerXNode ) X_Node_outerXNode = this;
for( i = 0; i < l; ++i ){
- html[ n ] = xnodes[ i ].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 + '>' );
+ !X_Node_outerXNode || X_Dom_DTD_EMPTY[ this[ '_tag' ] ] || ( html[ n ] = '<\/' + this[ '_tag' ] + '>' );
return html.join( _ );
};
+/*
+ * 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
if( text !== undefined ){
- if( this._xnodeType === 3 ){
- if( this._text !== text ){
- text ? ( this._text = text ) : delete this.text;
- this._root && X_Node_reserveUpdate();
- this._dirty |= X_Node_Dirty.CONTENT;
+ if( text === null ) text = '';
+ text += '';
+
+ if( !this[ '_tag' ] ){
+ if( this[ '_text' ] !== 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();
};
return this;
};
- if( !text ) return this.empty();
- if( ( xnodes = this._xnodes ) && xnodes.length === 1 && xnodes[ 0 ]._xnodeType === 3 ){
- xnodes[ 0 ].text( text );
+ if( ( xnodes = this[ '_xnodes' ] ) && xnodes.length === 1 && !xnodes[ 0 ][ '_tag' ] ){
+ xnodes[ 0 ][ 'text' ]( text );
return this;
};
- this.empty().createText( text );
+ // TODO ä¸ã¤ã®textnode ãæ®ãã±ã¼ã¹ å®å
¨ã«åé¤ãããå ´å㯠empty()ã使ã
+ if( !text ) return this[ 'empty' ]();
+ this[ 'empty' ]()[ 'createText' ]( text );
return this;
};
// getter
- if( this._xnodeType === 1 ){
- if( ( xnodes = this._xnodes ) && ( l = xnodes.length ) ){
+ if( this[ '_tag' ] ){
+ if( ( xnodes = this[ '_xnodes' ] ) && ( l = xnodes.length ) ){
for( texts = [], i = 0; i < l; ++i ){
- texts[ i ] = xnodes[ i ].text();
+ texts[ i ] = xnodes[ i ][ 'text' ]();
};
return texts.join( '' );
};
return '';
};
- return this._text;
+ return this[ '_text' ];
};
/*
* HTMLè¦ç´ ã«å¯¾ã㦠name ã®é¢æ°ãå®è¡ããã®æ»ãå¤ãè¿ããé¢æ°ã«æ¸¡ãå¼æ°ãä»»æã«è¨å®ã§ããã
*/
function X_Node_call( name /*, opt_args... */ ){
- var raw = this._rawObject || X_UA_DOM.IE4 && X_Node__ie4getRawNode( this ),
- l = arguments.length - 1,
- func, args, params, i;
+ var l = arguments.length - 1,
+ raw, func, args, params, i;
+
+ switch( name ){
+ case 'nodeType' :
+ return this[ '_tag' ] ? 1 : 3;
+ 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;
+
+ if( name === 'scrollTo' ){
+ raw.scrollLeft = arguments[ 1 ] || 0;
+ raw.scrollTop = arguments[ 2 ] || 0;
+ return;
+ };
+
func = raw[ name ];
- if( X.Type.isFunction( func ) ){
+ if( X_Type_isFunction( func ) ){
if( l ){
args = X_Object_cloneArray( arguments );
args.shift();
@@ -907,7 +1232,7 @@ function X_Node_call( name /*, opt_args... */ ){
};
return raw[ name ]();
} else
- if( X.Type.isUnknown( func ) ){
+ if( X_Type_isUnknown( func ) ){
// typeof func === unknown ã«å¯¾ç
// http://la.ma.la/blog/diary_200509031529.htm
if( l ){
@@ -948,230 +1273,436 @@ function X_Node_each( func /*, opt_args */ ){
/* --------------------------------------
* Async commit update
*
- * state:
- * 0 : no_rawObject
- * 1 : no_parent
- * 2 : no_root
- * 3 : dirty
- * 4 : clean
- *
- * remove :
- * root._reserveRemoval = [] ã«è¿½å ãcommitUpdate 㧠remove ã㦠state 㯠not_added
- * add :
- * root._reserveRemoval ã«ãããæ¶ã, new_parent._xnodes ã«æ¿å
¥ãsteta 㯠not_added ã«ã㦠commitUpdate ãå¾
ã¤
+ * TODO Timer ã DOM ã¤ãã³ãã®å¼ã³åºãã®æå¾ã«ãã¾ã ä¸åº¦ã commitUpdate ãã¦ããªããªã commitUpdate ãã¦ãã¾ãã
*/
function X_Node_reserveUpdate(){
- if( !X_Node_updateTimerID ) X_Node_updateTimerID = X.Timer.requestFrame( X_Node_startUpdate );
+ if( !X_Node_updateTimerID ) X_Node_updateTimerID = X_Timer_requestFrame( X_Node_startUpdate );
};
-function X_Node_startUpdate(){
- var removal, i, xnode, tmp;
+var X_Node_updateReservedByReleaseGPU = false;
+
+function X_Node_startUpdate( time ){
+ var removal, i, xnode;
- if( !X_Node_updateTimerID || X_ViewPort_readyState < X_TEMP.SYSTEM_EVENT_INIT ){
+ if( !X_Node_updateTimerID || X_ViewPort_readyState < X_EVENT_INIT ){
return;
};
- X.Timer.cancelFrame( X_Node_updateTimerID );
+ X_Timer_cancelFrame( X_Node_updateTimerID );
X_Node_updateTimerID = 0;
-
- // ãã®ã¤ãã³ãã§ãµã¤ãºãåãã¨ç¡éã«ã¼ãã«
- // X_ViewPort._listeners && X_ViewPort._listeners[ X.Event.BEFORE_UPDATE ] && X_ViewPort.dispatch( X.Dom.Event.BEFORE_UPDATE );
+ if( time ){
+ // X.Timer çµç±ã§ãªãã¨çºç«ããªã ãã®ã¤ãã³ãã§ãµã¤ãºãåãã¨ç¡éã«ã¼ãã«
+ X_System[ '_listeners' ] && X_System[ '_listeners' ][ X_EVENT_BEFORE_UPDATE ] && X_System[ 'dispatch' ]( X_EVENT_BEFORE_UPDATE );
+ };
removal = X_Node_reserveRemoval;
-
- //tmp = X_Node_body._rawObject.style.visibility;
- //this._rawObject.style.visibility = 'hidden';
-
- //console.log( '_actualRemove().' );
if( i = removal.length ){
for( ; i; ){
xnode = removal[ --i ];
+ // TODO GPU ã¬ã¤ã¤ã¼ã®åã®å ´åãremove ãã¹ãããããã éGPU ã¬ã¤ã¤ã¼ã¸ apppend ãããå ´åãclone ãã?
X_Node__actualRemove( xnode );
- !X_Node_body._state && xnode.kill();
+ ( xnode[ '_flags' ] & X_Node_State.EXIST ) === 0 && xnode[ 'kill' ]();
};
removal.length = 0;
};
-
- //console.log( 'start _startUpdate().' );
-
- /* X_Node_html._dirty ? */ X_Node__commitUpdate( X_Node_html ); /* : X_Node__commitUpdate( X_Node_body ); */;
- //console.log( 'end of _startUpdate().' );
+ if( X_Node_html[ '_flags' ] & X_Node_BitMask_IS_DIRTY ){
+ X_Node__commitUpdate( X_Node_html, X_Node_html[ '_rawObject' ].parentNode, null, X_Node_html[ '_flags' ] );
+ } else {
+ X_Node__commitUpdate( X_Node_head, X_Node_head[ '_rawObject' ].parentNode, null, X_Node_head[ '_flags' ] );
+ X_Node__commitUpdate( X_Node_body, X_Node_body[ '_rawObject' ].parentNode, null, X_Node_body[ '_flags' ] );
+ };
+
+ if( X_Node_updateReservedByReleaseGPU ){
+ X_Node_reserveUpdate();
+ X_Node_updateReservedByReleaseGPU = false;
+ };
- X_ViewPort._listeners && X_ViewPort._listeners[ X.Event.AFTER_UPDATE ] && X_ViewPort.asyncDispatch( X.Event.AFTER_UPDATE );
- //this._rawObject.style.visibility = tmp;
+ if( time ){
+ // X.Timer çµç±ã§ãªãã¨çºç«ããªã ãã®ã¤ãã³ãã§ãµã¤ãºãåãã¨ç¡éã«ã¼ãã«
+ 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 );
};
+/*
+ * 1. GPU_NOW ã®å ´åãåã®å¤æ´ã¯è¡ããªã
+ * 2. GPU解æ¾äºç´ ã®å ´å//ããã®è¦ç´ ã®ã¿å¤æ´ãè¡ããrAFãå¾ã«ããã«æ´æ°ãããããã©ã°ãç«ã¦ãã
+ * 3. GPUäºç´ -> GPU
+ * 4. style="display:none" ã®å ´åããã以ä¸ã®å¤æ´ãè¡ããªãã
+ * 5. ie5 é表示ãã©ã°ãç«ã£ã¦ãã¦ã親ã¨èªèº«ã® classã»id ã«ãã£ã¦é表示ã«ãªã£ã¦ãã¦ã親ã¨èªèº«ã«å¤æ´ããªããaccumulatedFlags ã使ç¨ã
+ * -> TODO ãã TREE ã®å¤æ´ãæ¤åºã§ããªãã remove ããã¨ãã« åã¾ã§ X_Node_State.IE5_DISPLAY_NONE_FIXãè½ã¨ãã
+ * 6. è¦ç´ ã®çæ
+ * 7. è¦ç´ ã®ä½ç½®ã®ãºã¬ãè£æ£
+ * 8. æ´æ°ã®é©ç¨
+ * 9. ie5 親åã³èªèº«ã¸ã®ã¯ã©ã¹ã»idæå®ã§ display:none ã«ãªãã±ã¼ã¹ããããããæ¤åºã
+ * ãã®ã¾ã¾ã§ã¯ãçæã¨ç ´æ£ãç¹°ãè¿ããã¦ãã¾ãã®ã§è¦ªã¨èªèº«ã®ã¯ã©ã¹ã»idãå¤ãã£ãå ´åãããªã¼ä½ç½®ã®å¤åããã£ãå ´åã«åçããã
+ */
var X_Node__commitUpdate =
X_UA_DOM.W3C ?
- ( function( that, parentElement, nextElement ){
- var elm = that._rawObject,
- xnodes, l, i, frg, next, k, v;
-
- if( that._state & X_Node_State.IE5_DISPLAY_NONE_FIX ){
- //alert( that._tag + ' ' + !!elm );
- // filter ã®å¹ãã¦ããè¦ç´ ã ãdisplay:none ãç¡è¦ããã模æ§ãfilter ãåãã°ããï¼
- // 親ããdisplay:none ã®å ´åã¯ï¼
- elm && elm.parentNode && X_Node__actualRemove( that );
- return nextElement;
+ ( function( that, parentElement, nextElement, accumulatedFlags ){
+ var elm = that[ '_rawObject' ],
+ created, xnodes, l, next;
+
+ // 1. GPU ä¸åã®æ´æ°ãã¹ããã
+ if( that[ '_flags' ] & X_Node_State.GPU_NOW ){
+ console.log( 'æ´æ°ã®skip ' + !!( that[ '_flags' ] & X_Node_BitMask_IS_DIRTY ) );
+ that[ '_flags' ] & X_Node_BitMask_IS_DIRTY && X_Node__updateRawNode( that, elm );
+ return elm;
};
- if( !elm || ( parentElement && elm.parentNode !== parentElement ) || ( nextElement && elm.nextSibling !== nextElement ) ){
- nextElement ?
- parentElement.insertBefore( X_Node__actualCreate( that ), nextElement ) :
- parentElement.appendChild( X_Node__actualCreate( that ) );
- X_Node__afterActualCreate( that );
+ // 2. GPU解æ¾äºç´
+ if( that[ '_flags' ] & X_Node_State.GPU_RELEASE_RESERVED ){
+ // console.log( 'GPU è§£æ¾ ' );
+ //X_Node_updateReservedByReleaseGPU = true;
+ //X_Node__updateRawNode( that, elm );
+ that[ '_flags' ] &= X_Node_BitMask_RESET_GPU;
+ //return elm;// TODO ãããããããã®ã¿ã¤ãã³ã°ã§æ´æ°ã§ããããã
+ };
- return elm || that._rawObject;
- } else
- if( ( xnodes = that._xnodes ) && ( l = xnodes.length ) ) {
+ // 3. GPUäºç´ -> GPU
+ if( that[ '_flags' ] & X_Node_State.GPU_RESERVED ){
+ that[ '_flags' ] &= X_Node_BitMask_RESET_GPU;
+ that[ '_flags' ] |= X_Node_State.GPU_NOW;
+ };
+
+ // 4. style="display:none" ã®å ´å
+ if( that[ '_flags' ] & X_Node_State.STYLE_IS_DISPLAY_NONE ){
+ if( X_Node_displayNoneFixForIE5 ){
+ // filter ã®å¹ãã¦ããè¦ç´ ãå«ãè¦ç´ 㯠display:none ãç¡è¦ãããã
+ // filter = '' ã§åé¤ã¯ã§ããããå表示æã« filter ãæ¶ããã -> filter ãªè¦ç´ ãåé¤ãã¦ãã¾ãã
+ if( elm && elm.parentNode ){
+ X_Node__actualRemove( that );
+ };
+ return nextElement;
+ };
+ elm && ( elm.style.display = 'none' );
+ return ( elm && elm.nextSibling === nextElement ) ? elm : nextElement;
+ };
+
+ // 5. ie5 é表示fixãã©ã°
+ accumulatedFlags |= that[ '_flags' ];
+
+ if( that[ '_flags' ] & X_Node_State.IE5_DISPLAY_NONE_FIX ){
+ if( accumulatedFlags & ( X_Node_State.DIRTY_POSITION | X_Node_State.DIRTY_ID | X_Node_State.DIRTY_CLASSNAME ) === 0 ){
+ return nextElement;
+ };
+ };
+
+ // 6. è¦ç´ ã®çæ
+ if( !elm ){
+ if( !that[ '_tag' ] ){
+ that[ '_flags' ] &= X_Node_BitMask_RESET_DIRTY;
+ that[ '_rawObject' ] = elm = document.createTextNode( X_String_chrReferanceTo( that[ '_text' ] ) );
+ if( !X_UA[ 'IE' ] ){
+ elm[ 'UID' ] = that[ '_uid' ];
+ };
+ } else
+ if( X_Node_strictElmCreation ){
+ that[ '_flags' ] & X_Node_State.OLD_CSSTEXT && X_Node_CSS_objToCssText( that, true ); // OLD_CSSTEXT ??
+
+ that[ '_rawObject' ] = elm =
+ document.createElement( [
+ '<', that[ '_tag' ],
+ ' UID="', that[ '_uid' ], '"',
+ that[ '_id' ] ? ' id="' + that[ '_id' ] + '"' : '',
+ that[ '_className' ] ? ' class="' + that[ '_className' ] + '"' : '',
+ X_Node_Attr_objToAttrText( that, true ),
+ that[ '_cssText' ] ? ' style="' + that[ '_cssText' ] + '"' : '',
+ '>' ].join( '' ) );
+ } else {
+ that[ '_rawObject' ] = elm = document.createElement( that[ '_tag' ] );
+ };
- /*if( elm.childNodes.length !== l && ( frg = X_Node_useDocumentFragment ) ){
- for( i = 0; i < l; ++i ){
- frg.appendChild( X_Node__actualCreate( xnodes[ i ], true ) );
+ // IE ã«ã¯è¦ç´ 追å ã®ã¿ã¤ãã³ã°ã§èµ·ããã¡ã¢ãªãªã¼ã¯ãããããã§è¿½å
+ if( !X_Node_addTreeAfterChildren ){
+ nextElement ?
+ parentElement.insertBefore( elm, nextElement ) :
+ parentElement.appendChild( elm );
+ };
+
+ if( that[ '_tag' ] ){
+ X_EventDispatcher_toggleAllEvents( that, true );// ã¤ãã³ãã®å¾©å¸°
+ that[ '_flags' ] |= X_Node_State.ACTUAL_LISTENING;
+
+ if( X_Node_documentFragment ){
+ //( frg = X_Node_documentFragment ).appendChild( elm );
+ // é£ç¶ããè¦ç´ ã®å·®ãæ¿ãã®å ´åã«æå¹
};
- elm.appendChild( frg );
- } else {*/
- for( ; l; ){
- next = X_Node__commitUpdate( xnodes[ --l ], elm, next );
+
+ if( X_Node_strictElmCreation ){
+ that[ '_flags' ] &= X_Node_BitMask_RESET_DIRTY;
+ // ie ã® string ããè¦ç´ ãä½ãå ´åããããã¯ã¼ã¯ç³»å±æ§ã¯ onload ã¤ãã³ããªã©ãæ¾ãããã«ãè¦ç´ çæ->ã¤ãã³ã復帰å¾ã«é©ç¨ãã
+ that[ '_newAttrs' ] && ( that[ '_flags' ] |= X_Node_State.DIRTY_ATTR ); // _newAttrs ã«ã¯ ãããã¯ã¼ã¯ç³»å±æ§ãå
¥ã£ã¦ãããNetwork ç³»ã®å±æ§ã¯é
ããã¦è¨å®
+ that[ '_flags' ] |= X_Node_State.DIRTY_IE_FILTER;// doc 追å å¾ã« filter ãæå®ããªãã¨æå¹ã«ãªããªãã
+ } else {
+ elm[ 'UID' ] = that[ '_uid' ];
+ that[ '_newAttrs' ] = that[ '_attrs' ];
+ that[ '_flags' ] &= X_Node_BitMask_RESET_DIRTY;
+ that[ '_flags' ] |= 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;
+
+ // http://outcloud.blogspot.jp/2010/09/iframe.html
+ // ãã®åé¡ã¯ firefox3.6 ã§ç¢ºèª
+ 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' );
+ };
+ };
};
- //};
+ };
+
+ created = true;
+ } else
+ // 7. è¦ç´ ã®ä½ç½®ã®ãºã¬ãè£æ£
+ if( elm.parentNode !== parentElement || ( nextElement && elm.nextSibling !== nextElement ) ){
+ nextElement ?
+ parentElement.insertBefore( elm, nextElement ) :
+ parentElement.appendChild( elm );
+ };
+
+ if( that[ '_listeners' ] && ( that[ '_flags' ] & X_Node_State.ACTUAL_LISTENING ) === 0 ){
+ X_EventDispatcher_toggleAllEvents( that, true );// ã¤ãã³ãã®éé¿
+ that[ '_flags' ] |= X_Node_State.ACTUAL_LISTENING;
+ };
+
+ // 8. æ´æ°ã®é©ç¨
+ if( accumulatedFlags & X_Node_BitMask_IS_DIRTY ){
+ delete that[ '_fontSize' ];
+ X_Node__updateRawNode( that, elm );
};
- delete that._fontSize;
- that._dirty && X_Node__updateRawNode( that, elm );
- if( that._state & X_Node_State.IE5_DISPLAY_NONE_FIX ){
- return nextElement;
+ // 9. ie5 only
+ // 親åã³èªèº«ã¸ã®ã¯ã©ã¹ã»idæå®ã§ display : none ã«ãªãã±ã¼ã¹ããããããæ¤åº
+ // çæã¨ç ´æ£ãç¹°ãè¿ããã¦ãã¾ãã親ã¨èªèº«ã® id, class ãå¤ãã£ãå ´åã ãåçæã accumulatedFlags & ( ID | CLASSNAME )
+ // currentStyle ã観ã¦ããã¨ãã¯ã¨ã©ã¼ã§åæ¢ãããalert ã¨æãã¨æ£å¸¸ã«åãã¦æ¯é¢æ»
è£
+ if( X_Node_displayNoneFixForIE5 && that[ '_tag' ] ){
+ if( elm.runtimeStyle.display === 'none' ){
+ X_Node__actualRemove( that );
+ that[ '_flags' ] |= X_Node_State.IE5_DISPLAY_NONE_FIX;
+ return nextElement;
+ } else {
+ that[ '_flags' ] &= ~X_Node_State.IE5_DISPLAY_NONE_FIX;
+ };
+ };
+
+ // 10. åè¦ç´ ã®æ´æ°ã
+ if( ( xnodes = that[ '_xnodes' ] ) && ( l = xnodes.length ) ) {
+ for( ; l; ){
+ next = X_Node__commitUpdate( xnodes[ --l ], elm, next, accumulatedFlags );
+ };
+ };
+
+ if( created && X_Node_addTreeAfterChildren ){
+ nextElement ?
+ parentElement.insertBefore( elm, nextElement ) :
+ parentElement.appendChild( elm );
+
+ if( X_UA[ 'Gecko' ] && that[ '_tag' ] === 'IFRAME' && elm.contentWindow ){
+ // tree ã«è¿½å ãããã¾ã§ contentWindow ã¯åå¨ããªãã
+ elm.contentWindow.location.replace = elm.src;
+ };
};
+
return elm;
}) :
X_UA_DOM.IE4 ?
- ( function( that, parentElement, prevElement ){
- var elm = that._rawObject || X_Node__ie4getRawNode( that ),
- xnodes, l, i, html, text, prev;
+ ( function( that, parentElement, prevElement, accumulatedFlags ){
+ var elm = that[ '_rawObject' ] || X_Node__ie4getRawNode( that ),
+ xnodes, l, i, dirty, mix, html, text, prev;
+ if( !that[ '_tag' ] ){
+ that[ '_flags' ] & X_Node_State.DIRTY_CONTENT && X_Node__updateRawNode( that, elm );
+ return elm;
+ };
+
+ // 4. style="display:none" ã®å ´å
+ if( that[ '_flags' ] & X_Node_State.STYLE_IS_DISPLAY_NONE ){
+ if( elm ){
+ elm.style.display = 'none';
+ if( elm.style.display !== 'none' ){ // ie4 ã® style 㯠currentStyle ç¸å½ãããããã? div 以å¤ã¸ã® display:none ãå¹ããªãã®ã§ remove ããã
+ X_Node__actualRemove( that );
+ return prevElement;
+ };
+ };
+ return elm || prevElement;
+ };
+
if( !elm ){
prevElement ?
- prevElement.insertAdjacentHTML( 'AfterEnd', X_Node__actualCreate( that ) ) :
- parentElement.insertAdjacentHTML( 'AfterBegin', X_Node__actualCreate( that ) );
+ prevElement.insertAdjacentHTML( 'AfterEnd', X_Node__actualCreate( that, false ) ) :
+ parentElement.insertAdjacentHTML( 'AfterBegin', X_Node__actualCreate( that, false ) );
X_Node__afterActualCreate( that );
- return that._rawObject || X_Node__ie4getRawNode( that );
+ return that[ '_rawObject' ] || X_Node__ie4getRawNode( that );
};
- xnodes = that._xnodes;
+ accumulatedFlags |= that[ '_flags' ];
+
+ xnodes = that[ '_xnodes' ];
l = xnodes ? xnodes.length : 0;
+ dirty = !!( that[ '_flags' ] & X_Node_State.IE4_DIRTY_CHILDREN );
+
+ /*
+ * HTML ã®ä¸ã« TextNode ã ã ãMIX_FIXEDãã§ãªãå ´åãåé¤ã追å ã親ã«éç¥
+ * HTML ã®ä¸ã« HTML ã ã
+ * HTML ã®ä¸ã¯ MIX -> TextNode, html ã®åé¤ãå¤æ´ã追å
+ * HTML ã®ä¸ã¯ MIX_FIXED -> TextNode ã ã«ç½®ãæãã¦ããã®ã§W3C DON çã«è§¦ããã¨ãã§ãã
+ */
+ if( dirty ){
+ that[ '_flags' ] &= ~X_Node_State.IE4_DIRTY_CHILDREN;
+ for( i = 0; i < l; ++i ){
+ if( xnodes[ i ][ '_tag' ] ){
+ that[ '_flags' ] |= X_Node_State.IE4_HAS_ELEMENT;
+ } else {
+ that[ '_flags' ] |= X_Node_State.IE4_HAS_TEXTNODE;
+ };
+ if( that[ '_flags' ] & X_Node_BitMask_IE4_IS_MIX === X_Node_BitMask_IE4_IS_MIX ){
+ mix = true;
+ break;
+ };
+ };
+ };
- if( that._dirty & X_Node_Dirty.IE4_TEXTNODE_FIX || ( that._state & X_Node_State.IE4_ONLY_TEXT && ( l !== 1 || xnodes[ 0 ]._xnodeType !== 3 ) ) ){ // 1 < l && elm.children.length === 0
+ if( that[ '_flags' ] & X_Node_State.IE4_FIXED || that[ '_flags' ] & X_Node_BitMask_IE4_IS_MIX === X_Node_State.IE4_HAS_ELEMENT ){
+ for( i = 0; i < l; ++i ){
+ prev = X_Node__commitUpdate( xnodes[ i ], elm, prev, accumulatedFlags );
+ };
+ } else
+ if( mix ){
html = [];
for( i = 0; i < l; ++i ){
- html[ i ] = X_Node__actualCreate( xnodes[ i ] );
+ html[ i ] = X_Node__actualCreate( xnodes[ i ], false );
};
elm.innerHTML = html.join( '' );
for( i = 0; i < l; ++i ){
X_Node__afterActualCreate( xnodes[ i ] );
};
- that._state &= ~X_Node_State.IE4_ONLY_TEXT;
- } else
- if( that._state & X_Node_State.IE4_ONLY_TEXT ){ // textNode ã swap ããå ´åã®æ¤åºã¯ã_root ã§è¡ã
- text = xnodes[ 0 ];
- if( text._dirty || !text._root ){
- elm.innerHTML = text._text;
- delete text._dirty;
- text._root = that._root;
- };
+ that[ '_flags' ] |= X_Node_State.IE4_FIXED;
} else
- if( l ){
+ if( that[ '_flags' ] & X_Node_State.IE4_HAS_TEXTNODE ){
+ dirty = dirty || false;
for( i = 0; i < l; ++i ){
- prev = X_Node__commitUpdate( xnodes[ i ], elm, prev );
+ text = xnodes[ i ];
+ if( text[ '_flags' ] & X_Node_BitMask_IS_DIRTY ){
+ text[ '_flags' ] &= X_Node_BitMask_RESET_DIRTY;
+ dirty = true;
+ };
};
+ if( dirty ) elm.innerHTML = that[ 'text' ]();
};
- delete that._fontSize;
- that._dirty && X_Node__updateRawNode( that, elm );
+ if( accumulatedFlags & X_Node_BitMask_IS_DIRTY ) delete that[ '_fontSize' ];
+
+ that[ '_flags' ] &= ~X_Node_State.DIRTY_POSITION;
+ that[ '_flags' ] & X_Node_BitMask_IS_DIRTY && X_Node__updateRawNode( that, elm );
return elm;
}) :
(function(){});
+/*
+ * GPU ã¬ã¤ã¤ã¼ãããã©ã¦ã¶ã¯ãåè¦ç´ ããå¤æ´ãå½ã¦ã¦ãã? <- ã¨ããããã親è¦ç´ ããã
+ */
var X_Node__updateRawNode =
X_UA_DOM.W3C ?
( function( that, elm ){
var attrs, rename, k, v;
// textNode
- if( that._dirty & X_Node_Dirty.CONTENT ){
- elm.data = X_String_chrReferanceTo( that._text );
- delete that._dirty;
+ if( !that[ '_tag' ] ){
+ elm.data = X_String_chrReferanceTo( that[ '_text' ] );
+ that[ '_flags' ] &= X_Node_BitMask_RESET_DIRTY;
return;
};
// id
- if( that._dirty & X_Node_Dirty.ID ){
- that._id ? ( elm.id = that._id ) : ( elm.id && elm.removeAttribute( 'id' ) );
+ if( that[ '_flags' ] & X_Node_State.DIRTY_ID ){
+ that[ '_id' ] ? ( elm.id = that[ '_id' ] ) : ( elm.id && elm.removeAttribute( 'id' ) );
};
// className
- if( that._dirty & X_Node_Dirty.CLASSNAME ){
- that._className ? ( elm.className = that._className ) : ( elm.className && elm.removeAttribute( X_UA.IE5678 ? 'className' : 'class' ) ); // className 㯠ie7-?
-
- // ie5 only
- if( X_Node_State.IE5_DISPLAY_NONE_FIX && elm.currentStyle.display === 'none' ){
- X_Node__actualRemove( that );
- that._state |= X_Node_State.IE5_DISPLAY_NONE_FIX;
- return;
+ if( that[ '_flags' ] & X_Node_State.DIRTY_CLASSNAME ){
+ that[ '_className' ] ? ( elm.className = that[ '_className' ] ) : ( elm.className && elm.removeAttribute( X_UA[ 'IE' ] < 8 ? 'className' : 'class' ) ); // className 㯠ie7-
+ };
+
+ // attr
+ if( that[ '_flags' ] & X_Node_State.DIRTY_ATTR && ( attrs = that[ '_newAttrs' ] || that[ '_attrs' ] ) ){
+ rename = X_Node_Attr_renameForDOM;
+
+ for( k in attrs ){
+ v = attrs[ k ];
+
+ switch( that[ '_tag' ] + k ){
+ case 'TEXTAREAvalue' :
+ // IETester 5.5 ã§ã¯ã¨ã©ã¼ãåºãªãã£ãï¼MultipulIE5.5 ã§ã¯ã¨ã©ã¼ãåºãã®ã§
+ if( !X_UA[ 'MacIE' ] && X_UA[ 'IE5x' ] ){
+ elm.firstChild ?
+ ( elm.firstChild.data = v || '' ) :
+ elm.appendChild( document.createTextNode( v || '' ) );
+ continue;
+ };
+ break;
+
+ case 'IFRAMEsrc' :
+ // http://outcloud.blogspot.jp/2010/09/iframe.html
+ // ãã®åé¡ã¯ firefox3.6 ã§ç¢ºèª
+ if( X_UA[ 'Gecko' ] && elm.contentWindow ){
+ elm.contentWindow.location.replace = elm.src = v || '';
+ continue;
+ };
+ break;
+
+ case 'IFRAMEname' :
+ // http://d.hatena.ne.jp/NeoCat/20080921/1221940658
+ // ãã¡ãã«ååãsetããªãã¨targetãåä½ããªã
+ // ããã£ã¦ãã¨ãã name ãå¤æ´ã§ããªããã°ã§ã¯? itozyun
+ // if( X_UA[ 'IE' ] ) elm.name = elm.contentWindow.name = v || '';
+ };
+
+ //if( X_EMPTY_OBJECT[ k ] ) continue;
+ // TODO IE ã§ã¯ input, ãªãã button, object ã type, name ã®å¤æ´ãåºæ¥ãªããåå¤ã§ç½®ãæãããã¨ãã¦ãä¸å¯
+ v === undefined ?
+ elm.removeAttribute( rename[ k ] || k ) :
+ ( elm[ rename[ k ] || k ] = X_Node_Attr_noValue[ k ] ? k : v );
};
+ delete that[ '_newAttrs' ];
};
// style
- // TODO display:none ã®å ´åãæ´æ°ãã¹ããã
- if( that._dirty & X_Node_Dirty.CSS ){
- if( that._cssText !== null || ( that._cssText = X_Node_CSS_objToCssText( that._css ) ) ){
- X_UA.Opera78 || X_UA.NN6 ?
- elm.setAttribute( 'style', that._cssText ) : // opera8ç¨
- ( elm.style.cssText = that._cssText );
+ if( that[ '_flags' ] & X_Node_State.DIRTY_CSS ){
+ 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' ] );
} else {
elm.style.cssText = ''; // IE5.5ä»¥ä¸ Safari3.2 ã§å¿
è¦
elm.removeAttribute( 'style' );
- delete that._cssText;
};
- };
-
- if( that._dirty & X_Node_Dirty.IE_FILTER ){
- elm.style.filter = X_Node_CSS_SPECIAL_FIX( that._css );
- };
-
- // attr
- // TODO display:none ã®å ´åãæ´æ°ãã¹ããã
- if( that._dirty & X_Node_Dirty.ATTR && ( attrs = that._newAttrs || that._attrs ) ){
- rename = X_Node_Attr_renameForDOM;
- for( k in attrs ){
- if( !X_UA.MacIE && ( X_UA.IE5 || X_UA.IE55 ) ){ // IETester 5.5 ã§ã¯ã¨ã©ã¼ãåºãªãã£ãï¼MultipulIE5.5 ã§ã¯ã¨ã©ã¼ãåºãã®ã§
- if( that._tag === 'TEXTAREA' && k === 'value' ){
- elm.firstChild ?
- ( elm.firstChild.data = attrs[ k ] ) :
- elm.appendChild( document.createTextNode( attrs[ k ] ) );
- continue;
- };
- };
- // TODO IE ã§ã¯ input, ãªãã buttonããtype ã®å¤æ´ãåºæ¥ãªããobject ã åå¤ã§ç½®ãæãããã¨ãã¦ãä¸å¯
- ( v = attrs[ k ] ) === undefined ?
- elm.removeAttribute( rename[ k ] || k ) :
- ( elm[ rename[ k ] || k ] = X_Node_Attr_noValue[ k ] ? k : v );
-
+ } else
+ if( that[ '_flags' ] & X_Node_State.DIRTY_IE_FILTER ){
+ v = X_Node_CSS_objToIEFilterText( that );
+ if( v ){
+ elm.style.filter = v;
+ that[ '_flags' ] |= X_Node_State.IE_FILTER_NOW;
+ } else {
+ elm.style.removeAttribute( 'filter' );
+ that[ '_flags' ] &= ~X_Node_State.IE_FILTER_NOW;
};
- delete that._newAttrs;
};
- delete that._dirty;
+ that[ '_flags' ] &= X_Node_BitMask_RESET_DIRTY;
}) :
X_UA_DOM.IE4 ?
( function( that, elm ){
var attrs, rename, k, v;
// fake textNode
- if( that._dirty & X_Node_Dirty.CONTENT ){
- elm.innerText = that._text;
- delete that._dirty;
+ if( !that[ '_tag' ] ){
+ elm.innerText = that[ '_text' ];
+ that[ '_flags' ] &= X_Node_BitMask_RESET_DIRTY;
return;
};
@@ -1180,41 +1711,45 @@ var X_Node__updateRawNode =
* titleãclassNameãidãlangãlanguage ã«ã¯ setAttribute ã§ãªããelement.id ã§ç´æ¥èªã¿æ¸ãã§ãã
*/
// id
- if( that._dirty & X_Node_Dirty.CONTENT ) elm.setAttribute( 'id', that._id || ( 'ie4uid' + xnode._uid ) );
+ if( that[ '_flags' ] & X_Node_State.DIRTY_ID ) elm.setAttribute( 'id', that[ '_id' ] || ( 'ie4uid' + that[ '_uid' ] ) );
// className
- if( that._dirty & X_Node_Dirty.CLASSNAME ){
- that._className ? ( elm.className = that._className ) : elm.removeAttribute( 'class' );
+ if( that[ '_flags' ] & X_Node_State.DIRTY_CLASSNAME ){
+ that[ '_className' ] ? ( elm.className = that[ '_className' ] ) : elm.removeAttribute( 'class' );
};
// style
- if( that._dirty & X_Node_Dirty.CSS ){
- if( that._cssText !== null || ( that._cssText = X_Node_CSS_objToCssText( that._css ) ) ){
- elm.style.cssText = that._cssText;
+ if( that[ '_flags' ] & X_Node_State.DIRTY_CSS ){
+ if( that[ '_flags' ] & X_Node_State.OLD_CSSTEXT ? X_Node_CSS_objToCssText( that ) : that[ '_cssText' ] ){
+ elm.style.cssText = that[ '_cssText' ];
} else {
elm.style.cssText = '';
elm.removeAttribute( 'style' );
- delete that._cssText;
};
- };
-
- if( that._dirty & X_Node_Dirty.IE_FILTER ){
- that._rawObject.style.filter = X_Node_CSS_SPECIAL_FIX( that._css );
+ } else
+ if( that[ '_flags' ] & X_Node_State.DIRTY_IE_FILTER ){
+ v = X_Node_CSS_objToIEFilterText( that );
+ if( v ){
+ elm.style.filter = v;
+ that[ '_flags' ] |= X_Node_State.IE_FILTER_NOW;
+ } else {
+ elm.style.removeAttribute( 'filter' );
+ that[ '_flags' ] &= ~X_Node_State.IE_FILTER_NOW;
+ };
};
// attr
- if( that._dirty & X_Node_Dirty.ATTR && ( attrs = that._newAttrs || that._attrs ) ){
+ if( that[ '_flags' ] & X_Node_State.DIRTY_ATTR && ( attrs = that[ '_newAttrs' ] || that[ '_attrs' ] ) ){
rename = X_Node_Attr_renameForDOM;
for( k in attrs ){
+ //if( X_EMPTY_OBJECT[ k ] ) continue;
( v = attrs[ k ] ) === undefined ?
elm.removeAttribute( rename[ k ] || k ) :
- //that._tag === 'TEXTAREA' && k === 'value' ?
- // ( elm.innerText = v ) :
elm.setAttribute( rename[ k ] || k, X_Node_Attr_noValue[ k ] ? k : v );
};
- delete that._newAttrs;
+ delete that[ '_newAttrs' ];
};
-
- delete that._dirty;
+
+ that[ '_flags' ] &= X_Node_BitMask_RESET_DIRTY;
}) :
(function(){});
@@ -1236,170 +1771,133 @@ var X_Node__updateRawNode =
* document.createElement of ie4 is only for OPTION & IMAGE.
*/
var X_Node__actualCreate =
- X_UA_DOM.W3C ? (function( that, isChild ){
- var elm = that._rawObject,
- xnodes, frg, i, l;
-
- if( that._xnodeType === 3 ){
- if( elm ) return elm;
- delete that._dirty;
- return that._rawObject = document.createTextNode( X_String_chrReferanceTo( that._text ) );
- };
-
- if( !elm ){
- if( that._dirty & X_Node_Dirty.CSS && !( that._cssText = X_Node_CSS_objToCssText( that._css ) ) ){
- delete that._cssText;
- };
- that._isNew = true;
- that._rawObject = elm =
- X_Node_strictElmCreation ?
- document.createElement( [
- '<', that._tag,
- ' 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._cssText ? ' style="' + that._cssText + '"' : '',
- '>' ].join( '' ) ) :
- document.createElement( that._tag );
- };
- if( X_Node_useDocumentFragment ){
- if( ( xnodes = that._xnodes ) && ( l = xnodes.length ) ){
- !isChild && ( frg = X_Node_useDocumentFragment ).appendChild( elm );
- for( i = 0; i < l; ++i ){
- elm.appendChild( X_Node__actualCreate( xnodes[ i ], true ) );
- };
- return frg || elm;
- };
- };
-
- return elm;
- }) :
- X_UA_DOM.IE4 ? (function( that, isChild ){
- var uid = that._uid,
+ X_UA_DOM.IE4 && (function( that, isChild ){
+ var uid = that[ '_uid' ],
html, xnodes, n, i, l;
- if( that._xnodeType === 3 ){
- html = [ '', that._text, '' ];// fake textNode
- delete that._rawObject;
+ if( !that[ '_tag' ] ){
+ html = [ '', that[ '_text' ], '' ];// fake textNode
+ delete that[ '_rawObject' ];
} else {
- if( that._rawObject && !isChild ) X_Node__actualRemove( that, true );
+ if( !isChild ) X_Node__actualRemove( that, /* true */ false );
- if( that._dirty & X_Node_Dirty.CSS && !( that._cssText = X_Node_CSS_objToCssText( that._css ) ) ){
- delete that._cssText;
- };
+ that[ '_flags' ] & X_Node_State.OLD_CSSTEXT && X_Node_CSS_objToCssText( that, true );
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._cssText ? ' style="' + that._cssText + '"' : '',
+ '<', that[ '_tag' ], ' id=', ( that[ '_id' ] || ( 'ie4uid' + uid ) ), ' UID="', uid, '"',
+ that[ '_className' ] ? ' class="' + that[ '_className' ] + '"' : '',
+ X_Node_Attr_objToAttrText( that, true ),
+ that[ '_cssText' ] ? ' style="' + that[ '_cssText' ] + '"' : '',
'>' ];
n = html.length;
- if( ( xnodes = that._xnodes ) && ( l = xnodes.length ) ){
- if( l === 1 && xnodes[ 0 ]._xnodeType === 3 ){
+ if( ( xnodes = that[ '_xnodes' ] ) && ( l = xnodes.length ) ){
+
+ that[ '_flags' ] &= ~X_Node_State.IE4_DIRTY_CHILDREN;
+ for( i = 0; i < l; ++i ){
+ if( xnodes[ i ][ '_tag' ] ){
+ that[ '_flags' ] |= X_Node_State.IE4_HAS_ELEMENT;
+ } else {
+ that[ '_flags' ] |= X_Node_State.IE4_HAS_TEXTNODE;
+ };
+ if( that[ '_flags' ] & X_Node_BitMask_IE4_IS_MIX === X_Node_BitMask_IE4_IS_MIX ){
+ break;
+ };
+ };
+
+ if( that[ '_flags' ] & X_Node_BitMask_IE4_IS_MIX === X_Node_State.IE4_HAS_TEXTNODE ){
// only textnode
- html[ n ] = xnodes[ 0 ]._text;
+ html[ n ] = that[ 'text' ]();
++n;
- that._state |= X_Node_State.IE4_ONLY_TEXT;
} else {
for( i = 0; i < l; ++i ){
html[ n ] = X_Node__actualCreate( xnodes[ i ], true );
++n;
- };
+ };
+ that[ '_flags' ] |= X_Node_State.IE4_FIXED;
};
};
- X_Dom_DTD_EMPTY[ that._tag ] || ( html[ n ] = '<\/' + that._tag + '>' );
+ X_Dom_DTD_EMPTY[ that[ '_tag' ] ] || ( html[ n ] = '<\/' + that[ '_tag' ] + '>' );
- delete that._newAttrs;
+ that[ '_newAttrs' ] && ( that[ '_flags' ] |= X_Node_State.DIRTY_ATTR );
};
return html.join( '' );
- }) :
- (function(){});
+ });
var X_Node__afterActualCreate =
- X_UA_DOM.W3C ? (function( that ){
- var elm = that._rawObject, xnodes, l, attrs, k, i;
-
- that._root = that.parent._root;
-
- if( that._xnodeType === 3 ){
- that._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 追å å¾ã«åã追å
- for( i = 0; i < l; ++i ){
- elm.appendChild( X_Node__actualCreate( xnodes[ i ], true ) );
- };
- };
- if( X_Node_strictElmCreation ){
- if( that._dirty & X_Node_Dirty.IE_FILTER ){
- elm.style.filter = X_Node_CSS_SPECIAL_FIX( that._css );
- };
- delete that._dirty;
- } else {
- elm.UID = that._uid;
- that._newAttrs = that._attrs;
- that._dirty = X_Node_Dirty.ID | X_Node_Dirty.CLASSNAME | X_Node_Dirty.CSS | X_Node_Dirty.ATTR | X_Node_Dirty.IE_FILTER;
- X_Node__updateRawNode( that, elm );
- };
-
- delete that._isNew;
- } else {
- that._dirty && X_Node__updateRawNode( that, elm );
- };
-
- for( i = 0; i < l; ++i ){
- X_Node__afterActualCreate( xnodes[ i ] );
- };
- // src ã®ãonload ãããã®ã§å
ã§ã¯ãªããï¼
- // ie ã® str ããè¦ç´ ãä½ãå ´åãsrcã ã ã¤ãã³ãè¨å®å¾ã§ã¯ãªããï¼
- X_EventDispatcher_toggleAllEvents( that, true );// ã¤ãã³ãã®å¾©å¸°
- }) :
- X_UA_DOM.IE4 ? (function( that ){
- var xnodes, i;
- that._root = that.parent._root;
+ X_UA_DOM.IE4 && (function( that ){
+ var xnodes, i, v;
- if( that._xnodeType !== 1 ) return that;
+ if( !that[ '_tag' ] ) return that;
- if( ( xnodes = that._xnodes ) && ( i = xnodes.length ) ){
+ if( ( xnodes = that[ '_xnodes' ] ) && ( i = xnodes.length ) ){
for( ; i; ){
X_Node__afterActualCreate( xnodes[ --i ] );
};
};
- // textarea ã¸ã® value ã®é©ç¨ã¯ããã§
- if( that._dirty & X_Node_Dirty.IE_FILTER ){
- X_Node__ie4getRawNode( that ).style.filter = X_Node_CSS_SPECIAL_FIX( that._css );
+ // ãããã¯ã¼ã¯ç³»å±æ§ã¨ filter ã¯è¦ç´ çæå¾ã«é©ç¨
+ if( that[ '_flags' ] & ( X_Node_State.DIRTY_ATTR | X_Node_State.DIRTY_IE_FILTER ) ){
+ X_Node__updateRawNode( that, that[ '_rawObject' ] || X_Node__ie4getRawNode( that ) );
+ } else {
+ that[ '_flags' ] &= X_Node_BitMask_RESET_DIRTY;
};
- delete that._dirty;
X_EventDispatcher_toggleAllEvents( that, true );// ã¤ãã³ãã®å¾©å¸°
- }) :
- (function(){});
+ });
var X_Node__actualRemove =
X_UA_DOM.W3C ?
+ // GPUã¬ã¤ã¤ã¼ã«ãããã¡ã¯ remove ããªãã-> GPU解é¤ãã¦ãã remove ãã
+ // Firefox34 ã§ã¯ééãããSafari ã§ä½åº¦ãã¢ãã¡ã¼ã·ã§ã³ãã¦ãããã¡ã«çºç
( function( that, isChild ){
- var xnodes = that._xnodes,
- elm = that._rawObject,
+ var xnodes = that[ '_xnodes' ],
+ elm = that[ '_rawObject' ],
child, i, l;
+
if( xnodes && ( l = xnodes.length ) ){
for( i = 0; i < l; ++i ){
child = xnodes[ i ];
- child._xnodeType === 1 && X_Node__actualRemove( child, true );
+ child[ '_tag' ] && X_Node__actualRemove( child, true );
};
};
if( !elm ) return;
- that._listeners && X_EventDispatcher_toggleAllEvents( that, false );// ã¤ãã³ãã®éé¿
- if( !X_UA.MacIE ){
- // elm.parentNode.tagName for ie7 -> that.state & BELONG_TREE_ACTUAL
+
+ if( that[ '_flags' ] & X_Node_State.ACTUAL_LISTENING ){
+ that[ '_listeners' ] && X_EventDispatcher_toggleAllEvents( that, false );// ã¤ãã³ãã®éé¿
+ that[ '_flags' ] &= ~X_Node_State.ACTUAL_LISTENING;
+ };
+
+ // ie5ã§ã¯ filter ã®å¹ãã¦ããè¦ç´ ãremoveæã«ç ´æ£ãã¦ãå度append æã«æ°è¦çæãã
+ // ã¡ãªã¿ã« elm.filters ã«è§¦ã㨠ie8 ã§ãªããã«ã©ã è½ã¡ãçºçããã
+ if( X_Node_displayNoneFixForIE5 ){
+ if( elm.filters && elm.filters.length ){
+ //elm.style.removeAttribute( 'filter' );
+ isChild = false;
+ delete that[ '_rawObject' ];
+ // ç ´æ£åã«ã¤ã³ã¿ã©ã¯ãã£ããªå±æ§å¤ãæ§ãã
+ if( X_Node_Attr_HAS_VALUE[ that[ '_tag' ] ] && ( !that[ '_newAttrs' ] || !X_Object_inObject( 'value', that[ '_newAttrs' ] ) ) ){
+ if( !that[ '_attrs' ] ) that[ '_attrs' ] = {};
+ that[ '_attrs' ].value = elm.value;
+ };
+ if( that[ '_tag' ] === 'OPTION' && ( !that[ '_newAttrs' ] || !X_Object_inObject( 'selected', that[ '_newAttrs' ] ) ) ){
+ if( !that[ '_attrs' ] ) that[ '_attrs' ] = {};
+ that[ '_attrs' ].selected = elm.selected;
+ };
+ if( that[ '_tag' ] === 'SELECT' && ( !that[ '_newAttrs' ] || !X_Object_inObject( 'selectedIndex', that[ '_newAttrs' ] ) ) ){
+ if( !that[ '_attrs' ] ) that[ '_attrs' ] = {};
+ that[ '_attrs' ].selectedIndex = elm.selectedIndex;
+ };
+ if( that[ '_tag' ] === 'INPUT' && that._attr && ( that._attr.type === 'checkbox' || that._attr.type === 'radio' ) && ( !that[ '_newAttrs' ] || !X_Object_inObject( 'checked', that[ '_newAttrs' ] ) ) ){
+ that[ '_attrs' ].checked = elm.checked;
+ };
+ // åè¦ç´ ã¸ã®åç
§ãå¤ã
+ elm.innerHTML = '';
+ };
+ };
+
+ if( !X_UA[ 'MacIE' ] ){
+ // 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 );
@@ -1407,8 +1905,8 @@ var X_Node__actualRemove =
}) :
X_UA_DOM.IE4 ?
( function( that, isChild ){
- var xnodes = that._xnodes,
- elm = that._rawObject || X_Node__ie4getRawNode( that ),
+ var xnodes = that[ '_xnodes' ],
+ elm = that[ '_rawObject' ] || X_Node__ie4getRawNode( that ),
i, l, xnode;
if( xnodes && ( l = xnodes.length ) ){
for( i = 0; i < l; ++i ){
@@ -1417,17 +1915,32 @@ 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 ) ) ){
- that._attrs.value = elm.value;
+ // ç ´æ£åã«ã¤ã³ã¿ã©ã¯ãã£ããªå±æ§å¤ãæ§ãã
+ if( X_Node_Attr_HAS_VALUE[ that[ '_tag' ] ] && ( !that[ '_newAttrs' ] || !X_Object_inObject( 'value', that[ '_newAttrs' ] ) ) ){
+ if( !that[ '_attrs' ] ) that[ '_attrs' ] = {};
+ that[ '_attrs' ].value = elm.value;
+ };
+ if( that[ '_tag' ] === 'OPTION' && ( !that[ '_newAttrs' ] || !X_Object_inObject( 'selected', that[ '_newAttrs' ] ) ) ){
+ if( !that[ '_attrs' ] ) that[ '_attrs' ] = {};
+ that[ '_attrs' ].selected = elm.selected;
+ };
+ if( that[ '_tag' ] === 'SELECT' && ( !that[ '_newAttrs' ] || !X_Object_inObject( 'selectedIndex', that[ '_newAttrs' ] ) ) ){
+ if( !that[ '_attrs' ] ) that[ '_attrs' ] = {};
+ that[ '_attrs' ].selectedIndex = elm.selectedIndex;
};
+ if( that[ '_tag' ] === 'INPUT' && that._attr && ( that._attr.type === 'checkbox' || that._attr.type === 'radio' ) && ( !that[ '_newAttrs' ] || !X_Object_inObject( 'checked', that[ '_newAttrs' ] ) ) ){
+ if( !that[ '_attrs' ] ) that[ '_attrs' ] = {};
+ that[ '_attrs' ].checked = elm.checked;
+ };
+
elm.removeAttribute( 'id' ); // ?
- //document.all[ that._id || ( 'ie4uid' + that._uid ) ] = null; // MacIE5 ã§ã¨ã©ã¼
+ //document.all[ that[ '_id' ] || ( 'ie4uid' + that[ '_uid' ] ) ] = null; // MacIE5 ã§ã¨ã©ã¼
if( !isChild ) elm.outerHTML = '';
- delete that._rawObject;
+ delete that[ '_rawObject' ];
}) :
(function(){});
-X_ViewPort.listenOnce( X.Event.UNLOAD, X_Node__actualRemove, [ X_Node_html, true ] );
+X_ViewPort[ 'listenOnce' ]( X_EVENT_UNLOAD, X_Node__actualRemove, [ X_Node_html, true ] );