From: itozyun Date: Wed, 26 Aug 2015 14:34:47 +0000 (+0900) Subject: Version 0.6.171, fix X.KB & fix X.Node for SVG & VML. X-Git-Url: http://git.osdn.jp/view?p=pettanr%2FclientJs.git;a=commitdiff_plain;h=733b1bb359e89b077ad347a5737b4cd610f0a8cb Version 0.6.171, fix X.KB & fix X.Node for SVG & VML. --- diff --git a/0.6.x/js/02_dom/02_XNodeFlags.js b/0.6.x/js/02_dom/02_XNodeFlags.js index 2b69e35..ff3ac0f 100644 --- a/0.6.x/js/02_dom/02_XNodeFlags.js +++ b/0.6.x/js/02_dom/02_XNodeFlags.js @@ -38,9 +38,25 @@ var X_NodeFlags_DESTROYED = 0x0, X_NodeFlags_IE4_HAS_ELEMENT = X_UA[ 'IE4' ] ? 2 << 22 : 0, X_NodeFlags_IE4_DIRTY_CHILDREN = X_UA[ 'IE4' ] ? 2 << 23 : 0, X_NodeFlags_IE4_FIXED = X_UA[ 'IE4' ] ? 2 << 24 : 0, - + X_NodeFlags_IE5_DISPLAY_NONE_FIX = X_UA[ 'IE5' ] && X_UA[ 'ActiveX' ] ? 2 << 24 : 0, + // http://modernizr.com/downloads/modernizr.js + // Thanks to Erik Dahlstrom + X_NodeFlags_IS_SVG = document.createElementNS && document.createElementNS( 'http://www.w3.org/2000/svg', 'svg' ).createSVGRect ? 2 << 25 : 0, + X_NodeFlags_IS_VML = + ( function(){ + if( !X_UA[ 'ActiveX' ] || X_UA[ 'IE' ] < 5 || 9 < X_UA[ 'IE' ] ) return 0; + + document.write( '' ); + + if( window[ 'vml' ] === 1 ){ + document.getElementById( 'vmltest' ).removeNode( true ); + return 2 << 26; + }; + return 0; + })(), + X_Node_BITMASK_RESET_STYLE = ( ( 2 << 29 ) - 1 + ( 2 << 29 ) ) ^ ( X_NodeFlags_STYLE_IS_DISPLAY_NONE | X_NodeFlags_STYLE_IS_INVISIBLE | diff --git a/0.6.x/js/02_dom/05_XNodeAttr.js b/0.6.x/js/02_dom/05_XNodeAttr.js index 2bb4817..a438590 100644 --- a/0.6.x/js/02_dom/05_XNodeAttr.js +++ b/0.6.x/js/02_dom/05_XNodeAttr.js @@ -238,6 +238,16 @@ function X_Node_attr( nameOrObj /* v */ ){ }; function X_Node_Attr_setAttr( that, attrs, newAttrs, name, v ){ switch( name ){ + case 'ns' : + case 'NS' : + if( v === 'svg' || v === 'SVG' ){ + that[ '_flags' ] |= XX_NodeFlags_IS_SVG; + }; + if( v === 'vml' || v === 'VML' ){ + that[ '_flags' ] |= XX_NodeFlags_IS_VML; + }; + return; + // case 'type' : TODO IE は input, button, object に対して type の再設定が出来ない _state が要素生成済なら不可 case 'UID' : case 'tag' : diff --git a/0.6.x/js/02_dom/20_XNode.js b/0.6.x/js/02_dom/20_XNode.js index 49ae640..aad360f 100644 --- a/0.6.x/js/02_dom/20_XNode.js +++ b/0.6.x/js/02_dom/20_XNode.js @@ -503,17 +503,26 @@ function X_Node_createTextAt( index, text ){ */ function X_Node_clone( opt_clone_children ){ var xnode, xnodes, i, l; + if( this[ '_tag' ] ){ X_Node_newByTag = true; xnode = Node( this[ '_tag' ], X_Object_copy( this[ '_attrs' ] ), X_Object_copy( this[ '_css' ] ) ) [ 'attr' ]( { 'id' : this[ '_id' ] } ) [ 'className' ]( this[ '_className' ] ); + + if( this[ '_flags' ] & X_NodeFlags_IS_SVG ){ + xnode[ '_flags' ] |= X_NodeFlags_IS_SVG; + }; + if( this[ '_flags' ] & X_NodeFlags_IS_VML ){ + xnode[ '_flags' ] |= X_NodeFlags_IS_VML; + }; + if( opt_clone_children && ( xnodes = this[ '_xnodes' ] ) && ( l = xnodes.length ) ){ for( i = 0; i < l; ++i ){ xnode[ 'append' ]( xnodes[ i ][ 'clone' ]( true ) ); }; }; - return xnode; + return xnode; }; X_Node_newByText = true; return Node( this[ '_text' ] ); @@ -566,6 +575,12 @@ function X_Node_append( v ){ v[ '_xnodes' ] && X_Node_toggleInTreeFlag( v[ '_xnodes' ], true ); X_Node_reserveUpdate(); }; + if( this[ '_flags' ] & X_NodeFlags_IS_SVG ){ + v[ '_flags' ] |= X_NodeFlags_IS_SVG; + }; + if( this[ '_flags' ] & X_NodeFlags_IS_VML ){ + v[ '_flags' ] |= X_NodeFlags_IS_VML; + }; return this; }; @@ -636,6 +651,12 @@ function X_Node_appendAt( start, v ){ v[ '_xnodes' ] && X_Node_toggleInTreeFlag( v[ '_xnodes' ], true ); X_Node_reserveUpdate(); }; + if( this[ '_flags' ] & X_NodeFlags_IS_SVG ){ + v[ '_flags' ] |= X_NodeFlags_IS_SVG; + }; + if( this[ '_flags' ] & X_NodeFlags_IS_VML ){ + v[ '_flags' ] |= X_NodeFlags_IS_VML; + }; return this; }; @@ -1145,8 +1166,12 @@ function X_Node_text( text ){ return this[ '_text' ]; }; -/* +/** * HTML要素に対して name の関数を実行しその戻り値を返す。関数に渡す引数も任意に設定できる。 + * @alias Node.prototype.call + * @param {string} [name] 要素の関数名 + * @return {*} + * @example node.call( 'focus' ); */ function X_Node_call( name /*, opt_args... */ ){ var l = arguments.length - 1, @@ -1386,7 +1411,11 @@ var X_Node__commitUpdate = that[ '_cssText' ] ? ' style="' + that[ '_cssText' ] + '"' : '', '>' ].join( '' ) ); } else { - that[ '_rawObject' ] = elm = document.createElement( that[ '_tag' ] ); + if( that[ '_flags' ] & X_NodeFlags_IS_SVG ){ + that[ '_rawObject' ] = elm = document.createElementNS( 'http://www.w3.org/2000/svg', that[ '_tag' ] ); + } else { + that[ '_rawObject' ] = elm = document.createElement( that[ '_tag' ] ); + }; }; // IE には要素追加のタイミングで起こるメモリリークがありここで追加 diff --git a/0.6.x/js/11_hid/01_KB.js b/0.6.x/js/11_hid/01_KB.js index 584cf0a..4d46047 100644 --- a/0.6.x/js/11_hid/01_KB.js +++ b/0.6.x/js/11_hid/01_KB.js @@ -18,119 +18,76 @@ * */ -var X_KB_TABLE = { - specials : { - '96' : 48, - '97' : 49, - '98' : 50, - '99' : 51, - '100' : 52, - '101' : 53, - '102' : 54, - '103' : 55, - '104' : 56, - '105' : 57, +var X_KB_SPECIALS = { - '8' : 'BS', - '9' : 'TAB', - '13' : 'ENTER', - '16' : 'SHIFT', - '17' : 'CTRL', - '18' : 'ALT', - '19' : 'PAUSE_BREAK', - '20' : 'SHIFT+CAPS_LOCK', - - '27' : 'ESC', - '28' : 'trans', - '29' : 'no trans', - - '33' : 'PAGE_UP', - '34' : 'PAGE_DOWN', - '35' : 'END', - '36' : 'HOME', - '37' : 'CSR_L', - '38' : 'CSR_U', - '39' : 'CSR_R', - '40' : 'CSR_D', - '45' : 'INS', - '44' : 'PRT_SCRN', - '46' : 'DEL', - - '91' : 'LWIN', - '92' : 'RWIN', - '93' : 'APP', - - '106' : 42, - '107' : 43, - '109' : 45, - '111' : 47, - '112' : 'F1', - '113' : 'F2', - '114' : 'F3', - '115' : 'F4', - '116' : 'F5', - '117' : 'F6', - '118' : 'F7', - '119' : 'F8', - '120' : 'F9', - '121' : 'F10', - '122' : 'F11', - '123' : 'F12', - - '144' : 'NUM_LOCK', - '145' : 'SCROLL_LOCK', - '208' : 'CAPS_LOCK', - '240' : 'CAPS_LOCK', - '242' : 'K/H', - '243' : 'H/Z', - '244' : 'H/Z' - - }, - // keypress 時に keyCode を直す 0 の場合、イベント発火せず。どのキーが押されたか?判定できないため - 'keypress' : { - // !-):33-41, *:42, +:43, ,:44, -:45, .:46, /:47, 0-9:48-57 , ::58 , ;:59 , <:60 , =:61, >:62, ?:63, @:64 - // A-Z:65-90, [:91, \:92, ]:93, ^:94, _:95, `:96, a-z:97-122, {:123, |:124, }:125, ~:126 - }, + + '8' : 'BS', + '9' : 'TAB', + '13' : 'ENTER', + '16' : 'SHIFT', + '17' : 'CTRL', + '18' : 'ALT', + '19' : 'PAUSE_BREAK', + '20' : 'SHIFT+CAPS_LOCK', - 'keyup' : { - '189' : '45,61', // ie, safari - '109' : '45,61', // firefox, opera - - '222' : '94,126', // firefox, ie, safari - '94' : '94,126', // opera + '27' : 'ESC', + '28' : 'trans', + '29' : 'no trans', - '226' : '92,95', // firefox, ie, safari, - '220' : 9.5 <= X_UA[ 'Opera' ] ? '92,95,124' : '92,124', // firefox, ie, safari, opera9.50+ - '92' : '92,95,124', // opera9.25 - - '192' : '64,96', // firefox, ie, safari - '64' : '64,96', // opera - - '219' : '91,123', // firefox, ie, safari, opera9.50+ - '91' : '91,123', // opera9.25 - - '187' : '59,43', // ie, safari - '61' : '59,43', // firefox, opera - - '186' : '58,42', // ie, safari - '59' : '58,42', // firefox, opera - - '221' : '93,125', // firefox, ie, safari, opera9.50+ - '93' : '93,125', // opera9.25 - - '188' : '44,60', // firefox, ie, safari, opera9.50+ - '44' : '44,60', // opera9.25 - - '190' : '46,62', // firefox, ie, safari, opera9.50+ - '46' : '46,62', // opera9.25 - - '191' : '47,63', // firefox, ie, safari, opera9.50+ - '47' : '47,63' // opera9.25 - } + '33' : 'PAGE_UP', + '34' : 'PAGE_DOWN', + '35' : 'END', + '36' : 'HOME', + '37' : 'CSR_L', + '38' : 'CSR_U', + '39' : 'CSR_R', + '40' : 'CSR_D', + '44' : 'PRT_SCRN', + '45' : 'INS', + '46' : 'DEL', + + '91' : 'LWIN', + '92' : 'RWIN', + '93' : 'APP', + + '96' : 48, + '97' : 49, + '98' : 50, + '99' : 51, + '100' : 52, + '101' : 53, + '102' : 54, + '103' : 55, + '104' : 56, + '105' : 57, + '106' : 42, + '107' : 43, + '109' : 45, + '111' : 47, + '112' : 'F1', + '113' : 'F2', + '114' : 'F3', + '115' : 'F4', + '116' : 'F5', + '117' : 'F6', + '118' : 'F7', + '119' : 'F8', + '120' : 'F9', + '121' : 'F10', + '122' : 'F11', + '123' : 'F12', + + '144' : 'NUM_LOCK', + '145' : 'SCROLL_LOCK', + '208' : 'CAPS_LOCK', + '240' : 'CAPS_LOCK', + '242' : 'K/H', + '243' : 'H/Z', + '244' : 'H/Z' }, X_KB_DOWN_KEYS = {}, X_KB_CANCELED = {}, - X_KB_lastIs10Key = 0, + X_KB_lastIs10Key = false, X_KB_lastKeyCode = 0, X_KB_TRANSFOEM = {}, @@ -148,17 +105,16 @@ var X_KB_TABLE = { switch( e.type ){ case 'keydown' : - if( X_KB_DOWN_KEYS[ keyCode ] ){ // 既に押されている、メタキー[shift,ctrl,alt]の変化はある? - return cb; + return X_KB_CANCELED[ keyCode ] ? X_CALLBACK_PREVENT_DEFAULT : cb; } else - if( special = X_KB_TABLE.specials[ keyCode ] ){ + if( special = X_KB_SPECIALS[ keyCode ] ){ if( X_Type_isNumber( special ) ){ // テンキーの [0]~[9] //chrCode = special; - X_KB_lastKeyCode = keyCode; + X_KB_lastKeyCode = keyCode; X_KB_lastIs10Key = true; return cb; } else { @@ -181,20 +137,27 @@ var X_KB_TABLE = { if( cb & X_CALLBACK_PREVENT_DEFAULT ){ X_KB_CANCELED[ keyCode ] = true; }; + /* + if( special === 'APP' ){ + X_ViewPort_active = false; + X_ViewPort[ 'dispatch' ]( X_EVENT_VIEW_DEACTIVATE ); + }; */ } else { X_KB_lastKeyCode = keyCode; - }; - + }; return cb; case 'keypress' : // keydown 側で発火しているものは再び発火しない - console.log( 'kp : ' + X_KB_DOWN_KEYS[ chrCode ] + ( X_KB_CANCELED[ chrCode ] ? ' Cancel!' : '' ) ); + console.log( 'keypress : chrCode:' + chrCode + ' down:' + X_KB_DOWN_KEYS[ chrCode ] + ( X_KB_CANCELED[ chrCode ] ? ' Cancel!' : '' ) ); if( X_KB_DOWN_KEYS[ chrCode ] ){ return X_KB_CANCELED[ chrCode ] ? X_CALLBACK_PREVENT_DEFAULT : cb; + } else + if( keyCode === 32 ){ + charCode = 32; }; - if( 33 <= chrCode && chrCode <= 126 ){ + if( 32 <= chrCode && chrCode <= 126 ){ X_KB_TRANSFOEM[ X_KB_lastKeyCode ] = chrCode; cb = this[ 'dispatch' ]( { @@ -217,7 +180,7 @@ var X_KB_TABLE = { cb = X_CALLBACK_PREVENT_DEFAULT; }; - if( ( special = X_KB_TABLE.specials[ keyCode ] ) && ( !X_KB_DOWN_KEYS[ keyCode ] && !X_KB_DOWN_KEYS[ special ] ) ){ + if( ( special = X_KB_SPECIALS[ keyCode ] ) && ( !X_KB_DOWN_KEYS[ keyCode ] && !X_KB_DOWN_KEYS[ special ] ) ){ cb |= this[ 'dispatch' ]( { type : 'keydown', keyCode : keyCode, @@ -237,10 +200,10 @@ var X_KB_TABLE = { chrCode = 0; if( !special ){ + // keyCode から charCode を復帰する chrCode = X_KB_TRANSFOEM[ keyCode ]; if( !chrCode ) return cb; delete X_KB_TRANSFOEM[ keyCode ]; - //keyCode = 0; }; cb |= this[ 'dispatch' ]( {