Ticket #8812: 8812_3.patch

File 8812_3.patch, 2.3 KB (added by Frederico Caldeira Knabben, 12 years ago)
  • _source/plugins/selection/plugin.js

     
    845845                                                        endIndex = siblings.length - 1,
    846846                                                        index = -1,
    847847                                                        position,
    848                                                         distance;
     848                                                        distance,
     849                                                        container;
    849850
    850851                                                // Binary search over all element childs to test the range to see whether
    851852                                                // range is right on the boundary of one element.
     
    896897                                                        {
    897898                                                                child = siblings[ siblings.length - 1 ];
    898899
    899                                                                 if ( child.nodeType == CKEDITOR.NODE_ELEMENT )
     900                                                                if ( child.nodeType != CKEDITOR.NODE_TEXT )
    900901                                                                        return { container : parent, offset : siblings.length };
    901902                                                                else
    902903                                                                        return { container : child, offset : child.nodeValue.length };
     
    904905
    905906                                                        // Start the measuring until distance overflows, meanwhile count the text nodes.
    906907                                                        var i = siblings.length;
    907                                                         while ( distance > 0 )
    908                                                                 distance -= siblings[ --i ].nodeValue.length;
     908                                                        while ( distance > 0 && i > 0 )
     909                                                        {
     910                                                                sibling = siblings[ --i ];
     911                                                                if ( sibling.nodeType == CKEDITOR.NODE_TEXT )
     912                                                                {
     913                                                                        container = sibling;
     914                                                                        distance -= sibling.nodeValue.length;
     915                                                                }
     916                                                        }
    909917
    910                                                         return  { container : siblings[ i ], offset : -distance };
     918                                                        return  { container : container, offset : -distance };
    911919                                                }
    912920                                                // Test range was one offset beyond OR behind the anchored text node.
    913921                                                else
     
    932940                                                                try
    933941                                                                {
    934942                                                                        sibling = child[ position > 0 ? 'previousSibling' : 'nextSibling' ];
    935                                                                         distance -= sibling.nodeValue.length;
     943                                                                        if ( sibling.nodeType == CKEDITOR.NODE_TEXT )
     944                                                                        {
     945                                                                                distance -= sibling.nodeValue.length;
     946                                                                                container = sibling;
     947                                                                        }
    936948                                                                        child = sibling;
    937949                                                                }
    938950                                                                // Measurement in IE could be somtimes wrong because of <select> element. (#4611)
     
    942954                                                                }
    943955                                                        }
    944956
    945                                                         return { container : child, offset : position > 0 ? -distance : child.nodeValue.length + distance };
     957                                                        return { container : container, offset : position > 0 ? -distance : container.nodeValue.length + distance };
    946958                                                }
    947959                                        };
    948960
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy