Ticket #6771: 6771_2.patch

File 6771_2.patch, 2.4 KB (added by Garry Yao, 13 years ago)
  • _source/core/htmlparser/fragment.js

     
    6464                        html = [],
    6565                        fragment = new CKEDITOR.htmlParser.fragment(),
    6666                        pendingInline = [],
    67                         pendingBRs = [],
    6867                        currentNode = fragment,
    6968                    // Indicate we're inside a <pre> element, spaces should be touched differently.
    7069                        inPre = false,
     
    7271
    7372                function checkPending( newTagName )
    7473                {
    75                         var pendingBRsSent;
    76 
    7774                        if ( pendingInline.length > 0 )
    7875                        {
    7976                                for ( var i = 0 ; i < pendingInline.length ; i++ )
     
    8582
    8683                                        if ( ( !currentDtd || currentDtd[ pendingName ] ) && ( !newTagName || !pendingDtd || pendingDtd[ newTagName ] || !CKEDITOR.dtd[ newTagName ] ) )
    8784                                        {
    88                                                 if ( !pendingBRsSent )
    89                                                 {
    90                                                         sendPendingBRs();
    91                                                         pendingBRsSent = 1;
    92                                                 }
    93 
    9485                                                // Get a clone for the pending element.
    9586                                                pendingElement = pendingElement.clone();
    9687
     
    10899                        }
    109100                }
    110101
    111                 function sendPendingBRs( brsToIgnore )
    112                 {
    113                         while ( pendingBRs.length - ( brsToIgnore || 0 ) > 0 )
    114                                 currentNode.add( pendingBRs.shift() );
    115                 }
    116 
    117102                function addElement( element, target, enforceCurrent )
    118103                {
    119104                        target = target || currentNode || fragment;
     
    195180                                return;
    196181                        }
    197182
    198                         if ( tagName == 'br' )
    199                         {
    200                                 pendingBRs.push( element );
    201                                 return;
    202                         }
    203 
    204183                        var currentName = currentNode.name;
    205184
    206185                        var currentDtd = currentName
     
    279258                        }
    280259
    281260                        checkPending( tagName );
    282                         sendPendingBRs();
    283261
    284262                        element.parent = currentNode;
    285263                        element.returnPoint = returnPoint;
     
    338316                                if ( currentNode.name == 'pre' )
    339317                                        inPre = false;
    340318
    341                                 if ( candidate._.isBlockLike )
    342                                         sendPendingBRs();
    343 
    344319                                addElement( candidate, candidate.parent );
    345320
    346321                                // The parent should start receiving new nodes now, except if
     
    366341                                        return;
    367342                        }
    368343
    369                         sendPendingBRs();
    370344                        checkPending();
    371345
    372346                        if ( fixForBody
     
    399373                // Parse it.
    400374                parser.parse( fragmentHtml );
    401375
    402                 // Send all pending BRs except one, which we consider a unwanted bogus. (#5293)
    403                 sendPendingBRs( !CKEDITOR.env.ie && 1 );
    404 
    405376                // Close all pending nodes.
    406377                while ( currentNode.type )
    407378                {
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy