OSDN Git Service

Version 0.6.82, X.Timer.remove() work well while onTimeout.
authoritozyun <itozyun@user.sourceforge.jp>
Sun, 21 Sep 2014 21:47:14 +0000 (06:47 +0900)
committeritozyun <itozyun@user.sourceforge.jp>
Sun, 21 Sep 2014 21:47:14 +0000 (06:47 +0900)
0.6.x/js/00_core/05_XTimer.js
0.6.x/js/00_core/06_XEventDispatcher.js
0.6.x/js/01_dom/10_XDom.js
0.6.x/js/01_dom/11_XDomNode.js
0.6.x/js/01_dom/12_XDomEvent.js
0.6.x/js/01_dom/14_XDomAttr.js
0.6.x/js/10_ui/06_AbstractUINode.js

index a36d4b8..a20cf2b 100644 (file)
@@ -2,22 +2,6 @@
  * use X.Callback\r
  */\r
 \r
-var _enterFrame =\r
-               window.requestAnimationFrame ||\r
-               window.webkitRequestAnimationFrame ||\r
-               window.mozRequestAnimationFrame ||\r
-               window.oRequestAnimationFrame ||\r
-               window.msRequestAnimationFrame ||\r
-               false,\r
-       _cancelFrame =\r
-               window.cancelRequestAnimationFrame ||\r
-               window.webkitCancelAnimationFrame ||\r
-               window.webkitCancelRequestAnimationFrame ||\r
-               window.mozCancelRequestAnimationFrame ||\r
-               window.oCancelRequestAnimationFrame ||\r
-               window.msCancelRequestAnimationFrame ||\r
-               false;\r
-\r
 /*\r
  * \r
  * http://please-sleep.cou929.nu/script-yielding-with-setimmediate.html\r
@@ -45,121 +29,52 @@ var _enterFrame =
         }\r
  */\r
 \r
