Ticket #4555: 4555_5.patch

File 4555_5.patch, 8.4 KB (added by Garry Yao, 14 years ago)
  • _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
     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
     506                        this.fireOnce( 'destroy' );
     507
    473508                        CKEDITOR.remove( this );
    474509                        CKEDITOR.fire( 'instanceDestroyed', null, this );
    475510                },
  • _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/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/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