Index: /CKEditor/trunk/_source/plugins/styles/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/styles/plugin.js	(revision 5264)
+++ /CKEditor/trunk/_source/plugins/styles/plugin.js	(revision 5265)
@@ -1,3 +1,3 @@
-/*
+﻿/*
 Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
 For licensing, see LICENSE.html or http://ckeditor.com/license
@@ -252,7 +252,7 @@
 
 						var elementAttr = element.getAttribute( attName ) || '';
-						if ( attribs[ attName ] ==
-							 ( attName == 'style' ?
-							   normalizeCssText( elementAttr, false ) : elementAttr  ) )
+						if ( attName == 'style' ?
+							compareCssText( attribs[ attName ], normalizeCssText( elementAttr, false ) ) 
+							: attribs[ attName ] == elementAttr  )
 						{
 							if ( !fullMatch )
@@ -1231,4 +1231,36 @@
 							 .toLowerCase();
 	}
+	
+	// Turn inline style text properties into one hash.
+	function parseStyleText( styleText )
+	{
+		var retval = {};
+		styleText
+		   .replace( /&quot;/g, '"' )
+		   .replace( /\s*([^ :;]+)\s*:\s*([^;]+)\s*(?=;|$)/g, function( match, name, value )
+		{
+			retval[ name ] = value;
+		} );
+		return retval;
+	}
+
+	function compareCssText( source, target )
+	{
+		typeof source == 'string' && ( source = parseStyleText( source ) );
+		typeof target == 'string' && ( target = parseStyleText( target ) );
+		for( var name in source )
+		{
+			// Value 'inheirt'  is treated as a wildcard,
+			// which will matches any value.   
+			if ( !( name in target &&
+					( target[ name ] == source[ name ]
+						|| source[ name ] == 'inherit'
+						|| target[ name ] == 'inherit' ) ) )
+			{
+				return false;
+			}
+		}
+		return true;
+	}
 
 	function applyStyle( document, remove )
Index: /CKEditor/trunk/_source/plugins/colorbutton/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/colorbutton/plugin.js	(revision 5264)
+++ /CKEditor/trunk/_source/plugins/colorbutton/plugin.js	(revision 5265)
@@ -87,5 +87,5 @@
 					panel.hide();
 
-					var style = new CKEDITOR.style( config['colorButton_' + type + 'Style'], color && { color : color } );
+					var style = new CKEDITOR.style( config['colorButton_' + type + 'Style'], { color : color || 'inherit' } );
 
 					editor.fire( 'saveSnapshot' );
Index: /CKEditor/trunk/CHANGES.html
===================================================================
--- /CKEditor/trunk/CHANGES.html	(revision 5264)
+++ /CKEditor/trunk/CHANGES.html	(revision 5265)
@@ -83,4 +83,5 @@
 		<li><a href="http://dev.fckeditor.net/ticket/3576">#3576</a> : Non-attributed element of the same name with the applied style is correctly removed.</li>
 		<li><a href="http://dev.fckeditor.net/ticket/5221">#5221</a> : Insert table into empty document cause JavaScript error thrown.</li>
+		<li><a href="http://dev.fckeditor.net/ticket/5242">#5242</a> : Apply 'automatic' color option of text color incorrectly removes background-color style.</li>
 	</ul>
 	<h3>
