Index: /CKEditor/branches/versions/3.1.x/CHANGES.html
===================================================================
--- /CKEditor/branches/versions/3.1.x/CHANGES.html	(revision 4620)
+++ /CKEditor/branches/versions/3.1.x/CHANGES.html	(revision 4621)
@@ -63,5 +63,4 @@
 		<li><a href="http://dev.fckeditor.net/ticket/4609">#4609</a> : Fixed flash object is lost when loading data from outside editor.</li>
 		<li><a href="http://dev.fckeditor.net/ticket/4625">#4625</a> : Fixed editor stay visible in a div with style 'visibility:hidden'.</li>
-		<li><a href="http://dev.fckeditor.net/ticket/4621">#4621</a> : Fixed clicking below table cause a empty table been generated.</li>
 		<li><a href="http://dev.fckeditor.net/ticket/3373">#3373</a> : Fixed empty context menu when there's no menu item at all.</li>
 		<li><a href="http://dev.fckeditor.net/ticket/4473">#4473</a> : Fixed setting rules on the same element tag name throw error.</li>
@@ -110,5 +109,5 @@
 		<li><a href="http://dev.fckeditor.net/ticket/4219">#4219</a> : Added fallback mechanism for config.language.</li>
 		<li><a href="http://dev.fckeditor.net/ticket/4194">#4194</a> : Added support for using multiple css style sheets within the editor.</li>
-		<li><a href="http://dev.fckeditor.net/ticket/4210">#4210</a> : Introducing the CKEditor plugin for jQuery (the jQuery adapter).</li>
+		<li><a href="http://dev.fckeditor.net/ticket/4463">#4463</a> : Added inline CSS support in all places where custom stylesheet could apply.</li>
 		<li><a href="http://dev.fckeditor.net/ticket/4343">#4343</a> : Added config option 'browserContextMenuOnCtrl' for 'contextmenu' plugin.</li>
 	</ul>
Index: /CKEditor/branches/versions/3.1.x/_samples/index.html
===================================================================
--- /CKEditor/branches/versions/3.1.x/_samples/index.html	(revision 4620)
+++ /CKEditor/branches/versions/3.1.x/_samples/index.html	(revision 4621)
@@ -37,5 +37,4 @@
 		<li><a href="api_dialog.html">Using the JavaScript API to customize dialogs</a></li>
 		<li><a href="enterkey.html">Using the "Enter" key in CKEditor</a></li>
-		<li><a href="jqueryadapter.html">jQuery adapter example</a></li>
 	</ul>
 	<div id="footer">
