Ticket #8520: 8520.patch

File 8520.patch, 3.0 KB (added by Garry Yao, 12 years ago)
  • _source/core/dom/node.js

     
    231231                        return new CKEDITOR.dom.document( this.$.ownerDocument || this.$.parentNode.ownerDocument );
    232232                },
    233233
    234                 getIndex : function( normalized )
     234                getIndex :  CKEDITOR.env.ie && CKEDITOR.env.version < 9 ? function( normalized )
    235235                {
    236236                        // Attention: getAddress depends on this.$
    237237
     238                        var parent = this.$.parentNode,
     239                                childs = parent.childNodes,
     240                                count = childs.length,
     241                                current,
     242                                index = 0;
     243
     244                        for ( var i = 0; i < count; i++ )
     245                        {
     246                                if ( ( current = childs[ i ] ) == this.$ )
     247                                        break;
     248
     249                                // sibling traversal may throw exceptions in old IEs.
     250                                try
     251                                {
     252                                        // When normalizing, do not count it if this is an
     253                                        // empty text node or if it's a text node following another one.
     254                                        if ( normalized && current.nodeType == 3 &&
     255                                                 ( !current.nodeValue.length ||
     256                                                   ( current.previousSibling && current.previousSibling.nodeType == 3 ) ) )
     257                                        {
     258                                                continue;
     259                                        }
     260                                }
     261                                catch(er){}
     262
     263                                index++;
     264                        }
     265
     266                        return index;
     267                }
     268                :
     269                function( normalized )
     270                {
     271                        // Attention: getAddress depends on this.$
     272
    238273                        var current = this.$,
    239274                                index = 0;
    240275
  • _source/plugins/selection/plugin.js

     
    730730                                                        return  { container : parent, offset : 0 };
    731731
    732732                                                var siblings = parent.children,
     733                                                        childNodes = parent.childNodes,
    733734                                                        child,
    734735                                                        sibling,
    735736                                                        testRange = range.duplicate(),
     
    820821                                                        if ( !distance )
    821822                                                                return { container : parent, offset : getNodeIndex( child ) + ( position > 0 ? 0 : 1 ) };
    822823
     824                                                        i = getNodeIndex( child );
    823825                                                        // Start the measuring until distance overflows, meanwhile count the text nodes.
    824826                                                        while ( distance > 0 )
    825827                                                        {
    826828                                                                try
    827829                                                                {
    828                                                                         sibling = child[ position > 0 ? 'previousSibling' : 'nextSibling' ];
     830                                                                        sibling = childNodes[ i -= position ];
     831                                                                        // Fix an exception when node value access on certain IE internal marker (~) got it broken. (#8520)
    829832                                                                        distance -= sibling.nodeValue.length;
    830833                                                                        child = sibling;
    831834                                                                }
    832                                                                 // Measurement in IE could be somtimes wrong because of <select> element. (#4611)
    833835                                                                catch( e )
    834836                                                                {
    835                                                                         return { container : parent, offset : getNodeIndex( child ) };
    836                                                                 }
    837                                                         }
     837                                                                        // Fix an exception with wrong measurement in IE < 8 because of <select> element. (#4611)
     838                                                                        if ( !sibling )
     839                                                                        {
     840                                                                                return { container : parent, offset : getNodeIndex( child ) };
     841                                                                        }
     842                                                                }
     843                                                        }
    838844
    839845                                                        return { container : child, offset : position > 0 ? -distance : child.nodeValue.length + distance };
    840846                                                }
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy