Index: /FCKeditor/branches/features/generic_plugin/editor/_source/internals/fckdocumentprocessor.js
===================================================================
--- /FCKeditor/branches/features/generic_plugin/editor/_source/internals/fckdocumentprocessor.js	(revision 1680)
+++ /FCKeditor/branches/features/generic_plugin/editor/_source/internals/fckdocumentprocessor.js	(revision 1681)
@@ -120,166 +120,117 @@
 
 // EMBED and OBJECT tags.
-var FCKEmbedAndObjectProcessor = FCKDocumentProcessor.AppendNew() ;
-FCKTools.Merge( FCKEmbedAndObjectProcessor,
-	{
-		ProcessDocument : function( doc )
-		{
-			var bIsDirty = FCK.IsDirty() ;
-
-			// Process OBJECTs first, since EMBEDs can sometimes go inside OBJECTS (e.g. Flash).
-			var aObjects = doc.getElementsByTagName( 'object' );
-			for ( var i = aObjects.length - 1 ; i >= 0 ; i-- )
-				this.ProcessObjectElement( aObjects[i] ) ;
-
-			// Now process any EMBEDs left.
-			var aEmbeds = doc.getElementsByTagName( 'embed' ) ;
-			for ( var i = aEmbeds.length - 1 ; i >= 0 ; i-- )
-				this.ProcessEmbedElement( aEmbeds[i] ) ;
-
-			if ( !bIsDirty )
-				FCK.ResetIsDirty() ;
+FCKEmbedAndObjectProcessor = (function()
+{
+	var classidProcessors = {} ;
+	var suffixProcessors = {} ;
+	var contentTypeProcessors = {} ;
+	var defaultObjectHandler = {
+		'Process' : function( el )
+		{
+			var clone = el.cloneNode( true ) ;
+			var fakeImg = FCKDocumentProcessor_CreateFakeImage( 'FCK__UnknownObject', clone ) ;
+			this.Refresh( fakeImg, el ) ;
+			el.parentNode.replaceChild( fakeImg, el ) ;
 		},
 
-		ProcessHtml : function( html )
-		{
-			var tmp = document.createElement( 'div' ) ;
-			tmp.innerHTML = html ;
-
-			// We're only processing <OBJECT> tags from HTML right now, so let's just ignore <EMBED> tag processing here for now.
-			this.ProcessObjectElement( tmp.firstChild ) ;
-			return tmp.innerHTML ;
-		},
-
-		ProcessObjectElement : function( el )
-		{
-			var classId = el.attributes.classid ;
-			if ( classId )
-			{
-				classId = classId.value.replace( /[ \t]/g, '' ).toLowerCase() ;
-				if ( this.ObjectProcessors[classId] )
-					this.ObjectProcessors[classId].Process( el ) ;
-				else
-					this.DefaultObjectHandler.Process( el ) ;
-			}
-			else
-				this.DefaultObjectHandler.Process( el ) ;
-		},
-
-		ProcessEmbedElement : function( el )
-		{
-			var suffix = el.src.match( /\.(\w+)(?:\?[0-9A-Za-z!'()*-._~+&=]*)?$/ ) ;
-			var type = el.attributes.type && el.attributes.type.nodeValue ;
-			if ( type && this.EmbedMimeTypeProcessors[type] )
-				this.EmbedMimeTypeProcessors[type].Process( el ) ;
-			else if ( suffix )
-			{
-				suffix = suffix[1].toLowerCase() ;
-				if ( this.EmbedSuffixProcessors[suffix] )
-					this.EmbedSuffixProcessors[suffix].Process( el ) ;
-				else
-					this.DefaultEmbedHandler.Process( el ) ;
-			}
-			else
-				this.DefaultEmbedHandler.Process( el ) ;
-		},
-
-		RefreshView : function( placeHolder, original )
-		{
-			if ( original.nodeName.IEquals( 'object' ) )
-			{
-				var classid = original.attributes.classid ;
-				if ( classid )
-				{
-					classId = classId.value.replace( /[ \t]/g, '' ).toLowerCase() ;
-					if ( this.ObjectProcessors[classId] )
-						this.ObjectProcessors[classId].Refresh.apply( this, [placeHolder, original] );
-					else
-						this.DefaultObjectHandler.Refresh( placeHolder, original );
+		'Refresh' : function( placeHolder, original )
+		{
+			if ( original.getAttribute( 'width' ) > 0 )
+				placeHolder.style.width = FCKTools.ConvertHtmlSizeToStyle( original.getAttribute( 'width' ) ) ;
+
+			if ( original.getAttribute( 'height' ) > 0 )
+				placeHolder.style.height = FCKTools.ConvertHtmlSizeToStyle( original.getAttribute( 'height' ) ) ;
+		}
+	} ;
+
+	var processElement = function( el )
+	{
+		var classId = el.nodeName.IEquals( 'object' ) && el.classid ;
+		classId = classId && classId.replace( /[ \t]/g, '' ).toLowerCase() ;
+		var uri = el.nodeName.IEquals( 'embed' ) && el.src ;
+		var suffix = uri && uri.match( /\.(\w+)(?:\?[0-9A-Za-z!'()*-._~+&=]*)?$/ ) ;
+		suffix = suffix && suffix[1] ;
+		var type = el.type ;
+
+		var retval = false ;
+		if ( type && contentTypeProcessors[type] )
+			retval = contentTypeProcessors[type].Process( el ) ;
+		if ( !retval && classId && classidProcessors[classId] )
+			retval = classidProcessors[classId].Process( el ) ;
+		if ( !retval && suffix && suffixProcessors[suffix] )
+			retval = suffixProcessors[suffix].Process( el ) ;
+		if ( !retval )
+			defaultObjectHandler.Process( el ) ;
+	}
+
+	return FCKTools.Merge( FCKDocumentProcessor.AppendNew(),
+		       {
+				ProcessDocument : function( doc )
+				{
+					var bIsDirty = FCK.IsDirty() ;
+
+					// Process OBJECTs first, since EMBEDs can sometimes go inside OBJECTS (e.g. Flash).
+					var aObjects = doc.getElementsByTagName( 'object' );
+					for ( var i = aObjects.length - 1 ; i >= 0 ; i-- )
+						processElement( aObjects[i] ) ;
+
+					// Now process any EMBEDs left.
+					var aEmbeds = doc.getElementsByTagName( 'embed' ) ;
+					for ( var i = aEmbeds.length - 1 ; i >= 0 ; i-- )
+						processElement( aEmbeds[i] ) ;
+
+					if ( !bIsDirty )
+						FCK.ResetIsDirty() ;
+				},
+
+				ProcessHtml : function( html )
+				{
+					var tmp = document.createElement( 'div' ) ;
+					tmp.innerHTML = html ;
+					processElement( tmp.firstChild ) ;
+					return tmp.innerHTML ;
+				},
+
+				RefreshView : function( placeHolder, original )
+				{
+					var classId = original.nodeName.IEquals( 'object' ) && original.classid ;
+					classId = classId && classId.replace( /[ \t]/g, '' ).toLowerCase() ;
+					var uri = original.nodeName.IEquals( 'embed' ) && original.src ;
+					var suffix = uri && uri.match( /\.(\w+)(?:\?[0-9A-Za-z!'()*-._~+&=]*)?$/ ) ;
+					suffix = suffix && suffix[1] ;
+					var type = original.type ;
+
+					var retval = false ;
+					if ( type && contentTypeProcessors[type] )
+						retval = contentTypeProcessors[type].Refresh( placeHolder, original ) ;
+					if ( !retval && classId && classidProcessors[classId] )
+						retval = classidProcessors[classId].Refresh( placeHolder, original ) ;
+					if ( !retval && suffix && suffixProcessors[suffix] )
+						retval = suffixProcessors[suffix].Refresh( placeHolder, original ) ;
+					if ( !retval )
+						defaultObjectHandler.Refresh( placeHolder, original ) ;
+				},
+
+				// Include the "clsid:" part to classID as well, case insensitive.
+				AttachClassIdHandler : function( classId, obj )
+				{
+					classId = classId.replace( /[ \t]/g, '' ).toLowerCase() ;
+					classidProcessors[classId] = obj ;
+				},
+
+				// Suffix is case insensitive.
+				AttachFileSuffixHandler : function( suffix, obj )
+				{
+					suffixProcessors[suffix.toLowerCase()] = obj ;
+				},
+
+				// MIME type is case sensitive since there are some MIME types that are distinguished by case alone.
+				AttachContentTypeHandler : function( mimestr, obj )
+				{
+					contentTypeProcessors[mimestr] = obj ;
 				}
-				else
-					this.DefaultObjectHandler.Refresh( placeHolder, original );
-			}
-			else
-			{
-				var suffix = original.src.match( /\.(\w+)(?:\?[0-9A-Za-z!'()*-._~+&=]*)?$/ ) ;
-				var type = original.attributes.type && el.attributes.type.nodeValue ;
-				if ( type && this.EmbedMimeTypeProcessors[type] )
-					this.EmbedMimeTypeProcessors[type].Refresh.apply( this, [placeHolder, original] ) ;
-				else if ( suffix )
-				{
-					suffix = suffix[1].toLowerCase() ;
-					if ( this.EmbedSuffixProcessors[suffix] )
-						this.EmbedSuffixProcessors[suffix].Refresh.apply( this, [placeHolder, original] ) ;
-					else
-						this.DefaultEmbedHandler.Refresh( placeHolder, original ) ;
-				}
-				else
-					this.DefaultEmbedHandler.Refresh( placeHolder, original ) ;
-			}
-		},
-
-		ObjectProcessors : {},
-		EmbedSuffixProcessors : {},
-		EmbedMimeTypeProcessors : {},
-
-		// Include the "clsid:" part to classID as well, case insensitive.
-		AttachObjectHandler : function( classId, obj )
-		{
-			classId = classId.replace( /[ \t]/g, '' ).toLowerCase() ;
-			this.ObjectProcessors[classId] = obj ;
-		},
-
-		// Suffix is case insensitive.
-		AttachEmbedHandlerByFileSuffix : function( suffix, obj )
-		{
-			this.EmbedSuffixProcessors[suffix.toLowerCase()] = obj ;
-		},
-
-		// MIME type is case sensitive since there are some MIME types that are distinguished by case alone.
-		AttachEmbedHandlerByMimeType : function( mimestr, obj )
-		{
-			this.EmbedMimeTypeProcessors[mimestr] = obj ;
-		},
-
-		DefaultObjectHandler : 
-		{
-			'Process' : function( el )
-			{
-				var clone = el.cloneNode( true ) ;
-				var fakeImg = FCKDocumentProcessor_CreateFakeImage( 'FCK__UnknownObject', clone ) ;
-				this.Refresh( fakeImg, el ) ;
-				el.parentNode.replaceChild( fakeImg, el ) ;
-			},
-
-			'Refresh' : function( placeHolder, original )
-			{
-				if ( original.getAttribute( 'width' ) > 0 )
-					placeHolder.style.width = FCKTools.ConvertHtmlSizeToStyle( original.getAttribute( 'width' ) ) ;
-
-				if ( original.getAttribute( 'height' ) > 0 )
-					placeHolder.style.height = FCKTools.ConvertHtmlSizeToStyle( original.getAttribute( 'height' ) ) ;
-			}
-		},
-
-		DefaultEmbedHandler : 
-		{
-			'Process' : function( el )
-			{
-				var clone = el.cloneNode( true ) ;
-				var fakeImg = FCKDocumentProcessor_CreateFakeImage( 'FCK__UnknownObject', clone ) ;
-				this.Refresh( fakeImg, el ) ;
-				el.parentNode.replaceChild( fakeImg, el ) ;
-			},
-
-			'Refresh' : function( placeHolder, original )
-			{
-				if ( original.getAttribute( 'width' ) > 0 )
-					placeHolder.style.width = FCKTools.ConvertHtmlSizeToStyle( original.getAttribute( 'width' ) ) ;
-
-				if ( original.getAttribute( 'height' ) > 0 )
-					placeHolder.style.height = FCKTools.ConvertHtmlSizeToStyle( original.getAttribute( 'height' ) ) ;
-			}
-		} 
-	} ) ;
+			} ) ;
+} )() ;
+
 if ( FCKBrowserInfo.IsIE )
 {
@@ -355,4 +306,6 @@
 	Process : function( el )
 	{
+		if ( !el.nodeName.IEquals( 'embed' ) )
+			return false ;
 		var clone = el.cloneNode( true ) ;
 		var fakeImg = FCKDocumentProcessor_CreateFakeImage( 'FCK__Flash', clone ) ;
@@ -360,15 +313,18 @@
 		this.Refresh( fakeImg, el ) ;
 		el.parentNode.replaceChild( fakeImg, el ) ;
+		return true ;
 	},
 
 	Refresh : function( placeHolderImage, originalEmbed )
 	{
+		if ( !originalEmbed.nodeName.IEquals( 'embed' ) )
+			return false ;
 		if ( originalEmbed.getAttribute( 'width' ) > 0 )
 			placeHolderImage.style.width = FCKTools.ConvertHtmlSizeToStyle( originalEmbed.getAttribute( 'width' ) ) ;
-
 		if ( originalEmbed.getAttribute( 'height' ) > 0 )
 			placeHolderImage.style.height = FCKTools.ConvertHtmlSizeToStyle( originalEmbed.getAttribute( 'height' ) ) ;
+		return true ;
 	}
 } ;
-FCKEmbedAndObjectProcessor.AttachEmbedHandlerByFileSuffix( 'swf', FCKFlashHandler ) ;
-FCKEmbedAndObjectProcessor.AttachEmbedHandlerByMimeType( 'application/x-shockwave-flash', FCKFlashHandler ) ;
+FCKEmbedAndObjectProcessor.AttachFileSuffixHandler( 'swf', FCKFlashHandler ) ;
+FCKEmbedAndObjectProcessor.AttachContentTypeHandler( 'application/x-shockwave-flash', FCKFlashHandler ) ;
