Ticket #8632: 8632_2.patch

File 8632_2.patch, 3.6 KB (added by Garry Yao, 12 years ago)
  • _source/core/dom/walker.js

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    1414
    1515                var node,
    1616                        range = this.range,
     17                        startCt = range.startContainer,
     18                        endCt = range.endContainer,
     19                        startOffset = range.startOffset,
     20                        endOffset = range.endOffset,
    1721                        guard,
    1822                        userGuard = this.guard,
    1923                        type = this.type,
     
    2428                {
    2529                        this._.start = 1;
    2630
    27                         // Trim text nodes and optmize the range boundaries. DOM changes
    28                         // may happen at this point.
    29                         range.trim();
    30 
    3131                        // A collapsed range must return null at first call.
    3232                        if ( range.collapsed )
    3333                        {
     
    3939                // Create the LTR guard function, if necessary.
    4040                if ( !rtl && !this._.guardLTR )
    4141                {
    42                         // Gets the node that stops the walker when going LTR.
    43                         var limitLTR = range.endContainer,
    44                                 blockerLTR = limitLTR.getChild( range.endOffset );
     42                        // The node that stops walker from moving up.
     43                        var limitLTR = endCt.type == CKEDITOR.NODE_ELEMENT ?
     44                                                   endCt :
     45                                                   endCt.getParent();
    4546
     47                        // The node that stops the walker from going to next.
     48                        var blockerLTR = endCt.type == CKEDITOR.NODE_ELEMENT ?
     49                                                         endCt.getChild( endOffset ) :
     50                                                         endCt.getNext();
     51
    4652                        this._.guardLTR = function( node, movingOut )
    4753                        {
    4854                                return ( ( !movingOut || !limitLTR.equals( node ) )
     
    5460                // Create the RTL guard function, if necessary.
    5561                if ( rtl && !this._.guardRTL )
    5662                {
    57                         // Gets the node that stops the walker when going LTR.
    58                         var limitRTL = range.startContainer,
    59                                 blockerRTL = ( range.startOffset > 0 ) && limitRTL.getChild( range.startOffset - 1 );
     63                        // The node that stops walker from moving up.
     64                        var limitRTL = startCt.type == CKEDITOR.NODE_ELEMENT ?
     65                                                   startCt :
     66                                                   startCt.getParent();
    6067
     68                        // The node that stops the walker from going to next.
     69                        var blockerRTL = startCt.type == CKEDITOR.NODE_ELEMENT ?
     70                                                 startOffset ?
     71                                                 startCt.getChild( startOffset - 1 ) : null :
     72                                                 startCt.getPrevious();
     73
    6174                        this._.guardRTL = function( node, movingOut )
    6275                        {
    6376                                return ( ( !movingOut || !limitRTL.equals( node ) )
     
    89102                else
    90103                {
    91104                        // Get the first node to be returned.
    92 
    93105                        if ( rtl )
    94106                        {
    95                                 node = range.endContainer;
     107                                node = endCt;
    96108
    97                                 if ( range.endOffset > 0 )
     109                                if ( node.type == CKEDITOR.NODE_ELEMENT )
    98110                                {
    99                                         node = node.getChild( range.endOffset - 1 );
    100                                         if ( guard( node ) === false )
    101                                                 node = null;
    102                                 }
    103                                 else
    104                                         node = ( guard ( node, true ) === false ) ?
    105                                                 null : node.getPreviousSourceNode( true, type, guard );
    106                         }
     111                                        if ( endOffset > 0 )
     112                                                node = node.getChild( endOffset - 1 );
     113                                        else
     114                                                node = ( guard ( node, true ) === false ) ?
     115                                                        null : node.getPreviousSourceNode( true, type, guard );
     116                                }
     117                        }
    107118                        else
    108119                        {
    109                                 node = range.startContainer;
    110                                 node = node.getChild( range.startOffset );
     120                                node = startCt;
    111121
    112                                 if ( node )
     122                                if ( node.type == CKEDITOR.NODE_ELEMENT )
    113123                                {
    114                                         if ( guard( node ) === false )
    115                                                 node = null;
     124                                        if ( ! ( node = node.getChild( startOffset ) ) )
     125                                                node = ( guard ( startCt, true ) === false ) ?
     126                                                        null : startCt.getNextSourceNode( true, type, guard ) ;
    116127                                }
    117                                 else
    118                                         node = ( guard ( range.startContainer, true ) === false ) ?
    119                                                 null : range.startContainer.getNextSourceNode( true, type, guard ) ;
    120128                        }
     129
     130                        if ( node && guard( node ) === false )
     131                                node = null;
    121132                }
    122133
    123134                while ( node && !this._.end )
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy