Ticket #4555: 4555_4.patch

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

Proposed patch

  • _source/core/dom/domobject.js

     
    115115                                        delete nativeListeners[ eventName ];
    116116                                }
    117117                        }
     118                },
     119
     120                /** @ignore */
     121                removeAllListeners : function()
     122                {
     123                        // Call the original implementation.
     124                        CKEDITOR.event.prototype.removeAllListeners.apply( this );
     125
     126                        var nativeListeners = this.getCustomData( '_cke_nativeListeners' );
     127                        for( eventName in nativeListeners)
     128                        {
     129                                var listener = nativeListeners[ eventName ];
     130                                if ( this.$.removeEventListener )
     131                                        this.$.removeEventListener( eventName, listener, false );
     132                                else if ( this.$.detachEvent )
     133                                        this.$.detachEvent( 'on' + eventName, listener );
     134
     135                                delete nativeListeners[ eventName ];
     136                        }
    118137                }
    119138        };
    120139})();
     
    197216        };
    198217
    199218        /**
     219         * @name CKEDITOR.dom.domObject.prototype.clearCustomData
     220         */
     221        domObjectProto.clearCustomData = function()
     222        {
     223                // Clear all event listeners
     224                this.removeAllListeners();
     225
     226                var expandoNumber = this.$._cke_expando;
     227                expandoNumber && delete customData[ expandoNumber ];
     228        };
     229
     230        /**
    200231         * @name CKEDITOR.dom.domObject.prototype.getCustomData
    201232         */
    202233        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 );
    472                         this.fire( 'destroy' );
     479
     480                        var toolbars,
     481                                index, j, items,
     482                                commands = this._.commands;
     483
     484                        if (this.toolbox)
     485                        {
     486                                toolbars = this.toolbox.toolbars;
     487                                for( index = 0; index < toolbars.length ; index++ )
     488                                {
     489                                        items = toolbars[ index ].items;
     490                                        for ( j = 0; j<items.length ; j++)
     491                                        {
     492                                                var instance = items[ j ];
     493                                                if ( instance.clickFn ) CKEDITOR.tools.removeFunction( instance.clickFn );
     494                                                if ( instance.keyDownFn ) CKEDITOR.tools.removeFunction( instance.keyDownFn );
     495
     496                                                if ( instance.index ) CKEDITOR.ui.button._.instances[ instance.index ] = null;
     497                                        }
     498                                }
     499                        }
     500
     501                        for (var command in commands)
     502                                commands[ command ].removeAllListeners();
     503
     504                        if (this.contextMenu)
     505                                CKEDITOR.tools.removeFunction( this.contextMenu._.functionId );
     506
     507                        if (this._.filebrowserFn)
     508                                CKEDITOR.tools.removeFunction( this._.filebrowserFn );
     509
     510                        this.fireOnce( 'destroy' );
     511                        this.removeAllListeners();
     512
    473513                        CKEDITOR.remove( this );
    474514                        CKEDITOR.fire( 'instanceDestroyed', null, this );
    475515                },
  • _source/core/event.js

     
    318318                        },
    319319
    320320                        /**
     321                         * Removes any listener set on this object.
     322                         * To avoid memory leaks we must assure that there are no
     323                         * references left after the object is no longer needed.
     324                         */
     325                        removeAllListeners : function()
     326                        {
     327                                var events = getPrivate( this );
     328                                for(var e in events )
     329                                        delete events[ e ];
     330                        },
     331
     332                        /**
    321333                         * Checks if there is any listener registered to a given event.
    322334                         * @param {String} eventName The event name.
    323335                         * @example
  • _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

     
    130130                                } );
    131131                        }
    132132
    133                         // Table dialog must be aware of it.
    134                         CKEDITOR.on( 'dialogDefinition', function( ev )
     133                        var onDialogDefinition = function( ev )
     134                        {
     135                                if ( ev.editor != editor )
     136                                        return;
     137
     138                                var dialogName = ev.data.name;
     139
     140                                if ( dialogName == 'table' || dialogName == 'tableProperties' )
    135141                                {
    136                                         if ( ev.editor != editor )
    137                                                 return;
     142                                        var dialogDefinition = ev.data.definition,
     143                                                infoTab = dialogDefinition.getContents( 'info' ),
     144                                                borderField = infoTab.get( 'txtBorder' ),
     145                                                originalCommit = borderField.commit;
    138146
    139                                         var dialogName = ev.data.name;
    140 
    141                                         if ( dialogName == 'table' || dialogName == 'tableProperties' )
     147                                        borderField.commit = CKEDITOR.tools.override( originalCommit, function( org )
    142148                                        {
    143                                                 var dialogDefinition = ev.data.definition,
    144                                                         infoTab = dialogDefinition.getContents( 'info' ),
    145                                                         borderField = infoTab.get( 'txtBorder' ),
    146                                                         originalCommit = borderField.commit;
     149                                                return function( data, selectedTable )
     150                                                        {
     151                                                                org.apply( this, arguments );
     152                                                                var value = parseInt( this.getValue(), 10 );
     153                                                                selectedTable[ ( !value || value <= 0 ) ? 'addClass' : 'removeClass' ]( showBorderClassName );
     154                                                        };
     155                                        } );
     156                                }
     157                        };
    147158
    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                                 });
     159                        // Table dialog must be aware of it.
     160                        CKEDITOR.on( 'dialogDefinition', onDialogDefinition);
     161                        editor.on( 'destroy', function() {  CKEDITOR.removeListener( 'dialogDefinition', onDialogDefinition ) } );
    159162                }
    160163
    161164        });
  • _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

     
    690690
    691691                                                        unload : function( holderElement )
    692692                                                        {
     693                                                                editor.document.getDocumentElement().clearCustomData();
     694                                                                editor.document.getBody().clearCustomData();
     695
     696                                                                editor.window.clearCustomData();
     697                                                                editor.document.clearCustomData();
     698
    693699                                                                editor.window = editor.document = iframe = mainElement = isPendingFocus = null;
    694700
    695701                                                                editor.fire( 'contentDomUnload' );
     
    758764                                                        editor.focus();
    759765                                                } );
    760766                                } );
     767                                editor.on( 'destroy', function()
     768                                {
     769                                        ieFocusGrabber.clearCustomData();
     770                                } );
    761771                        }
    762772                }
    763773        });
  • _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