Index: /CKEditor/trunk/CHANGES.html
===================================================================
--- /CKEditor/trunk/CHANGES.html	(revision 7537)
+++ /CKEditor/trunk/CHANGES.html	(revision 7538)
@@ -75,4 +75,6 @@
 		<li><a href="http://dev.ckeditor.com/ticket/8941">#8941</a> : [Webkit] Content region disappeared when resizing the browser.</li>
 		<li><a href="http://dev.ckeditor.com/ticket/8968">#8968</a> : [Firefox] The forcePasteAsPlainText configuration is not working when using Ctrl/Cmd-V.</li>
+		<li><a href="http://dev.ckeditor.com/ticket/6217">#6217</a> : Handled DEL/BACKSPACE key at the boundary of table to unifiy the cursor position.</li>
+		<li><a href="http://dev.ckeditor.com/ticket/8950">#8950</a> : Chagend the cursor position after calling editor::insertElement on block element.</li>
 	</ul>
 	<h3>
Index: /CKEditor/trunk/_source/core/dom/element.js
===================================================================
--- /CKEditor/trunk/_source/core/dom/element.js	(revision 7537)
+++ /CKEditor/trunk/_source/core/dom/element.js	(revision 7538)
@@ -737,5 +737,6 @@
 					|| this.getComputedStyle( 'visibility' ) == 'hidden'
 				 	|| this.is( 'a' ) && this.data( 'cke-saved-name' ) && !this.getChildCount()
-					|| CKEDITOR.dtd.$nonEditable[ name ] )
+					|| CKEDITOR.dtd.$nonEditable[ name ]
+					|| CKEDITOR.dtd.$empty[ name ] )
 			{
 				return false;
Index: /CKEditor/trunk/_source/core/dom/range.js
===================================================================
--- /CKEditor/trunk/_source/core/dom/range.js	(revision 7537)
+++ /CKEditor/trunk/_source/core/dom/range.js	(revision 7538)
@@ -529,5 +529,5 @@
 			{
 				baseId = 'cke_bm_' + CKEDITOR.tools.getNextNumber();
-				startNode.setAttribute( 'id', baseId + 'S' );
+				startNode.setAttribute( 'id', baseId + ( collapsed ? 'C' : 'S' ) );
 			}
 
@@ -560,5 +560,5 @@
 
 			return {
-				startNode : serializable ? baseId + 'S' : startNode,
+				startNode : serializable ? baseId + ( collapsed ? 'C' : 'S' ) : startNode,
 				endNode : serializable ? baseId + 'E' : endNode,
 				serializable : serializable,
@@ -1956,10 +1956,6 @@
 				var next;
 
-				if ( node.type == CKEDITOR.NODE_ELEMENT
-						&& node.isEditable( false )
-						&& !CKEDITOR.dtd.$nonEditable[ node.getName() ] )
-				{
+				if ( node.type == CKEDITOR.NODE_ELEMENT && node.isEditable( false ) )
 					next = node[ isMoveToEnd ? 'getLast' : 'getFirst' ]( nonWhitespaceOrBookmarkEval );
-				}
 
 				if ( !childOnly && !next )
@@ -1967,4 +1963,13 @@
 
 				return next;
+			}
+
+			// Handle non-editable element e.g. HR.
+			if ( el.type == CKEDITOR.NODE_ELEMENT && !el.isEditable( false ) )
+			{
+				this.moveToPosition( el, isMoveToEnd ?
+										 CKEDITOR.POSITION_AFTER_END :
+										 CKEDITOR.POSITION_BEFORE_START );
+				return true;
 			}
 
Index: /CKEditor/trunk/_source/core/dom/walker.js
===================================================================
--- /CKEditor/trunk/_source/core/dom/walker.js	(revision 7537)
+++ /CKEditor/trunk/_source/core/dom/walker.js	(revision 7538)
@@ -447,5 +447,5 @@
 	};
 
-	CKEDITOR.dom.walker.bogus = function( type, isReject )
+	CKEDITOR.dom.walker.bogus = function( isReject )
 	{
 		function nonEmpty( node )
Index: /CKEditor/trunk/_source/plugins/horizontalrule/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/horizontalrule/plugin.js	(revision 7537)
+++ /CKEditor/trunk/_source/plugins/horizontalrule/plugin.js	(revision 7538)
@@ -15,17 +15,6 @@
 		exec : function( editor )
 		{
-			var hr = editor.document.createElement( 'hr' ),
-				range = new CKEDITOR.dom.range( editor.document );
-
+			var hr = editor.document.createElement( 'hr' );
 			editor.insertElement( hr );
-
-			// If there's nothing or a non-editable block followed by, establish a new paragraph
-			// to make sure cursor is not trapped.
-			range.moveToPosition( hr, CKEDITOR.POSITION_AFTER_END );
-			var next = hr.getNext();
-			if ( !next || next.type == CKEDITOR.NODE_ELEMENT && !next.isEditable() )
-				range.fixBlock( true, editor.config.enterMode == CKEDITOR.ENTER_DIV ? 'div' : 'p'  );
-
-			range.select();
 		}
 	};
Index: /CKEditor/trunk/_source/plugins/wysiwygarea/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/wysiwygarea/plugin.js	(revision 7537)
+++ /CKEditor/trunk/_source/plugins/wysiwygarea/plugin.js	(revision 7538)
@@ -14,5 +14,7 @@
 	var emptyParagraphRegexp = /(^|<body\b[^>]*>)\s*<(p|div|address|h\d|center|pre)[^>]*>\s*(?:<br[^>]*>|&nbsp;|\u00A0|&#160;)?\s*(:?<\/\2>)?\s*(?=$|<\/body>)/gi;
 
-	var notWhitespaceEval = CKEDITOR.dom.walker.whitespaces( true );
+	var notWhitespaceEval = CKEDITOR.dom.walker.whitespaces( true ),
+	  notBogus = CKEDITOR.dom.walker.bogus( true ),
+	  notEmpty = function( node ) { return notWhitespaceEval( node ) && notBogus( node ); };
 
 	// Elements that could blink the cursor anchoring beside it, like hr, page-break. (#6554)
@@ -268,14 +270,26 @@
 				range.moveToPosition( lastElement, CKEDITOR.POSITION_AFTER_END );
 
-				// If we're inserting a block element immediatelly followed by
-				// another block element, the selection must move there. (#3100,#5436)
+				// If we're inserting a block element immediately followed by
+				// another block element, the selection must be optimized. (#3100,#5436,#8950)
 				if ( isBlock )
 				{
-					var next = lastElement.getNext( notWhitespaceEval ),
+					var next = lastElement.getNext( notEmpty ),
 						nextName = next && next.type == CKEDITOR.NODE_ELEMENT && next.getName();
 
-					// Check if it's a block element that accepts text.
-					if ( nextName && CKEDITOR.dtd.$block[ nextName ] && CKEDITOR.dtd[ nextName ]['#'] )
+					// If the next one is a text block, move cursor to the start of it's content.
+					if ( nextName && CKEDITOR.dtd.$block[ nextName ] )
+					{
+						if ( CKEDITOR.dtd[ nextName ][ '#' ] )
+							range.moveToElementEditStart( next );
+						// Otherwise move cursor to the before end of the last element.
+						else
+							range.moveToElementEditEnd( lastElement );
+					}
+					// Open a new line if the block is inserted at the end of parent.
+					else if ( !next )
+					{
+						next = range.fixBlock( true, this.config.enterMode == CKEDITOR.ENTER_DIV ? 'div' : 'p' );
 						range.moveToElementEditStart( next );
+					}
 				}
 			}
