Index: _source/core/tools.js
===================================================================
--- _source/core/tools.js	(revision 4373)
+++ _source/core/tools.js	Tue Nov 03 00:41:16 CST 2009
@@ -98,6 +98,15 @@
 		},
 
 		/**
+		 * 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.
 		 * @param {Object} target The object to be extended.
@@ -220,6 +229,27 @@
 		} )(),
 
 		/**
+		 * 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.
 		 * @param {String} text The string to be encoded.
Index: _source/plugins/wysiwygarea/plugin.js
===================================================================
--- _source/plugins/wysiwygarea/plugin.js	(revision 4371)
+++ _source/plugins/wysiwygarea/plugin.js	Mon Nov 02 23:35:32 CST 2009
@@ -560,9 +560,7 @@
 									editor.config.docType +
 									'<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' ) +
 										'</style>'+
Index: _source/plugins/menu/plugin.js
===================================================================
--- _source/plugins/menu/plugin.js	(revision 4367)
+++ _source/plugins/menu/plugin.js	Mon Nov 02 23:42:34 CST 2009
@@ -132,7 +132,7 @@
 				{
 					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: _source/core/skins.js
===================================================================
--- _source/core/skins.js	(revision 4362)
+++ _source/core/skins.js	Tue Nov 03 00:02:52 CST 2009
@@ -20,7 +20,7 @@
 	var preloaded = {};
 	var paths = {};

-	var loadedPart = function( skinName, part, callback )
+	var loadPart = function( skinName, part, callback )
 	{
 		// Get the skin definition.
 		var skinDefinition = loaded[ skinName ];
@@ -33,6 +33,18 @@
 			}
 		};

+		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 ] )
 		{
@@ -43,7 +55,7 @@
 				CKEDITOR.imageCacher.load( preload, function()
 					{
 						preloaded[ skinName ] = 1;
-						loadedPart( skinName, part, callback );
+						loadPart( skinName, part, callback );
 					} );
 				return;
 			}
@@ -96,11 +108,24 @@
 			// Load the "css" pieces.
 			if ( !cssIsLoaded )
 			{
-				appendSkinPath( part.css );
+				var cssPart = part.css;

-				for ( var c = 0 ; c < part.css.length ; c++ )
-					CKEDITOR.document.appendStyleSheet( part.css[ c ] );
+				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;
 			}

@@ -119,7 +144,7 @@
 			checkIsLoaded();
 		}
 	};
-
+
 	return /** @lends CKEDITOR.skins */ {

 		/**
@@ -156,29 +181,19 @@
 				skinPath = editor.skinPath;

 			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
 			{
 				paths[ skinName ] = skinPath;
 				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: _source/core/editor.js
===================================================================
--- _source/core/editor.js	(revision 4373)
+++ _source/core/editor.js	Tue Nov 03 00:07:46 CST 2009
@@ -124,7 +124,7 @@
 		editor.fireOnce( 'configLoaded' );
 
 		// Load language file.
-		loadLang( editor );
+		loadSkin( editor );
 	};
 
 	var loadLang = function( editor )
@@ -246,7 +246,7 @@
 
 						// Load the editor skin.
 						editor.fire( 'pluginsLoaded' );
-						loadSkin( editor );
+						loadTheme( editor );
 					});
 			});
 	};
@@ -255,7 +255,7 @@
 	{
 		CKEDITOR.skins.load( editor, 'editor', function()
 			{
-				loadTheme( editor );
+				loadLang( editor );
 			});
 	};
 
Index: _source/core/dom/document.js
===================================================================
--- _source/core/dom/document.js	(revision 3332)
+++ _source/core/dom/document.js	Mon Nov 02 23:35:32 CST 2009
@@ -52,6 +52,21 @@
 			}
 		},
 
+		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 )
 		{
 			var element = new CKEDITOR.dom.element( name, this );
Index: _source/plugins/stylescombo/plugin.js
===================================================================
--- _source/plugins/stylescombo/plugin.js	(revision 4365)
+++ _source/plugins/stylescombo/plugin.js	Tue Nov 03 00:07:34 CST 2009
@@ -26,7 +26,7 @@
 
 					panel :
 					{
-						css : [ CKEDITOR.getUrl( editor.skinPath + 'editor.css' ) ].concat( config.contentsCss ),
+						css : editor.skin.editor.css.concat( config.contentsCss ),
 						voiceLabel : lang.panelVoiceLabel
 					},
 
Index: _source/plugins/panel/plugin.js
===================================================================
--- _source/plugins/panel/plugin.js	(revision 4197)
+++ _source/plugins/panel/plugin.js	Mon Nov 02 23:35:32 CST 2009
@@ -160,7 +160,7 @@
 						// It looks strange, but for FF2, the styles must go
 						// 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: _source/plugins/preview/plugin.js
===================================================================
--- _source/plugins/preview/plugin.js	(revision 4363)
+++ _source/plugins/preview/plugin.js	Mon Nov 02 23:35:32 CST 2009
@@ -37,9 +37,7 @@
 					'<head>' +
 					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() +
 					'</body></html>';
Index: _source/plugins/dialog/plugin.js
===================================================================
--- _source/plugins/dialog/plugin.js	(revision 4373)
+++ _source/plugins/dialog/plugin.js	Tue Nov 03 00:42:12 CST 2009
@@ -7,11 +7,6 @@
  * @fileOverview The floating dialog plugin.
  */
 
-CKEDITOR.plugins.add( 'dialog',
-	{
-		requires : [ 'dialogui' ]
-	});
-
 /**
  * No resize for this dialog.
  * @constant
@@ -73,9 +68,6 @@
 		return null;
 	}
 
-	// Stores dialog related data from skin definitions. e.g. margin sizes.
-	var skinData = {};
-
 	/**
 	 * This is the base class for runtime dialog objects. An instance of this
 	 * class represents a single named dialog for a single editor instance.
@@ -1437,7 +1429,7 @@
 			element = dialog.getElement().getFirst(),
 			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' )
 			magnetDistance = 20;
@@ -1515,7 +1507,7 @@
 			minWidth = definition.minWidth || 0,
 			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 )
 		{
@@ -2672,18 +2664,7 @@
 			}
 		};
 	})();
-
-	// 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 );
-		};
-	} )();
+})();
-})();
 
 // Extend the CKEDITOR.editor class with dialog specific functions.
 CKEDITOR.tools.extend( CKEDITOR.editor.prototype,
@@ -2736,6 +2717,11 @@
 		}
 	});
 
+CKEDITOR.plugins.add( 'dialog',
+	{
+		requires : [ 'dialogui' ]
+	});
+
 // Dialog related configurations.
 
 /**
Index: _source/plugins/font/plugin.js
===================================================================
--- _source/plugins/font/plugin.js	(revision 4363)
+++ _source/plugins/font/plugin.js	Mon Nov 02 23:42:34 CST 2009
@@ -36,7 +36,7 @@
 
 				panel :
 				{
-					css : [ CKEDITOR.getUrl( editor.skinPath + 'editor.css' ) ].concat( config.contentsCss ),
+					css : editor.skin.editor.css.concat( config.contentsCss ),
 					voiceLabel : lang.panelVoiceLabel
 				},
 
Index: _source/plugins/colorbutton/plugin.js
===================================================================
--- _source/plugins/colorbutton/plugin.js	(revision 4036)
+++ _source/plugins/colorbutton/plugin.js	Tue Nov 03 00:06:28 CST 2009
@@ -31,7 +31,7 @@
 
 					panel :
 					{
-						css : [ CKEDITOR.getUrl( editor.skinPath + 'editor.css' ) ]
+						css : editor.skin.editor.css
 					},
 
 					onBlock : function( panel, blockName )
Index: _source/core/resourcemanager.js
===================================================================
--- _source/core/resourcemanager.js	(revision 3308)
+++ _source/core/resourcemanager.js	Tue Nov 03 00:41:16 CST 2009
@@ -86,7 +86,8 @@
 		if ( this.registered[ name ] )
 			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: _source/plugins/format/plugin.js
===================================================================
--- _source/plugins/format/plugin.js	(revision 4363)
+++ _source/plugins/format/plugin.js	Tue Nov 03 00:06:10 CST 2009
@@ -33,7 +33,7 @@
 
 				panel :
 				{
-					css : [ CKEDITOR.getUrl( editor.skinPath + 'editor.css' ) ].concat( config.contentsCss ),
+					css : editor.skin.editor.css.concat( config.contentsCss ),
 					voiceLabel : lang.panelVoiceLabel
 				},
 
Index: _source/skins/kama/skin.js
===================================================================
--- _source/skins/kama/skin.js	(revision 4373)
+++ _source/skins/kama/skin.js	Tue Nov 03 00:44:16 CST 2009
@@ -203,7 +203,7 @@
 	};
 })() );

-if ( CKEDITOR.dialog )
+CKEDITOR.on( 'dialogPluginReady', function()
 {
 	CKEDITOR.dialog.on( 'resize', function( evt )
 		{
@@ -258,8 +258,8 @@
 					el.setStyle( 'height', ( body.$.offsetHeight - 31 - 14 ) + 'px' );
 				},
 				100 );
-		});
+		} );
-}
+} );

 /**
  * The base user interface color to be used by the editor. Not all skins are
Index: _source/skins/v2/skin.js
===================================================================
--- _source/skins/v2/skin.js	(revision 3342)
+++ _source/skins/v2/skin.js	Tue Nov 03 00:44:16 CST 2009
@@ -23,7 +23,7 @@
 	};
 })() );

-if ( CKEDITOR.dialog )
+CKEDITOR.on( 'dialogPluginReady', function()
 {
 	CKEDITOR.dialog.on( 'resize', function( evt )
 		{
@@ -69,5 +69,5 @@
 					el.setStyle( 'height', ( body.$.offsetHeight - 31 - 14 ) + 'px' );
 				},
 				100 );
-		});
+		} );
-}
+} );
Index: _source/skins/office2003/skin.js
===================================================================
--- _source/skins/office2003/skin.js	(revision 3983)
+++ _source/skins/office2003/skin.js	Tue Nov 03 00:44:16 CST 2009
@@ -23,7 +23,7 @@
 	};
 })() );

-if ( CKEDITOR.dialog )
+CKEDITOR.on( 'dialogPluginReady', function()
 {
 	CKEDITOR.dialog.on( 'resize', function( evt )
 		{
@@ -73,5 +73,5 @@
 			// Ensure size is correct for RTL mode. (#4003)
 			if ( evt.editor.lang.dir == 'rtl' )
 				setTimeout( fixSize, 1000 );
-		});
+		} );
-}
+} );