Index: Editor/branches/versions/3.1.x/_samples/jqueryadapter.html
===================================================================
--- /CKEditor/branches/versions/3.1.x/_samples/jqueryadapter.html	(revision 4620)
+++ 	(revision )
@@ -1,68 +1,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<!--
-Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
-For licensing, see LICENSE.html or http://ckeditor.com/license
--->
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-	<title>jQuery adapter - CKEditor Sample</title>
-	<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js"></script>
-<!-- CKReleaser %REMOVE_LINE%
-	<script type="text/javascript" src="../ckeditor.js"></script>
-	<script type="text/javascript" src="../adapters/jquery.js"></script>
-CKReleaser %REMOVE_START% -->
-	<script type="text/javascript" src="../ckeditor_source.js"></script>
-	<script type="text/javascript" src="../_source/adapters/jquery.js"></script>
-<!-- CKReleaser %REMOVE_END% -->
-	<script type="text/javascript">
-		$( function()
-		{
-			var config = {
-				toolbar :
-				[
-					[ 'Bold', 'Italic', '-', 'NumberedList', 'BulletedList', '-', 'Link', 'Unlink' ],
-					[ 'UIColor' ]
-				]
-			};
-
-			// Initialize the editor.
-			// Callback function can be passed and executed after full instance creation.
-			$( '.jquery_ckeditor' ).ckeditor( config );
-		} );
-	</script>
-</head>
-<body>
-	<div id="html">
-		<form action="sample_posteddata.php" method="post">
-			<p>
-				<label for="editor1">
-					Editor 1:</label><br />
-				<textarea id="editor1" name="editor1" class="jquery_ckeditor" rows="10" cols="80">&lt;p&gt;This is some &lt;strong&gt;sample text&lt;/strong&gt;. You are using &lt;a href="http://www.fckeditor.net/"&gt;CKEditor&lt;/a&gt;.&lt;/p&gt;</textarea>
-			</p>
-			<p>
-				<input type="submit" value="Submit" />
-			</p>
-		</form>
-	</div>
-	<div id="code">
-		<pre>
-&lt;script type=&quot;text/javascript&quot;&gt;
-	$( function()
-	{
-		$( '.jquery_ckeditor' ).<b>ckeditor()</b>;
-	} );
-&lt;/script&gt;
-		</pre>
-		<pre>
-&lt;form action=""&gt;
-  &lt;p&gt;
-    &lt;label for="editor1"&gt;
-      Editor 1:&lt;/label&gt;&lt;br /&gt;
-    &lt;textarea id="editor1" name="editor1" <b>class="jquery_ckeditor"</b> rows="10" cols="80"&gt;&lt;p&gt;This is some &lt;strong&gt;sample text&lt;/strong&gt;. You are using &lt;a href="http://www.fckeditor.net/"&gt;CKEditor&lt;/a&gt;.&lt;/p&gt;&lt;/textarea&gt;
-  &lt;/p&gt;
-  &lt;p&gt;
-&lt;/form&gt;
-</pre>
-	</div>
-</body>
-</html>
Index: /CKEditor/branches/versions/3.1.x/_source/core/dom/document.js
===================================================================
--- /CKEditor/branches/versions/3.1.x/_source/core/dom/document.js	(revision 4620)
+++ /CKEditor/branches/versions/3.1.x/_source/core/dom/document.js	(revision 4621)
@@ -53,4 +53,19 @@
 		},
 
+		appendStyleText : function( cssStyleText )
+		{
+			if ( this.$.createStyleSheet )
+			{
+				var styleSheet = this.$.createStyleSheet( "" );
+				styleSheet.cssText = cssStyleText ;
+			}
+			else
+			{
+				var style = new CKEDITOR.dom.element( 'style', this );
+				style.append( new CKEDITOR.dom.text( cssStyleText, this ) );
+				this.getHead().append( style );
+			}
+		},
+
 		createElement : function( name, attribsAndStyles )
 		{
Index: /CKEditor/branches/versions/3.1.x/_source/core/dom/range.js
===================================================================
--- /CKEditor/branches/versions/3.1.x/_source/core/dom/range.js	(revision 4620)
+++ /CKEditor/branches/versions/3.1.x/_source/core/dom/range.js	(revision 4621)
@@ -1184,6 +1184,5 @@
 							blockBoundary,
 							!blockBoundary.is( 'br' ) &&
-							( !enlargeable && this.checkStartOfBlock()
-							  || enlargeable && blockBoundary.contains( enlargeable ) ) ?
+							( !enlargeable || blockBoundary.contains( enlargeable ) ) ?
 								CKEDITOR.POSITION_AFTER_START :
 								CKEDITOR.POSITION_AFTER_END );
@@ -1210,6 +1209,6 @@
 					this.setEndAt(
 							blockBoundary,
-							( !enlargeable && this.checkEndOfBlock()
-							  || enlargeable && blockBoundary.contains( enlargeable ) ) ?
+							!blockBoundary.is( 'br' ) &&
+							( !enlargeable || blockBoundary.contains( enlargeable ) ) ?
 								CKEDITOR.POSITION_BEFORE_END :
 								CKEDITOR.POSITION_BEFORE_START );
Index: /CKEditor/branches/versions/3.1.x/_source/core/editor.js
===================================================================
--- /CKEditor/branches/versions/3.1.x/_source/core/editor.js	(revision 4620)
+++ /CKEditor/branches/versions/3.1.x/_source/core/editor.js	(revision 4621)
@@ -125,5 +125,5 @@
 
 		// Load language file.
