Ticket #2876: 2876.patch
File 2876.patch, 5.2 KB (added by , 15 years ago) |
---|
-
_source/core/dom/domwalker.js
5 5 6 6 (function() 7 7 { 8 var fireDomWalkerEvent= function( transistionType, fromNode, toNode )8 var move = function( transistionType, fromNode, toNode ) 9 9 { 10 var eventData = { from : fromNode, to : toNode, type : transistionType }; 11 this.fire( transistionType, eventData ); 12 this._.actionEvents.push( eventData ); 10 var data = { from : fromNode, to : toNode, type : transistionType }; 11 this['move'+transistionType.charAt(0).toUpperCase() 12 + transistionType.substring(1).toLowerCase()].call( this, data ); 13 this._.actionEvents.push( data ); 13 14 }; 14 15 15 16 CKEDITOR.dom.domWalker = function( node ) … … 34 35 if ( current.getChildCount() > 0 ) 35 36 { 36 37 next = current.getChild( 0 ); 37 fireDomWalkerEvent.call( this, 'down', current, next );38 move.call( this, 'down', current, next ); 38 39 return next; 39 40 } 40 41 else if ( current.getNext() ) … … 40 41 else if ( current.getNext() ) 41 42 { 42 43 next = current.getNext(); 43 fireDomWalkerEvent.call( this, 'sibling', current, next );44 move.call( this, 'sibling', current, next ); 44 45 return next; 45 46 } 46 47 else … … 46 47 else 47 48 { 48 49 var ancestor = current.getParent(); 49 fireDomWalkerEvent.call( this, 'up', current, ancestor );50 move.call( this, 'up', current, ancestor ); 50 51 51 52 while ( ancestor ) 52 53 { … … 53 54 if ( ancestor.getNext() ) 54 55 { 55 56 next = ancestor.getNext(); 56 fireDomWalkerEvent.call( this, 'sibling', ancestor, next );57 move.call( this, 'sibling', ancestor, next ); 57 58 return next; 58 59 } 59 60 else … … 59 60 else 60 61 { 61 62 next = ancestor.getParent(); 62 fireDomWalkerEvent.call( this, 'up', ancestor, next );63 move.call( this, 'up', ancestor, next ); 63 64 ancestor = next; 64 65 } 65 66 } … … 89 90 if ( current.getPrevious() ) 90 91 { 91 92 var lastChild = current.getPrevious(); 92 fireDomWalkerEvent.call( this, 'sibling', current, lastChild );93 move.call( this, 'sibling', current, lastChild ); 93 94 while ( lastChild.getChildCount() > 0 ) 94 95 { 95 96 next = lastChild.getChild( lastChild.getChildCount() - 1 ); 96 fireDomWalkerEvent.call( this, 'down', lastChild, next );97 move.call( this, 'down', lastChild, next ); 97 98 lastChild = next; 98 99 } 99 100 return lastChild; … … 101 102 else 102 103 { 103 104 next = current.getParent(); 104 fireDomWalkerEvent.call( this, 'up', current, next );105 move.call( this, 'up', current, next ); 105 106 return next; 106 107 } 107 108 return null; … … 123 124 this._.stopFlag = false; 124 125 125 126 // The default behavior is to stop once the end of document is reached. 126 guardFunc = guardFunc || function( evt ) {}; 127 128 this.on( 'sibling', guardFunc ); 129 this.on( 'up', guardFunc ); 130 this.on( 'down', guardFunc ); 127 guardFunc = guardFunc || function( data ) {}; 128 129 this.moveSibling = this.moveUp = this.moveDown = guardFunc; 131 130 while( ( !retval || retval.node ) && !this._.stopFlag ) 132 131 { 133 132 retval = this.next(); … … 133 132 retval = this.next(); 134 133 this.fire( 'step', retval ); 135 134 } 136 this.removeListener( 'sibling', guardFunc );137 this.removeListener( 'up', guardFunc );138 this.removeListener( 'down', guardFunc );139 135 return retval; 140 136 }, 141 137 … … 145 141 this._.stopFlag = false; 146 142 147 143 // The default behavior is top stop once the start of document is reached. 148 guardFunc = guardFunc || function( evt) {};144 guardFunc = guardFunc || function( data ) {}; 149 145 150 this.on( 'sibling', guardFunc ); 151 this.on( 'up', guardFunc ); 152 this.on( 'down', guardFunc ); 146 this.moveSibling = this.moveUp = this.moveDown = guardFunc; 153 147 while( ( !retval || retval.node ) && !this._.stopFlag ) 154 148 { 155 149 retval = this.back(); … … 155 149 retval = this.back(); 156 150 this.fire( 'step', retval ); 157 151 } 158 this.removeListener( 'sibling', guardFunc );159 this.removeListener( 'up', guardFunc );160 this.removeListener( 'down', guardFunc );161 152 return retval; 162 153 }, 163 154 … … 211 202 212 203 CKEDITOR.dom.domWalker.blockBoundary = function( customNodeNames ) 213 204 { 214 return function( evt)205 return function( data ) 215 206 { 216 var to = evt.data.to,217 from = evt.data.from;207 var to = data.to, 208 from = data.from; 218 209 if ( to && to.type == CKEDITOR.NODE_ELEMENT ) 219 210 { 220 211 if ( to.isBlockBoundary( customNodeNames ) ) … … 219 210 { 220 211 if ( to.isBlockBoundary( customNodeNames ) ) 221 212 { 222 evt.stop();223 213 this.stop(); 224 214 return; 225 215 } … … 224 214 return; 225 215 } 226 216 } 227 if ( ( evt.data.type == 'up' || evt.data.type == 'sibling' ) && from && from.type == CKEDITOR.NODE_ELEMENT )217 if ( ( data.type == 'up' || data.type == 'sibling' ) && from && from.type == CKEDITOR.NODE_ELEMENT ) 228 218 { 229 219 if ( from.isBlockBoundary( customNodeNames ) ) 230 220 { 231 evt.stop();232 221 this.stop(); 233 222 } 234 223 }