+++ /dev/null
-var _AbstractDisplayNode = X.Class.create(\r
- '_AbstractDisplayNode',\r
- X.Class.ABSTRACT | X.Class.PRIVATE_DATA,\r
- {\r
- phase : 0,\r
- root : null,\r
- rootData : null,\r
- parent : null,\r
- parentData : null,\r
- rawElement : null,\r
- rawStyle : null,\r
- \r
- //events : null, // X.EventDispatcher で設定される\r
- reserveEvents : null,\r
- gesture : null,\r
- //elmScroll : null,\r
- //elmScroller : null,\r
- //elmScrollbar : null,\r
- \r
- style : null,\r
- styleData : null,\r
- forChrome : false, // メッキ\r
-\r
- x : 0,\r
- y : 0,\r
- w : 0,\r
- h : 0,\r
- t : 0, // top\r
- l : 0, // left\r
- b : 0, // bottom\r
- r : 0, // right\r
- absoluteX : 0,\r
- absoluteY : 0,\r
- //_scrollX : 0,\r
- //_scrollY : 0,\r
- scrollingX : 0,\r
- scrollingY : 0,\r
- _cursor : '',\r
- hitChildData : null,\r
- hitSelf : false,\r
- _disabled : false,\r
- _childDisabled : false,\r
- through : false,\r
- clip : false,\r
- hover : false,\r
- hoverStyleName : null,\r
- isHover : false,\r
- scroll : false,\r
- dragdrop : false,\r
- tooltip : null,\r
- \r
- _content : null,\r
- updateContent : false,\r
- \r
- boxWidth : 0,\r
- boxHeight : 0,\r
- contentL : 0,\r
- contentT : 0,\r
- contentR : 0,\r
- contentB : 0,\r
- boxSizingOffsetLR : 0,\r
- boxSizingOffsetTB : 0, \r
- contentWidth : 0,\r
- minContentWidth : 0,\r
- maxContentWidth : AUTO,\r
- lastContentWidth : -1,\r
- contentHeight : 0,\r
- minContentHeight : 0,\r
- maxContentHeight : AUTO,\r
- \r
- // :hover, :focus, :disabled\r
- \r
- initialize : function( root, rootData, parent, parentData, parentElement ){\r
- this.root = root;\r
- this.rootData = rootData;\r
- this.parent = parent;\r
- this.parentData = parentData;\r
- this.rawElement = X.Dom.Node.create( 'div' ); //document.createElement( 'div' );\r
- //this.rawStyle = this.rawElement.style;\r
- \r
- this.styleData.initialize();\r
- \r
- this.phase = 1;\r
- this.User.dispatch( { type : X.UI.Event.INIT } );\r
- },\r
- \r
- addToParent : function( parentElement ){\r
- //parentElement && parentElement.appendChild( this.rawElement );\r
- parentElement && parentElement.append( this.rawElement );\r
- \r
- this.phase = 2;\r
- this.User.dispatch( { type : X.UI.Event.ADDED } );\r
- },\r
-\r
- /* Rellay\r
- afterAddition : function(){\r
- this.styleData.afterAddition();\r
- \r
- this.phase = 3;\r
- this.User.dispatch( { type : X.UI.Event.CREATION_COMPLETE } );\r
- }, */\r
- \r
- creationComplete : function(){\r
- if( this.phase < 3 ) return;\r
- \r
- var nodes = this.nodes,\r
- l, i;\r
- if( nodes ){\r
- for( i = 0, l = nodes.length; i < l; ++i ){\r
- nodes[ i ].creationComplete();\r
- };\r
- };\r
- this.mesure();\r
- \r
- // this.scroll === true && ScrollBarManager.register( this );\r
- \r
- // html 要素が親に追加されるまで控えていたイベントの登録\r
- var events = this.reserveEvents,\r
- i;\r
- if( !events ) return;\r
- for( ; events.length; ){\r
- this.User.listen.apply( this.User, events.shift() );\r
- };\r
- delete this.reserveEvents;\r
- },\r
- \r
- mesure : function(){\r
- var elm = this.rawElement,\r
- x, y, w, h, parent;\r
- if( elm ){\r
- w = elm.width();//w = elm.offsetWidth;\r
- h = elm.height();//h = elm.offsetHeight;\r
- x = elm.x();//x = elm.offsetLeft;\r
- y = elm.y();//y = elm.offsetTop; \r
- if( this.x !== x || this.y !== y || this.w !== w || this.h !== h ){\r
- this.x = x;\r
- this.y = y;\r
- this.w = w;\r
- this.h = h;\r
- ( parent = this.parentData ) && this.updateAbsoluteXY( parent.absoluteX, parent.absoluteY );\r
- }; \r
- };\r
- this.updateRectangle();\r
- },\r
- \r
- updateAbsoluteXY : function( x, y /* , scrollX, scrollY */ ){\r
- var nodes = this.nodes, i;\r
- this.absoluteX = x = this.x + x;\r
- this.absoluteY = y = this.y + y;\r
- if( !nodes ) return;\r
- for( i = nodes.length; i; ){\r
- nodes[ --i ].updateAbsoluteXY( x, y );\r
- };\r
- },\r
- \r
- updateRectangle : function(){\r
- var w = this.w, h = this.h, x = this.x, y = this.y,\r
- l = x, t = y, r = x + w, b = y + h,\r
- nodes = this.nodes, i, node;\r
- \r
- if( nodes && this.clip === false ){\r
- for( i = nodes.length; i; ){\r
- node = nodes[ --i ];\r
- if( node.l + x < l ) l = x + node.l;\r
- if( node.t + y < t ) t = y + node.t;\r
- if( r < node.r + x ) r = x + node.r;\r
- if( b < node.b + y ) b = y + node.b;\r
- };\r
- };\r
- // update\r
- if( b !== this.b || r !== this.r || t !== this.t || l !== this.l ){\r
- this.l = l;\r
- this.t = t;\r
- this.r = r;\r
- this.b = b;\r
- this.parentData && this.parentData.clip === false && this.parentData.updateRectangle();\r
- };\r
- },\r
- \r
- capcher : function( x, y ){\r
- var nodes, child, _x, _y, hit, i;\r
- if( this._disabled === true ) return false;\r
- delete this.hitChildData;\r
- x -= this.x;\r
- y -= this.y;\r
- // この部分 Box に移動\r
- if( nodes = this.nodes ){\r
- _x = x - this.scrollingX;\r
- _y = y - this.scrollingY;\r
- for( i = nodes.length; i; ){\r
- child = nodes[ --i ];\r
- if( child._disabled === false && child.l <= _x && _x < child.r && child.t <= _y && _y < child.b && child.capcher( _x, _y ) === true ){\r
- this.hitChildData = child;\r
- break;\r
- };\r
- };\r
- };\r
- if( this.through === true ){\r
- this.hitChildData && this.hitSelf === false && this.rootData.hoverList.push( this );\r
- return !!this.hitChildData;\r
- };\r
- hit = 0 <= x && x < this.w && 0 <= y && y < this.h;\r
- ( this.hitChildData || hit ) && this.hitSelf === false && this.rootData.hoverList.push( this );\r
- if( hit === true && this.hitChildData === null ) this.rootData.targetNodeData = this;\r
- return hit || !!this.hitChildData;\r
- },\r
- \r
- dispatch : function( e ){\r
- var xve = X.UI.Event,\r
- ret = X.EventDispatcher.prototype.dispatch.call( this.User, e ),\r
- type = e.type;\r
- if( ret & X.Callback.MONOPOLY && !this.hitChildData && ( xve._POINTER_MOVE === type || xve.type._MOUSE_MOVE === type || xve.FILE_DRAG === type ) ){\r
- this.rootData.monopolyNodeData = this;\r
- return ret;\r
- };\r
- this.rootData.monopolyNodeData = null;\r
- if( xve._START_BUBLEUP < type && this.parentData && ret & X.Callback.STOP_PROPAGATION === 0 && ret & X.Callback.STOP_NOW === 0 ) return this.parentData.dispatch( e );\r
- return ret;\r
- },\r
- \r
- _remove : function(){\r
- switch( this.phase ){\r
- case 4:\r
- case 3:\r
- //this.styleData.afterAddition();\r
- case 2:\r
- //this.rawElement.parentNode.removeChild( this.rawElement );\r
- this.rawElement.remove();\r
- case 1:\r
- //this.styleData.initialize();\r
- delete this.root;\r
- delete this.rootData;\r
- delete this.parent;\r
- delete this.parentData;\r
- delete this.rawElement;\r
- delete this.rawStyle;\r
- };\r
- delete this.phase;\r
- },\r
- //killed\r
- \r
- \r
- content : function( v ){\r
- if( Type.isString( v ) === true ){\r
- if( !this.rawText || this.rawText.data !== v ){\r
- this._content = v;\r
- this.updateContent = true;\r
- };\r
- return this.User;\r
- } else\r
- if( v === null ){\r
- if( this._content !== v && this.rawText ){\r
- this.updateContent = true;\r
- };\r
- delete this._content;\r
- return this.User;\r
- };\r
- if( this._content || this._content === null ) return this._content;\r
- if( this.rawText ) return this.rawText.data;\r
- return null;\r
- },\r
- paint : function( dirty ){\r
- var content = this._content,\r
- style = this.styleData; \r
- if( this.updateContent === true || ( style && style.hasPaint === true ) ){\r
- if( !this.rawElement ){\r
- this.rawElement = DOM.createDiv();\r
- this.__parent.addDisplayElement( this );\r
- };\r
- dirty !== 0 && this.commitStyle(); \r
- if( this.updateContent === true ){\r
- if( content !== null ){\r
- if( !this.rawText ){\r
- this.rawText = DOM.cerateText();\r
- this.rawElement.appendChild( this.rawText );\r
- };\r
- this.rawText.data = content; \r
- } else\r
- if( this.rawText ){\r
- DOM.correct( this.rawText );\r
- delete this.rawText;\r
- delete this.contentWidth;\r
- delete this.conetntHeight;\r
- delete this.scrollWidth; \r
- delete this.scrollHeight;\r
- }; \r
- };\r
- } else\r
- if( this.rawElement && content === null && ( !style || style.hasPaint === false ) ){\r
- this.__parent.removeDisplayElement( this );\r
- DOM.correct( this.rawElement );\r
- delete this.contentWidth;\r
- delete this.conetntHeight;\r
- };\r
- },\r
- commitStyle : function(){\r
- var css;\r
- if( this.rawElement ){\r
- css = this.styleData ? this.styleData.cssText( this ) : '';\r
- if( this.contentWidth !== AUTO ) css += 'width:' + this.contentWidth + 'px';\r
- if( this.contentHeight !== AUTO ) css += 'height:' + this.contentHeight + 'px';\r
- //this.rawElement.style.cssText = css;\r
- this.rawElement.cssText( css );\r
- };\r
- },\r
- /*\r
- * 親の サイズを元に自身のサイズを計算していく\r
- */\r
- preMesure : function( allowW, allowH ){\r
- var style = this.styleData,\r
- styles, calc, box, min, max,\r
- contentW, contentH, allowSize, boxMinus,\r
- paddingT, paddingR, paddingB, paddingL,\r
- borderT, borderR, borderB, borderL;//,\r
- //marginT, marginR, marginB, marginL;\r
-\r
- if( style ){\r
- styles = style.data;\r
- calc = _AbstractDisplayNode.calcValue;\r
- box = styles[ X.Css.AttrNo.sizing ];\r
- \r
- // Width が確定するパターン\r
- // 自身が constraintW の場合 親が AUTO ではない\r
- // 自身が constraintW でない場合自身が AUTO はなくかつ親 が AUTO の場合 or 自身は % でない\r
- if( style.constraintW ? allowW !== AUTO : !style.autoWidth && ( allowW !== AUTO || !style.percentWidth ) ){\r
- if( style.constraintW ){ // 制約レイアウト\r
- contentW = allowW - calc( styles[ X.Css.AttrNo.left ], allowW ) - calc( styles[ X.Css.AttrNo.right ], allowW );\r
- } else {\r
- contentW = _AbstractDisplayNode.finalValue( styles[ X.Css.AttrNo.width ], styles[ X.Css.AttrNo.minWidth ], styles[ X.Css.AttrNo.maxWidth ], allowW ); \r
- };\r
- paddingR = calc( styles[ X.Css.AttrNo.padding + 1 ], allowW );\r
- paddingL = calc( styles[ X.Css.AttrNo.padding + 3 ], allowW );\r
- borderR = styles[ X.Css.AttrNo.border + 1 ];\r
- borderL = styles[ X.Css.AttrNo.margin + 3 ];\r
- // marginR = calc( styles[ X.Css.AttrNo.margin + 1 ], allowW );\r
- // marginL = calc( styles[ X.Css.AttrNo.margin + 3 ], allowW );\r
- boxMinus = 0;\r
- switch( box ){\r
- //case 3 : // margin-box\r
- // boxMinus = - marginR - marginL;\r
- case 2 : // border-box\r
- boxMinus -= borderR + borderL;\r
- case 1 : // padding-box\r
- boxMinus -= paddingR + paddingL;\r
- // case 0 : // content-box\r
- };\r
- this.contentL = /* marginL + */ borderL + paddingL;\r
- this.contentR = /* marginR + */ borderR + paddingR; \r
- this.contentWidth = contentW + boxMinus;\r
- this.boxWidth = contentW - boxMinus + this.contentL + this.contentR;\r
- this.boxSizingOffsetLR = boxMinus;\r
- } else {\r
- this.boxWidth = this.contentWidth = AUTO;\r
- min = styles[ X.Css.AttrNo.minWidth ];\r
- max = styles[ X.Css.AttrNo.maxWidth ];\r
- this.minContentWidth = 1 <= min ? min : 0;\r
- this.maxContentWidth = 1 <= max ? max : AUTO;\r
- delete this.boxSizingOffsetLR;\r
- };\r
- \r
- // Height\r
- if( style.constraintH ? allowH !== AUTO : !style.autoHeight && ( allowH !== AUTO || !style.percentHeight ) ){\r
- if( style.constraintH ){ // 制約レイアウト\r
- contentH = allowH - calc( styles[ X.Css.AttrNo.top ], allowH ) - calc( styles[ X.Css.AttrNo.bottom ], allowH );\r
- } else {\r
- contentH = _AbstractDisplayNode.finalValue( styles[ X.Css.AttrNo.height ], styles[ X.Css.AttrNo.minHeight ], styles[ X.Css.AttrNo.maxHeight ], allowH );\r
- };\r
- allowSize = styles[ X.Css.AttrNo.pageBox ] === true ? allowH : allowW;\r
- paddingT = calc( styles[ X.Css.AttrNo.padding + 0 ], allowSize );// paddingTRBL の % 指定は 最大幅に対して TB でも幅に対して\r
- paddingB = calc( styles[ X.Css.AttrNo.padding + 2 ], allowSize );\r
- borderT = styles[ X.Css.AttrNo.border + 0 ];\r
- borderB = styles[ X.Css.AttrNo.border + 2 ];\r
- // marginT = calc( styles[ X.Css.AttrNo.margin + 0 ], allowSize );// marginTRBL の % 指定は 最大幅に対して TB でも幅に対して\r
- // marginB = calc( styles[ X.Css.AttrNo.margin + 2 ], allowSize );\r
- this.boxHeight = contentH;\r
- boxMinus = 0;\r
- switch( box ){\r
- // case 3 : // margin-box\r
- // boxMinus = - marginT - marginR;\r
- case 2 : // border-box\r
- boxMinus = borderT + borderB;\r
- case 1 : // padding-box\r
- boxMinus -= paddingT + paddingB;\r
- // case 0 : // content-box\r
- }; \r
- this.contentT = /* marginT + */ borderT + paddingT;\r
- this.conetntB = /* marginB + */ borderB + paddingB; \r
- this.contentHeight = contentH + boxMinus;\r
- this.boxHeight = contentH - boxMinus + this.contentT + this.conetntB;\r
- this.boxSizingOffsetTB = boxMinus;\r
- } else {\r
- this.boxHeight = this.contentHeight = AUTO;\r
- min = styles[ X.Css.AttrNo.minHeight ];\r
- max = styles[ X.Css.AttrNo.maxHeight ];\r
- this.minContentHeight = 1 <= min ? min : 0;\r
- this.maxContentHeight = 1 <= max ? max : AUTO;\r
- delete this.boxSizingOffsetTB;\r
- };\r
- } else {\r
- this.boxWidth = this.contentWidth = allowW;\r
- this.boxHeight = this.contentHeight = allowH;\r
- delete this.minContentHeight;\r
- delete this.maxContentHeight;\r
- delete this.contentL;\r
- delete this.contentT;\r
- delete this.contentR;\r
- delete this.contentB;\r
- };\r
- },\r
- \r
- /**\r
- * 要素の追加・削除\r
- * 1. ペイントがある // 予約のみ\r
- * 2. コンテンツがある // 予約のみ *\r
- * 3. コンテンツを削除 // 予約のみ\r
- * 4. 要素を削除 // 予約のみ\r
- * \r
- * コンテンツの再計算\r
- * 0. 要素追加して css セット\r
- * 1. コンテンツの変更\r
- * 2. font 指定の変更\r
- * 3. contentWidth の変更 (コンテンツの高さの再計算) 前回の contentWidth の保持\r
- * \r
- * contentSize, scrollSize の決定\r
- */\r
- _mesure : function( dirty ){\r
- var content = this._content,\r
- root = this.rootData,\r
- style = this.styleData,\r
- w = this.contentWidth,\r
- h = this.contentHeight;\r
- switch( this.updateContent === true ? X.Css.Dirty.CONTENT : dirty ){\r
- case X.Css.Dirty.CONTENT : // コンテンツが変更された\r
- this.paint( 0 );\r
- this.lastContentWidth = -1;\r
- case X.Css.Dirty.FONT : // フォントサイズが変更された\r
- this.commitStyle();\r
- case X.Css.Dirty.REFLOW : // レイアウトの再計算が必要\r
- /* http://web-designs.seesaa.net/article/188400668.html\r
- * min-width の値が max-width の値より大きい場合は、max-width の値は min-width の値に設定される。\r
- * \r
- * テキストノードがあり\r
- * 1. contentWidth === AUTO\r
- * style を更新して contentWidth の決定\r
- * min or max に引っかかったら style 更新\r
- * contentHeight === AUTO の場合\r
- * textHeight の決定\r
- * contentHeight !== AUTO の場合 scrollHeight のみ更新\r
- * 2. contentHeight === AUTO かつ \r
- * コンテンツの高さの再取得が必要( contentWidth が最終計測時の contentWidth と一致 かつ フォント・コンテンツに変更無し の場合再取得不要)\r
- * style を更新して contentHeight の決定\r
- * 必要でない\r
- * 3. content のサイズがすでに決定している\r
- * コンテンツの高さの再取得が必要\r
- * 必要でない\r
- */ \r
- if( this.rawText ){\r
- if( w === AUTO ){\r
- w = this.contentWidth = this.elm.offsetWidth;\r
- this.scrollWidth = w + this.contentL + this.contentR;\r
- if( this.maxContentWidth < w - this.boxSizingOffsetLR ) this.contentWidth = this.maxContentWidth + this.boxSizingOffsetLR;\r
- if( w - this.boxSizingOffsetLR < this.minContentWidth ) this.contentWidth = this.minContentWidth + this.boxSizingOffsetLR;\r
- this.lastContentWidth = this.contentWidth;\r
- \r
- w !== this.contentWidth && this.commitStyle();\r
- \r
- if( h === AUTO ){\r
- h = this.conetntHeight = this.elm.offsetHeight;\r
- this.scrollHeight = h + this.contentT + this.contentB;\r
- if( this.maxContentHeight < h - this.boxSizingOffsetTB ) this.contentHeight = this.maxContentHeight + this.boxSizingOffsetTB;\r
- if( h - this.boxSizingOffsetTB < this.minContentHeight ) this.contentHeight = this.minContentHeight + this.boxSizingOffsetTB;\r
- } else {\r
- this.scrollHeight = this.elm.offsetHeight + this.contentT + this.contentB;\r
- };\r
- } else\r
- if( h === AUTO ){\r
- if( w !== this.lastContentWidth || dirty !== X.Css.Dirty.REFLOW ){\r
- this.commitStyle();\r
- this.lastContentWidth = w;\r
- h = this.conetntHeight = this.elm.offsetHeight;\r
- this.scrollWidth = w + this.contentL + this.contentR;\r
- this.scrollHeight = h + this.contentT + this.contentB;\r
- if( this.maxContentHeight < h - this.boxSizingOffsetTB ) this.contentHeight = this.maxContentHeight + this.boxSizingOffsetTB;\r
- if( h - this.boxSizingOffsetTB < this.minContentHeight ) this.contentHeight = this.minContentHeight + this.boxSizingOffsetTB; \r
- } else {\r
- this.scrollWidth = w + this.contentL + this.contentR;\r
- this.scrollHeight = h + this.contentT + this.contentB;\r
- root.paintReserve( this );\r
- };\r
- } else {\r
- if( dirty !== X.Css.Dirty.REFLOW ){\r
- this.commitStyle();\r
- this.scrollWidth = this.elm.offsetWidth + this.contentL + this.contentR;\r
- this.scrollHeight = this.elm.offsetHeight + this.contentT + this.contentB;\r
- } else {\r
- root.paintReserve( this );\r
- this.scrollWidth = w + this.contentL + this.contentR;\r
- this.scrollHeight = h + this.contentT + this.contentB;\r
- };\r
- }; \r
- } else {\r
- if( w === AUTO ) this.contentWidth = w = 0 < this.minContentWidth ? this.minContentWidth : 0;\r
- if( h === AUTO ) this.contentHeight = h = 0 < this.minContentHeight ? this.minContentHeight : 0;\r
- this.scrollWidth = w + this.contentL + this.contentR;\r
- this.scrollHeight = h + this.contentT + this.contentB;\r
- root.paintReserve( this ); \r
- };\r
- break; \r
- case X.Css.Dirty.PAINT : // 再描画のみ必要\r
- root.paintReserve( this );\r
- break; \r
- };\r
- },\r
- /**\r
- * 自身のコンテンツサイズを元に AUTO な width, height を確定していく\r
- */\r
- postMesure : function(){\r
- var style = this.styleData,\r
- styles, calc, box,\r
- contentW, contentH,\r
- contentSize, contentPlus,\r
- paddingT, paddingR, paddingB, paddingL,\r
- borderT, borderR, borderB, borderL,\r
- min, max;\r
- if( style ){\r
- styles = style.data;\r
- calc = _AbstractDisplayNode.advancedCalcValue;\r
- contentW = this.contentWidth;\r
- box = styles[ X.Css.AttrNo.sizing ];\r
- \r
- // Width\r
- if( this.boxWidth === AUTO ){\r
- paddingR = calc( styles[ X.Css.AttrNo.padding + 1 ], contentW ); \r
- paddingL = calc( styles[ X.Css.AttrNo.padding + 3 ], contentW ); \r
- borderR = styles[ X.Css.AttrNo.border + 1 ]; \r
- borderL = styles[ X.Css.AttrNo.border + 3 ]; \r
- //marginR = calc( styles[ X.Css.AttrNo.margin + 1 ], contentW );\r
- //marginL = calc( styles[ X.Css.AttrNo.margin + 3 ], contentW );\r
- contentPlus = 0;\r
- switch( box ){\r
- //case 3 : // margin-box\r
- // contentPlus = ( marginR + marginL );\r
- case 2 : // border-box\r
- contentPlus = borderR + borderL;\r
- case 1 : // padding-box\r
- contentPlus += paddingR + paddingL;\r
- // case 0 : // content-box\r
- };\r
- contentW += contentPlus;\r
- if( !style.constraintW ){\r
- min = styles[ X.Css.AttrNo.minWidth ];\r
- max = styles[ X.Css.AttrNo.maxWidth ];\r
- if( contentW < min && 1 <= min && contentPlus < min ){\r
- this.contentWidth = min - contentPlus;\r
- } else\r
- if( max < contentW && 1 <= max && contentPlus < max ){\r
- this.contentWidth = max - contentPlus;\r
- };\r
- };\r
- this.contentL = /* marginL + */ borderL + paddingL;\r
- this.contentR = /* marginR + */ borderR + paddingR;\r
- this.boxWidth = this.contentWidth + this.contentL + this.contentR;\r
- };\r
- // Height\r
- if( this.boxHeight === AUTO ){\r
- contentH = this.contentHeight;\r
- contentSize = styles[ X.Css.AttrNo.pageBox ] === true ? contentH : contentW;\r
- paddingT = calc( styles[ X.Css.AttrNo.padding + 0 ], contentSize );// paddingTRBL の % 指定は 最大幅に対して TB でも幅に対して\r
- paddingB = calc( styles[ X.Css.AttrNo.padding + 2 ], contentSize );\r
- borderT = styles[ X.Css.AttrNo.border + 0 ];\r
- borderB = styles[ X.Css.AttrNo.border + 2 ];\r
- //marginT = calc( styles[ X.Css.AttrNo.margin + 0 ], contentSize );// marginTRBL の % 指定は 最大幅に対して TB でも幅に対して\r
- //marginB = calc( styles[ X.Css.AttrNo.margin + 2 ], contentSize );\r
- contentPlus = 0;\r
- switch( box ){\r
- //case 3 : // margin-box\r
- //contentPlus = ( marginT + marginB );\r
- case 2 : // border-box\r
- contentPlus = borderT + borderB;\r
- case 1 : // padding-box\r
- contentPlus += paddingT + paddingB;\r
- // case 0 : // content-box\r
- };\r
- contentH += contentPlus;\r
- if( !style.constraintH ){\r
- min = styles[ X.Css.AttrNo.minHeight ];\r
- max = styles[ X.Css.AttrNo.maxHeight ];\r
- if( contentH < min && 1 <= min && contentPlus < min ){\r
- this.contentHeight = min - contentPlus;\r
- } else\r
- if( max < contentH && 1 <= max && contentPlus < max ){\r
- this.contentHeight = max - contentPlus;\r
- };\r
- };\r
- this.contentT = marginT + borderT + paddingT;\r
- this.contentB = marginB + borderB + paddingB; \r
- this.boxHeight = this.contentHeight + this.contentT + this.contentB;\r
- }; \r
- } else {\r
- this.boxWidth = this.contentWidth;\r
- this.boxHeight = this.contentHeight;\r
- delete this.minContentHeight;\r
- delete this.maxContentHeight;\r
- delete this.contentL;\r
- delete this.contentT;\r
- delete this.contentR;\r
- delete this.contentB;\r
- };\r
- }\r
- }\r
-);\r
-\r
-_AbstractDisplayNode.finalValue = function( styleValue, styleMin, styleMax, srcValue ){\r
- var calc = _AbstractDisplayNode.calcValue,\r
- v = calc( styleValue, srcValue ),\r
- min = calc( styleMin, srcValue ),\r
- max = calc( styleMax, srcValue );\r
- if( v < min ) return min;\r
- if( max < v ) return max;\r
- return v;\r
-};\r
-_AbstractDisplayNode.calcValue = function( styleValue, srcValue ){\r
- switch( styleValue ){\r
- case 0 :\r
- return 0;\r
- case AUTO :\r
- return AUTO;\r
- case FULL :\r
- return srcValue; // 100%\r
- };\r
- if( 1 <= styleValue ) return styleValue; // legth\r
- if( -1 < styleValue ) return FLOOR( srcValue * styleValue ); // % \r
- return styleValue; // - length\r
-};\r
-_AbstractDisplayNode.advancedCalcValue = function( styleValue, srcValue ){\r
- switch( styleValue ){\r
- case 0 :\r
- return 0;\r
- case AUTO :\r
- return srcValue;\r
- case FULL :\r
- throw new Error( 'advancedCalcValue FULL' ); \r
- // return ; // 100%\r
- };\r
- if( 1 <= styleValue ) return styleValue; \r
- if( -1 < styleValue ) return FLOOR( ( srcValue / ( 1 - styleValue ) ) * styleValue ); // % \r
- return styleValue; // - length\r
-};\r
-\r
-\r
-var AbstractDisplayNode = X.EventDispatcher.inherits(\r
- 'AbstractDisplayNode',\r
- X.Class.ABSTRACT | X.Class.SUPER_ACCESS,\r
- {\r
- style : null,\r
- parent : function(){\r
- return X.Class._getPrivate( this ).parent;\r
- },\r
- root : function(){\r
- return X.Class._getPrivate( this ).root;\r
- },\r
- listen : function( type, arg1, arg2 ){\r
- var root, data, events, counter;\r
- if( X.UI.Event._START_POINTER <= type && type <= X.UI.Event._END_POINTER ){\r
- data = X.Class._getPrivate( this );\r
- if( data.phase < 3 ){\r
- if( !( events = data.reserveEvents ) ) data.reserveEvents = events = [];\r
- events[ events.length ] = [ type, arg1, arg2 ];\r
- return this;\r
- };\r
- if( X.UI.Event._START_XUI_EVENT < type && type < X.UI.Event._END_XUI_EVENT ){\r
- if( !this.gesture ){\r
- this.gesture = new X.UI.Gesture( data.root, this, type );\r
- } else {\r
- this.gesture.listen( type );\r
- };\r
- } else {\r
- root = data.rootData;\r
- counter = root.eventCounter;\r
- if( counter[ type ] ){\r
- ++counter[ type ];\r
- } else {\r
- counter[ type ] = 1; \r
- root.elmMouseCatch.listen( X.UI.Event.IdToName[ type ], eventRellay );\r
- };\r
- };\r
- };\r
- return X.EventDispatcher.prototype.listen.apply( this, arguments );\r
- },\r
- unlisten : function( type, arg1, arg2 ){\r
- var root, data, events, i, ev, counter;\r
- if( X.UI.Event._START_POINTER <= type && type <= X.UI.Event._END_POINTER ){\r
- data = X.Class._getPrivate( this );\r
- if( data.phase < 3 ){\r
- if( !( events = data.reserveEvents ) ) return this;\r
- for( i = events.length; i; ){\r
- ev = events[ --i ];\r
- if( ev[ 0 ] === type && ev[ 1 ] === arg1 && ev[ 2 ] === arg2 ){\r
- events.split( i, 1 );\r
- return this;\r
- };\r
- }; \r
- return this;\r
- };\r
-\r
- if( X.UI.Event._START_XUI_EVENT < type && type < X.UI.Event._END_XUI_EVENT ){\r
- this.gesture && this.gesture.unlisten( type );\r
- } else {\r
- root = data.rootData;\r
- counter = root.eventCounter;\r
- if( !counter[ type ] ) return this;\r
- --counter[ type ];\r
- if( counter[ type ] === 0 ){\r
- X.Dom.Event.remove( root.elmMouseCatch, X.UI.Event.IdToName[ type ], eventRellay );\r
- delete counter[ type ];\r
- };\r
- };\r
- };\r
- return X.EventDispatcher.prototype.unlisten.apply( this, arguments );\r
- },\r
- getNextNode : function(){\r
- \r
- },\r
- getPrevNode : function(){\r
- \r
- },\r
- dispatch : function( e ){\r
- return X.Class._getPrivate( this ).dispatch( e );\r
- },\r
- nodeIndex : function( v ){\r
- var data = X.Class._getPrivate( this );\r
- if( typeof v === 'number' ){\r
- // data.nodeIndex( v );\r
- return this;\r
- };\r
- return data.parentData ? data.parentData.nodes.indexOf( data ) : 0;\r
- },\r
- displayIndex : function(){\r
- \r
- },\r
- // ちゃんとやれば不要!\r
- mesure : function(){\r
- var data = X.Class._getPrivate( this );\r
- data.mesure();\r
- 4 <= data.phase && data.rootData.reserveCalc();\r
- return this;\r
- },\r
- getX : function(){\r
- // dirty の場合、rootData.calculate\r
- return X.Class._getPrivate( this ).x;\r
- },\r
- getY : function(){\r
- // dirty の場合、rootData.calculate\r
- return X.Class._getPrivate( this ).y;\r
- },\r
- getAbsoluteX : function(){\r
- // dirty の場合、rootData.calculate\r
- return X.Class._getPrivate( this ).absoluteX;\r
- },\r
- getAbsoluteY: function(){\r
- // dirty の場合、rootData.calculate\r
- return X.Class._getPrivate( this ).absoluteY;\r
- },\r
- getWidth : function(){\r
- // dirty の場合、rootData.calculate\r
- return X.Class._getPrivate( this ).w;\r
- },\r
- getHeight : function(){\r
- // dirty の場合、rootData.calculate\r
- return X.Class._getPrivate( this ).h;\r
- },\r
- scrollTo : function( x, y ){\r
- X.Class._getPrivate( this ).scrollTo( x, y );\r
- },\r
- getScrollX : function( v ){\r
- // dirty の場合、rootData.calculate\r
- return X.Class._getPrivate( this ).scrollX( v );\r
- },\r
- getScrollY : function( v ){\r
- // dirty の場合、rootData.calculate\r
- return X.Class._getPrivate( this ).scrollY( v );\r
- },\r
- disabled : function( v ){\r
- return X.Class._getPrivate( this ).disabled( v );\r
- },\r
- cursor : function( v ){\r
- return X.Class._getPrivate( this ).cursor( v );\r
- }\r
- }\r
-);
\ No newline at end of file