Index: CKEditor/releases/stable/_source/plugins/stylescombo/plugin.js
===================================================================
--- CKEditor/releases/stable/_source/plugins/stylescombo/plugin.js	(revision 5207)
+++ CKEditor/releases/stable/_source/plugins/stylescombo/plugin.js	(revision 5375)
@@ -6,6 +6,4 @@
 (function()
 {
-	var stylesManager;
-
 	CKEDITOR.plugins.add( 'stylescombo',
 	{
@@ -16,18 +14,36 @@
 			var config = editor.config,
 				lang = editor.lang.stylesCombo,
-				pluginPath = this.path,
-				styles;
-
-			if ( !stylesManager )
-				stylesManager = CKEDITOR.stylesSet;
-
-			var comboStylesSet = config.stylesCombo_stylesSet.split( ':' ),
-				styleSetName = comboStylesSet[ 0 ],
-				externalPath = comboStylesSet[ 1 ];
-
-			stylesManager.addExternal( styleSetName,
-					externalPath ?
-						comboStylesSet.slice( 1 ).join( ':' ) :
-						pluginPath + 'styles/' + styleSetName + '.js', '' );
+				styles = {},
+				stylesList = [];
+
+			function loadStylesSet( callback )
+			{
+				editor.getStylesSet( function( stylesDefinitions )
+				{
+					if ( !stylesList.length )
+					{
+						var style,
+							styleName;
+
+						// Put all styles into an Array.
+						for ( var i = 0 ; i < stylesDefinitions.length ; i++ )
+						{
+							var styleDefinition = stylesDefinitions[ i ];
+
+							styleName = styleDefinition.name;
+
+							style = styles[ styleName ] = new CKEDITOR.style( styleDefinition );
+							style._name = styleName;
+
+							stylesList.push( style );
+						}
+
+						// Sorts the Array, so the styles get grouped by type.
+						stylesList.sort( sortStyles );
+					}
+
+					callback && callback();
+				});
+			}
 
 			editor.ui.addRichCombo( 'Styles',
@@ -48,34 +64,12 @@
 						var combo = this;
 
-						CKEDITOR.stylesSet.load( styleSetName, function( stylesSet )
+						loadStylesSet( function()
 							{
-								var stylesDefinitions = stylesSet[ styleSetName ],
-									style,
-									styleName,
-									stylesList = [];
-
-								styles = {};
-
-								// Put all styles into an Array.
-								for ( var i = 0 ; i < stylesDefinitions.length ; i++ )
-								{
-									var styleDefinition = stylesDefinitions[ i ];
-
-									styleName = styleDefinition.name;
-
-									style = styles[ styleName ] = new CKEDITOR.style( styleDefinition );
-									style._name = styleName;
-
-									stylesList.push( style );
-								}
-
-								// Sorts the Array, so the styles get grouped
-								// by type.
-								stylesList.sort( sortStyles );
+								var style, styleName;
 
 								// Loop over the Array, adding all items to the
 								// combo.
 								var lastType;
-								for ( i = 0 ; i < stylesList.length ; i++ )
+								for ( var i = 0 ; i < stylesList.length ; i++ )
 								{
 									style = stylesList[ i ];
@@ -92,5 +86,5 @@
 									combo.add(
 										styleName,
-										style.type == CKEDITOR.STYLE_OBJECT ? styleName : buildPreview( style._.definition ),
+										style.type == CKEDITOR.STYLE_OBJECT ? styleName : style.buildPreview(),
 										styleName );
 								}
@@ -109,13 +103,4 @@
 						var style = styles[ value ],
 							selection = editor.getSelection();
-
-						if ( style.type == CKEDITOR.STYLE_OBJECT )
-						{
-							var element = selection.getSelectedElement();
-							if ( element )
-								style.applyToObject( element );
-
-							return;
-						}
 
 						var elementPath = new CKEDITOR.dom.elementPath( selection.getStartElement() );
@@ -164,5 +149,5 @@
 					onOpen : function()
 					{
-						if ( CKEDITOR.env.ie )
+						if ( CKEDITOR.env.ie || CKEDITOR.env.webkit )
 							editor.focus();
 
@@ -170,5 +155,4 @@
 
 						var element = selection.getSelectedElement(),
-							elementName = element && element.getName(),
 							elementPath = new CKEDITOR.dom.elementPath( element || selection.getStartElement() );
 
@@ -181,23 +165,13 @@
 								type = style.type;
 
-							if ( type == CKEDITOR.STYLE_OBJECT )
+							if ( style.checkActive( elementPath ) )
+								this.mark( name );
+							else if ( type == CKEDITOR.STYLE_OBJECT && !style.checkApplicable( elementPath ) )
 							{
-								if ( element && style.element == elementName )
-								{
-									if ( style.checkElementRemovable( element, true ) )
-										this.mark( name );
-
-									counter[ type ]++;
-								}
-								else
-									this.hideItem( name );
+								this.hideItem( name );
+								counter[ type ]--;
 							}
-							else
-							{
-								if ( style.checkActive( elementPath ) )
-									this.mark( name );
-
-								counter[ type ]++;
-							}
+
+							counter[ type ]++;
 						}
 
@@ -212,38 +186,8 @@
 					}
 				});
+
+			editor.on( 'instanceReady', function() { loadStylesSet(); } );
 		}
 	});
-
-	function buildPreview( styleDefinition )
-	{
-		var html = [];
-
-		var elementName = styleDefinition.element;
-
-		// Avoid <bdo> in the preview.
-		if ( elementName == 'bdo' )
-			elementName = 'span';
-
-		html = [ '<', elementName ];
-
-		// Assign all defined attributes.
-		var attribs	= styleDefinition.attributes;
-		if ( attribs )
-		{
-			for ( var att in attribs )
-			{
-				html.push( ' ', att, '="', attribs[ att ], '"' );
-			}
-		}
-
-		// Assign the style attribute.
-		var cssStyle = CKEDITOR.style.getStyleText( styleDefinition );
-		if ( cssStyle )
-			html.push( ' style="', cssStyle, '"' );
-
-		html.push( '>', styleDefinition.name, '</', elementName, '>' );
-
-		return html.join( '' );
-	}
 
 	function sortStyles( styleA, styleB )
@@ -259,24 +203,2 @@
 	}
 })();
-
-/**
- * The "styles definition set" to load into the styles combo. The styles may
- * be defined in the page containing the editor, or can be loaded on demand
- * from an external file when opening the styles combo for the fist time. In
- * the second case, if this setting contains only a name, the styles definition
- * file will be loaded from the "styles" folder inside the stylescombo plugin
- * folder. Otherwise, this setting has the "name:url" syntax, making it
- * possible to set the URL from which loading the styles file.
- * @type string
- * @default 'default'
- * @example
- * // Load from the stylescombo styles folder (mystyles.js file).
- * config.stylesCombo_stylesSet = 'mystyles';
- * @example
- * // Load from a relative URL.
- * config.stylesCombo_stylesSet = 'mystyles:/editorstyles/styles.js';
- * @example
- * // Load from a full URL.
- * config.stylesCombo_stylesSet = 'mystyles:http://www.example.com/editorstyles/styles.js';
- */
-CKEDITOR.config.stylesCombo_stylesSet = 'default';
