Index: /CKEditor/branches/features/v4-ui/_source/skins/kama/mainui.css
===================================================================
--- /CKEditor/branches/features/v4-ui/_source/skins/kama/mainui.css	(revision 7103)
+++ /CKEditor/branches/features/v4-ui/_source/skins/kama/mainui.css	(revision 7104)
@@ -4,5 +4,5 @@
 */
 
-.cke_skin_kama
+.cke_skin_kama .cke_container
 {
 	-moz-border-radius: 5px;
@@ -10,10 +10,6 @@
 	border-radius: 5px;
 	border: 1px solid #D3D3D3;
-	padding: 5px;
-}
-
-.cke_shared .cke_skin_kama .cke_wrapper
-{
-	padding-bottom: 0;
+	padding: 3px;
+	border-collapse: separate;
 }
 
@@ -45,4 +41,10 @@
 	padding:0px 5px;
 }
+
+.cke_shared .cke_skin_kama .cke_contents
+{
+	padding: 5px;
+}
+
 .cke_skin_kama .cke_bottom
 {
@@ -193,2 +195,7 @@
 	overflow: hidden;
 }
+
+.cke_clear_float
+{
+	clear:both;
+}
Index: /CKEditor/branches/features/v4-ui/_source/themes/default/theme.js
===================================================================
--- /CKEditor/branches/features/v4-ui/_source/themes/default/theme.js	(revision 7103)
+++ /CKEditor/branches/features/v4-ui/_source/themes/default/theme.js	(revision 7104)
@@ -13,5 +13,17 @@
 	var hiddenSkins = {};
 
