Show
Ignore:
Timestamp:
09/26/08 02:06:12 (1 year ago)
Author:
callum.linden
Message:

Fix for DEV-21419 (Caret doesn't always appear in edit fields on Windows)
Reviewed by: Andrew Cheah

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/llmozlib2/llembeddedbrowserwindow.cpp

    r16 r20  
    116116        mBkgGreen( 0xff ), 
    117117        mBkgBlue( 0xff ), 
    118         mCaretRed( 0x0 ), 
    119         mCaretGreen( 0x0 ), 
    120         mCaretBlue( 0x0 ), 
     118        mCaretRed( 0x00 ), 
     119        mCaretGreen( 0x00 ), 
     120        mCaretBlue( 0x00 ), 
    121121        m404RedirectUrl( "" ), 
    122122        mFlipBitmap( false ) 
     
    683683{ 
    684684        nsCOMPtr< nsIWebBrowserFocus > focus = do_QueryInterface( mWebBrowser ); 
     685        if ( ! focus ) 
     686                return NS_ERROR_FAILURE; 
    685687 
    686688        nsCOMPtr< nsIDOMElement > focusedElement; 
     
    690692 
    691693        nsCOMPtr<nsIContent> focusedContent = do_QueryInterface( focusedElement ); 
    692  
    693         nsCOMPtr< nsIDOMWindow > domWindow; 
    694         mWebBrowser->GetContentDOMWindow( getter_AddRefs( domWindow ) ); 
    695         if ( ! domWindow ) 
     694        if ( ! focusedContent ) 
    696695                return NS_ERROR_FAILURE; 
    697696 
    698         nsCOMPtr< nsIDOMDocument > domDocument; 
    699         domWindow->GetDocument( getter_AddRefs( domDocument ) ); 
    700         if ( ! domDocument ) 
    701                 return NS_ERROR_FAILURE; 
    702  
    703         nsCOMPtr< nsIDocument> document = do_QueryInterface( domDocument ); 
    704         if ( ! document ) 
    705                 return NS_ERROR_FAILURE; 
    706  
    707         nsIPresShell* presShell = document->GetShellAt( 0 ); 
     697        nsIPresShell* presShell = focusedContent->GetCurrentDoc()->GetShellAt( 0 ); 
    708698        if ( ! presShell ) 
    709699                return NS_ERROR_FAILURE; 
     
    711701        nsCOMPtr< nsICaret > caret; 
    712702        presShell->GetCaret( getter_AddRefs( caret ) ); 
     703        if ( ! caret ) 
     704                return NS_ERROR_FAILURE; 
    713705 
    714706        nsIFrame* frame = nsnull; 
     
    719711        nsCOMPtr<nsISelectionController> selCtrl; 
    720712        frame->GetSelectionController( presShell->GetPresContext(), getter_AddRefs( selCtrl ) ); 
     713        if ( ! selCtrl ) 
     714                return NS_ERROR_FAILURE; 
    721715 
    722716        nsCOMPtr<nsISelection> selection; 
    723717        selCtrl->GetSelection( nsISelectionController::SELECTION_NORMAL, getter_AddRefs( selection ) ); 
     718        if ( ! selection ) 
     719                return NS_ERROR_FAILURE; 
    724720 
    725721        PRBool collapsed; 
     
    727723        nsIView* caretView; 
    728724        caret->GetCaretCoordinates( nsICaret::eTopLevelWindowCoordinates, selection, &coords, &collapsed, &caretView ); 
     725        if ( ! caretView ) 
     726                return NS_ERROR_FAILURE; 
    729727 
    730728        float twips2Pixls = presShell->GetPresContext()->TwipsToPixels();