Ticket #4555: 4555_7.patch

File 4555_7.patch, 11.3 KB (added by Alfonso Martínez de Lizarrondo, 14 years ago)

Revised patch

  • _source/core/dom/domobject.js

     
    115115                                        delete nativeListeners[ eventName ];
    116116                                }
    117117                        }
     118                },
     119
     120                /**
     121                 * Removes any listener set on this object.
     122                 * To avoid memory leaks we must assure that there are no
     123                 * references left after the object is no longer needed.
     124                 */
     125                removeAllListeners : function()
     126                {
     127                        var nativeListeners = this.getCustomData( '_cke_nativeListeners' );
     128                        for ( eventName in nativeListeners)
     129                        {
     130                                var listener = nativeListeners[ eventName ];
     131                                if ( this.$.removeEventListener )
     132                                        this.$.removeEventListener( eventName, listener, false );
     133                                else if ( this.$.detachEvent )
     134                                        this.$.detachEvent( 'on' + eventName, listener );
     135
     136                                delete nativeListeners[ eventName ];
     137                        }
    118138                }
    119139        };
    120140})();
     
    197217        };
    198218
    199219        /**
     220         * Removes any data stored on this object.
     221         * To avoid memory leaks we must assure that there are no
     222         * references left after the object is no longer needed.
     223         * @name CKEDITOR.dom.domObject.prototype.clearCustomData
     224         * @function
     225         */
     226        domObjectProto.clearCustomData = function()
     227        {
     228                // Clear all event listeners
     229                this.removeAllListeners();
     230
     231                var expandoNumber = this.$._cke_expando;
     232                expandoNumber && delete customData[ expandoNumber ];
     233        };
     234
     235        /**
    200236         * @name CKEDITOR.dom.domObject.prototype.getCustomData
    201237         */
    202238        domObjectProto.getUniqueId = function()
  • _source/core/editor.js

     
    468468                        if ( !noUpdate )
    469469                                this.updateElement();
    470470
     471                        if ( this.mode )
     472                        {
     473                                var holderElement = this.getThemeSpace( 'contents' ),
     474                                        currentMode = this._.modes[ editor.mode ];
     475                                currentMode.unload( holderElement );
     476                        }
     477
    471478                        this.theme.destroy( this );
     479
     480                        var toolbars,
     481                                index, j, items;
     482
     483                        if (this.toolbox)
     484                        {
     485                                toolbars = this.toolbox.toolbars;
     486                                for( index = 0; index < toolbars.length ; index++ )
     487                                {
     488                                        items = toolbars[ index ].items;
     489                                        for ( j = 0; j<items.length ; j++)
     490                                        {
     491                                                var instance = items[ j ];
     492                                                if ( instance.clickFn ) CKEDITOR.tools.removeFunction( instance.clickFn );
     493                                                if ( instance.keyDownFn ) CKEDITOR.tools.removeFunction( instance.keyDownFn );
     494
     495                                                if ( instance.index ) CKEDITOR.ui.button._.instances[ instance.index ] = null;
     496                                        }
     497                                }
     498                        }
     499
     500                        if (this.contextMenu)
     501                                CKEDITOR.tools.removeFunction( this.contextMenu._.functionId );
     502
     503                        if (this._.filebrowserFn)
     504                                CKEDITOR.tools.removeFunction( this._.filebrowserFn );
     505
    472506                        this.fire( 'destroy' );
    473507                        CKEDITOR.remove( this );
    474508                        CKEDITOR.fire( 'instanceDestroyed', null, this );
  • _source/core/imagecacher.js

     
    1111        {
    1212                var doCallback = function()
    1313                        {
     14                                img.removeAllListeners();
    1415                                loaded[ image ] = 1;
    1516                                callback();
    1617                        };
  • _source/plugins/button/plugin.js

     
    6969         */
    7070        render : function( editor, output )
    7171        {
    72                 var env = CKEDITOR.env;
     72                var env = CKEDITOR.env,
     73                        id = this._.id = 'cke_' + CKEDITOR.tools.getNextNumber(),
     74                        classes = '',
     75                        command = this.command, // Get the command name.
     76                        clickFn,
     77                        index;
    7378
    74                 var id = this._.id = 'cke_' + CKEDITOR.tools.getNextNumber();
    7579                this._.editor = editor;
    7680
    7781                var instance =
     
    9094                        }
    9195                };
    9296
    93                 var clickFn = CKEDITOR.tools.addFunction( instance.execute, instance );
     97                instance.clickFn = clickFn = CKEDITOR.tools.addFunction( instance.execute, instance );
    9498
    95                 var index = CKEDITOR.ui.button._.instances.push( instance ) - 1;
     99                instance.index = index = CKEDITOR.ui.button._.instances.push( instance ) - 1;
    96100
    97                 var classes = '';
    98 
    99                 // Get the command name.
    100                 var command = this.command;
    101 
    102101                if ( this.modes )
    103102                {
    104103                        editor.on( 'mode', function()
  • _source/plugins/filebrowser/plugin.js

     
    378378                init : function( editor, pluginPath )
    379379                {
    380380                        editor._.filebrowserFn = CKEDITOR.tools.addFunction( setUrl, editor );
     381                }
     382        } );
    381383
    382                         CKEDITOR.on( 'dialogDefinition', function( evt )
     384        CKEDITOR.on( 'dialogDefinition', function( evt )
     385        {
     386                var definition = evt.data.definition,
     387                        element;
     388                // Associate filebrowser to elements with 'filebrowser' attribute.
     389                for ( var i in definition.contents )
     390                {
     391                        element = definition.contents[ i ] ;
     392                        attachFileBrowser( evt.editor, evt.data.name, definition, element.elements );
     393                        if ( element.hidden && element.filebrowser )
    383394                        {
    384                                 var definition = evt.data.definition,
    385                                         element;
    386                                 // Associate filebrowser to elements with 'filebrowser' attribute.
    387                                 for ( var i in definition.contents )
    388                                 {
    389                                         element = definition.contents[ i ] ;
    390                                         attachFileBrowser( evt.editor, evt.data.name, definition, element.elements );
    391                                         if ( element.hidden && element.filebrowser )
    392                                         {
    393                                                 element.hidden = !isConfigured( definition, element[ 'id' ], element.filebrowser );
    394                                         }
    395                                 }
    396                         } );
     395                                element.hidden = !isConfigured( definition, element[ 'id' ], element.filebrowser );
     396                        }
    397397                }
    398398        } );
    399399
  • _source/plugins/resize/plugin.js

     
    5555                                        }
    5656                                } );
    5757
     58                        editor.on( 'destroy', function() { CKEDITOR.tools.removeFunction( mouseDownFn ) } );
     59
    5860                        editor.on( 'themeSpace', function( event )
    5961                                {
    6062                                        if ( event.data.space == 'bottom' )
  • _source/plugins/richcombo/plugin.js

     
    130130                                        var element = CKEDITOR.document.getById( id ).getChild( 1 );
    131131                                        element.focus();
    132132                                },
    133                                 execute : clickFn
     133                                clickFn : clickFn
    134134                        };
    135135
    136136                        editor.on( 'mode', function()
     
    161161                                        ev.preventDefault();
    162162                                });
    163163
     164                        // For clean up
     165                        instance.keyDownFn = keyDownFn;
     166
    164167                        output.push(
    165168                                '<span class="cke_rcombo">',
    166169                                '<span id=', id );
  • _source/plugins/showborders/plugin.js

     
    129129                                        }
    130130                                } );
    131131                        }
     132                }
     133        });
    132134
    133                         // Table dialog must be aware of it.
    134                         CKEDITOR.on( 'dialogDefinition', function( ev )
    135                                 {
    136                                         if ( ev.editor != editor )
    137                                                 return;
     135        // Table dialog must be aware of it.
     136        CKEDITOR.on( 'dialogDefinition', function( ev )
     137        {
     138                var dialogName = ev.data.name;
    138139
    139                                         var dialogName = ev.data.name;
     140                if ( dialogName == 'table' || dialogName == 'tableProperties' )
     141                {
     142                        var dialogDefinition = ev.data.definition,
     143                                infoTab = dialogDefinition.getContents( 'info' ),
     144                                borderField = infoTab.get( 'txtBorder' ),
     145                                originalCommit = borderField.commit;
    140146
    141                                         if ( dialogName == 'table' || dialogName == 'tableProperties' )
     147                        borderField.commit = CKEDITOR.tools.override( originalCommit, function( org )
     148                        {
     149                                return function( data, selectedTable )
    142150                                        {
    143                                                 var dialogDefinition = ev.data.definition,
    144                                                         infoTab = dialogDefinition.getContents( 'info' ),
    145                                                         borderField = infoTab.get( 'txtBorder' ),
    146                                                         originalCommit = borderField.commit;
    147 
    148                                                 borderField.commit = CKEDITOR.tools.override( originalCommit, function( org )
    149                                                 {
    150                                                         return function( data, selectedTable )
    151                                                                 {
    152                                                                         org.apply( this, arguments );
    153                                                                         var value = parseInt( this.getValue(), 10 );
    154                                                                         selectedTable[ ( !value || value <= 0 ) ? 'addClass' : 'removeClass' ]( showBorderClassName );
    155                                                                 };
    156                                                 } );
    157                                         }
    158                                 });
     151                                                org.apply( this, arguments );
     152                                                var value = parseInt( this.getValue(), 10 );
     153                                                selectedTable[ ( !value || value <= 0 ) ? 'addClass' : 'removeClass' ]( showBorderClassName );
     154                                        };
     155                        } );
    159156                }
    160 
    161157        });
     158
    162159} )();
    163160
    164161/**
  • _source/plugins/sourcearea/plugin.js

     
    138138
    139139                                                unload : function( holderElement )
    140140                                                {
     141                                                        textarea.clearCustomData();
    141142                                                        editor.textarea = textarea = null;
    142143
    143144                                                        if ( onResize )
  • _source/plugins/toolbar/plugin.js

     
    284284                                                                        editor.execCommand( 'toolbarCollapse' );
    285285                                                                } );
    286286
     287                                                        editor.on( 'destroy', function () {
     288                                                                        CKEDITOR.tools.removeFunction( collapserFn );
     289                                                                } );
     290
    287291                                                        var collapserId = 'cke_' + CKEDITOR.tools.getNextNumber();
    288292
    289293                                                        editor.addCommand( 'toolbarCollapse',
  • _source/plugins/wysiwygarea/plugin.js

     
    691691
    692692                                                        unload : function( holderElement )
    693693                                                        {
     694                                                                editor.document.getDocumentElement().clearCustomData();
     695                                                                editor.document.getBody().clearCustomData();
     696
     697                                                                editor.window.clearCustomData();
     698                                                                editor.document.clearCustomData();
     699
    694700                                                                editor.window = editor.document = iframe = mainElement = isPendingFocus = null;
    695701
    696702                                                                editor.fire( 'contentDomUnload' );
     
    759765                                                        editor.focus();
    760766                                                } );
    761767                                } );
     768                                editor.on( 'destroy', function()
     769                                {
     770                                        ieFocusGrabber.clearCustomData();
     771                                } );
    762772                        }
    763773                }
    764774        });
  • _source/themes/default/theme.js

     
    229229                destroy : function( editor )
    230230                {
    231231                        var container = editor.container;
     232                        container.clearCustomData();
     233                        editor.element.clearCustomData();
    232234
    233235                        /*
    234236                         * IE BUG: Removing the editor DOM elements while the selection is inside
     
    256258                                container.remove();
    257259
    258260                        if ( editor.elementMode == CKEDITOR.ELEMENT_MODE_REPLACE )
    259                         {
    260261                                editor.element.show();
    261                                 delete editor.element;
    262                         }
     262
     263                        delete editor.element;
    263264                }
    264265        };
    265266})() );
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy