Changeset 407

Show
Ignore:
Timestamp:
2007-07-04 11:59:24 (19 months ago)
Author:
martinkou
Message:

Fixed #933 : Fixed the FCKDomRange.MoveToSelection() crash in Internet Explorer by adding sanity checks.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • FCKeditor/trunk/editor/_source/classes/fckdomrange_ie.js

    r400 r407  
    3434        if ( oSel.type != 'Control' ) 
    3535        { 
     36                var eMarkerStart = this._GetSelectionMarkerTag( true ) ; 
     37                var eMarkerEnd = this._GetSelectionMarkerTag( false ) ; 
     38 
     39                if ( ! ( eMarkerStart && eMarkerEnd ) ) 
     40                { 
     41                        this._Range.setStart( this.Window.document.body, 0 ); 
     42                        this._Range.setEnd( this.Window.document.body, 0 ); 
     43                        this._Range.collapse(); 
     44                        this._UpdateElementInfo(); 
     45                        return; 
     46                } 
     47 
    3648                // Set the start boundary. 
    37                 eMarker = this._GetSelectionMarkerTag( true ) ; 
    38                 this._Range.setStart( eMarker.parentNode, FCKDomTools.GetIndexOf( eMarker ) ) ; 
    39                 eMarker.parentNode.removeChild( eMarker ) ; 
     49                this._Range.setStart( eMarkerStart.parentNode, FCKDomTools.GetIndexOf( eMarkerStart ) ) ; 
     50                eMarkerStart.parentNode.removeChild( eMarkerStart ) ; 
    4051 
    4152                // Set the end boundary. 
    42                 var eMarker = this._GetSelectionMarkerTag( false ) ; 
    43                 this._Range.setEnd( eMarker.parentNode, FCKDomTools.GetIndexOf( eMarker ) ) ; 
    44                 eMarker.parentNode.removeChild( eMarker ) ; 
     53                this._Range.setEnd( eMarkerEnd.parentNode, FCKDomTools.GetIndexOf( eMarkerEnd ) ) ; 
     54                eMarkerEnd.parentNode.removeChild( eMarkerEnd ) ; 
    4555 
    4656                this._UpdateElementInfo() ; 
     
    123133        oRange.collapse( toStart === true ) ; 
    124134 
     135        // IE might take the range object to the main window instead of inside the editor iframe window. 
     136        // This is known to happen when the editor window has not been selected before (See #933). 
     137        // We need to avoid that. 
     138        if (oRange.parentElement().document != this.Window.document) 
     139                return null; 
     140 
    125141        // Paste a marker element at the collapsed range and get it from the DOM. 
    126142        var sMarkerId = 'fck_dom_range_temp_' + (new Date()).valueOf() + '_' + Math.floor(Math.random()*1000) ;