-	function checkSharedSpace( editor, spaceName )
+	/*
+	 * Wrap the editor UI structure with environment selectors.
+	 */
+	function envHtml( editor, html )
+	{
+		var envs = [ 'cke_'+editor.lang.dir, CKEDITOR.env.cssClass, editor.skinClass ];
+		editor.config.sharedSpaces && envs.push( 'cke_shared' );
+		for ( var i = 0; i < envs.length; i++ )
+			html = '<span class="' + envs[ i ] + '">' + html + '</span>';
+		return html;
+	}
+
+	function buildSharedSpace( editor, spaceName, spaceContent )
 	{
 		var container,
@@ -28,16 +40,15 @@
 		{
 			// Creates an HTML structure that reproduces the editor class hierarchy.
-			var html =
-				'<span class="cke_shared "' +
-				' dir="'+ editor.lang.dir + '"' +
-				'>' +
-				'<span class="' + editor.skinClass + ' ' + editor.id + ' cke_editor_' + editor.name + '">' +
-				'<span class="' + CKEDITOR.env.cssClass + '">' +
-				'<span class="cke_wrapper cke_' + editor.lang.dir + '">' +
-				'<span class="cke_editor">' +
-				'<div class="cke_' + spaceName + '">' +
-				'</div></span></span></span></span></span>';
-
-			var mainContainer = element.append( CKEDITOR.dom.element.createFromHtml( html, element.getDocument() ) );
+			var html = envHtml( editor,
+					'<div class="cke_container">' +
+						'<div class="cke_editor">' +
+							'<div class="cke_' + spaceName + '">' + spaceContent +
+								'<div class="cke_clear_float"></div>' +
+							'</div>' +
+						'</div>' +
+					'</div>'
+			);
+
+			var mainContainer = element.append( CKEDITOR.dom.element.createFromHtml( html ) );
 
 			// Only the first container starts visible. Others get hidden.
@@ -79,4 +90,6 @@
 	}
 
+	function listOfClass() { return Array.prototype.join.call( arguments, ' ' ); }
+
 	return /** @lends CKEDITOR.theme */ {
 		build : function( editor, themePath )
@@ -100,9 +113,9 @@
 
 
-			var sharedTop		= topHtml && checkSharedSpace( editor, 'top' ),
-				sharedBottoms	= checkSharedSpace( editor, 'bottom' );
-
-			sharedTop		&& ( sharedTop.setHtml( topHtml )		, topHtml = '' );
-			sharedBottoms	&& ( sharedBottoms.setHtml( bottomHtml ), bottomHtml = '' );
+			if ( buildSharedSpace( editor, 'top', topHtml ) )
+				topHtml = '';
+
+			if ( buildSharedSpace( editor, 'bottom', bottomHtml ) )
+				bottomHtml = '';
 
 			var hideSkin = '<style>.' + editor.skinClass + '{visibility:hidden;}</style>';
@@ -112,18 +125,21 @@
 				hiddenSkins[ editor.skinClass ] = 1;
 
-			var container = CKEDITOR.dom.element.createFromHtml( [
+			var id = 'cke_editor_' + name,
+				labelId =  id + '_label',
+				containerCls = listOfClass( 'cke_container', editor.id );
+
+			var chrome = CKEDITOR.dom.element.createFromHtml( envHtml( editor, [
+				'<label id="'+ labelId +'" class="cke_voice_label">' + editor.lang.editor + '</label>' +
 				'<table' +
-					' id="cke_', name, '"' +
-					' class="', editor.skinClass, ' ', editor.id, ' cke_editor_', name, '"' +
+					' id="', id, '"' +
+					' class="'+ containerCls +'"' +
 					' dir="', editor.lang.dir, '"' +
-					' title="', ( CKEDITOR.env.gecko ? ' ' : '' ), '"' +
 					' lang="', editor.langCode, '"' +
 						( CKEDITOR.env.webkit? ' tabindex="' + tabIndex + '"' : '' ) +
 					' role="application"' +
-					' aria-labelledby="cke_', name, '_arialbl"' +
+					' aria-labelledby="'+ labelId +
 					'>' +
-					'<tr class="cke_wrapper ' , CKEDITOR.env.cssClass, '" role="presentation">' +
-						'<td class="cke_wrapper cke_', editor.lang.dir, '" role="presentation">' +
-						'<label id="cke_', name, '_arialbl" class="cke_voice_label">' + editor.lang.editor + '</label>' +
+					'<tr role="presentation">' +
+						'<td role="presentation">' +
 							'<table class="cke_editor" role="presentation">' +
 								'<tr', topHtml		? '' : ' style="display:none"', ' role="presentation"><td id="cke_top_'		, name, '" class="cke_top" role="presentation">'	, topHtml		, '</td></tr>' +
@@ -131,16 +147,17 @@
 								'<tr', bottomHtml	? '' : ' style="display:none"', ' role="presentation"><td id="cke_bottom_'	, name, '" class="cke_bottom" role="presentation">'	, bottomHtml	, '</td></tr>' +
 							'</table>' +
-							//Hide the container when loading skins, later restored by skin css.
-							hideSkin +
 						'</td>' +
 					'</tr>' +
-				'</table>' ].join( '' ) );
-
-			container.unselectable();
+				'</table>' +
+				//Hide the container when loading skins, later restored by skin css.
+				hideSkin
+			].join( '' ) ) );
 
 			if ( elementMode == CKEDITOR.ELEMENT_MODE_REPLACE )
-				container.insertAfter( element );
+				chrome.insertAfter( element );
 			else
-				element.append( container );
+				element.append( chrome );
+
+			var container = CKEDITOR.document.getById( id );
 
 			/**
@@ -154,4 +171,6 @@
 			editor.container = container;
 
+			// Disallow text selection over editor chrome.
+			container.unselectable();
 			// Disable browser context menu for editor's chrome.
 			container.disableContextMenu();
@@ -162,5 +181,5 @@
 				var func = ( editor.lang.dir != evt.data ? 'add' : 'remove' ) + 'Class';
 
-				container.getChild( 1 )[ func ]( 'cke_mixed_dir_content' );
+				container[ func ]( 'cke_mixed_dir_content' );
 
 				// Put the mixed direction class on the respective element also for shared spaces.