-		loadLang( editor );
+		loadSkin( editor );
 	};
 
@@ -247,5 +247,5 @@
 						// Load the editor skin.
 						editor.fire( 'pluginsLoaded' );
-						loadSkin( editor );
+						loadTheme( editor );
 					});
 			});
@@ -256,5 +256,5 @@
 		CKEDITOR.skins.load( editor, 'editor', function()
 			{
-				loadTheme( editor );
+				loadLang( editor );
 			});
 	};
Index: /CKEditor/branches/versions/3.1.x/_source/core/resourcemanager.js
===================================================================
--- /CKEditor/branches/versions/3.1.x/_source/core/resourcemanager.js	(revision 4620)
+++ /CKEditor/branches/versions/3.1.x/_source/core/resourcemanager.js	(revision 4621)
@@ -87,5 +87,6 @@
 			throw '[CKEDITOR.resourceManager.add] The resource name "' + name + '" is already registered.';
 
-		this.registered[ name ] = definition || {};
+		CKEDITOR.fire( name + CKEDITOR.tools.capitalize( this.fileName ) + 'Ready',
+				this.registered[ name ] = definition || {} );
 	},
 
Index: /CKEditor/branches/versions/3.1.x/_source/core/skins.js
===================================================================
--- /CKEditor/branches/versions/3.1.x/_source/core/skins.js	(revision 4620)
+++ /CKEditor/branches/versions/3.1.x/_source/core/skins.js	(revision 4621)
@@ -21,5 +21,5 @@
 	var paths = {};
 
-	var loadedPart = function( skinName, part, callback )
+	var loadPart = function( skinName, part, callback )
 	{
 		// Get the skin definition.
@@ -34,4 +34,16 @@
 		};
 
+		function fixCSSTextRelativePath( cssStyleText, baseUrl )
+		{
+			return cssStyleText.replace( /url\s*\(([\s'"]*)(.*?)([\s"']*)\)/g,
+					function( match, opener, path, closer )
+					{
+						if ( /^\/|^\w?:/.test( path ) )
+							return match;
+						else
+							return 'url(' + baseUrl + opener +  path + closer + ')';
+					} );
+		}
+		
 		// Check if we need to preload images from it.
 		if ( !preloaded[ skinName ] )
@@ -44,5 +56,5 @@
 					{
 						preloaded[ skinName ] = 1;
-						loadedPart( skinName, part, callback );
+						loadPart( skinName, part, callback );
 					} );
 				return;
@@ -97,9 +109,22 @@
 			if ( !cssIsLoaded )
 			{
-				appendSkinPath( part.css );
-
-				for ( var c = 0 ; c < part.css.length ; c++ )
-					CKEDITOR.document.appendStyleSheet( part.css[ c ] );
-
+				var cssPart = part.css;
+
+				if ( CKEDITOR.tools.isArray( cssPart ) )
+				{
+					appendSkinPath( cssPart );
+					for ( var c = 0 ; c < cssPart.length ; c++ )
+						CKEDITOR.document.appendStyleSheet( cssPart[ c ] );
+				}
+				else
+				{
+					cssPart = fixCSSTextRelativePath(
+								cssPart, CKEDITOR.getUrl( paths[ skinName ] ) );
+					// Processing Inline CSS part.
+					CKEDITOR.document.appendStyleText( cssPart );
+				}
+
+				part.css = cssPart;
+				
 				cssIsLoaded = 1;
 			}
@@ -157,14 +182,5 @@
 
 			if ( loaded[ skinName ] )
-			{
-				loadedPart( skinName, skinPart, callback );
-
-				// Get the skin definition.
-				var skinDefinition = loaded[ skinName ];
-
-				// Trigger init function if any.
-				if ( skinDefinition.init )
-					skinDefinition.init( editor );
-			}
+				loadPart( skinName, skinPart, callback );
 			else
 			{
@@ -172,12 +188,12 @@
 				CKEDITOR.scriptLoader.load( skinPath + 'skin.js', function()
 						{
-							loadedPart( skinName, skinPart, callback );
-
 							// Get the skin definition.
-							var skinDefinition = loaded[ skinName ];
+							var skinDefinition = editor.skin = loaded[ skinName ];
 
 							// Trigger init function if any.
 							if ( skinDefinition.init )
 								skinDefinition.init( editor );
+
+							 loadPart( skinName, skinPart, callback );
 						});
 			}
