Index: /CKEditor/trunk/CHANGES.html
===================================================================
--- /CKEditor/trunk/CHANGES.html	(revision 6477)
+++ /CKEditor/trunk/CHANGES.html	(revision 6478)
@@ -63,4 +63,5 @@
 		<li><a href="http://dev.ckeditor.com/ticket/6984">#6984</a> : [FF] Tailing line breaks are lost in enter mode BR.</li>
 		<li><a href="http://dev.ckeditor.com/ticket/6987">#6987</a> : [IE] Text selection lost when calling editor::insertHtml from dialog in some situation.</li>
+		<li><a href="http://dev.ckeditor.com/ticket/6865">#6865</a> : BiDi mirroring doesn't work when a text direction change is done through dialog.</li>
 		<li>Updated the following language files:<ul>
 			<li><a href="http://dev.ckeditor.com/ticket/7124">#7124</a> : Czech;</li>
Index: /CKEditor/trunk/_source/plugins/bidi/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/bidi/plugin.js	(revision 6477)
+++ /CKEditor/trunk/_source/plugins/bidi/plugin.js	(revision 6478)
@@ -77,4 +77,7 @@
 	function switchDir( element, dir, editor, database )
 	{
+		if ( element.isReadOnly() )
+			return;
+
 		// Mark this element as processed by switchDir.
 		CKEDITOR.dom.element.setMarker( database, element, 'bidi_processed', 1 );
@@ -102,7 +105,4 @@
 			return null;
 
-		// Reuse computedState if we already have it.
-		var dirBefore = useComputedState ? elementDir : element.getComputedStyle( 'direction' );
-
 		// Clear direction on this element.
 		element.removeStyle( 'direction' );
@@ -119,16 +119,4 @@
 			// Set new direction for this element.
 			element.setAttribute( 'dir', dir );
-
-		// If the element direction changed, we need to switch the margins of
-		// the element and all its children, so it will get really reflected
-		// like a mirror. (#5910)
-		if ( dir != dirBefore )
-		{
-			editor.fire( 'dirChanged',
-				{
-					node : element,
-					dir : dir
-				} );
-		}
 
 		editor.forceNextSelectionCheck();
@@ -192,6 +180,5 @@
 						selectedElement = getFullySelected( range, guardElements, enterMode );
 
-					if ( selectedElement && !selectedElement.isReadOnly() )
-						switchDir( selectedElement, dir, editor, database );
+					selectedElement && switchDir( selectedElement, dir, editor, database );
 
 					var iterator,
@@ -223,5 +210,5 @@
 
 					while ( ( block = iterator.getNextParagraph( enterMode == CKEDITOR.ENTER_P ? 'p' : 'div' ) ) )
-						!block.isReadOnly() && switchDir( block, dir, editor, database );
+						switchDir( block, dir, editor, database );
 					}
 
@@ -262,7 +249,53 @@
 
 			editor.on( 'selectionChange', onSelectionChange );
+			editor.on( 'contentDom', function()
+			{
+				editor.document.on( 'dirChanged', function( evt )
+				{
+					editor.fire( 'dirChanged',
+						{
+							node : evt.data,
+							dir : evt.data.getDirection( 1 )
+						} );
+				})
+			});
 		}
 	});
 
+	// If the element direction changed, we need to switch the margins of
+	// the element and all its children, so it will get really reflected
+	// like a mirror. (#5910)
+	function dirChangeNotifier( org )
+	{
+		var isAttribute = org == elementProto.setAttribute,
+			isRemoveAttribute = org == elementProto.removeAttribute,
+			dirStyleRegexp = /\bdirection\s*:\s*(.*?)\s*(:?$|;)/;
+
+		return function( name, val )
+		{
+			if ( !this.getDocument().equals( CKEDITOR.document ) )
+			{
+				var orgDir, dir;
+				if ( name == ( isAttribute || isRemoveAttribute ? 'dir' : 'direction' ) ||
+					 name == 'style' && ( isRemoveAttribute || dirStyleRegexp.test( val ) ) )
+				{
+					orgDir = this.getDirection( 1 );
+					var retval = org.apply( this, arguments );
+					if ( orgDir != this.getDirection( 1 ) )
+					{
+						this.getDocument().fire( 'dirChanged', this );
+						return retval;
+					}
+				}
+			}
+
+			return org.apply( this, arguments );
+		};
+	}
+
+	var elementProto = CKEDITOR.dom.element.prototype,
+		methods = [ 'setStyle', 'removeStyle', 'setAttribute', 'removeAttribute' ];
+	for ( var i = 0; i < methods.length; i++ )
+		elementProto[ methods[ i ] ] = CKEDITOR.tools.override( elementProto[ methods [ i ] ], dirChangeNotifier );
 })();
 
Index: /CKEditor/trunk/_source/plugins/dialogadvtab/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/dialogadvtab/plugin.js	(revision 6477)
+++ /CKEditor/trunk/_source/plugins/dialogadvtab/plugin.js	(revision 6478)
@@ -36,12 +36,4 @@
 		var attrName = this.att,
 			value = this.getValue();
-
-		// Broadcast Lang Dir change
-		if ( attrName == 'dir' )
-		{
-			var dir = element.getAttribute( attrName );
-			if ( dir != value && element.getParent() )
-				this._.dialog._.editor.fire( 'dirChanged', { node : element, dir : value || element.getDirection( 1 ) } );
-		}
 
 		if ( value )
Index: /CKEditor/trunk/_source/plugins/editingblock/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/editingblock/plugin.js	(revision 6477)
+++ /CKEditor/trunk/_source/plugins/editingblock/plugin.js	(revision 6478)
@@ -198,4 +198,5 @@
 	CKEDITOR.editor.prototype.focus = function()
 	{
+		this.forceNextSelectionCheck();
 		var mode = getMode( this );
 		if ( mode )
