Index: /CKEditor/trunk/_source/plugins/domiterator/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/domiterator/plugin.js	(revision 3453)
+++ /CKEditor/trunk/_source/plugins/domiterator/plugin.js	(revision 3454)
@@ -12,49 +12,22 @@
 (function()
 {
-	// Functions ported over from v2.
-	function getTouchedStartNode( range )
+	
+	/**
+	 * Find next source order node, ignore bookmark nodes and stop at the specified end node.
+	 * @param {Object} currentNode 
+	 * @param {Object} endNode
+	 */
+	function getNextSourceNode( currentNode, endNode, startFromSibling )
 	{
-		var container = range.startContainer;
-
-		if ( range.collapsed || container.type != CKEDITOR.NODE_ELEMENT )
-			return container;
-
-		return container.getChildCount() > range.startOffset ? container.getChild( range.startOffset ) : container;
-	}
-
-	function getTouchedEndNode( range )
-	{
-		var container = range.endContainer;
-
-		if ( range.collapsed || container.type != CKEDITOR.NODE_ELEMENT )
-			return container;
-
-		return container.getChildCount() > range.endOffset ? container.getChild( range.endOffset ) : container;
-	}
-
-	function getNextSourceNode( currentNode, startFromSibling, nodeType, stopSearchNode )
-	{
-		if ( !currentNode )
-			return null;
-
-		var node;
-
-		if ( !startFromSibling && currentNode.getFirst && currentNode.getFirst() )
-			node = currentNode.getFirst();
-		else
+		var next = currentNode;
+		do
 		{
-			if ( stopSearchNode && currentNode.equals( stopSearchNode ) )
-				return null;
-
-			node = currentNode.getNext();
-
-			if ( !node && ( !stopSearchNode || !stopSearchNode.equals( currentNode.parentNode ) ) )
-				return getNextSourceNode( currentNode.getParent(), true, nodeType, stopSearchNode );
+			next = next.getNextSourceNode( 
+				startFromSibling, null, endNode );
 		}
-
-		if ( nodeType && node && node.type != nodeType )
-			return getNextSourceNode( node, false, nodeType, stopSearchNode );
-
-		return node;
+		while( next && next.getName 
+					&& next.getName() == 'span' 
+					&& next.getAttribute( '_fck_bookmark' ) )
+		return next;
 	}
 
@@ -93,7 +66,14 @@
 				range = this.range.clone();
 				range.enlarge( this.forceBrBreak ? CKEDITOR.ENLARGE_LIST_ITEM_CONTENTS : CKEDITOR.ENLARGE_BLOCK_CONTENTS );
-
-				this._.nextNode = getTouchedStartNode( range );
-				this._.lastNode = getTouchedEndNode( range );
+				
+				var boundary = range.getBoundaryNodes();
+				this._.nextNode = boundary.startNode;
+				this._.lastNode = boundary.endNode.getNextSourceNode( true );
+				// Probably the document end is reached, we need a marker node.  
+				if ( !this._.lastNode )
+				{
+						this._.lastNode = range.document.createText( '' );
+						this._.lastNode.insertAfter(  boundary.endNode );
+				}
 
 				// Let's reuse this variable.
@@ -232,6 +212,6 @@
 				if ( isLast )
 					break;
-
-				currentNode = getNextSourceNode( currentNode, continueFromSibling, null, lastNode );
+				
+				currentNode = getNextSourceNode( currentNode, lastNode, continueFromSibling );
 			}
 
@@ -304,5 +284,5 @@
 
 					this._.nextNode = ( block.equals( lastNode ) ? null :
-							getNextSourceNode( range.getBoundaryNodes().endNode, true, null, lastNode ) );
+						getNextSourceNode( range.getBoundaryNodes().endNode, lastNode, true ) );
 				}
 			}
@@ -335,5 +315,6 @@
 			// next interation.
 			if ( !this._.nextNode )
-				this._.nextNode = ( isLast || block.equals( lastNode ) ) ? null : getNextSourceNode( block, true, null, lastNode );
+				this._.nextNode = ( isLast || block.equals( lastNode ) ) ? null : 
+					getNextSourceNode( block, lastNode, true );
 
 			return block;