Index: /CKEditor/branches/versions/3.1.x/_source/core/tools.js
===================================================================
--- /CKEditor/branches/versions/3.1.x/_source/core/tools.js	(revision 4620)
+++ /CKEditor/branches/versions/3.1.x/_source/core/tools.js	(revision 4621)
@@ -99,4 +99,13 @@
 
 		/**
+		 * Turn the first letter of string to upper-case.
+		 * @param {String} str
+		 */
+		capitalize: function( str )
+		{
+			return str.charAt( 0 ).toUpperCase() + str.substring( 1 ).toLowerCase();
+		},
+
+		/**
 		 * Copy the properties from one object to another. By default, properties
 		 * already present in the target object <strong>are not</strong> overwritten.
@@ -230,4 +239,25 @@
 
 		/**
+		 * Build the HTML snippet of a set of <style>/<link>.
+		 * @param css {String|Array} Each of which are url (absolute) of a CSS file or
+		 * a trunk of style text.
+		 */
+		buildStyleHtml : function ( css )
+		{
+			css = [].concat( css );
+			var item, retval = [];
+			for ( var i = 0; i < css.length; i++ )
+			{
+				item = css[ i ];
+				// Is CSS style text ?
+				if ( /@import|[{}]/.test(item) )
+					retval.push('<style>' + item + '</style>');
+				else
+					retval.push('<link type="text/css" rel=stylesheet href="' + item + '">');
+			}
+			return retval.join( '' );
+		},
+
+		/**
 		 * Replace special HTML characters in a string with their relative HTML
 		 * entity values.
Index: /CKEditor/branches/versions/3.1.x/_source/plugins/colorbutton/plugin.js
===================================================================
--- /CKEditor/branches/versions/3.1.x/_source/plugins/colorbutton/plugin.js	(revision 4620)
+++ /CKEditor/branches/versions/3.1.x/_source/plugins/colorbutton/plugin.js	(revision 4621)
@@ -32,5 +32,5 @@
 					panel :
 					{
-						css : [ CKEDITOR.getUrl( editor.skinPath + 'editor.css' ) ]
+						css : editor.skin.editor.css
 					},
 
Index: /CKEditor/branches/versions/3.1.x/_source/plugins/dialog/plugin.js
===================================================================
--- /CKEditor/branches/versions/3.1.x/_source/plugins/dialog/plugin.js	(revision 4620)
+++ /CKEditor/branches/versions/3.1.x/_source/plugins/dialog/plugin.js	(revision 4621)
@@ -7,9 +7,4 @@
  * @fileOverview The floating dialog plugin.
  */
