Index: /CKEditor/branches/features/contenteditable/_source/core/dom/rangelist.js
===================================================================
--- /CKEditor/branches/features/contenteditable/_source/core/dom/rangelist.js	(revision 5568)
+++ /CKEditor/branches/features/contenteditable/_source/core/dom/rangelist.js	(revision 5568)
@@ -0,0 +1,181 @@
+/*
+Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+( function()
+{
+	/**
+	 * Representation of multiple ranges within a selection.
+	 * @param {CKEDITOR.dom.range | Array<{CKEDITOR.dom.range> | undefined } ranges
+	 *  The ranges consist of this list, note that if an array of ranges is specified,
+	 *  the range sequence should compliant with the selection order, this class is
+	 *  will not help to sort them.
+	 */
+	CKEDITOR.dom.rangeList = function( ranges )
+	{
+		if ( !ranges )
+			ranges = [];
+		else if ( ranges instanceof CKEDITOR.dom.range )
+			ranges = [ ranges ];
+
+		this._ =
+		{
+			ranges : ranges,
+			count : ranges.length
+		}
+
+	};
+
+	// Update the specified range which has been mangled by previous insertion of
+	// range bookmark nodes.(#3256)
+	function updateDirtyRange( bookmark, dirtyRange , checkEnd )
+	{
+		var serializable = bookmark.serializable,
+			container = dirtyRange[ checkEnd ? 'endContainer' : 'startContainer' ],
+			offset = checkEnd ? 'endOffset' : 'startOffset',
+			bookmarkStart = serializable ?
+				dirtyRange.document.getById( bookmark.startNode )
+				: bookmark.startNode,
+			bookmarkEnd = serializable ?
+			  dirtyRange.document.getById( bookmark.endNode )
+			  : bookmark.endNode;
+
+		if ( container.equals( bookmarkStart.getPrevious() ) )
+		{
+			dirtyRange.startOffset = dirtyRange.startOffset
+					- container.getLength() - bookmarkEnd.getPrevious().getLength();
+			container = bookmarkEnd.getNext();
+		}
+		else if ( container.equals( bookmarkEnd.getPrevious() ) )
+		{
+			dirtyRange.startOffset = dirtyRange.startOffset - container.getLength();
+			container = bookmarkEnd.getNext();
+		}
+
+		container.equals( bookmarkStart.getParent() ) && dirtyRange[ offset ]++;
+		container.equals( bookmarkEnd.getParent() ) && dirtyRange[ offset ]++;
+
+		// Update and return this range.
+		dirtyRange[ checkEnd ? 'endContainer' : 'startContainer' ] = container;
+		return dirtyRange;
+	}
+
+	CKEDITOR.dom.rangeList.prototype = {
+		/**
+		 * Appending the specified range object to end of current list.
+		 * @param { CKEDITOR.dom.range} range
+		 * @example
+		 * var rangeList = new CKEDITOR.dom.rangeList();
+		 * var range = new CKEDITOR.dom.range();
+		 * ...
+		 * rangeList.add( range );
+		 * alert( rangeList.getItem( 0 ) );
+		 */
+		add : function( range, index )
+		{
+			this._.ranges.splice( index || 0, 0, range );
+			this._.count++;
+		},
+		
+		remove : function( index )
+		{
+			this._.ranges.splice( index, 1 );
+			this._.count--;
+		},
+
+		replace : function( index, newRange )
+		{
+			this._.ranges.splice( index, 1, newRange );
+		},
+
+		getItem : function( index )
+		{
+			return this._.ranges[ index ] || null;
+		},
+
+		count : function()
+		{
+			return this._.count;
+		},
+
+		/**
+		 * Create an instance of rangeList iterator, it should be only used while
+		 * the processing of each range is possibly polluting other this._.ranges, e.g. destroy
+		 * the following range's start container OR change others' offset value;
+		 * Otherwise, simply iterating with {@link CKEDITOR.dom.rangeList::getItem}
+		 * in a for loop.
+		 */
+		createIterator : function()
+		{
+			var rangeList = this,
+				bookmarks,
+				current;
+
+			return {
+
+				getNextRange : function()
+				{
+					if ( !rangeList.count() || current === rangeList.count() - 1 )
+						return null;
+					else
+						current =  current == undefined ? 0 : current + 1;
+
+					var range = rangeList.getItem( current );
+
+					// Multiple ranges might be mangled by each other.
+					if ( rangeList.count() > 1 )
+					{
+						// Bookmarking all other ranges on the first iteration.
+						if ( current == 0 )
+							bookmarks = rangeList.createBookmarks();
+
+						bookmarks.length && range.moveToBookmark( bookmarks.shift() );
+					}
+
+					return range;
+				}
+			};
+		},
+
+		createBookmarks : function( serializable )
+		{
+			var retval = [], bookmark;
+			for ( var i = 0; i < this._.count ; i++ )
+			{
+				retval.push( bookmark = this._.ranges[ i ].createBookmark( serializable, true) );
+
+				// Updating the container & offset values for ranges
+				// that have been touched.
+				for ( var j = i + 1; j < this._.count; j++ )
+				{
+					this._.ranges[ j ] = updateDirtyRange( bookmark, this._.ranges[ j ] );
+					this._.ranges[ j ] = updateDirtyRange( bookmark, this._.ranges[ j ], true );
+				}
+			}
+			return retval;
+		},
+
+		/**
+		 * Apply each of the supplied bookmarks to the corresponding range at the index.
+		 * @param bookmarks
+		 */
+		moveToBookmarks :  function( bookmarks )
+		{
+			for ( var i = 0 ; i < this._.ranges.length ; i++ )
+				this._.ranges[ i ].moveToBookmark( bookmarks[ i ] );
+		},
+
+		createBookmarks2 : function( normalized )
+		{
+			var bookmarks = [];
+
+			for ( var i = 0 ; i < this._.ranges.length ; i++ )
+				bookmarks.push( this._.ranges[ i ].createBookmark2( normalized ) );
+
+			return bookmarks;
+		}
+
+	};
+
+
+} )();
Index: /CKEditor/branches/features/contenteditable/_source/core/loader.js
===================================================================
--- /CKEditor/branches/features/contenteditable/_source/core/loader.js	(revision 5567)
+++ /CKEditor/branches/features/contenteditable/_source/core/loader.js	(revision 5568)
@@ -1,3 +1,3 @@
-﻿/*
+/*
 Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
 For licensing, see LICENSE.html or http://ckeditor.com/license
@@ -24,5 +24,5 @@
 		var scripts =
 		{
-			'core/_bootstrap'		: [ 'core/config', 'core/ckeditor', 'core/plugins', 'core/scriptloader', 'core/tools', /* The following are entries that we want to force loading at the end to avoid dependence recursion */ 'core/dom/comment', 'core/dom/elementpath', 'core/dom/text', 'core/dom/range' ],
+			'core/_bootstrap'		: [ 'core/config', 'core/ckeditor', 'core/plugins', 'core/scriptloader', 'core/tools', /* The following are entries that we want to force loading at the end to avoid dependence recursion */ 'core/dom/comment', 'core/dom/elementpath', 'core/dom/text', 'core/dom/range','core/dom/rangelist' ],
 			'core/ajax'				: [ 'core/xml' ],
 			'core/ckeditor'			: [ 'core/ckeditor_basic', 'core/dom', 'core/dtd', 'core/dom/document', 'core/dom/element', 'core/editor', 'core/event', 'core/htmlparser', 'core/htmlparser/element', 'core/htmlparser/fragment', 'core/htmlparser/filter', 'core/htmlparser/basicwriter', 'core/tools' ],