-X.Timer = {\r
-       INTERVAL_TIME  : 16,\r
-       TICKET_LIST    : [],\r
-       uid            : 0,\r
-       timerId        : 0,\r
-       endTime        : 0, // iOS\r
-       next           : 0,\r
-       busy           : false, // for Opera7\r
-       \r
-       REQ_FRAME_LIST : [],\r
-       requestID      : 0,\r
+\r
+// ------------------------------------------------------------------------- //\r
+// ------------ local variables -------------------------------------------- //\r
+// ------------------------------------------------------------------------- //\r
+\r
+var X_Timer_SET_TIMEOUT   = window.setTimeout,\r
+       X_Timer_CLEAR_TIMEOUT = window.clearTimeout,\r
        \r
-       _loop : function(){\r
-               var next  = X.Timer.next,\r
-                       list  = X.Timer.TICKET_LIST,\r
-                       i     = 0,\r
-                       l     = list.length,\r
-                       limit = X.getTime() + X.Timer.INTERVAL_TIME / 2,\r
-                       heavy,\r
-                       q, f, c, r;\r
-               \r
-               if( X.Timer.busy ){\r
-                       alert( 'busy!' );\r
-               };\r
-               \r
-               X.Timer.busy = true;\r
-               \r
-           for( ; i < l; ++i ){\r
-               q = list[ i ];\r
-                       if( 0 < ( q.last -= next ) ) continue;\r
-                       if( heavy ){\r
-                               if( q.last <= 0 ) q.last = 1;\r
-                               continue;\r
-                       };\r
-                       c = q.count;\r
-                       \r
-                       if( q.k ){\r
-                               q.a = [];\r
-                               r = X.Callback._proxyCallback( q );\r
-                       } else {\r
-                               r = q.f();\r
-                       };\r
-                       \r
-                       console.log( 'fire....' );\r
-                       \r
-                       if( limit <= X.getTime() ){\r
-                               console.log( 'heavy' );\r
-                               // 関数の実行に時間が係る場合、次のタイミングに\r
-                               heavy = true;\r
-                       };                      \r
-                       \r
-                       if( r & X.Callback.UN_LISTEN || c === 1 ){\r
-                               list.splice( i, 1 );\r
-                               --i;\r
-                               --l;\r
-                               continue;\r
-                       } else\r
-                       if( 1 < c ) --q.count;\r
-                       q.last = q.time;\r
-           };\r
-           X.Timer.timerId = 0;\r
-           X.Timer.busy = false;\r
-           X.Timer._update();\r
-       },\r
-       _update : function(){\r
-               var list = X.Timer.TICKET_LIST,\r
-                       i    = list.length,\r
-                       n;\r
-               if( i === 0 ){\r
-                       X.Timer.timerId && window.clearTimeout( X.Timer.timerId );\r
-                       X.Timer.timerId = 0;\r
-                       return;\r
-               };\r
-               \r
-               1 < i && list.sort( x_timer_compareQueue );\r
+       X_Timer_REQ_ANIME_FRAME =\r
+               window.requestAnimationFrame ||\r
+               window.webkitRequestAnimationFrame ||\r
+               window.mozRequestAnimationFrame ||\r
+               window.oRequestAnimationFrame ||\r
+               window.msRequestAnimationFrame ||\r
+               false,\r
+       X_Timer_CANCEL_ANIME_FRAME =\r
+               window.cancelRequestAnimationFrame ||\r
+               window.webkitCancelAnimationFrame ||\r
+               window.webkitCancelRequestAnimationFrame ||\r
+               window.mozCancelRequestAnimationFrame ||\r
+               window.oCancelRequestAnimationFrame ||\r
+               window.msCancelRequestAnimationFrame ||\r
+               false,\r
                \r
-           n = list[ i - 1 ].last;\r
-           \r
-           if( n < X.Timer.next || X.Timer.timerId === 0 ){\r
-               X.Timer.timerId && window.clearTimeout( X.Timer.timerId );\r
-               X.Timer.timerId = window.setTimeout( X.Timer._loop, X.Timer.INTERVAL_TIME * n );\r
-               X.Timer.endTime = X.getTime() + X.Timer.INTERVAL_TIME * n; // iOS\r
-               X.Timer.next = n;\r
-           };\r
-       },\r
+       X_Timer_INTERVAL_TIME  = 16,\r
+       X_Timer_TICKET_LIST    = [],\r
+       X_Timer_removal        = null,\r
+       X_Timer_uid            = 0,\r
+       X_Timer_timerId        = 0,\r
+       X_Timer_next           = 0,\r
+       X_Timer_busyTimeout    = false, \r
+       X_Timer_endTime        = 0, // iOS\r
        \r
-       // ページを読み込んでからの時間\r
-       _onEnterFrame : function ( time ){\r
-               var list = X.Timer.REQ_FRAME_LIST,\r
-                       l    = list.length,\r
-                       i    = 0, q;\r
+       X_Timer_REQ_FRAME_LIST = [],\r
+       X_Timer_requestID      = 0,\r
+       X_Timer_busyOnFrame    = false;\r
 \r
-               time = time || X.getTime();\r
-               // console.log( X.getTime() + ' , ' + time );\r
-           for( ; i < l; ++i ){\r
-               q = list[ i ];\r
-               \r
-                       if( q.k ){\r
-                               q.a = [ time ];\r
-                               X.Callback._proxyCallback( q );\r
-                       } else {\r
-                               q( time );\r
-                       };\r
-           };\r
-\r
-           list.splice( 0, l );\r
-           if( list.length ){\r
-               X.Timer.requestID = _enterFrame ? _enterFrame( X.Timer._onEnterFrame ) : X.Timer.add( 0, 1, X.Timer._onEnterFrame );\r
-           };\r
-       },\r
+// ------------------------------------------------------------------------- //\r
+// --- interface ----------------------------------------------------------- //\r
+// ------------------------------------------------------------------------- //\r
+X.Timer = {\r
        \r
        add : function( time, opt_count, args1, args2, args3 ){\r
-               var list = X.Timer.TICKET_LIST,\r
+               var list = X_Timer_TICKET_LIST,\r
                        hash, obj;\r
-               time = time < X.Timer.INTERVAL_TIME ? 1 : time / X.Timer.INTERVAL_TIME | 0; // 正の数で使える「Math.floor(x)」を「(x | 0)」に;\r
+               time = time < X_Timer_INTERVAL_TIME ? 1 : time / X_Timer_INTERVAL_TIME | 0; // 正の数で使える「Math.floor(x)」を「(x | 0)」に;\r
                \r
                if( !X.Type.isNumber( opt_count ) ){\r
                        args3 = args2;\r
@@ -175,101 +90,243 @@ X.Timer = {
                hash.time  = time;\r
                hash.last  = time;\r
                hash.count = opt_count;\r
-               hash.uid   = ++X.Timer.uid;\r
+               hash.uid   = ++X_Timer_uid;\r
                list[ list.length ] = hash;\r
                \r
-           !X.Timer.busy && X.Timer._update();\r
-           return X.Timer.uid;\r
+           !X_Timer_busyTimeout && X_Timer_update();\r
+           return X_Timer_uid;\r
        },\r
+       \r
        once : function( time, args1, args2, args3 ){\r
                return X.Timer.add( time, 1, args1, args2, args3 );\r
        },\r
+       \r
        remove : function( uid ){\r
-               var list = X.Timer.TICKET_LIST,\r
+               var list = X_Timer_TICKET_LIST,\r
                        i    = list.length,\r
                        l    = i,\r
                        f, q;\r
-               for( ; i; ){\r
-                       // TODO\r
-                       // fire 中の cancel\r
-                       if( ( q = list[ --i ] ).uid === uid ){\r
-                               list.splice( i, 1 );\r
-                               !X.Timer.busy && ( /* q[ INDEX_COUNT ] <= next  || */ l === 1 ) && X.Timer._update();\r
-                               break;\r
-                       };\r
+               // fire 中の cancel\r
+               if( X_Timer_busyTimeout ){\r
+                       if( !X_Timer_removal ) X_Timer_removal = {};\r
+                       X_Timer_removal[ uid ] = true;\r
+               } else {\r
+                       for( ; i; ){\r
+       \r
+                               if( ( q = list[ --i ] ).uid === uid ){\r
+                                       list.splice( i, 1 );\r
+                                       ( /* q[ INDEX_COUNT ] <= next  || */ l === 1 ) && X_Timer_update();\r
+                                       break;\r
+                               };\r
+                       };                              \r
                };\r
        },\r
        \r
-       requestFrame : _enterFrame ?\r
+       requestFrame : X_Timer_REQ_ANIME_FRAME ?\r
                (function( args1, args2, args3 ){\r
-                       var i = X.Timer.REQ_FRAME_LIST.length,\r
+                       var i = X_Timer_REQ_FRAME_LIST.length,\r
                                f;\r
-                       i === 0 && ( X.Timer.requestID = _enterFrame( X.Timer._onEnterFrame ) );\r
-                       f = X.Timer.REQ_FRAME_LIST[ i ] = X.Callback._classifyCallbackArgs( args1, args2, args3 );\r
-                       return f.uid = ++X.Timer.uid;\r
+                       i === 0 && ( X_Timer_requestID = X_Timer_REQ_ANIME_FRAME( X_Timer_onEnterFrame ) );\r
+                       f = X_Timer_REQ_FRAME_LIST[ i ] = X.Callback._classifyCallbackArgs( args1, args2, args3 );\r
+                       return f.uid = ++X_Timer_uid;\r
                }) :\r
                (function( args1, args2, args3 ){\r
-                       var i = X.Timer.REQ_FRAME_LIST.length,\r
+                       var i = X_Timer_REQ_FRAME_LIST.length,\r
                                f;\r
-                       i === 0 && ( X.Timer.requestID = X.Timer.add( 0, 1, X.Timer._onEnterFrame ) );\r
-                       f = X.Timer.REQ_FRAME_LIST[ i ] = X.Callback._classifyCallbackArgs( args1, args2, args3 );\r
-                       return f.uid = ++X.Timer.uid;\r
+                       i === 0 && ( X_Timer_requestID = X.Timer.add( 0, 1, X_Timer_onEnterFrame ) );\r
+                       f = X_Timer_REQ_FRAME_LIST[ i ] = X.Callback._classifyCallbackArgs( args1, args2, args3 );\r
+                       return f.uid = ++X_Timer_uid;\r
                }),\r
        \r
-       cancelFrame : _cancelFrame ?\r
+       cancelFrame : X_Timer_CANCEL_ANIME_FRAME ?\r
                (function( uid ){\r
-                       var list = X.Timer.REQ_FRAME_LIST,\r
+                       var list = X_Timer_REQ_FRAME_LIST,\r
                                l    = list.length,\r
                                i    = l,\r
                                f;\r
-                       for( ; i; ){\r
-                               if( ( f = list[ --i ] ).uid < uid ) break;\r
-                               if( f.uid === uid ){\r
-                                       // TODO\r
-                                       // fire 中の cancel\r
-                                       list.splice( i, 1 );\r
-                                       l === 1 && _cancelFrame( X.Timer.requestID );\r
-                                       break;\r
-                               };\r
+                       // fire 中の cancel\r
+                       if( X_Timer_busyOnFrame ){\r
+                               if( !X_Timer_removal ) X_Timer_removal = {};\r
+                               X_Timer_removal[ uid ] = true;\r
+                       } else {\r
+                               for( ; i; ){\r
+                                       if( ( f = list[ --i ] ).uid < uid ) break;\r
+                                       if( f.uid === uid ){\r
+                                               list.splice( i, 1 );\r
+                                               l === 1 && X_Timer_CANCEL_ANIME_FRAME( X_Timer_requestID );\r
+                                               break;\r
+                                       };\r
+                               };                              \r
                        };\r
                }) :\r
                (function( uid ){\r
-                       var list = X.Timer.REQ_FRAME_LIST,\r
+                       var list = X_Timer_REQ_FRAME_LIST,\r
                                l    = list.length,\r
                                i    = l,\r
                                f;\r
-                       for( ; i; ){\r
-                               if( ( f = list[ --i ] ).uid < uid ) break;\r
-                               if( f.uid === uid ){\r
-                                       list.splice( i, 1 );\r
-                                       l === 1 && X.Timer.remove( X.Timer.requestID );\r
-                                       break;\r
+                       // fire 中の cancel\r
+                       if( X_Timer_busyOnFrame ){\r
+                               if( !X_Timer_removal ) X_Timer_removal = {};\r
+                               X_Timer_removal[ uid ] = true;\r
+                       } else {\r
+                               for( ; i; ){\r
+                                       if( ( f = list[ --i ] ).uid < uid ) break;\r
+                                       if( f.uid === uid ){\r
+                                               list.splice( i, 1 );\r
+                                               l === 1 && X.Timer.remove( X_Timer_requestID );\r
+                                               break;\r
+                                       };\r
                                };\r
                        };\r
                })\r
        \r
 };\r
 \r
-// 大きい -> 小さい\r
-function x_timer_compareQueue( a, b ){\r
-       return a.last < b.last ? 1 : a.last === b.last ? 0 : -1;\r
+// ------------------------------------------------------------------------- //\r
+// --- implements ---------------------------------------------------------- //\r
+// ------------------------------------------------------------------------- //\r
+\r
+if( X.UA.IE < 5 || X.UA.MacIE ){\r
+       X.Timer[ '_' ] = X_Timer_onTimeout;\r
+       X_Timer_onTimeout = 'X.Timer._()';\r
+};\r
+\r
+function X_Timer_onTimeout(){\r
+       var next  = X_Timer_next,\r
+               list  = X_Timer_TICKET_LIST,\r
+               i     = 0,\r
+               l     = list.length,\r
+               limit = X.getTime() + X_Timer_INTERVAL_TIME / 2,\r
+               heavy,\r
+               q, f, c, r, uid;\r
+       \r
+       if( X_Timer_busyTimeout ){\r
+               alert( 'busy!' );\r
+       };\r
+       \r
+       X_Timer_busyTimeout = true;\r
+       \r
+    for( ; i < l; ++i ){\r
+       q = list[ i ];\r
+       if( X_Timer_removal && X_Timer_removal[ q.uid ] ) continue;\r
+               if( 0 < ( q.last -= next ) ) continue;\r
+               if( heavy ){\r
+                       if( q.last <= 0 ) q.last = 1;\r
+                       continue;\r
+               };\r
+               c = q.count;\r
+               \r
+               if( q.k ){\r
+                       q.a = [];\r
+                       r = X.Callback._proxyCallback( q );\r
+               } else {\r
+                       r = q.f();\r
+               };\r
+               \r
+               //console.log( 'fire....' );\r
+               \r
+               if( limit <= X.getTime() ){\r
+                       console.log( '******* heavy!' );\r
+                       // 関数の実行に時間がかかる場合、次のタイミングに\r
+                       heavy = true;\r
+               };\r
+               \r
+               if( r & X.Callback.UN_LISTEN || c === 1 ){\r
+                       list.splice( i, 1 );\r
+                       --i;\r
+                       --l;\r
+                       continue;\r
+               } else\r
+               if( 1 < c ) --q.count;\r
+               q.last = q.time;\r
+    };\r
+    X_Timer_timerId     = 0;\r
+    X_Timer_busyTimeout = false;\r
+    if( X_Timer_removal ){\r
+       for( uid in X_Timer_removal ){\r
+               X.Timer.remove( X_Timer_removal[ uid ] );\r
+       };\r
+       X_Timer_removal = null;\r
+    };\r
+    X_Timer_update();\r
 };\r
 \r
+function X_Timer_update(){\r
+       var list = X_Timer_TICKET_LIST,\r
+               i    = list.length,\r
+               n;\r
+       if( i === 0 ){\r
+               X_Timer_timerId && X_Timer_CLEAR_TIMEOUT( X_Timer_timerId );\r
+               X_Timer_timerId = 0;\r
+               return;\r
+       };\r
+       \r
+       1 < i && list.sort( X_Timer_compareQueue );\r
+       \r
+    n = list[ i - 1 ].last;\r
+    \r
+    if( n < X_Timer_next || X_Timer_timerId === 0 ){\r
+       X_Timer_timerId && X_Timer_CLEAR_TIMEOUT( X_Timer_timerId );\r
+       X_Timer_timerId = X_Timer_SET_TIMEOUT( X_Timer_onTimeout, X_Timer_INTERVAL_TIME * n );\r
+       X_Timer_endTime = X.getTime() + X_Timer_INTERVAL_TIME * n; // iOS\r
+       X_Timer_next = n;\r
+    };\r
+};\r
 \r
 // http://havelog.ayumusato.com/develop/javascript/e528-ios6_scrolling_timer_notcall.html\r
 // iOS6 スクロール中のタイマー発火絡みのバグ備忘\r
 if( X.UA.iOS ){\r
        window.addEventListener( 'scroll', function(){\r
-               if( X.Timer.timerId ){\r
-                       window.clearTimeout( X.Timer.timerId );\r
-                       X.Timer.timerId = window.setTimeout( X.Timer._loop, Math.max( 0, X.Timer.endTime - X.getTime() ) );\r
+               var last;\r
+               if( X_Timer_timerId ){\r
+                       X_Timer_CLEAR_TIMEOUT( X_Timer_timerId );\r
+                       last = X_Timer_endTime - X.getTime();\r
+                       X_Timer_timerId = X_Timer_SET_TIMEOUT( X_Timer_onTimeout, 0 < last ? last : 0 );\r
                };\r
        });\r
 };\r
 \r
-if( X.UA.IE < 5 || X.UA.MacIE ){\r
-       X.Timer[ '_ie_loop' ] = X.Timer._loop;\r
-       X.Timer._loop = 'X.Timer._ie_loop()';\r
+\r
+// ページを読み込んでからの時間\r
+function X_Timer_onEnterFrame( time ){\r
+       var list = X_Timer_REQ_FRAME_LIST,\r
+               l    = list.length,\r
+               i    = 0, q, uid;\r
+\r
+       time = time || X.getTime();\r
+       X_Timer_busyOnFrame = true;\r
+       // console.log( X.getTime() + ' , ' + time );\r
+    for( ; i < l; ++i ){\r
+       q = list[ i ];\r
+       \r
+       if( X_Timer_removal && X_Timer_removal[ q.uid ] ) continue;\r
+       \r
+               if( q.k ){\r
+                       q.a = [ time ];\r
+                       X.Callback._proxyCallback( q );\r
+               } else {\r
+                       q( time );\r
+               };\r
+    };\r
+\r
+    list.splice( 0, l );\r
+    if( list.length ){\r
+       X_Timer_requestID = X_Timer_REQ_ANIME_FRAME ? X_Timer_REQ_ANIME_FRAME( X_Timer_onEnterFrame ) : X.Timer.add( 0, 1, X_Timer_onEnterFrame );\r
+    };\r
+    \r
+    X_Timer_busyOnFrame = false;\r
+    if( X_Timer_removal ){\r
+       for( uid in X_Timer_removal ){\r
+               X.Timer.cancelFrame( X_Timer_removal[ uid ] );\r
+       };\r
+       X_Timer_removal = null;\r
+    };\r
+};\r
+\r
+// 大きい -> 小さい\r
+function X_Timer_compareQueue( a, b ){\r
+       return a.last < b.last ? 1 : a.last === b.last ? 0 : -1;\r
 };\r
 \r
+\r
 console.log( 'X.Core.Timer' );\r
index 152c63e..4f1f136 100644 (file)
@@ -34,32 +34,34 @@ X.Event = {
 // ------------------------------------------------------------------------- //\r
 // ------------ local variables -------------------------------------------- //\r
 // ------------------------------------------------------------------------- //\r
-var x_eventdispatcher_once       = false,\r
-       x_eventdispatcher_needsIndex = false,\r
-       x_eventdispatcher_temp       = {};\r
+var X_EventDispatcher_once       = false,\r
+       X_EventDispatcher_needsIndex = false,\r
+       X_EventDispatcher_temp       = {},\r
+       \r
+       X_EventDispatcher_safariPreventDefault = false; //  // Safari3-\r
 \r
 if( X.UA.MacIE ){\r
-       x_eventdispatcher_temp.DOM_W3C    = true;\r
-       x_eventdispatcher_temp.EVENT_DOM0 = true;\r
+       X_EventDispatcher_temp.DOM_W3C    = true;\r
+       X_EventDispatcher_temp.EVENT_DOM0 = true;\r
 } else\r
 if( X.UA.IE4 ){ // ie4 & iemobi4\r
-       x_eventdispatcher_temp.DOM_IE4    = true;\r
-       x_eventdispatcher_temp.EVENT_DOM0 = true;\r
+       X_EventDispatcher_temp.DOM_IE4    = true;\r
+       X_EventDispatcher_temp.EVENT_DOM0 = true;\r
 } else\r
 if( document.getElementById ){\r
-       x_eventdispatcher_temp.DOM_W3C = true;\r
+       X_EventDispatcher_temp.DOM_W3C = true;\r
        if( document.addEventListener ){\r
-               x_eventdispatcher_temp.EVENT_W3C = true;\r
+               X_EventDispatcher_temp.EVENT_W3C = true;\r
        } else\r
        if( document.attachEvent ){\r
-               x_eventdispatcher_temp.EVENT_IE = true;\r
+               X_EventDispatcher_temp.EVENT_IE = true;\r
        } else {\r
-               x_eventdispatcher_temp.EVENT_DOM0 = true;\r
+               X_EventDispatcher_temp.EVENT_DOM0 = true;\r
        };\r
 } else\r
 if( document.all ){\r
-       x_eventdispatcher_temp.DOM_IE4    = true;\r
-       x_eventdispatcher_temp.EVENT_DOM0 = true;\r
+       X_EventDispatcher_temp.DOM_IE4    = true;\r
+       X_EventDispatcher_temp.EVENT_DOM0 = true;\r
 } else\r
 if( document.layers ){\r
        \r
@@ -72,7 +74,7 @@ if( document.layers ){
 // ------------------------------------------------------------------------- //\r
 \r
 /**\r
- * イベントターゲットをラップする場合(widnow, document, Image, XHR 等)、通常は new 時に渡します。参照:コンストラクタ実体 {@link X.EventDispatcher.Constructor}\r
+ * イベントターゲット(widnow, document, Image, XHR 等)をラップする場合、通常は new 時に渡します。参照:コンストラクタ実体 {@link X.EventDispatcher.Constructor}\r
  * アプリケーション独自のイベントをやり取りしたいだけ、という場合、イベントターゲットは不要です。\r
  * @class\r
  * @classdesc EventTarget オブジェクトをラップしたり、アプリケーションで独自に定義したイベントを発信するためのクラスです。\r
@@ -164,12 +166,20 @@ X.EventDispatcher =
                                };\r
                        },\r
 \r
+               /**\r
+                * 登録されたイベントリスナを呼び出す。イベントリスナの返り値(数値)を OR したものを返す。\r
+                * @this {X.EventDispatcher}\r
+                * @return {number}\r
+                * @param {(eventHash|string|number)} e\r
+                */     \r
+                       dispatch : X_EventDispatcher_dispatch,\r
+\r
            /**\r
             * \r
             * @this {X.EventDispatcher}\r
             */\r
-                       on     : x_eventdispatcher_listen,\r
-                       listen : x_eventdispatcher_listen,\r
+                       on     : X_EventDispatcher_listen,\r
+                       listen : X_EventDispatcher_listen,\r
                \r
                /**\r
                 * 一度 dispatch された時に自動で unlisten されるフラグを立てて listen する。\r
@@ -181,14 +191,14 @@ X.EventDispatcher =
                 * @param {Array=} opt_arg3\r
                 */\r
                        listenOnce : function( type, opt_arg1, opt_arg2, opt_arg3 ){\r
-                               x_eventdispatcher_once = true;\r
+                               X_EventDispatcher_once = true;\r
                                this.listen( type, opt_arg1, opt_arg2, opt_arg3 );\r
-                               x_eventdispatcher_once = false;\r
+                               X_EventDispatcher_once = false;\r
                                return this;\r
                        },\r
                        \r
-                       off      : x_eventdispatcher_unlisten,\r
-                       unlisten : x_eventdispatcher_unlisten,\r
+                       off      : X_EventDispatcher_unlisten,\r
+                       unlisten : X_EventDispatcher_unlisten,\r
 \r
                /**\r
                 * イベントリスナの登録状況を真偽値で返す。戻り値が数値(index)の場合もあるが、これは内部のみで使用。\r
@@ -224,104 +234,12 @@ X.EventDispatcher =
                                };\r
                                for( i = list.length; i; ){\r
                                        f = list[ --i ];\r
-                                       if( f === hash || ( f.x === hash.x && f.f === hash.f && f.s === hash.s ) ) return x_eventdispatcher_needsIndex ? i : true;\r
+                                       if( f === hash || ( f.x === hash.x && f.f === hash.f && f.s === hash.s ) ) return X_EventDispatcher_needsIndex ? i : true;\r
                                };\r
                                return false;\r
                        },\r
 \r
                /**\r
-                * 登録されたイベントリスナを呼び出す。イベントリスナの返り値(数値)を OR したものを返す。\r
-                * @this {X.EventDispatcher}\r
-                * @return {number}\r
-                * @param {(eventHash|string|number)} e\r
-                */     \r
-                       dispatch : function( e ){\r
-                               // dispatch 中の listen は?\r
-                               var list  = this[ '_listeners' ],\r
-                                       ret   = X.Callback.NONE,\r
-                                       type  = e[ 'type' ],\r
-                                       unlistens, i, l, f, r, sysOnly;\r
-                               \r
-                               if( !list || !( list = list[ type || e ] ) ) return ret;\r
-                               \r
-                               // 数値, 文字が渡された場合\r
-                               if( !type ){\r
-                                       e = { type : type = e };\r
-                               };\r
-                               e.target = e.target || this;\r
-                               \r
-                               ++this._dispatching;\r
-                               \r
-                               // todo:\r
-                               // type も保存\r
-                               this._unlistens = this._unlistens || {};\r
-                               unlistens = this._unlistens[ type ];\r
-                               \r
-                               for( i = 0; i < list.length; ++i ){\r
-                                       f = list[ i ];\r
-                                       if( !unlistens ){\r
-                                               unlistens = this._unlistens[ type ];\r
-                                       };\r
-                                       if( unlistens && unlistens.indexOf( f ) !== -1 ) continue;\r
-                                       \r
-                                       r = X.Callback.NONE;\r
-                                       if( f.k ){\r
-                                               f.a = [ e ];\r
-                                               r = X.Callback._proxyCallback( f );\r
-                                       } else {\r
-                                               r = f.call( this, e );\r
-                                       };\r
-                                       \r
-                                       if( f.once || r & X.Callback.UN_LISTEN ){\r
-                                               // dispatch 中に unlisten が作られることがある\r
-                                               if( !unlistens ){\r
-                                                       unlistens = this._unlistens || ( this._unlistens = {} );\r
-                                                       unlistens = unlistens[ type ] || ( unlistens[ type ] = [] );\r
-                                               };\r
-                                               unlistens.indexOf( f ) === -1 && ( unlistens[ unlistens.length ] = f );\r
-                                       };\r
-\r
-                                       if( r & X.Callback.STOP_NOW ){\r
-                                               sysOnly = true;\r
-                                       };\r
-                                       ret |= r;\r
-                               };\r
-                               \r
-                               if( ( --this._dispatching ) === 0 ){\r
-                                       // dispatch 中に unlisten された要素の削除\r
-                                       unlistens = this._unlistens;\r
-                                       delete this._dispatching;\r
-                                       delete this._unlistens;                                 \r
-                                       \r
-                                       for( type in unlistens ){\r
-                                               list = unlistens[ type ];\r
-                                               for( i = list.length; i; ){\r
-                                                       this.unlisten( type, list[ --i ] );\r
-                                               };\r
-                                               list.length = 0;\r
-                                               delete unlistens[ type ];\r
-                                       };\r
-                                       \r
-                                       if( this._killReserved ){\r
-                                               this.kill();\r
-                                       } else\r
-                                       if( list = this._reserves ){\r
-                                               for( i = 0, l = list.length; i < l; ++i ){\r
-                                                       f = list[ i ];\r
-                                                       x_eventdispatcher_once = f[ 4 ];\r
-                                                       this.listen( f[ 0 ], f[ 1 ], f[ 2 ], f[ 3 ] );\r
-                                                       x_eventdispatcher_once = false;\r
-                                                       f.length = 0;\r
-                                               };\r
-                                               list.length = 0;\r
-                                               delete this._reserves;\r
-                                       };\r
-                               };\r
-                               \r
-                               return ret;\r
-                       },\r
-\r
-               /**\r
                 * delay(ミリ秒)後にイベントを dispatch する。戻り値は uid = X.Timer.add() のタイマーID(数値)。X.Timer.remove(uid) でタイマーを解除して dispatch を中止できる。\r
                 * @this {X.EventDispatcher}\r
                 * @return {number}\r
@@ -339,6 +257,97 @@ X.EventDispatcher =
 // ------------------------------------------------------------------------- //\r
 \r
 /**\r
+ * 登録されたイベントリスナを呼び出す。イベントリスナの返り値(数値)を OR したものを返す。イベントハッシュでなく、string|number を渡すと内部でイベントハッシュを作る\r
+ * @this {X.EventDispatcher}\r
+ * @return {number} X.Callback で定義された数値\r
+ * @param {(eventHash|string|number)} e\r
+ */\r
+function X_EventDispatcher_dispatch( e ){\r
+       var list  = this[ '_listeners' ],\r
+               ret   = X.Callback.NONE,\r
+               type  = e[ 'type' ],\r
+               unlistens, i, l, f, r, sysOnly;\r
+       \r
+       if( !list || !( list = list[ type || e ] ) ) return ret;\r
+       \r
+       // 数値, 文字が渡された場合\r
+       if( !type ){\r
+               e = { type : type = e };\r
+       };\r
+       e.target = e.target || this;\r
+       \r
+       ++this._dispatching;\r
+       \r
+       // todo:\r
+       // type も保存\r
+       this._unlistens = this._unlistens || {};\r
+       unlistens = this._unlistens[ type ];\r
+       \r
+       for( i = 0; i < list.length; ++i ){\r
+               f = list[ i ];\r
+               if( !unlistens ){\r
+                       unlistens = this._unlistens[ type ];\r
+               };\r
+               if( unlistens && unlistens.indexOf( f ) !== -1 ) continue;\r
+               \r
+               r = X.Callback.NONE;\r
+               if( f.k ){\r
+                       f.a = [ e ];\r
+                       r = X.Callback._proxyCallback( f );\r
+               } else {\r
+                       r = f.call( this, e );\r
+               };\r
+               \r
+               if( f.once || r & X.Callback.UN_LISTEN ){\r
+                       // dispatch 中に unlisten が作られることがある\r
+                       if( !unlistens ){\r
+                               unlistens = this._unlistens || ( this._unlistens = {} );\r
+                               unlistens = unlistens[ type ] || ( unlistens[ type ] = [] );\r
+                       };\r
+                       unlistens.indexOf( f ) === -1 && ( unlistens[ unlistens.length ] = f );\r
+               };\r
+\r
+               if( r & X.Callback.STOP_NOW ){\r
+                       sysOnly = true;\r
+               };\r
+               ret |= r;\r
+       };\r
+       \r
+       if( ( --this._dispatching ) === 0 ){\r
+               // dispatch 中に unlisten された要素の削除\r
+               unlistens = this._unlistens;\r
+               delete this._dispatching;\r
+               delete this._unlistens;                                 \r
+               \r
+               for( type in unlistens ){\r
+                       list = unlistens[ type ];\r
+                       for( i = list.length; i; ){\r
+                               this.unlisten( type, list[ --i ] );\r
+                       };\r
+                       list.length = 0;\r
+                       delete unlistens[ type ];\r
+               };\r
+               \r
+               if( this._killReserved ){\r
+                       this.kill();\r
+               } else\r
+               if( list = this._reserves ){\r
+                       for( i = 0, l = list.length; i < l; ++i ){\r
+                               f = list[ i ];\r
+                               X_EventDispatcher_once = f[ 4 ];\r
+                               this.listen( f[ 0 ], f[ 1 ], f[ 2 ], f[ 3 ] );\r
+                               X_EventDispatcher_once = false;\r
+                               f.length = 0;\r
+                       };\r
+                       list.length = 0;\r
+                       delete this._reserves;\r
+               };\r
+       };\r
+       \r
+       return ret;\r
+};\r
+\r
+/**\r
  * \r
  * @this {X.EventDispatcher}\r
  * @return {X.EventDispatcher}\r
@@ -347,13 +356,13 @@ X.EventDispatcher =
  * @param {(function|Array=} opt_arg2\r
  * @param {Array=} opt_arg3\r
  */\r
-function x_eventdispatcher_listen( type, opt_arg1, opt_arg2, opt_arg3 ){\r
+function X_EventDispatcher_listen( type, opt_arg1, opt_arg2, opt_arg3 ){\r
        var list = this._listeners,\r
                i, r, f;\r
        \r
        if( this._dispatching ){\r
                if( !this._reserves ) this._reserves = [];\r
-               this._reserves[ this._reserves.length ] = [ type, opt_arg1, opt_arg2, opt_arg3, x_eventdispatcher_once ];\r
+               this._reserves[ this._reserves.length ] = [ type, opt_arg1, opt_arg2, opt_arg3, X_EventDispatcher_once ];\r
                return this;\r
        };\r
        \r
@@ -364,7 +373,7 @@ function x_eventdispatcher_listen( type, opt_arg1, opt_arg2, opt_arg3 ){
                return this;\r
        };\r
        \r
-       ( !list || !list[ type ] ) && X.Type.isString( type ) && x_eventdispatcher_actualAddEvent( this, type );\r
+       ( !list || !list[ type ] ) && X.Type.isString( type ) && X_EventDispatcher_actualAddEvent( this, type );\r
        \r
        if( this.listening( type, opt_arg1, opt_arg2, opt_arg3 ) ) return this;\r
 \r
@@ -373,7 +382,7 @@ function x_eventdispatcher_listen( type, opt_arg1, opt_arg2, opt_arg3 ){
        \r
        f = X.Callback._classifyCallbackArgs( opt_arg1, opt_arg2, opt_arg3, this );\r
        list[ list.length ] = f;\r
-       f.once = x_eventdispatcher_once;\r
+       f.once = X_EventDispatcher_once;\r
        \r
        return this;\r
 };\r
@@ -387,7 +396,7 @@ function x_eventdispatcher_listen( type, opt_arg1, opt_arg2, opt_arg3 ){
  * @param {(function|Array=} opt_arg2\r
  * @param {Array=} opt_arg3\r
  */\r
-function x_eventdispatcher_unlisten( opt_type, opt_arg1, opt_arg2, opt_arg3 ){\r
+function X_EventDispatcher_unlisten( opt_type, opt_arg1, opt_arg2, opt_arg3 ){\r
        var list = this._listeners,\r
                _list, reserves, unlistens, i, f;\r
        if( !list ) return this;\r
@@ -430,9 +439,9 @@ function x_eventdispatcher_unlisten( opt_type, opt_arg1, opt_arg2, opt_arg3 ){
                };\r
        };\r
        \r
-       x_eventdispatcher_needsIndex = true;\r
+       X_EventDispatcher_needsIndex = true;\r
        i = this.listening( opt_type, opt_arg1, opt_arg2, opt_arg3 );\r
-       x_eventdispatcher_needsIndex = false;\r
+       X_EventDispatcher_needsIndex = false;\r
        if( i === false ) return this;\r
 \r
        f = ( _list = list[ opt_type ] )[ i ];\r
@@ -446,7 +455,7 @@ function x_eventdispatcher_unlisten( opt_type, opt_arg1, opt_arg2, opt_arg3 ){
                _list.splice( i, 1 );\r
                if( !_list.length ){\r
                        delete this._listeners[ opt_type ];\r
-                       X.Type.isString( opt_type ) && x_eventdispatcher_actualRemoveEvent( this, opt_type );\r
+                       X.Type.isString( opt_type ) && X_EventDispatcher_actualRemoveEvent( this, opt_type );\r
                        if( X.isEmptyObject( this._listeners ) ) delete this._listeners;\r
                };\r
        };\r
@@ -454,15 +463,15 @@ function x_eventdispatcher_unlisten( opt_type, opt_arg1, opt_arg2, opt_arg3 ){
 };\r
 \r
 \r
-var x_eventdispatcher_actualAddEvent =\r
+var X_EventDispatcher_actualAddEvent =\r
        // Days on the Moon DOM Events とブラウザの実装 \r
        // http://nanto.asablo.jp/blog/2007/03/23/1339502\r
        // Safari 2 では関数オブジェクトしか EventListener として使えませんが、Safari のナイトリービルドでは handleEvent メソッドを持つオブジェクトも EventListener として使えるようです。\r
-       x_eventdispatcher_temp.EVENT_W3C && ( X.UA.WebKit < 525.13 || X.UA.Opera7 || X.UA.NetFront < 4 ) ? // Safari3-\r
+       X_EventDispatcher_temp.EVENT_W3C && ( X.UA.WebKit < 525.13 || X.UA.Opera7 || X.UA.NetFront < 4 ) ? // Safari3-\r
                (function( that, type ){\r
                        var raw = that._rawObject;\r
                        if( !raw ) return; \r
-                       that._handleEvent = that._handleEvent || X.Callback.create( that, x_eventdispatcher_actualHandleEvent );\r
+                       that._handleEvent = that._handleEvent || X.Callback.create( that, X_EventDispatcher_actualHandleEvent );\r
                        type = X.Dom.Event.Rename[ type] || type;\r
                        if( raw.addEventListener ){\r
                                raw.addEventListener( type, that._handleEvent, false );\r
@@ -471,14 +480,14 @@ var x_eventdispatcher_actualAddEvent =
                                raw[ 'on' + type ] = that._handleEvent;\r
                        };\r
                }) :\r
-       x_eventdispatcher_temp.EVENT_W3C ?\r
+       X_EventDispatcher_temp.EVENT_W3C ?\r
                (function( that, type ){\r
                        if( that._rawObject ){\r
-                               that._handleEvent = that._handleEvent || X.Callback.create( that, x_eventdispatcher_actualHandleEvent );\r
+                               that._handleEvent = that._handleEvent || X.Callback.create( that, X_EventDispatcher_actualHandleEvent );\r
                                that._rawObject.addEventListener( X.Dom.Event.Rename[ type ] || type, that._handleEvent, false );\r
                        };\r
                }) :\r
-       x_eventdispatcher_temp.EVENT_IE ?\r
+       X_EventDispatcher_temp.EVENT_IE ?\r
                (function( that, type ){\r
                        var raw = that._rawObject;\r
                        if( !raw ) return;\r
@@ -488,9 +497,9 @@ var x_eventdispatcher_actualAddEvent =
                        //};\r
                        if( that._isXHR ){\r
                                // ie8- の XHR は window.event が更新されないため, eventType 毎に callback を指定する\r
-                               raw[ 'on' + type ] = X.Callback.create( that, X.EventDispatcher.prototype.dispatch, [ type ] );\r
+                               raw[ 'on' + type ] = X.Callback.create( that, X_EventDispatcher_dispatch, [ type ] );\r
                        } else {\r
-                               that._handleEvent = that._handleEvent || X.Callback.create( that, x_eventdispatcher_actualHandleEvent );\r
+                               that._handleEvent = that._handleEvent || X.Callback.create( that, X_EventDispatcher_actualHandleEvent );\r
                                \r
                                if( raw.attachEvent ){\r
                                        raw.attachEvent( 'on' + type, that._handleEvent );\r
@@ -503,12 +512,12 @@ var x_eventdispatcher_actualAddEvent =
                (function( that, type ){\r
                        var raw = that._rawObject || ( that._ie4getRawNode && that._ie4getRawNode() );\r
                        if( !raw ) return;\r
-                       raw[ 'on' + ( X.Dom.Event.Rename[ type ] || type ) ] = that._handleEvent = that._handleEvent || X.Callback.create( that, x_eventdispatcher_actualHandleEvent );\r
+                       raw[ 'on' + ( X.Dom.Event.Rename[ type ] || type ) ] = that._handleEvent = that._handleEvent || X.Callback.create( that, X_EventDispatcher_actualHandleEvent );\r
                });\r
 \r
 \r
-var x_eventdispatcher_actualRemoveEvent =\r
-       x_eventdispatcher_temp.EVENT_W3C && ( X.UA.WebKit < 525.13 || X.UA.Opera7 || X.UA.NetFront < 4 ) ? // Safari3-\r
+var X_EventDispatcher_actualRemoveEvent =\r
+       X_EventDispatcher_temp.EVENT_W3C && ( X.UA.WebKit < 525.13 || X.UA.Opera7 || X.UA.NetFront < 4 ) ? // Safari3-\r
                (function( that, type ){\r
                        var raw = that._rawObject;\r
                        if( !raw ) return;\r
@@ -524,7 +533,7 @@ var x_eventdispatcher_actualRemoveEvent =
                                delete that._handleEvent;\r
                        };\r
                }) :\r
-       x_eventdispatcher_temp.EVENT_W3C ?\r
+       X_EventDispatcher_temp.EVENT_W3C ?\r
                (function( that, type ){\r
                        var raw = that._rawObject;\r
                        if( !raw ) return;\r
@@ -534,7 +543,7 @@ var x_eventdispatcher_actualRemoveEvent =
                                delete that._handleEvent;\r
                        };\r
                }) :\r
-       x_eventdispatcher_temp.EVENT_IE ?\r
+       X_EventDispatcher_temp.EVENT_IE ?\r
                (function( that, type ){\r
                        var raw = that._rawObject;\r
                        if( !raw ) return;\r
@@ -576,7 +585,7 @@ var x_eventdispatcher_actualRemoveEvent =
 // handleEvent を拡張可能にするために、クロージャに移動した\r
 // Is this in regard to the Safari 1.x preventDefault bug on click/dblclick?\r
 // https://groups.google.com/forum/#!msg/comp.lang.javascript/uYEuCHjHxnw/yKoHtZJPa1QJ\r
-var x_eventdispatcher_actualHandleEvent =\r
+var X_EventDispatcher_actualHandleEvent =\r
        X.UA.IE4 || X.UA.IE5678 ? // ie45678 EVENT_IE & EVENT_DOM0 for ie4\r
                (function(){\r
                        var ret;\r
@@ -585,7 +594,7 @@ var x_eventdispatcher_actualHandleEvent =
                                //type = 'readystatechange';\r
                        };\r
                        \r
-                       ret = X.EventDispatcher.prototype.dispatch.call( this, new X.Dom.Event( event, this, this._rawObject ) );\r
+                       ret = X_EventDispatcher_dispatch.call( this, new X.Dom.Event( event, this, this._rawObject ) );\r
 \r
                        if( ret & X.Callback.STOP_PROPAGATION ){\r
                                event.cancelBubble = true;\r
@@ -597,7 +606,7 @@ var x_eventdispatcher_actualHandleEvent =
                }) :\r
        //X.Dom.EVENT_W3C & EVENT_DOM0\r
                (function( e ){\r
-                       var ret = X.EventDispatcher.prototype.dispatch.call( this, new X.Dom.Event( e, this ) );\r
+                       var ret = X_EventDispatcher_dispatch.call( this, new X.Dom.Event( e, this ) );\r
                        \r
                        if( ret & X.Callback.STOP_PROPAGATION ){\r
                                e.stopPropagation();\r
@@ -607,33 +616,43 @@ var x_eventdispatcher_actualHandleEvent =
                                e.preventDefault();\r
                                if( X.UA.WebKit < 525.13 ){ // Safari3-\r
                                        if( e.type === 'click' || e.type === 'dbclick' ){\r
-                                               X.Dom._safariPreventDefault = true;\r
+                                               X_EventDispatcher_safariPreventDefault = true;\r
                                        };\r
                                };\r
                                return false;\r
                        };\r
                });\r
 \r
+if( X.UA.WebKit < 525.13 ){ // Safari3-\r
+       document.documentElement.onclick =\r
+       document.documentElement.ondbclick = function( e ){\r
+                       if( X_EventDispatcher_safariPreventDefault ){\r
+                               X_EventDispatcher_safariPreventDefault = false;\r
+                               e.preventDefault();\r
+                               return false;\r
+                       };\r
+               };\r
+};\r
 \r
 // イベントの退避、dom が画面から抜かれる場合に実施しておく\r
-X.EventDispatcher.prototype._migrateEvent = function(){\r
-       var hash = this._listeners,\r
+function X_EventDispatcher_migrateEvent( that ){\r
+       var hash = that._listeners,\r
                type;\r
        if( !hash ) return;\r
        for( type in hash ){\r
                // 数字イベントの除外\r
-               '' + parseFloat( type ) !== type && x_eventdispatcher_actualRemoveEvent( this, type );\r
+               '' + parseFloat( type ) !== type && X_EventDispatcher_actualRemoveEvent( that, type );\r
        };\r
 };\r
 \r
 // 退避したイベントの復帰\r
-X.EventDispatcher.prototype._restoreEvent = function(){\r
-       var hash = this._listeners,\r
+function X_EventDispatcher_restoreEvent( that ){\r
+       var hash = that._listeners,\r
                type;\r
        if( !hash ) return;\r
        for( type in hash ){\r
                // 数字イベントの除外\r
-               '' + parseFloat( type ) !== type && x_eventdispatcher_actualAddEvent( this, type );\r
+               '' + parseFloat( type ) !== type && X_EventDispatcher_actualAddEvent( that, type );\r
        };\r
 };\r
 \r
index 63a799c..f2e05fc 100644 (file)
@@ -186,7 +186,7 @@ X.Dom = X.Class._override(
                                case 'beforeunload' :\r
                                        \r
                                        // ie では a href="javascript" な要素でも beforeunload が起こる\r
-                                       href = e.target && e.target.attr( 'href' );\r
+                                       href = e.target && e.target.attr && e.target.attr( 'href' );\r
                                        if( href && href.indexOf && href.indexOf( 'javascript:' ) === 0 ) return X.Callback.PREVENT_DEFAULT | X.Callback.STOP_PROPAGATION;\r
                                        \r
                                        return X.Dom.dispatch( { type : X.Dom.Event.BEFORE_UNLOAD } );\r
@@ -223,7 +223,7 @@ X.Dom = X.Class._override(
                                 */\r
                                X.Dom.asyncDispatch( 0, { type : type, w : X.Dom.w, h : X.Dom.h } );\r
                        };\r
-                       return x_eventdispatcher_listen.apply( X.Dom, arguments );\r
+                       return X_EventDispatcher_listen.apply( X.Dom, arguments );\r
                },\r
                \r
                getPointerPosition : function(){\r
index d9bd701..2e19ddf 100644 (file)
@@ -144,13 +144,14 @@ X.Dom.Node = X.EventDispatcher.inherits(
                                                v.UID           = uid;\r
                                                this._state     = X.Dom.State.EXIST;\r
                                                break;\r
+                                       /*\r
                                        case Node.IS_WINDOW :\r
                                        case Node.IS_DOCUMENT :\r
                                                if( xnode = Node._getXNode( v ) ) return xnode;\r
                                                this._rawObject = v;\r
                                                this._xnodeType = 2;\r
                                                this._state     = X.Dom.State.DISPLAY_BLOCK;\r
-                                               break;\r
+                                               break; */\r
                                        default :\r
                                                if( Node.none ) return Node.none;\r
                                                return;\r
@@ -180,12 +181,7 @@ Node._getType = function( v ){
        if( !v ) return 0;\r
        if( v === window ) return Node.IS_WINDOW;\r
        if( v === document ) return Node.IS_DOCUMENT;\r
-       if( v.constructor === window.Image ) return Node.IS_IMAGE;\r
-       if( X.UA.WebKit < 525.13 ){ // Safari3-\r
-               if( v.src !== undefined && v.onload !== undefined && X.Type.isNumber( v.height ) && X.Type.isNumber( v.width ) && X.Type.isBoolean( v.complete ) ){\r
-                       return Node.IS_IMAGE;\r
-               };\r
-       };      \r
+       if( X.Type.isImage( v ) ) return Node.IS_IMAGE;\r
        if( v.constructor === Node ) return Node.IS_XNODE;\r
        if( v.constructor === X.Dom.NodeList ) return Node.IS_XNODE_LIST;\r
        if( X.Type.isHTMLElement( v ) ) return Node.IS_RAW_HTML;\r
@@ -258,11 +254,11 @@ Node.isXmlDocument =
 \r
 Node._chashe     = [];\r
 Node.none        = Node._chashe[ 0 ] = new Node();\r
-Node._window     = new Node( window ); // Node._chashe[ 1 ]\r
-Node._document   = new Node( document ); // Node._chashe[ 2 ]\r
-Node._html       = null; // Node._chashe[ 3 ]\r
-Node._body       = null;// = Node._chashe[ 4 ] body\r
-Node._systemNode = null;// = Node._chashe[ ? ]\r
+Node._window     = new X.EventDispatcher( window );\r
+Node._document   = new X.EventDispatcher( document );\r
+Node._html       = null; // = Node._chashe[ 1 ] <html>\r
+Node._body       = null; // = Node._chashe[ 2 ] <body>\r
+Node._systemNode = null; // = Node._chashe[ ? ]\r
 \r
 Node._reserveRemoval = [];\r
 \r
@@ -912,7 +908,7 @@ Node.prototype._startUpdate = function(){
                return;\r
        };\r
        if( this._updateTimerID ){\r
-               //X.Timer.cancelFrame( this._updateTimerID ); // fire 中の cancel が動かない、、、\r
+               X.Timer.cancelFrame( this._updateTimerID );\r
                this._updateTimerID = 0;\r
        } else {\r
                return;\r
@@ -954,6 +950,8 @@ Node.prototype._commitUpdate =
 \r
                        if( this._state & X.Dom.State.IE5_DISPLAY_NONE_FIX ){\r
                                //alert( this._tag + ' ' + !!elm );\r
+                               // filter の効いている要素だけdisplay:none が無視される模様。filter を切ればよい?\r
+                               // 親が、display:none の場合は?\r
                                elm && elm.parentNode && this._actualRemove();\r
                                return nextElement;\r
                        };\r
@@ -1064,6 +1062,7 @@ Node.prototype._updateRawNode =
                                };\r
                        };\r
                        // style\r
+                       // TODO display:none の場合、更新をスキップ\r
                        if( this._dirty & X.Dom.Dirty.CSS ){\r
                                if( this._cssText !== null || ( this._cssText = X.Dom.Style.objToCssText( this._css ) ) ){\r
                                        X.UA.Opera78 || X.UA.NN6 ?\r
@@ -1081,6 +1080,7 @@ Node.prototype._updateRawNode =
                        };\r
                        \r
                        // attr\r
+                       // TODO display:none の場合、更新をスキップ\r
                        if( this._dirty & X.Dom.Dirty.ATTR && ( attrs = this._newAttrs || this._attrs ) ){\r
                                rename = X.Dom.Attr.renameForDOM;\r
                                for( k in attrs ){\r
@@ -1092,7 +1092,7 @@ Node.prototype._updateRawNode =
                                                        continue;\r
                                                };\r
                                        };\r
-                                       k === 'type' && alert( this._dirty + ' ' + elm.outerHTML );\r
+                                       // TODO IE では input, なぜか buttonも、type の変更が出来ない、k === 'type' && alert( this._dirty + ' ' + elm.outerHTML );\r
                                        ( v = attrs[ k ] ) === undefined ?\r
                                                elm.removeAttribute( rename[ k ] || k ) :\r
                                                ( elm[ rename[ k ] || k ] = X.Dom.Attr.noValue[ k ] ? k : v );                          \r
@@ -1299,7 +1299,7 @@ Node.prototype._afterActualCreate =
                };\r
                // src の onload があるので先ではないか?\r
                // ie の str から要素を作る場合、srcだけ イベント設定後ではないか?\r
-               this._restoreEvent();// イベントの復帰\r
+               X_EventDispatcher_restoreEvent( this );// イベントの復帰\r
        }) :\r
        X.Dom.DOM_IE4 ? (function(){\r
                var xnodes, i;\r
@@ -1317,7 +1317,7 @@ Node.prototype._afterActualCreate =
                        this._ie4getRawNode().style.filter = X.Dom.Style.SPECIAL_FIX( this._css );\r
                };\r
                delete this._dirty;\r
-               this._restoreEvent();// イベントの復帰\r
+               X_EventDispatcher_restoreEvent( this );// イベントの復帰\r
        }) :\r
        (function(){});\r
 \r
@@ -1335,7 +1335,7 @@ Node.prototype._actualRemove =
                        };\r
 \r
                        if( !elm ) return;\r
-                       this._xnodeType === 1 && this._migrateEvent();// イベントの退避\r
+                       this._xnodeType === 1 && X_EventDispatcher_migrateEvent( this );// イベントの退避\r
                        // elm.parentNode.tagName for ie7\r
                        if( !X.UA.MacIE ){\r
                                !isChild && elm.parentNode && elm.parentNode.tagName && elm.parentNode.removeChild( elm );\r
@@ -1355,7 +1355,7 @@ Node.prototype._actualRemove =
                        };\r
 \r
                        if( !elm ) return;\r
-                       this._xnodeType === 1 && this._migrateEvent();// イベントの退避\r
+                       this._xnodeType === 1 && X_EventDispatcher_migrateEvent( this );// イベントの退避\r
                        \r
                        if( X.Dom.Attr.HAS_VALUE[ this._tag ] && ( !this._newAttrs || !X.inObject( 'value', this._newAttrs ) ) ){\r
                                this._attrs.value = elm.value;\r
index 3f906a5..fd81b01 100644 (file)
@@ -336,16 +336,5 @@ X.Dom.listenOnce( X.Dom.Event.XDOM_READY, function(e){
        console.log( 'X.Dom XDomReady ' + X.Dom.readyState );\r
 } );\r
 \r
-if( X.UA.WebKit < 525.13 ){ // Safari3-\r
-       document.documentElement.onclick =\r
-       document.documentElement.ondbclick = function( e ){\r
-                       if( X.Dom._safariPreventDefault ){\r
-                               X.Dom._safariPreventDefault = false;\r
-                               e.preventDefault();\r
-                               return false;\r
-                       };\r
-               };\r
-};\r
-\r
 X.Dom.listen( X.Dom.Event.VIEW_RESIZED, function(e){ console.log( 'X.Dom VIEW_RESIZED ' + e.w + ' x ' + e.h ); } );\r
 \r
index 840bfa7..3fd0ed2 100644 (file)
@@ -136,9 +136,9 @@ X.Dom.Node.prototype.attr = function( nameOrObj /* v */ ){
                                if( X.Dom.Attr.HAS_VALUE[ this._tag ] ){\r
                                        if( this._newAttrs && X.inObject( nameOrObj, this._newAttrs ) ) return this._newAttrs[ nameOrObj ];\r
                                        if( elm = X.Dom.DOM_IE4 ? this._rawObject || this._ie4getRawNode() : this._rawObject ){\r
-                                               attrs[ nameOrObj ] = elm[ nameOrObj ]; // getAttribute( nameOrObj )?\r
+                                               if( !attrs ) attrs = this._attrs = {};\r
+                                               return attrs[ nameOrObj ] = elm[ nameOrObj ]; // getAttribute( nameOrObj )?\r
                                        };\r
-                                       return attrs[ nameOrObj ];\r
                                };\r
                                break;\r
                };\r
@@ -167,7 +167,7 @@ X.Dom.Node.prototype._setAttr = function( attrs, newAttrs, name, v ){
                case 'cssText' :\r
                        return this.cssText( v );\r
        };\r
-       \r
+       // debug\r
        if( name.indexOf( 'on' ) === 0 ){\r
                X.Notification.warn( 'xnode.attr("' + name + '") is wrong, xnode.listen() & xnode.unlisten().' );\r
                return;\r
index be7926f..9074dec 100644 (file)
@@ -780,12 +780,12 @@ X.UI._AbstractUINode = X.EventDispatcher.inherits(
                        };\r
                        f = X.Callback._classifyCallbackArgs( arg1, arg2, arg3 );\r
                        if( !f.k ){\r
-                               return x_eventdispatcher_listen.call( this, type, this.User, f );\r
+                               return X_EventDispatcher_listen.call( this, type, this.User, f );\r
                        } else\r
                        if( f.k === X.Callback._FUNC_ONLY ){\r
-                               return x_eventdispatcher_listen.call( this, type, this.User, f.f, f.s );\r
+                               return X_EventDispatcher_listen.call( this, type, this.User, f.f, f.s );\r
                        };\r
-                       return x_eventdispatcher_listen.apply( this, arguments );\r
+                       return X_EventDispatcher_listen.apply( this, arguments );\r
                },\r
                unlisten : function( type, arg1, arg2, arg3 ){\r
                        var root, events, i, ev, counter, f;\r
@@ -827,7 +827,7 @@ X.UI._AbstractUINode = X.EventDispatcher.inherits(
                \r
                dispatch : function( e ){\r
                        var xve  = X.UI.Event,\r
-                               ret  = X.EventDispatcher.prototype.dispatch.call( this, e ),\r
+                               ret  = X_EventDispatcher_dispatch.call( this, e ),\r
                                type = e.type;\r
                        if( ret & X.Callback.MONOPOLY && !this.hitChildData && ( xve._POINTER_MOVE === type || xve._MOUSE_MOVE === type || xve.FILE_DRAG === type ) ){\r
                                this.rootData.monopolyNodeData = this;\r