-
-CKEDITOR.plugins.add( 'dialog',
-	{
-		requires : [ 'dialogui' ]
-	});
 
 /**
@@ -73,7 +68,4 @@
 		return null;
 	}
-
-	// Stores dialog related data from skin definitions. e.g. margin sizes.
-	var skinData = {};
 
 	/**
@@ -1457,5 +1449,5 @@
 			editor = dialog.getParentEditor(),
 			magnetDistance = editor.config.dialog_magnetDistance,
-			margins = skinData[ editor.skinName ].margins || [ 0, 0, 0, 0 ];
+			margins = editor.skin.margins || [ 0, 0, 0, 0 ];
 
 		if ( typeof magnetDistance == 'undefined' )
@@ -1535,5 +1527,5 @@
 			minHeight = definition.minHeight || 0,
 			resizable = definition.resizable,
-			margins = skinData[ dialog.getParentEditor().skinName ].margins || [ 0, 0, 0, 0 ];
+			margins = dialog.getParentEditor().skin.margins || [ 0, 0, 0, 0 ];
 
 		function topSizer( coords, dy )
@@ -2692,15 +2684,4 @@
 		};
 	})();
-
-	// Grab the margin data from skin definition and store it away.
-	CKEDITOR.skins.add = ( function()
-	{
-		var original = CKEDITOR.skins.add;
-		return function( skinName, skinDefinition )
-		{
-			skinData[ skinName ] = { margins : skinDefinition.margins };
-			return original.apply( this, arguments );
-		};
-	} )();
 })();
 
@@ -2756,4 +2737,9 @@
 			return null;
 		}
+	});
+
+CKEDITOR.plugins.add( 'dialog',
+	{
+		requires : [ 'dialogui' ]
 	});
 
Index: /CKEditor/branches/versions/3.1.x/_source/plugins/font/plugin.js
===================================================================
--- /CKEditor/branches/versions/3.1.x/_source/plugins/font/plugin.js	(revision 4620)
+++ /CKEditor/branches/versions/3.1.x/_source/plugins/font/plugin.js	(revision 4621)
@@ -37,5 +37,5 @@
 				panel :
 				{
-					css : [ CKEDITOR.getUrl( editor.skinPath + 'editor.css' ) ].concat( config.contentsCss ),
+					css : editor.skin.editor.css.concat( config.contentsCss ),
 					voiceLabel : lang.panelVoiceLabel
 				},
Index: /CKEditor/branches/versions/3.1.x/_source/plugins/format/plugin.js
===================================================================
--- /CKEditor/branches/versions/3.1.x/_source/plugins/format/plugin.js	(revision 4620)
+++ /CKEditor/branches/versions/3.1.x/_source/plugins/format/plugin.js	(revision 4621)
@@ -34,5 +34,5 @@
 				panel :
 				{
-					css : [ CKEDITOR.getUrl( editor.skinPath + 'editor.css' ) ].concat( config.contentsCss ),
+					css : editor.skin.editor.css.concat( config.contentsCss ),
 					voiceLabel : lang.panelVoiceLabel
 				},
Index: /CKEditor/branches/versions/3.1.x/_source/plugins/menu/plugin.js
===================================================================
--- /CKEditor/branches/versions/3.1.x/_source/plugins/menu/plugin.js	(revision 4620)
+++ /CKEditor/branches/versions/3.1.x/_source/plugins/menu/plugin.js	(revision 4621)
@@ -138,5 +138,5 @@
 					panel = this._.panel = new CKEDITOR.ui.floatPanel( this.editor, CKEDITOR.document.getBody(),
 						{
-							css : [ CKEDITOR.getUrl( editor.skinPath + 'editor.css' ) ],
+							css : editor.skin.editor.css,
 							level : this._.level - 1,
 							className : editor.skinClass + ' cke_contextmenu'
Index: /CKEditor/branches/versions/3.1.x/_source/plugins/panel/plugin.js
===================================================================
--- /CKEditor/branches/versions/3.1.x/_source/plugins/panel/plugin.js	(revision 4620)
+++ /CKEditor/branches/versions/3.1.x/_source/plugins/panel/plugin.js	(revision 4621)
@@ -161,5 +161,5 @@
 						// after <body>, so it (body) becames immediatelly
 						// available. (#3031)
-						'<link type="text/css" rel=stylesheet href="' + this.css.join( '"><link type="text/css" rel="stylesheet" href="' ) + '">' +
+						CKEDITOR.tools.buildStyleHtml( this.css ) +
 					'<\/html>' );
 				doc.$.close();
Index: /CKEditor/branches/versions/3.1.x/_source/plugins/preview/plugin.js
===================================================================
--- /CKEditor/branches/versions/3.1.x/_source/plugins/preview/plugin.js	(revision 4620)
+++ /CKEditor/branches/versions/3.1.x/_source/plugins/preview/plugin.js	(revision 4621)
@@ -38,7 +38,5 @@
 					baseTag +
 					'<title>' + editor.lang.preview + '</title>' +
-					'<link type="text/css" rel="stylesheet" href="' +
-					[].concat( editor.config.contentsCss ).join( '"><link type="text/css" rel="stylesheet" href="' ) +
-					'">' +
+					CKEDITOR.tools.buildStyleHtml( editor.config.contentsCss ) +
 					'</head>' + bodyHtml +
 					editor.getData() +
Index: /CKEditor/branches/versions/3.1.x/_source/plugins/stylescombo/plugin.js
===================================================================
--- /CKEditor/branches/versions/3.1.x/_source/plugins/stylescombo/plugin.js	(revision 4620)
+++ /CKEditor/branches/versions/3.1.x/_source/plugins/stylescombo/plugin.js	(revision 4621)
@@ -27,5 +27,5 @@
 					panel :
 					{
-						css : [ CKEDITOR.getUrl( editor.skinPath + 'editor.css' ) ].concat( config.contentsCss ),
+						css : editor.skin.editor.css.concat( config.contentsCss ),
 						voiceLabel : lang.panelVoiceLabel
 					},
Index: /CKEditor/branches/versions/3.1.x/_source/plugins/wysiwygarea/plugin.js
===================================================================
--- /CKEditor/branches/versions/3.1.x/_source/plugins/wysiwygarea/plugin.js	(revision 4620)
+++ /CKEditor/branches/versions/3.1.x/_source/plugins/wysiwygarea/plugin.js	(revision 4621)
@@ -593,7 +593,5 @@
 									'<html dir="' + editor.config.contentsLangDirection + '">' +
 									'<head>' +
-										'<link type="text/css" rel="stylesheet" href="' +
-										[].concat( editor.config.contentsCss ).join( '"><link type="text/css" rel="stylesheet" href="' ) +
-										'">' +
+										CKEDITOR.tools.buildStyleHtml( editor.config.contentsCss ) +
 										'<style type="text/css" _fcktemp="true">' +
 											editor._.styles.join( '\n' ) +
Index: /CKEditor/branches/versions/3.1.x/_source/skins/kama/skin.js
===================================================================
--- /CKEditor/branches/versions/3.1.x/_source/skins/kama/skin.js	(revision 4620)
+++ /CKEditor/branches/versions/3.1.x/_source/skins/kama/skin.js	(revision 4621)
@@ -204,5 +204,5 @@
 })() );
 
-if ( CKEDITOR.dialog )
+CKEDITOR.on( 'dialogPluginReady', function()
 {
 	CKEDITOR.dialog.on( 'resize', function( evt )
@@ -259,6 +259,6 @@
 				},
 				100 );
-		});
-}
+		} );
+} );
 
 /**
Index: /CKEditor/branches/versions/3.1.x/_source/skins/office2003/skin.js
===================================================================
--- /CKEditor/branches/versions/3.1.x/_source/skins/office2003/skin.js	(revision 4620)
+++ /CKEditor/branches/versions/3.1.x/_source/skins/office2003/skin.js	(revision 4621)
@@ -24,5 +24,5 @@
 })() );
 
-if ( CKEDITOR.dialog )
+CKEDITOR.on( 'dialogPluginReady', function()
 {
 	CKEDITOR.dialog.on( 'resize', function( evt )
@@ -74,4 +74,4 @@
 			if ( evt.editor.lang.dir == 'rtl' )
 				setTimeout( fixSize, 1000 );
-		});
-}
+		} );
+} );
Index: /CKEditor/branches/versions/3.1.x/_source/skins/v2/skin.js
===================================================================
--- /CKEditor/branches/versions/3.1.x/_source/skins/v2/skin.js	(revision 4620)
+++ /CKEditor/branches/versions/3.1.x/_source/skins/v2/skin.js	(revision 4621)
@@ -24,5 +24,5 @@
 })() );
 
-if ( CKEDITOR.dialog )
+CKEDITOR.on( 'dialogPluginReady', function()
 {
 	CKEDITOR.dialog.on( 'resize', function( evt )
@@ -70,4 +70,4 @@
 				},
 				100 );
-		});
-}
+		} );
+} );
