#922: Generic EMBED and OBJECT placeholder
--------------------------+-------------------------------------------------
  Reporter:  fredck       |       Owner:  martinkou        
      Type:  New Feature  |      Status:  assigned         
  Priority:  Normal       |   Milestone:  FCKeditor 2.6    
 Component:  General      |     Version:                   
Resolution:               |    Keywords:  Confirmed Review?
--------------------------+-------------------------------------------------
Comment (by fredck):

 We've found out that the ProtectSource and ProtectHtml part of the code is
 not needed, as we can use ProtectTags on IE to solve the <object> problem.

 There are also some other improvements that could be done.

  * Looking at the defaultObjectHandler and the FCKFlashHandler code, we
 see duplication. Maybe it is a good idea having defaultObjectHandler
 publicly available (FCKEmbedAndObjectProcessor.DefaultObjectHandler),
 making it possible to reuse that code on custom object handlers.

  * The FCKFlashHandler.Refresh code don't have to check if it is dealing
 with an <embed> or not. It should be exactly like
 defaultObjectHandler.Refresh.

  * Actually, the AttachClassIdHandler, AttachFileSuffixHandler and
 AttachContentTypeHandler should expect a function only to be passed (the
 current Process function contents), not an object defining the "Process"
 and "Refresh".

  * The processElement function is to be rewritten. The following should
 give the exact same results, but is clearer and performs better (not
 tested):

 {{{
 var processElement = function( el )
 {
         // Look for a Content Type processor.
         var type = el.type ;
         if ( type && contentTypeProcessors[type] &&
 contentTypeProcessors[type].Process( el ) )
                 return ;

         var nodeName = el.nodeName.toLowerCase() ;

         // Look for a Class ID processor.
         if ( nodeName == 'object' && el.classid )
         {
                 var classidProcessor = classidProcessors[
 el.classId.replace( /[ \t]/g, '' ).toLowerCase() ] ;

                 if ( classidProcessor && classidProcessor.Process( el ) )
                         return ;
         }

         // Look for a file name suffix processor.
         if ( nodeName == 'embed' && el.src )
         {
                 var suffix = el.src.match( /\.(\w+)(?:\?[0-9A-
 Za-z!'()*-._~+&=]*)?$/ ) ;
                 suffix = suffix && suffix[1] ;

                 if ( suffix && suffixProcessors[suffix] &&
 suffixProcessors[suffix].Process( el ) )
                         return ;
         }

         // Return the default one.
         defaultObjectHandler.Process( el ) ;
 }
 }}}

  * The exact same changes proposed with the above snippet are applicable
 to FCKEmbedAndObjectProcessor.RefreshView. That code duplication don't
 smells good anyway.

  * Came to my eyes that the FCK.IsDirty() save/reset trick done in
 FCKEmbedAndObjectProcessor.ProcessDocument should be done in
 FCKDocumentProcessor.Process instead (I know, it was already in the code).

 ---

 After writing the above points and after some long thoughts about it, it
 seems that our the custom object handler proposal is much more complex
 than what it should be. It also bring limitations to the system.

 Much probably all we really need is:
 FCKEmbedAndObjectProcessor.AddCustomHandler( <function>). Then for each
 object or embed found, the custom handler function is called. If it
 returns "=== false", no further handlers are checked, otherwise the
 default one is used.

 Then, it is up to the custom handler function to test if the element found
 is good or not for it, by checking the element name, class id, content
 type, or any other attribute it wants too, making it possible to create
 custom handlers for <object> elements containing specific <param>
 elements, for example. It would give much flexibility, making our code
 changes quite small to provide this generic object placeholder.

 It means that, if we go with this simplification, all the above points
 should be ignored, except the last one.

-- 
Ticket URL: <http://dev.fckeditor.net/ticket/922#comment:5>
FCKeditor <http://www.fckeditor.net>
The text editor for Internet
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
FCKeditor-Trac mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fckeditor-trac

Reply via email to