Index: /CKEditor/trunk/CHANGES.html
===================================================================
--- /CKEditor/trunk/CHANGES.html	(revision 5388)
+++ /CKEditor/trunk/CHANGES.html	(revision 5389)
@@ -148,4 +148,5 @@
 		<li><a href="http://dev.fckeditor.net/ticket/5505">#5505</a> : Image dialog throw JavaScript error when click close dialog before preview area is loading.</li>
 		<li><a href="http://dev.fckeditor.net/ticket/5144">#5144</a> : [Chrome] Paste in webkit somtimes leaves extra 'div' element.</li>
+		<li><a href="http://dev.fckeditor.net/ticket/5021">#5021</a> : [Firefox] Typing in empty document start from second line in enterMode=BR.</li>
 		<li>Updated the following language files:<ul>
 			<li><a href="http://dev.fckeditor.net/ticket/5326">#5326</a> : Catalan;</li>
Index: /CKEditor/trunk/_source/plugins/wysiwygarea/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/wysiwygarea/plugin.js	(revision 5388)
+++ /CKEditor/trunk/_source/plugins/wysiwygarea/plugin.js	(revision 5389)
@@ -375,5 +375,30 @@
 						}
 						else
+						{
+							// Gecko need a key event to 'wake up' the editing
+							// ability when document is empty.(#3864)
+							if ( CKEDITOR.env.gecko && !body.childNodes.length )
+							{
+								setTimeout( function()
+								{
+									restoreDirty( editor );
+
+									// Simulating keyboard character input by dispatching a keydown of white-space text.
+									var keyEventSimulate = domDocument.$.createEvent( "KeyEvents" );
+									keyEventSimulate.initKeyEvent( 'keypress', true, true, domWindow.$, false,
+										false, false, false, 0, 32 );
+									domDocument.$.dispatchEvent( keyEventSimulate );
+
+									// Restore the original document status by placing the cursor before a bogus br created (#5021).
+									domDocument.createElement( 'br', { attributes: { '_moz_editor_bogus_node' : 'TRUE', '_moz_dirty' : "" } } )
+										.replace( domDocument.getBody().getFirst() );
+									var nativeRange = new CKEDITOR.dom.range( domDocument );
+									nativeRange.setStartAt( new CKEDITOR.dom.element( body ) , CKEDITOR.POSITION_AFTER_START );
+									nativeRange.select();
+								}, 0 );
+							}
+
 							domDocument.designMode = 'on';
+						}
 
 						// IE, Opera and Safari may not support it and throw
@@ -440,31 +465,4 @@
 						focusTarget.on( 'focus', function()
 							{
-								// Gecko need a key event to 'wake up' the editing
-								// ability when document is empty.(#3864)
-								if ( CKEDITOR.env.gecko )
-								{
-									var first = body;
-									while ( first.firstChild )
-										first = first.firstChild;
-
-									if ( !first.nextSibling
-										&& ( 'BR' == first.tagName )
-										&& first.hasAttribute( '_moz_editor_bogus_node' ) )
-									{
-										restoreDirty( editor );
-										var keyEventSimulate = domDocument.$.createEvent( "KeyEvents" );
-										keyEventSimulate.initKeyEvent( 'keypress', true, true, domWindow.$, false,
-											false, false, false, 0, 32 );
-										domDocument.$.dispatchEvent( keyEventSimulate );
-										var bogusText = domDocument.getBody().getFirst() ;
-										// Compensate the line maintaining <br> if enterMode is not block.
-										if ( editor.config.enterMode == CKEDITOR.ENTER_BR )
-											domDocument.createElement( 'br', { attributes: { '_moz_dirty' : "" } } )
-												.replace( bogusText );
-										else
-											bogusText.remove();
-									}
-								}
-
 								editor.focusManager.focus();
 							});
