Index: /FCKeditor/trunk/editor/_source/classes/fckstyle.js
===================================================================
--- /FCKeditor/trunk/editor/_source/classes/fckstyle.js	(revision 848)
+++ /FCKeditor/trunk/editor/_source/classes/fckstyle.js	(revision 849)
@@ -99,5 +99,5 @@
 		// ApplyToRange is not valid for FCK_STYLE_OBJECT types.
 		// Use ApplyToObject instead.
-		
+
 		switch ( this.GetType() )
 		{
@@ -114,5 +114,5 @@
 		this.ApplyToRange( range, selectIt ) ;
 	},
-	
+
 	/**
 	 * Apply the style to an object. Valid for FCK_STYLE_BLOCK types only.
@@ -122,5 +122,5 @@
 		if ( !objectElement )
 			return ;
-		
+
 		this.BuildElement( null, objectElement ) ;
 	},
@@ -144,9 +144,5 @@
 	RemoveFromRange : function( range, selectIt )
 	{
-		if ( range.CheckIsCollapsed() )
-			return ;
-
-		// Expand the range, if inside inline element boundaries.
-		range.Expand( 'inline_elements' ) ;
+		var bookmark ;
 
 		// Create the attribute list to be used later for element comparisons.
@@ -154,5 +150,54 @@
 		var styleOverrides = this._GetOverridesForComparison() ;
 
-		// Get the bookmark nodes.
+		// If collapsed, we are removing all conflicting styles from the range
+		// parent tree.
+		if ( range.CheckIsCollapsed() )
+		{
+			// Bookmark the range so we can re-select it after processing.
+			var bookmark = range.CreateBookmark( true ) ;
+
+			var path = new FCKElementPath( range.StartNode || range.StartContainer ) ;
+
+			for ( var i = 0 ; i < path.Elements.length ; i++ )
+			{
+				var pathElement = path.Elements[i] ;
+				if ( this.CheckElementRemovable( pathElement ) )
+				{
+					var pathElementName = pathElement.nodeName.toLowerCase() ;
+
+					if ( pathElementName == this.Element )
+					{
+						// Remove any attribute that conflict with this style, no
+						// matter their values.
+						for ( var att in styleAttribs )
+						{
+							if ( FCKDomTools.HasAttribute( pathElement, att ) )
+							{
+								if ( att == 'style' )
+									this._RemoveStylesFromElement( pathElement ) ;
+								else
+									FCKDomTools.RemoveAttribute( pathElement, att ) ;
+							}
+						}
+					}
+
+					// Remove overrides defined to the same element name.
+					this._RemoveOverrides( pathElement, styleOverrides[ pathElementName ] ) ;
+
+					// Remove the element if no more attributes are available.
+					this._RemoveNoAttribElement( pathElement ) ;
+				}
+			}
+
+				// Re-select the original range.
+			if ( selectIt )
+				range.SelectBookmark( bookmark ) ;
+
+			return ;
+		}
+
+		// Expand the range, if inside inline element boundaries.
+		range.Expand( 'inline_elements' ) ;
+
 		// Bookmark the range so we can re-select it after processing.
 		var bookmark = range.CreateBookmark( true ) ;
@@ -424,21 +469,21 @@
 		}
 	},
-	
+
 	_RemoveStylesFromElement : function( element )
 	{
 		var elementStyle = element.style.cssText ;
 		var pattern = this.GetFinalStyleValue() ;
-		
+
 		if ( elementStyle.length > 0 && pattern.length == 0 )
 			return ;
-			
-		pattern = '(^|;)\\s*(' + 
+
+		pattern = '(^|;)\\s*(' +
 			pattern.replace( /\s*([^ ]+):.*?(;|$)/g, '$1|' ).replace( /\|$/, '' ) +
 			'):[^;]+' ;
-			
+
 		var regex = new RegExp( pattern, 'gi' ) ;
-		
+
 		elementStyle = elementStyle.replace( regex, '' ).Trim() ;
-		
+
 		if ( elementStyle.length == 0 || elementStyle == ';' )
 			FCKDomTools.RemoveAttribute( element, 'style' ) ;
@@ -533,5 +578,5 @@
 		return el ;
 	},
-	
+
 	_CompareAttributeValues : function( attName, valueA, valueB )
 	{
@@ -541,5 +586,5 @@
 			valueB = valueB.replace( /;$/, '' ).toLowerCase() ;
 		}
-		
+
 		return ( valueA == valueB )
 	},
@@ -549,5 +594,5 @@
 		var attValue = this._StyleDesc.Attributes ;
 		var attValue = attValue ? attValue[ attName ] : null ;
-		
+
 		if ( !attValue && attName == 'style' )
 			return this.GetFinalStyleValue() ;
@@ -568,7 +613,7 @@
 			// Using custom Replace() to guarantee the correct scope.
 			attValue = attValue.Replace( FCKRegexLib.StyleVariableAttName, this._GetVariableReplace, this ) ;
-			attValue = FCKTools.NormalizeCssText( attValue ) ;			
-		}
-		
+			attValue = FCKTools.NormalizeCssText( attValue ) ;
+		}
+
 		return attValue ;
 	},
@@ -605,5 +650,5 @@
 		// Bookmark the range so we can re-select it after processing.
 		var bookmark ;
-		
+
 		if ( selectIt )
 			bookmark = range.CreateBookmark( true ) ;
@@ -611,5 +656,5 @@
 		var iterator = new FCKDomRangeIterator( range ) ;
 		iterator.EnforceRealBlocks = true ;
-		
+
 		var block ;
 		while( ( block = iterator.GetNextParagraph() ) )		// Only one =
@@ -692,9 +737,9 @@
 			// tag exists and has contents, replace it with the real element.
 			// range.Window.document.execCommand( 'FontName', false, '__FCKeditorTemp' ) ;
-			
+
 			// For now, we do nothing for collapsed selections.
 			return ;
 		}
-		
+
 		var elementName = this.Element ;
 
@@ -839,5 +884,5 @@
 			range.SelectBookmark( bookmark ) ;
 	},
-	
+
 	_FixBookmarkStart : function( startNode )
 	{
@@ -968,5 +1013,5 @@
 		// Builds the StyleText.
 		var stylesText = ( this._StyleDesc.Attributes ? this._StyleDesc.Attributes['style'] || '' : '' ) ;
-		
+
 		if ( stylesText.length > 0 )
 			stylesText += ';' ;
@@ -982,5 +1027,5 @@
 			stylesText = FCKTools.NormalizeCssText( stylesText ) ;
 		}
-		
+
 		return (this._GetStyleText = function() { return stylesText ; })() ;
 	},
