Index: CKEditor/trunk/CHANGES.html
===================================================================
--- CKEditor/trunk/CHANGES.html	(revision 6005)
+++ CKEditor/trunk/CHANGES.html	(revision 6007)
@@ -91,5 +91,4 @@
 		<li><a href="http://dev.ckeditor.com/ticket/6508">#6508</a> : BiDi: Margin mirroring logic doesn't honor CSS direction.</li>
 		<li><a href="http://dev.ckeditor.com/ticket/6043">#6043</a> : BIDI: When we apply RTL direction to a right aligned Paragraph, Paragraph is not moved to left & Alignment of Paragraph is not changed.</li>
-		<li><a href="http://dev.ckeditor.com/ticket/6485">#6485</a> : BIDI: When direction is applied on partial selected list, the style is been incorrectly applied on the entired list.</li>
 		<li><a href="http://dev.ckeditor.com/ticket/6087">#6087</a> : Cursor of input fields in dialog isn't visible in RLT .</li>
 		<li><a href="http://dev.ckeditor.com/ticket/5595">#5595</a> : Extra leading spaces added in preformatted block.</li>
Index: CKEditor/trunk/_source/core/dom/rangelist.js
===================================================================
--- CKEditor/trunk/_source/core/dom/rangelist.js	(revision 6005)
+++ CKEditor/trunk/_source/core/dom/rangelist.js	(revision 6007)
@@ -1,3 +1,3 @@
-/*
+﻿/*
 Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
 For licensing, see LICENSE.html or http://ckeditor.com/license
@@ -40,8 +40,5 @@
 			{
 				var rangeList = this,
-					bookmark = CKEDITOR.dom.walker.bookmark(),
-					emptySpaces = CKEDITOR.dom.walker.whitespaces(),
-					guard = function( node ) { return ! ( node.is && node.is( 'tr' ) ); },
-						bookmarks = [],
+					bookmarks = [],
 					current;
 
@@ -53,7 +50,6 @@
 					/**
 					 * Retrieves the next range in the list.
-					 * @param {Boolean} mergeConsequent Whether join two adjacent ranges into single, e.g. consequent table cells.
 					 */
-					getNextRange : function( mergeConsequent )
+					getNextRange : function()
 					{
 						current = current == undefined ? 0 : current + 1;
@@ -70,56 +66,9 @@
 							{
 								// Make sure bookmark correctness by reverse processing.
-								for ( var i = rangeList.length - 1; i >= 0; i-- )
+								for ( var i = rangeList.length - 1; i > 0; i-- )
 									bookmarks.unshift( rangeList[ i ].createBookmark( true ) );
 							}
-
-							if ( mergeConsequent )
-							{
-								// Figure out how many ranges should be merged.
-								var mergeCount = 0;
-								while ( rangeList[ current + mergeCount + 1 ] )
-								{
-									var doc = range.document,
-										found = 0,
-										left =  doc.getById( bookmarks[ mergeCount ].endNode ),
-										right = doc.getById( bookmarks[ mergeCount + 1 ].startNode ),
-										next;
-
-									// Check subsequent range.
-									while ( 1 )
-									{
-										next = left.getNextSourceNode( false );
-										if ( !right.equals( next ) )
-										{
-											// This could be yet another bookmark or
-											// walking across block boundaries.
-											if ( bookmark( next ) || ( next.type == CKEDITOR.NODE_ELEMENT && next.isBlockBoundary() ) )
-											{
-												left = next;
-												continue;
-											}
-										}
-										else
-											found = 1;
-
-										break;
-									}
-
-									if ( !found )
-										break;
-
-									mergeCount++;
-								}
-							}
-
-							range.moveToBookmark( bookmarks.shift() );
-							
-							// Merge ranges finally after moving to bookmarks.
-							while( mergeCount-- )
-							{
-								var next = rangeList[ ++current ];
-								next.moveToBookmark( bookmarks.shift() );
-								range.setEnd( next.endContainer, next.endOffset );
-							}
+							else
+								range.moveToBookmark( bookmarks.shift() );
 						}
 