@@ -42,4 +42,5 @@
 			'core/dom/domobject'	: [ 'core/dom/event' ],
 			'core/dom/range'		: [ 'core/dom/document', 'core/dom/documentfragment', 'core/dom/element', 'core/dom/walker' ],
+			'core/dom/rangelist'    : [ 'core/dom/range' ],
 			'core/dom/text'			: [ 'core/dom/node', 'core/dom/domobject' ],
 			'core/dom/walker'		: [ 'core/dom/node' ],
Index: /CKEditor/branches/features/contenteditable/_source/plugins/blockquote/plugin.js
===================================================================
--- /CKEditor/branches/features/contenteditable/_source/plugins/blockquote/plugin.js	(revision 5567)
+++ /CKEditor/branches/features/contenteditable/_source/plugins/blockquote/plugin.js	(revision 5568)
@@ -1,3 +1,3 @@
-﻿/*
+/*
 Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
 For licensing, see LICENSE.html or http://ckeditor.com/license
@@ -48,5 +48,6 @@
 			var state = editor.getCommand( 'blockquote' ).state,
 				selection = editor.getSelection(),
-				range = selection && selection.getRanges( true )[0];
+				ranges = selection && selection.getRanges( true ),
+				range = ranges.count() && ranges.getItem( 0 );
 
 			if ( !range )
Index: /CKEditor/branches/features/contenteditable/_source/plugins/enterkey/plugin.js
===================================================================
--- /CKEditor/branches/features/contenteditable/_source/plugins/enterkey/plugin.js	(revision 5567)
+++ /CKEditor/branches/features/contenteditable/_source/plugins/enterkey/plugin.js	(revision 5568)
@@ -1,3 +1,3 @@
-﻿/*
+/*
 Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
 For licensing, see LICENSE.html or http://ckeditor.com/license
@@ -347,11 +347,11 @@
 
 		// Delete the contents of all ranges except the first one.
-		for ( var i = ranges.length - 1 ; i > 0 ; i-- )
-		{
-			ranges[ i ].deleteContents();
+		for ( var i = ranges.count() - 1 ; i > 0 ; i-- )
+		{
+			ranges.getItem( i ).deleteContents();
 		}
 
 		// Return the first range.
-		return ranges[ 0 ];
+		return ranges.getItem( 0 );
 	}
 })();
Index: /CKEditor/branches/features/contenteditable/_source/plugins/find/dialogs/find.js
===================================================================
--- /CKEditor/branches/features/contenteditable/_source/plugins/find/dialogs/find.js	(revision 5567)
+++ /CKEditor/branches/features/contenteditable/_source/plugins/find/dialogs/find.js	(revision 5568)
@@ -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,6 +252,8 @@
 
 				// Apply the highlight.
-				var range = this.toDomRange();
+				var range = this.toDomRange(),
+					bookmark = range.createBookmark();
 				highlightStyle.applyToRange( range );
+				range.moveToBookmark( bookmark );
 				this._.highlightRange = range;
 
@@ -274,5 +276,7 @@
 					return;
 
+				var bookmark = this._.highlightRange.createBookmark();
 				highlightStyle.removeFromRange( this._.highlightRange );
+				this._.highlightRange.moveToBookmark( bookmark );
 				this.updateFromDomRange( this._.highlightRange );
 				this._.highlightRange = null;
@@ -563,8 +567,11 @@
 			var searchRange,
 				sel = editor.getSelection(),
+				ranges,
 				body = editor.document.getBody();
-			if ( sel && !isDefault )
-			{
-				searchRange = sel.getRanges()[ 0 ].clone();
+
+			if ( !isDefault && sel
+				 && ( ranges = sel.getRanges() ) && ranges.count() )
+			{
+				searchRange = ranges.getItem( 0 ).clone();
 				searchRange.collapse( true );
 			}
Index: /CKEditor/branches/features/contenteditable/_source/plugins/indent/plugin.js
===================================================================
--- /CKEditor/branches/features/contenteditable/_source/plugins/indent/plugin.js	(revision 5567)
+++ /CKEditor/branches/features/contenteditable/_source/plugins/indent/plugin.js	(revision 5568)
@@ -269,5 +269,5 @@
 		{
 			var selection = editor.getSelection(),
-				range = selection && selection.getRanges( true )[0];
+				range = selection && selection.getRanges( true ).getItem( 0 );
 
 			if ( !range )
Index: /CKEditor/branches/features/contenteditable/_source/plugins/justify/plugin.js
===================================================================
--- /CKEditor/branches/features/contenteditable/_source/plugins/justify/plugin.js	(revision 5567)
+++ /CKEditor/branches/features/contenteditable/_source/plugins/justify/plugin.js	(revision 5568)
@@ -1,3 +1,3 @@
-﻿/*
+/*
 Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
 For licensing, see LICENSE.html or http://ckeditor.com/license
@@ -80,7 +80,7 @@
 				iterator,
 				block;
-			for ( var i = ranges.length - 1 ; i >= 0 ; i-- )
+			for ( var i = ranges.count() - 1 ; i >= 0 ; i-- )
 			{
-				iterator = ranges[ i ].createIterator();
+				iterator = ranges.getItem( i ).createIterator();
 				iterator.enlargeBr = enterMode != CKEDITOR.ENTER_BR;
 
Index: /CKEditor/branches/features/contenteditable/_source/plugins/link/plugin.js
===================================================================
--- /CKEditor/branches/features/contenteditable/_source/plugins/link/plugin.js	(revision 5567)
+++ /CKEditor/branches/features/contenteditable/_source/plugins/link/plugin.js	(revision 5568)
@@ -1,3 +1,3 @@
-﻿/*
+/*
 Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
 For licensing, see LICENSE.html or http://ckeditor.com/license
@@ -178,5 +178,5 @@
 	{
 		var range;
-		try { range  = editor.getSelection().getRanges()[ 0 ]; }
+		try { range  = editor.getSelection().getRanges().getItem( 0 ); }
 		catch( e ) { return null; }
 
@@ -206,11 +206,12 @@
 			element;
 
-		for ( var i = 0 ; i < ranges.length ; i++ )
-		{
-			rangeRoot = ranges[i].getCommonAncestor( true );
+		for ( var range, i = 0 ; i < ranges.count() ; i++ )
+		{
+			range = ranges.getItem( i );
+			rangeRoot = range.getCommonAncestor( true );
 			element = rangeRoot.getAscendant( 'a', true );
 			if ( !element )
 				continue;
-			ranges[i].selectNodeContents( element );
+			range.selectNodeContents( element );
 		}
 
Index: /CKEditor/branches/features/contenteditable/_source/plugins/list/plugin.js
===================================================================
--- /CKEditor/branches/features/contenteditable/_source/plugins/list/plugin.js	(revision 5567)
+++ /CKEditor/branches/features/contenteditable/_source/plugins/list/plugin.js	(revision 5568)
@@ -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,8 +386,9 @@
 			var doc = editor.document,
 				selection = editor.getSelection(),
-				ranges = selection && selection.getRanges( true );
+				ranges = selection && selection.getRanges( true ),
+				range;
 
 			// There should be at least one selected range.
-			if ( !ranges || ranges.length < 1 )
+			if ( !ranges.count() )
 				return;
 
@@ -404,13 +405,14 @@
 							( editor.config.enterMode == CKEDITOR.ENTER_DIV ? 'div' : 'br' ) );
 					paragraph.appendTo( body );
-					ranges = [ new CKEDITOR.dom.range( doc ) ];
+					ranges = new CKEDITOR.dom.rangeList( new CKEDITOR.dom.range( doc ) );
 					// IE exception on inserting anything when anchor inside <br>.
 					if ( paragraph.is( 'br' ) )
 					{
-						ranges[ 0 ].setStartBefore( paragraph );
-						ranges[ 0 ].setEndAfter( paragraph );
+						ranges.getItem( 0 ).setStartBefore( paragraph );
+						ranges.getItem( 0 ).setEndAfter( paragraph );
 					}
 					else
-						ranges[ 0 ].selectNodeContents( paragraph );
+						ranges.getItem( 0 ).selectNodeContents( paragraph );
+
 					selection.selectRanges( ranges );
 				}
@@ -419,6 +421,6 @@
 				else
 				{
-					var range = ranges.length == 1 && ranges[ 0 ],
-						enclosedNode = range && range.getEnclosedNode();
+					range = ranges.count() == 1 && ranges.getItem( 0 );
+					var enclosedNode = range && range.getEnclosedNode();
 					if ( enclosedNode && enclosedNode.is
 						&& this.type == enclosedNode.getName() )
@@ -436,7 +438,7 @@
 				database = {};
 
-			while ( ranges.length > 0 )
-			{
-				range = ranges.pop();
+			for ( range, i = 0 ; i < ranges.count() ; i++ )
+			{
+				range = ranges.getItem( i );
 
 				var boundaryNodes = range.getBoundaryNodes(),
@@ -466,5 +468,5 @@
 
 					// First, try to group by a list ancestor.
-					for ( var i = pathElementsCount - 1; i >= 0 && ( element = pathElements[ i ] ); i-- )
+					for ( var j = pathElementsCount - 1; j >= 0 && ( element = pathElements[ j ] ); j-- )
 					{
 						if ( listNodeNames[ element.getName() ]
Index: /CKEditor/branches/features/contenteditable/_source/plugins/removeformat/plugin.js
===================================================================
--- /CKEditor/branches/features/contenteditable/_source/plugins/removeformat/plugin.js	(revision 5567)
+++ /CKEditor/branches/features/contenteditable/_source/plugins/removeformat/plugin.js	(revision 5568)
@@ -38,5 +38,5 @@
 				var ranges = editor.getSelection().getRanges( true );
 
-				for ( var i = ranges.length - 1, range ; range = ranges[ i ] ; i-- )
+				for ( var range, i = 0 ; i < ranges.count() ; i++ )
 				{
 					if ( range.collapsed )
Index: /CKEditor/branches/features/contenteditable/_source/plugins/selection/plugin.js
===================================================================
--- /CKEditor/branches/features/contenteditable/_source/plugins/selection/plugin.js	(revision 5567)
+++ /CKEditor/branches/features/contenteditable/_source/plugins/selection/plugin.js	(revision 5568)
@@ -243,5 +243,5 @@
 								}
 
-								savedRange = nativeSel && sel.getRanges()[ 0 ];
+								savedRange = nativeSel && sel.getRanges().getItem( 0 );
 
 								checkSelectionChangeTimeout.call( editor );
@@ -648,5 +648,5 @@
 					return cache.ranges;
 				else if ( !cache.ranges )
-					cache.ranges = func.call( this );
+					cache.ranges = new CKEDITOR.dom.rangeList( func.call( this ) );
 
 				// Split range into multiple by read-only nodes.
@@ -654,12 +654,12 @@
 				{
 					var ranges = cache.ranges;
-					for ( var i = 0; i < ranges.length; i++ )
-					{
-						var range = ranges[ i ];
+					for ( var i = 0; i < ranges.count(); i++ )
+					{
+						var range = ranges.getItem( i );
 
 						// Drop range spans inside one ready-only node.
 						var parent = range.getCommonAncestor();
 						if ( parent.isReadOnly())
-							ranges.splice( i, 1 );
+							ranges.remove( i );
 
 						if ( range.collapsed )
@@ -687,5 +687,5 @@
 								range.setEndBefore( next );
 								newRange.setStartAfter( next );
-								ranges.splice( i + 1, 0, newRange );
+								ranges.add( newRange, i + 1 );
 								break;
 							}
@@ -724,5 +724,5 @@
 				case CKEDITOR.SELECTION_TEXT :
 
-					var range = this.getRanges()[0];
+					var range = this.getRanges().getItem( 0 );
 
 					if ( range )
@@ -898,5 +898,5 @@
 				this._.cache.selectedElement = element;
 				this._.cache.startElement = element;
-				this._.cache.ranges = [ range ];
+				this._.cache.ranges = new CKEDITOR.dom.rangeList( range );
 				this._.cache.type = CKEDITOR.SELECTION_ELEMENT;
 
@@ -944,11 +944,11 @@
 		},
 
-		selectRanges : function( ranges )
+		selectRanges : function( rangeList )
 		{
 			if ( this.isLocked )
 			{
 				this._.cache.selectedElement = null;
-				this._.cache.startElement = ranges[ 0 ].getTouchedStartNode();
-				this._.cache.ranges = ranges;
+				this._.cache.startElement = rangeList.getItem( 0 ).getTouchedStartNode();
+				this._.cache.ranges = rangeList;
 				this._.cache.type = CKEDITOR.SELECTION_TEXT;
 
@@ -958,15 +958,13 @@
 			if ( CKEDITOR.env.ie )
 			{
-				if ( ranges.length > 1 )
+				var first = rangeList.getItem( 0 );
+				if ( rangeList.count() > 1 )
 				{
 					// IE doesn't accept multiple ranges selection, so we join all into one.
-					var last = ranges[ ranges.length -1 ] ;
-					ranges[ 0 ].setEnd( last.endContainer, last.endOffset );
-					ranges.length = 1;
+					var last = rangeList.getItem( rangeList.count() - 1 );
+					first.setEnd( last.endContainer, last.endOffset );
 				}
 
-				if ( ranges[ 0 ] )
-					ranges[ 0 ].select();
-
+				first.select();
 				this.reset();
 			}
@@ -975,15 +973,16 @@
 				var sel = this.getNative();
 
-				if ( ranges.length )
+				if ( rangeList.count() )
 					sel.removeAllRanges();
 
-				for ( var i = 0 ; i < ranges.length ; i++ )
-				{
-					if ( i < ranges.length -1 )
-					{
-						var left = ranges[ i  ], right = ranges[ i +1 ];
-						var between = left.clone();
+				for ( var i = 0 ; i < rangeList.count() ; i++ )
+				{
+					if ( i < rangeList.count() -1 )
+					{
+						var left = rangeList.getItem( i ), right = rangeList.getItem( i + 1 ),
+								between = left.clone();
+
 						between.setStart( left.endContainer, left.endOffset );
-						between.setEnd( right.startContainer, left.startOffset );
+						between.setEnd( right.startContainer, right.startOffset );
 
 						if ( !between.collapsed )
@@ -994,12 +993,12 @@
 							{
 								left.setEnd( right.endContainer, right.endOffset );
-								ranges.splice( i + 1, 1 );
+								rangeList.remove( i + 1 );
 							}
 						}
 					}
 
-					var range = ranges[ i ];
-					var nativeRange = this.document.$.createRange();
-					var startContainer = range.startContainer;
+					var range = rangeList.getItem( i ),
+						nativeRange = this.document.$.createRange(),
+						startContainer = range.startContainer;
 
 					// In FF2, if we have a collapsed range, inside an empty
@@ -1027,53 +1026,20 @@
 		createBookmarks : function( serializable )
 		{
-			var retval = [],
-				ranges = this.getRanges(),
-				length = ranges.length,
-				bookmark;
-			for ( var i = 0; i < length ; i++ )
-			{
-			    retval.push( bookmark = ranges[ i ].createBookmark( serializable, true ) );
-
-				serializable = bookmark.serializable;
-
-				var bookmarkStart = serializable ? this.document.getById( bookmark.startNode ) : bookmark.startNode,
-					bookmarkEnd = serializable ? this.document.getById( bookmark.endNode ) : bookmark.endNode;
-
-			    // Updating the offset values for rest of ranges which have been mangled(#3256).
-			    for ( var j = i + 1 ; j < length ; j++ )
-			    {
-			        var dirtyRange = ranges[ j ],
-			               rangeStart = dirtyRange.startContainer,
-			               rangeEnd = dirtyRange.endContainer;
-
-			       rangeStart.equals( bookmarkStart.getParent() ) && dirtyRange.startOffset++;
-			       rangeStart.equals( bookmarkEnd.getParent() ) && dirtyRange.startOffset++;
-			       rangeEnd.equals( bookmarkStart.getParent() ) && dirtyRange.endOffset++;
-			       rangeEnd.equals( bookmarkEnd.getParent() ) && dirtyRange.endOffset++;
-			    }
-			}
-
-			return retval;
+			return this.getRanges().createBookmarks( serializable );
 		},
 
 		createBookmarks2 : function( normalized )
 		{
-			var bookmarks = [],
-				ranges = this.getRanges();
-
-			for ( var i = 0 ; i < ranges.length ; i++ )
-				bookmarks.push( ranges[i].createBookmark2( normalized ) );
-
-			return bookmarks;
+			return this.getRanges().createBookmarks2( normalized );
 		},
 
 		selectBookmarks : function( bookmarks )
 		{
-			var ranges = [];
+			var ranges = new CKEDITOR.dom.rangeList();
 			for ( var i = 0 ; i < bookmarks.length ; i++ )
 			{
 				var range = new CKEDITOR.dom.range( this.document );
-				range.moveToBookmark( bookmarks[i] );
-				ranges.push( range );
+				range.moveToBookmark( bookmarks[ i ] );
+				ranges.add( range );
 			}
 			this.selectRanges( ranges );
Index: /CKEditor/branches/features/contenteditable/_source/plugins/styles/plugin.js
===================================================================
--- /CKEditor/branches/features/contenteditable/_source/plugins/styles/plugin.js	(revision 5567)
+++ /CKEditor/branches/features/contenteditable/_source/plugins/styles/plugin.js	(revision 5568)
@@ -1,3 +1,3 @@
-﻿/*
+/*
 Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
 For licensing, see LICENSE.html or http://ckeditor.com/license
@@ -371,7 +371,4 @@
 		var dtd = CKEDITOR.dtd[ elementName ] || ( isUnknownElement = true, CKEDITOR.dtd.span );
 
-		// Bookmark the range so we can re-select it after processing.
-		var bookmark = range.createBookmark();
-
 		// Expand the range.
 		range.enlarge( CKEDITOR.ENLARGE_ELEMENT );
@@ -541,5 +538,4 @@
 		firstNode.remove();
 		lastNode.remove();
-		range.moveToBookmark( bookmark );
 		// Minimize the result range to exclude empty text nodes. (#5374)
 		range.shrink( CKEDITOR.SHRINK_TEXT );
@@ -1262,16 +1258,16 @@
 	function applyStyle( document, remove )
 	{
-		// Get all ranges from the selection.
-		var selection = document.getSelection();
-		var ranges = selection.getRanges( true );
-
-		var func = remove ? this.removeFromRange : this.applyToRange;
-
-		// Apply the style to the ranges.
-		for ( var i = ranges.length -1 ; i >= 0 ; i-- )
-			func.call( this, ranges[ i ] );
-
-		// Select the ranges again.
-		selection.selectRanges( ranges );
+		var selection = document.getSelection(),
+			// Bookmark the range so we can re-select it after processing.
+			bookmarks = selection.createBookmarks(),
+			ranges = selection.getRanges( true ),
+			func = remove ? this.removeFromRange : this.applyToRange,
+			range;
+
+		var iterator = ranges.createIterator();
+		while ( range = iterator.getNextRange() )
+			func.call( this, range );
+
+		selection.selectBookmarks( bookmarks );
 	}
 })();
Index: /CKEditor/branches/features/contenteditable/_source/plugins/tabletools/plugin.js
===================================================================
--- /CKEditor/branches/features/contenteditable/_source/plugins/tabletools/plugin.js	(revision 5567)
+++ /CKEditor/branches/features/contenteditable/_source/plugins/tabletools/plugin.js	(revision 5568)
@@ -1,3 +1,3 @@
-﻿/*
+/*
 Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
 For licensing, see LICENSE.html or http://ckeditor.com/license
@@ -42,7 +42,7 @@
 		}
 
-		for ( var i = 0 ; i < ranges.length ; i++ )
-		{
-			var range = ranges[ i ];
+		for ( var i = 0 ; i < ranges.count() ; i++ )
+		{
+			var range = ranges.getItem( i );
 
 			if ( range.collapsed )
@@ -769,7 +769,7 @@
 						// Maintain the selection point at where the table was deleted.
 						selection.selectElement( table );
-						var range = selection.getRanges()[0];
-						range.collapse();
-						selection.selectRanges( [ range ] );
+						var ranges = selection.getRanges();
+						ranges.getItem( 0 ).collapse();
+						selection.selectRanges( ranges );
 
 						// If the table's parent has only one child, remove it,except body,as well.( #5416 )
Index: /CKEditor/branches/features/contenteditable/_source/plugins/wysiwygarea/plugin.js
===================================================================
--- /CKEditor/branches/features/contenteditable/_source/plugins/wysiwygarea/plugin.js	(revision 5567)
+++ /CKEditor/branches/features/contenteditable/_source/plugins/wysiwygarea/plugin.js	(revision 5568)
@@ -1,3 +1,3 @@
-﻿/*
+/*
 Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
 For licensing, see LICENSE.html or http://ckeditor.com/license
@@ -69,5 +69,5 @@
 				ranges = selection.getRanges( true );
 
-			if ( !ranges.length )
+			if ( !ranges.count() )
 				return;
 
@@ -79,8 +79,7 @@
 			var range, clone, lastElement, bookmark;
 
-			for ( var i = ranges.length - 1 ; i >= 0 ; i-- )
+			for ( var i = ranges.count() - 1 ; i >= 0 ; i-- )
 			{
-				range = ranges[ i ];
-
+				range = ranges.getItem( i );
 				// Remove the original contents.
 				range.deleteContents();
@@ -129,5 +128,5 @@
 				range.moveToElementEditStart( next );
 
-			selection.selectRanges( [ range ] );
+			selection.selectRanges( new CKEDITOR.dom.rangeList( range ) );
 
 			if ( selIsLocked )
@@ -191,5 +190,5 @@
 			blockLimit = path.blockLimit,
 			selection = evt.data.selection,
-			range = selection.getRanges()[0],
+			range = selection.getRanges().getItem( 0 ),
 			body = editor.document.getBody(),
 			enterMode = editor.config.enterMode;
Index: /CKEditor/branches/features/contenteditable/ckeditor.pack
===================================================================
--- /CKEditor/branches/features/contenteditable/ckeditor.pack	(revision 5567)
+++ /CKEditor/branches/features/contenteditable/ckeditor.pack	(revision 5568)
@@ -1,3 +1,3 @@
-/*
+﻿/*
  * CKPackager - Sample Package file
  */
@@ -130,4 +130,5 @@
 					'_source/core/dom/walker.js',
 					'_source/core/dom/range.js',
+					'_source/core/dom/rangelist.js',
 					'_source/core/_bootstrap.js',
 					'_source/skins/kama/skin.js',
Index: /CKEditor/branches/features/contenteditable/config.js
===================================================================
--- /CKEditor/branches/features/contenteditable/config.js	(revision 5567)
+++ /CKEditor/branches/features/contenteditable/config.js	(revision 5568)
@@ -1,3 +1,3 @@
-﻿/*
+/*
 Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
 For licensing, see LICENSE.html or http://ckeditor.com/license
@@ -9,3 +9,10 @@
 	// config.language = 'fr';
 	// config.uiColor = '#AADC6E';
+	config.scayt_autoStartup = false;
+//	config.emailProtection = 'mt(NAME,DOMAIN,SUBJECT,BODY)';
+//	config.toolbar = [ ['Templates','-','Styles','Format','Font','FontSize'] ];
+//	config.enterMode = 1;
+//	config.shiftEnterMode = 1;
+//	config.forceEnterMode = true;
+//	config.resize_dir = 'horizontal';
 };
