Ticket #5614: 5614.patch
| File 5614.patch, 5.2 KB (added by , 16 years ago) |
|---|
-
_source/core/dom/text.js
119 119 return this.$.nodeValue.substr( indexA ); 120 120 else 121 121 return this.$.nodeValue.substring( indexA, indexB ); 122 }, 123 124 /** 125 * Whether the text node contains only empty-space AND has no visual impacts. 126 */ 127 isEmptySpaces : function() 128 { 129 return !( CKEDITOR.tools.trim( this.getText() ) 130 || this.getAscendant( 'pre' ) ); 122 131 } 123 132 }); -
_source/core/dom/node.js
209 209 { 210 210 for ( var i = 0 ; i < parentNode.childNodes.length ; i++ ) 211 211 { 212 var candidate = parentNode.childNodes[i];212 var candidate = new CKEDITOR.dom.node( parentNode.childNodes[ i ] ); 213 213 214 if ( candidate.type == CKEDITOR.NODE_TEXT 215 && candidate.isEmptySpaces() ) 216 { 217 continue; 218 } 219 214 220 if ( normalized && 215 candidate. nodeType == 3&&216 candidate. previousSibling&&217 candidate. previousSibling.nodeType == 3)221 candidate.type == CKEDITOR.NODE_TEXT && 222 candidate.getPrevious() && 223 candidate.getPrevious().type == CKEDITOR.NODE_TEXT ) 218 224 { 219 225 continue; 220 226 } 221 227 222 228 currentIndex++; 223 229 224 if ( candidate == node )230 if ( candidate.$ == node ) 225 231 break; 226 232 } 227 233 -
_source/core/dom/range.js
500 500 startOffset += previous.getLength(); 501 501 } 502 502 503 // Exclude empty-spaces-only nodes from start. (#5614) 504 var previousOffset = startOffset - 1; 505 while ( startContainer.type == CKEDITOR.NODE_ELEMENT 506 && previousOffset >= 0 ) 507 { 508 var child = startContainer.getChild( previousOffset-- ); 509 if ( child.type == CKEDITOR.NODE_TEXT 510 && child.isEmptySpaces() ) 511 startOffset--; 512 } 513 503 514 // Process the end only if not normalized. 504 515 if ( !this.isCollapsed ) 505 516 { … … 527 538 endContainer = previous; 528 539 endOffset += previous.getLength(); 529 540 } 530 } 531 } 541 542 // Exclude empty-spaces-only nodes from end. (#5614) 543 previousOffset = endOffset - 1; 544 while ( endContainer.type == CKEDITOR.NODE_ELEMENT 545 && previousOffset >= 0 ) 546 { 547 child = endContainer.getChild( previousOffset-- ); 548 if ( child.type == CKEDITOR.NODE_TEXT 549 && child.isEmptySpaces() ) 550 endOffset--; 551 } 552 } 553 } 532 554 533 555 return { 534 556 start : startContainer.getAddress( normalized ), … … 552 574 var endContainer = bookmark.end && this.document.getByAddress( bookmark.end, bookmark.normalized ), 553 575 endOffset = bookmark.endOffset; 554 576 577 if ( startContainer.type == CKEDITOR.NODE_ELEMENT ) 578 { 579 var children = startContainer.getChildren(); 580 for ( var i = 0, count = children.count(); i < count ; i++ ) 581 { 582 var child = children.getItem( i ); 583 if ( child.type == CKEDITOR.NODE_TEXT 584 && child.isEmptySpaces() ) 585 { 586 startOffset--; 587 } 588 } 589 } 590 555 591 // Set the start boundary. 556 592 this.setStart( startContainer, startOffset ); 557 593 558 594 // Set the end boundary. If not available, collapse it. 559 595 if ( endContainer ) 596 { 597 if ( endContainer.type == CKEDITOR.NODE_ELEMENT ) 598 { 599 children = endContainer.getChildren(); 600 for ( i = 0, count = children.count(); i < count ; i++ ) 601 { 602 child = children.getItem( i ); 603 if ( child.type == CKEDITOR.NODE_TEXT 604 && child.isEmptySpaces() ) 605 { 606 endOffset--; 607 } 608 } 609 } 610 560 611 this.setEnd( endContainer, endOffset ); 612 } 561 613 else 614 { 562 615 this.collapse( true ); 563 } 616 } 617 } 564 618 else // Created with createBookmark(). 565 619 { 566 620 var serializable = bookmark.serializable, -
_source/core/dom/document.js
125 125 126 126 for (var j = 0 ; j < $.childNodes.length ; j++ ) 127 127 { 128 var candidate = $.childNodes[ j ];128 var candidate = new CKEDITOR.dom.node( $.childNodes[ j ] ); 129 129 130 130 if ( normalized === true && 131 candidate. nodeType == 3&&132 candidate. previousSibling&&133 candidate. previousSibling.nodeType == 3)131 candidate.type == CKEDITOR.NODE_TEXT && 132 candidate.getPrevious() && 133 candidate.getPrevious().type == CKEDITOR.NODE_TEXT ) 134 134 { 135 135 continue; 136 136 } 137 137 138 if ( candidate.type == CKEDITOR.NODE_TEXT 139 && candidate.isEmptySpaces() ) 140 { 141 continue; 142 } 143 138 144 currentIndex++; 139 145 140 146 if ( currentIndex == target ) 141 147 { 142 $ = candidate ;148 $ = candidate.$; 143 149 break; 144 150 } 145 151 }