Index: CKEditor/trunk/_source/core/dom/walker.js
===================================================================
--- CKEditor/trunk/_source/core/dom/walker.js	(revision 6005)
+++ CKEditor/trunk/_source/core/dom/walker.js	(revision 6007)
@@ -1,3 +1,3 @@
-/*
+﻿/*
 Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
 For licensing, see LICENSE.html or http://ckeditor.com/license
@@ -386,5 +386,5 @@
 			// Is bookmark node?
 			isBookmark = contentOnly ? isBookmark : isBookmark || isBookmarkNode( node );
-			return !! ( isReject ^ isBookmark );
+			return isReject ^ isBookmark;
 		};
 	};
@@ -400,5 +400,5 @@
 			var isWhitespace = node && ( node.type == CKEDITOR.NODE_TEXT )
 							&& !CKEDITOR.tools.trim( node.getText() );
-			return !! ( isReject ^ isWhitespace );
+			return isReject ^ isWhitespace;
 		};
 	};
@@ -419,5 +419,5 @@
 			// all sorts of empty paragraph, e.g. <br />.
 			var isInvisible = whitespace( node ) || node.is && !node.$.offsetHeight;
-			return !! ( isReject ^ isInvisible );
+			return isReject ^ isInvisible;
 		};
 	};
Index: CKEditor/trunk/_source/plugins/bidi/plugin.js
===================================================================
--- CKEditor/trunk/_source/plugins/bidi/plugin.js	(revision 6005)
+++ CKEditor/trunk/_source/plugins/bidi/plugin.js	(revision 6007)
@@ -1,3 +1,3 @@
-/*
+﻿/*
 Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
 For licensing, see LICENSE.html or http://ckeditor.com/license
@@ -6,9 +6,9 @@
 (function()
 {
-	var guardElements = { table:1, tbody: 1, tr:1, ul:1, ol:1, blockquote:1, div:1 },
+	var guardElements = { table:1, ul:1, ol:1, blockquote:1, div:1 },
 		directSelectionGuardElements = {},
 		// All guard elements which can have a direction applied on them.
 		allGuardElements = {};
-	CKEDITOR.tools.extend( directSelectionGuardElements, guardElements, { p:1, div:1, li:1 } );
+	CKEDITOR.tools.extend( directSelectionGuardElements, guardElements, { tr:1, p:1, div:1, li:1 } );
 	CKEDITOR.tools.extend( allGuardElements, directSelectionGuardElements, { td:1 } );
 
@@ -131,7 +131,16 @@
 	}
 
-	function getFullySelected( range, elements )
-	{
-		var ancestor = range.getCommonAncestor( false, true );
+	function getFullySelected( selection, elements )
+	{
+		var ancestor = selection.getCommonAncestor();
+		if ( ancestor.type != CKEDITOR.NODE_ELEMENT )
+			return;
+
+		var ranges = selection.getRanges();
+
+		// Join multiple ranges.
+		var range = new CKEDITOR.dom.range( selection.document );
+		range.setStart( ranges[ 0 ].startContainer, ranges[ 0 ].startOffset );
+		range.setEnd( ranges[ ranges.length - 1 ].endContainer, ranges[ ranges.length - 1 ].endOffset );
 
 		range.enlarge( CKEDITOR.ENLARGE_BLOCK_CONTENTS );
@@ -140,11 +149,9 @@
 				&& range.checkBoundaryOfElement( ancestor, CKEDITOR.END ) )
 		{
-			var parent;
-			while ( ancestor && ancestor.type == CKEDITOR.NODE_ELEMENT
-					&& ( parent = ancestor.getParent() )
-					&& parent.getChildCount() == 1
-					&& ( !( ancestor.getName() in elements ) || ( parent.getName() in elements ) )
+			while ( ancestor.type == CKEDITOR.NODE_ELEMENT
+					&& !( ancestor.getName() in elements )
+					&& ancestor.getParent().getChildCount() == 1
 					)
-				ancestor = parent;
+				ancestor = ancestor.getParent();
 
 			return ancestor.type == CKEDITOR.NODE_ELEMENT
@@ -165,45 +172,36 @@
 			{
 				var database = {};
-
+				// Apply do directly selected elements from guardElements.
+				var selectedElement = ranges[ 0 ].getEnclosedNode();
+
+				// If this is not our element of interest, apply to fully selected elements from guardElements.
+				if ( !selectedElement || selectedElement
+						&& !( selectedElement.type == CKEDITOR.NODE_ELEMENT && selectedElement.getName() in directSelectionGuardElements )
+					)
+					selectedElement = getFullySelected( selection, guardElements );
+
+				if ( selectedElement && !selectedElement.isReadOnly() )
+					switchDir( selectedElement, dir, editor, database );
+				
 				// Creates bookmarks for selection, as we may split some blocks.
 				var bookmarks = selection.createBookmarks();
 
-				var rangeIterator = ranges.createIterator(),
-					range,
-					i = 0;
-
-				while ( ( range = rangeIterator.getNextRange( 1 ) ) )
+				var iterator,
+					block;
+
+				for ( var i = ranges.length - 1 ; i >= 0 ; i-- )
 				{
-					// Apply do directly selected elements from guardElements.
-					var selectedElement = range.getEnclosedNode();
-
-					// If this is not our element of interest, apply to fully selected elements from guardElements.
-					if ( !selectedElement || selectedElement
-							&& !( selectedElement.type == CKEDITOR.NODE_ELEMENT && selectedElement.getName() in directSelectionGuardElements )
-						)
-						selectedElement = getFullySelected( range, guardElements );
-
-					if ( selectedElement && !selectedElement.isReadOnly() )
-						switchDir( selectedElement, dir, editor, database );
-
-					var iterator,
-						block;
-
+					// Array of elements processed as guardElements.
+					var processedElements = [];
 					// Walker searching for guardElements.
-					var walker = new CKEDITOR.dom.walker( range );
-
-					var start = bookmarks[ i ].startNode,
-						end = bookmarks[ i++ ].endNode;
-
+					var walker = new CKEDITOR.dom.walker( ranges[ i ] );
 					walker.evaluator = function( node )
 					{
-						return !! ( node.type == CKEDITOR.NODE_ELEMENT
-								&& node.getName() in guardElements
-								&& !( node.getName() == ( enterMode == CKEDITOR.ENTER_P ) ? 'p' : 'div'
-									&& node.getParent().type == CKEDITOR.NODE_ELEMENT
-									&& node.getParent().getName() == 'blockquote' )
-								// Element must be fully included in the range as well. (#6485).
-								&& node.getPosition( start ) & CKEDITOR.POSITION_FOLLOWING
-								&& ( ( node.getPosition( end ) & CKEDITOR.POSITION_PRECEDING + CKEDITOR.POSITION_CONTAINS ) == CKEDITOR.POSITION_PRECEDING ) );
+						return node.type == CKEDITOR.NODE_ELEMENT
+							&& node.getName() in guardElements
+							&& !( node.getName() == ( enterMode == CKEDITOR.ENTER_P ) ? 'p' : 'div'
+								&& node.getParent().type == CKEDITOR.NODE_ELEMENT
+								&& node.getParent().getName() == 'blockquote'
+							);
 					};
 
@@ -211,16 +209,16 @@
 						switchDir( block, dir, editor, database );
 
-					iterator = range.createIterator();
+					iterator = ranges[ i ].createIterator();
 					iterator.enlargeBr = enterMode != CKEDITOR.ENTER_BR;
 
 					while ( ( block = iterator.getNextParagraph( enterMode == CKEDITOR.ENTER_P ? 'p' : 'div' ) ) )
 						!block.isReadOnly() && switchDir( block, dir, editor, database );
+
+					CKEDITOR.dom.element.clearAllMarkers( database );
+
+					editor.forceNextSelectionCheck();
+					// Restore selection position.
+					selection.selectBookmarks( bookmarks );
 				}
-
-				CKEDITOR.dom.element.clearAllMarkers( database );
-
-				editor.forceNextSelectionCheck();
-				// Restore selection position.
-				selection.selectBookmarks( bookmarks );
 
 				editor.focus();
Index: CKEditor/trunk/_source/plugins/domiterator/plugin.js
===================================================================
--- CKEditor/trunk/_source/plugins/domiterator/plugin.js	(revision 6005)
+++ CKEditor/trunk/_source/plugins/domiterator/plugin.js	(revision 6007)
@@ -1,3 +1,3 @@
-/*
+﻿/*
 Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
 For licensing, see LICENSE.html or http://ckeditor.com/license
@@ -66,5 +66,5 @@
 
 				var walker = new CKEDITOR.dom.walker( range ),
-					ignoreBookmarkTextEvaluator = CKEDITOR.dom.walker.bookmark( false, true );
+					ignoreBookmarkTextEvaluator = CKEDITOR.dom.walker.bookmark( true, true );
 				// Avoid anchor inside bookmark inner text.
 				walker.evaluator = ignoreBookmarkTextEvaluator;
