Index: CKEditor/branches/features/v4-domiterator/_source/plugins/indent/plugin.js
===================================================================
--- CKEditor/branches/features/v4-domiterator/_source/plugins/indent/plugin.js	(revision 6495)
+++ CKEditor/branches/features/v4-domiterator/_source/plugins/indent/plugin.js	(revision 6496)
@@ -1,3 +1,3 @@
-﻿/*
+﻿﻿/*
 Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
 For licensing, see LICENSE.html or http://ckeditor.com/license
@@ -11,4 +11,5 @@
 {
 	var listNodeNames = { ol : 1, ul : 1 },
+		applicable = { table:1, ul:1, ol:1, blockquote:1, div:1 },
 		isNotWhitespaces = CKEDITOR.dom.walker.whitespaces( true ),
 		isNotBookmark = CKEDITOR.dom.walker.bookmark( false, true );
@@ -78,5 +79,5 @@
 	function isListItem( node )
 	{
-		return node.type = CKEDITOR.NODE_ELEMENT && node.is( 'li' );
+		return node.type == CKEDITOR.NODE_ELEMENT && node.is( 'li' );
 	}
 
@@ -86,14 +87,22 @@
 			var self = this, database = {};
 
-			function indentList( listNode )
-			{
-				// Our starting and ending points of the range might be inside some blocks under a list item...
-				// So before playing with the iterator, we need to expand the block to include the list items.
-				var startContainer = range.startContainer,
+			function indentList( listNode, range )
+			{
+				var startContainer, endContainer;
+
+				if ( range )
+				{
+					startContainer = range.startContainer;
 					endContainer = range.endContainer;
-				while ( startContainer && !startContainer.getParent().equals( listNode ) )
-					startContainer = startContainer.getParent();
-				while ( endContainer && !endContainer.getParent().equals( listNode ) )
-					endContainer = endContainer.getParent();
+					while ( startContainer && !startContainer.getParent().equals( listNode ) )
+						startContainer = startContainer.getParent();
+					while ( endContainer && !endContainer.getParent().equals( listNode ) )
+						endContainer = endContainer.getParent();
+				}
+				else
+				{
+					startContainer = listNode.getFirst( isListItem );
+					endContainer = listNode.getLast( isListItem );
+				}
 
 				if ( !startContainer || !endContainer )
@@ -102,6 +111,6 @@
 				// Now we can iterate over the individual items on the same tree depth.
 				var block = startContainer,
-					itemsToMove = [],
-					stopFlag = false;
+						itemsToMove = [],
+						stopFlag = false;
 				while ( !stopFlag )
 				{
@@ -119,5 +128,5 @@
 				// ancestor node that is still a list.
 				var listParents = listNode.getParents( true );
-				for ( var i = 0 ; i < listParents.length ; i++ )
+				for ( var i = 0; i < listParents.length; i++ )
 				{
 					if ( listParents[i].getName && listNodeNames[ listParents[i].getName() ] )
@@ -128,6 +137,6 @@
 				}
 				var indentOffset = self.name == 'indent' ? 1 : -1,
-					startItem = itemsToMove[0],
-					lastItem = itemsToMove[ itemsToMove.length - 1 ];
+						startItem = itemsToMove[0],
+						lastItem = itemsToMove[ itemsToMove.length - 1 ];
 
 				// Convert the list DOM tree into a one dimensional array.
@@ -144,6 +153,6 @@
 				}
 
-				for ( i = lastItem.getCustomData( 'listarray_index' ) + 1 ;
-						i < listArray.length && listArray[i].indent > baseIndent ; i++ )
+				for ( i = lastItem.getCustomData( 'listarray_index' ) + 1;
+				      i < listArray.length && listArray[i].indent > baseIndent; i++ )
 					listArray[i].indent += indentOffset;
 
@@ -160,11 +169,11 @@
 					{
 						var children = newList.listNode.getChildren(),
-							pendingLis = [],
-							count = children.count(),
-							child;
-
-						for ( i = count - 1 ; i >= 0 ; i-- )
+								pendingLis = [],
+								count = children.count(),
+								child;
+
+						for ( i = count - 1; i >= 0; i-- )
 						{
-							if ( ( child = children.getItem( i ) ) && child.is && child.is( 'li' )  )
+							if ( ( child = children.getItem( i ) ) && child.is && child.is( 'li' ) )
 								pendingLis.push( child );
 						}
@@ -178,17 +187,20 @@
 				if ( pendingLis && pendingLis.length )
 				{
-					for (  i = 0; i < pendingLis.length ; i++ )
+					for ( i = 0; i < pendingLis.length; i++ )
 					{
 						var li = pendingLis[ i ],
-							followingList = li;
+								followingList = li;
 
 						// Nest preceding <ul>/<ol> inside current <li> if any.
 						while ( ( followingList = followingList.getNext() ) &&
-							   followingList.is &&
-							   followingList.getName() in listNodeNames )
+								followingList.is &&
+								followingList.getName() in listNodeNames )
 						{
 							// IE requires a filler NBSP for nested list inside empty list item,
 							// otherwise the list item will be inaccessiable. (#4476)
-							if ( CKEDITOR.env.ie && !li.getFirst( function( node ){ return isNotWhitespaces( node ) && isNotBookmark( node ); } ) )
+							if ( CKEDITOR.env.ie && !li.getFirst( function( node )
+							                                      {
+								                                      return isNotWhitespaces( node ) && isNotBookmark( node );
+							                                      } ) )
 								li.append( range.document.createText( '\u00a0' ) );
 
@@ -199,15 +211,4 @@
 					}
 				}
-			}
-
-			function indentBlock()
-			{
-				var iterator = range.createIterator(),
-					enterMode = editor.config.enterMode;
-				iterator.enforceRealBlocks = true;
-				iterator.enlargeBr = enterMode != CKEDITOR.ENTER_BR;
-				var block;
-				while ( ( block = iterator.getNextParagraph( enterMode == CKEDITOR.ENTER_P ? 'p' : 'div' ) ) )
-					indentElement( block );
 			}
 
@@ -236,5 +237,10 @@
 
 					if ( indentStep < 0 )
-						return false;
+					{
+						if ( element.getName() in listNodeNames )
+							indentList( element );
+						else
+							return false;
+					}
 
 					indentStep = Math.min( indentStep, editor.config.indentClasses.length );
@@ -254,5 +260,10 @@
 
 					if ( currentOffset < 0 )
-						return false;
+					{
+						if ( element.getName() in listNodeNames )
+							indentList( element );
+						else
+							return false;
+					}
 
 					currentOffset = Math.max( currentOffset, 0 );
@@ -326,10 +337,18 @@
 					// Only do that for indenting or when using indent classes or when there is something to outdent. (#6141)
 					if ( !( indentWholeList &&
-						( self.name == 'indent' || self.useIndentClasses || parseInt( nearestListBlock.getStyle( getIndentCssProperty( nearestListBlock ) ), 10 ) ) &&
+							( self.name == 'indent' || self.useIndentClasses || parseInt( nearestListBlock.getStyle( getIndentCssProperty( nearestListBlock ) ), 10 ) ) &&
 							indentElement( nearestListBlock, !hasMultipleItems && firstListItem.getDirection() ) ) )
-								indentList( nearestListBlock );
+								indentList( nearestListBlock, range );
 				}
 				else
-					indentBlock();
+				{
+					var blockIterator = range.createIterator( applicable ),
+						enterMode = editor.config.enterMode,
+						block;
+
+					blockIterator.enlargeBr = enterMode != CKEDITOR.ENTER_BR;
+					while ( ( block = blockIterator.getNextParagraph( enterMode == CKEDITOR.ENTER_P ? 'p' : 'div' ) ) )
+						indentElement( block );
+				}
 			}
 
