Index: /CKEditor/trunk/CHANGES.html
===================================================================
--- /CKEditor/trunk/CHANGES.html	(revision 7243)
+++ /CKEditor/trunk/CHANGES.html	(revision 7244)
@@ -80,4 +80,5 @@
 		<li><a href="http://dev.ckeditor.com/ticket/7912">#7912</a> : Cursor trapped in invisible element after enter key.</li>
 		<li><a href="http://dev.ckeditor.com/ticket/7645">#7645</a> : Full list/table deletion with backspace/delete key.</li>
+		<li><a href="http://dev.ckeditor.com/ticket/8050">#8050</a> : Auto grow feature better fits with content styles.</li>
 		<li>Updated the following language files:<ul>
 			<li><a href="http://dev.ckeditor.com/ticket/8128">#8128</a> : Italian;</li>
Index: /CKEditor/trunk/_source/plugins/autogrow/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/autogrow/plugin.js	(revision 7243)
+++ /CKEditor/trunk/_source/plugins/autogrow/plugin.js	(revision 7244)
@@ -8,27 +8,43 @@
  */
 (function(){
+
+	// Actual content height, figured out by appending check the last element's document position.
+	function contentHeight( scrollable )
+	{
+		var overflowY = scrollable.getStyle( 'overflow-y' );
+
+		var doc = scrollable.getDocument();
+		// Create a temporary marker element.
+		var marker = CKEDITOR.dom.element.createFromHtml( '<span style="margin:0;padding:0;border:0;clear:both;width:1px;height:1px;display:block;">' + ( CKEDITOR.env.webkit ? '&nbsp;' : '' ) + '</span>', doc );
+		doc[ CKEDITOR.env.ie? 'getBody' : 'getDocumentElement']().append( marker );
+
+		var height = marker.getDocumentPosition( doc ).y + marker.$.offsetHeight;
+		marker.remove();
+		scrollable.setStyle( 'overflow-y', overflowY );
+		return height;
+	}
+
 	var resizeEditor = function( editor )
 	{
 		if ( !editor.window )
 			return;
+
 		var doc = editor.document,
+			iframe = new CKEDITOR.dom.element( doc.getWindow().$.frameElement ),
+			body = doc.getBody(),
+			htmlElement = doc.getDocumentElement(),
 			currentHeight = editor.window.getViewPaneSize().height,
-			newHeight;
+			// Quirks mode overflows body, standards overflows document element
+			scrollable = doc.$.compatMode == 'BackCompat' ? body : htmlElement,
+			newHeight = contentHeight( scrollable );
 
-		// We can not use documentElement to calculate the height for IE (#6061).
-		// It is not good for IE Quirks, yet using offsetHeight would also not work as expected (#6408).
-		// We do the same for FF because of the html height workaround (#6341).
-		if ( CKEDITOR.env.ie || CKEDITOR.env.gecko )
-			newHeight = doc.getBody().$.scrollHeight + ( CKEDITOR.env.ie && CKEDITOR.env.quirks ? 0 : 24 );
-		else
-			newHeight = doc.getDocumentElement().$.offsetHeight;
+		// Additional space specified by user.
+		newHeight += ( editor.config.autoGrow_bottomSpace || 0 );
 
-		var min = editor.config.autoGrow_minHeight,
-			max = editor.config.autoGrow_maxHeight;
-		( min == undefined ) && ( editor.config.autoGrow_minHeight = min = 200 );
-		if ( min )
-			newHeight = Math.max( newHeight, min );
-		if ( max )
-			newHeight = Math.min( newHeight, max );
+		var min = editor.config.autoGrow_minHeight != undefined ? editor.config.autoGrow_minHeight : 200,
+			max = editor.config.autoGrow_maxHeight || Infinity;
+
+		newHeight = Math.max( newHeight, min );
+		newHeight = Math.min( newHeight, max );
 
 		if ( newHeight != currentHeight )
@@ -37,5 +53,13 @@
 			editor.resize( editor.container.getStyle( 'width' ), newHeight, true );
 		}
+
+		if ( scrollable.$.scrollHeight > scrollable.$.clientHeight && newHeight < max )
+			scrollable.setStyle( 'overflow-y', 'hidden' );
+		else
+			scrollable.removeStyle( 'overflow-y' );
+
+
 	};
+
 	CKEDITOR.plugins.add( 'autogrow',
 	{
@@ -56,5 +80,11 @@
 						( !maximize || maximize.state != CKEDITOR.TRISTATE_ON ) )
 					{
-						setTimeout( function(){ resizeEditor( evt.editor ); }, 100 );
+						setTimeout( function()
+						{
+							resizeEditor( evt.editor );
+							// Second pass to make correction upon
+							// the first resize, e.g. scrollbar.
+							resizeEditor( evt.editor );
+						}, 100 );
 					}
 				});
@@ -101,2 +131,11 @@
  *				to determine a different height value to be used instead.
  */
+
+
+/**
+ *  Extra height in pixel to leave between the bottom boundary of content with document size when auto resizing.
+ * @name CKEDITOR.config.autoGrow_bottomSpace
+ * @type Number
+ * @default 0
+ * @since 3.6.2
+ */
