Ticket #2876: 2876.patch

File 2876.patch, 5.2 KB (added by Garry Yao, 15 years ago)
  • _source/core/dom/domwalker.js

     
    55
    66(function()
    77{
    8         var fireDomWalkerEvent = function( transistionType, fromNode, toNode )
     8        var move = function( transistionType, fromNode, toNode )
    99                {
    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 );
    1314                };
    1415
    1516        CKEDITOR.dom.domWalker = function( node )
     
    3435                                if ( current.getChildCount() > 0 )
    3536                                {
    3637                                        next = current.getChild( 0 );
    37                                         fireDomWalkerEvent.call( this, 'down', current, next );
     38                                        move.call( this, 'down', current, next );
    3839                                        return next;
    3940                                }
    4041                                else if ( current.getNext() )
     
    4041                                else if ( current.getNext() )
    4142                                {
    4243                                        next = current.getNext();
    43                                         fireDomWalkerEvent.call( this, 'sibling', current, next );
     44                                        move.call( this, 'sibling', current, next );
    4445                                        return next;
    4546                                }
    4647                                else
     
    4647                                else
    4748                                {
    4849                                        var ancestor = current.getParent();
    49                                         fireDomWalkerEvent.call( this, 'up', current, ancestor );
     50                                        move.call( this, 'up', current, ancestor );
    5051
    5152                                        while ( ancestor )
    5253                                        {
     
    5354                                                if ( ancestor.getNext() )
    5455                                                {
    5556                                                        next = ancestor.getNext();
    56                                                         fireDomWalkerEvent.call( this, 'sibling', ancestor, next );
     57                                                        move.call( this, 'sibling', ancestor, next );
    5758                                                        return next;
    5859                                                }
    5960                                                else
     
    5960                                                else
    6061                                                {
    6162                                                        next = ancestor.getParent();
    62                                                         fireDomWalkerEvent.call( this, 'up', ancestor, next );
     63                                                        move.call( this, 'up', ancestor, next );
    6364                                                        ancestor = next;
    6465                                                }
    6566                                        }
     
    8990                                if ( current.getPrevious() )
    9091                                {
    9192                                        var lastChild = current.getPrevious();
    92                                         fireDomWalkerEvent.call( this, 'sibling', current, lastChild );
     93                                        move.call( this, 'sibling', current, lastChild );
    9394                                        while ( lastChild.getChildCount() > 0 )
    9495                                        {
    9596                                                next = lastChild.getChild( lastChild.getChildCount() - 1 );
    96                                                 fireDomWalkerEvent.call( this, 'down', lastChild, next );
     97                                                move.call( this, 'down', lastChild, next );
    9798                                                lastChild = next;
    9899                                        }
    99100                                        return lastChild;
     
    101102                                else
    102103                                {
    103104                                        next = current.getParent();
    104                                         fireDomWalkerEvent.call( this, 'up', current, next );
     105                                        move.call( this, 'up', current, next );
    105106                                        return next;
    106107                                }
    107108                                return null;
     
    123124                        this._.stopFlag = false;
    124125
    125126                        // 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;
    131130                        while( ( !retval || retval.node ) && !this._.stopFlag )
    132131                        {
    133132                                retval = this.next();
     
    133132                                retval = this.next();
    134133                                this.fire( 'step', retval );
    135134                        }
    136                         this.removeListener( 'sibling', guardFunc );
    137                         this.removeListener( 'up', guardFunc );
    138                         this.removeListener( 'down', guardFunc );
    139135                        return retval;
    140136                },
    141137
     
    145141                        this._.stopFlag = false;
    146142
    147143                        // The default behavior is top stop once the start of document is reached.
    148                         guardFunc = guardFunc || function( evt ) {};
     144                        guardFunc = guardFunc || function( data ) {};
    149145
    150                         this.on( 'sibling', guardFunc );
    151                         this.on( 'up', guardFunc );
    152                         this.on( 'down', guardFunc );
     146                        this.moveSibling = this.moveUp = this.moveDown = guardFunc;
    153147                        while( ( !retval || retval.node ) && !this._.stopFlag )
    154148                        {
    155149                                retval = this.back();
     
    155149                                retval = this.back();
    156150                                this.fire( 'step', retval );
    157151                        }
    158                         this.removeListener( 'sibling', guardFunc );
    159                         this.removeListener( 'up', guardFunc );
    160                         this.removeListener( 'down', guardFunc );
    161152                        return retval;
    162153                },
    163154
     
    211202
    212203        CKEDITOR.dom.domWalker.blockBoundary = function( customNodeNames )
    213204        {
    214                 return function( evt )
     205                return function( data )
    215206                {
    216                         var to = evt.data.to,
    217                                 from = evt.data.from;
     207                        var to = data.to,
     208                                from = data.from;
    218209                        if ( to && to.type == CKEDITOR.NODE_ELEMENT )
    219210                        {
    220211                                if ( to.isBlockBoundary( customNodeNames ) )
     
    219210                        {
    220211                                if ( to.isBlockBoundary( customNodeNames ) )
    221212                                {
    222                                         evt.stop();
    223213                                        this.stop();
    224214                                        return;
    225215                                }
     
    224214                                        return;
    225215                                }
    226216                        }
    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 )
    228218                        {
    229219                                if ( from.isBlockBoundary( customNodeNames ) )
    230220                                {
    231                                         evt.stop();
    232221                                        this.stop();
    233222                                }
    234223                        }
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy