Fix for 52150; show caret in new composer/mail composer/AIM windows. If the editor is focussed on creation, show the caret instead of relying on a focus event. r, sr = kin,saari, hyatt
git-svn-id: svn://10.0.0.236/trunk@80042 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -39,6 +39,7 @@
|
||||
#include "nsIDiskDocument.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
#include "nsICSSLoader.h"
|
||||
@@ -91,6 +92,8 @@
|
||||
#include "nsIRefreshURI.h"
|
||||
#include "nsIPref.h"
|
||||
|
||||
#include "nsILookAndFeel.h"
|
||||
|
||||
///////////////////////////////////////
|
||||
// Editor Includes
|
||||
///////////////////////////////////////
|
||||
@@ -630,6 +633,43 @@ nsEditorShell::PrepareDocumentForEditing(nsIDocumentLoader* aLoader, nsIURI *aUr
|
||||
// (this also turns on the caret)
|
||||
mEditor->SetCaretToDocumentStart();
|
||||
}
|
||||
|
||||
// show the caret, if our window is focussed already
|
||||
nsCOMPtr<nsIDOMWindowInternal> contentInternal = do_QueryReferent(mContentWindow);
|
||||
nsCOMPtr<nsPIDOMWindow> privContent(do_QueryInterface(contentInternal));
|
||||
|
||||
if (privContent)
|
||||
{
|
||||
nsCOMPtr<nsIDOMXULCommandDispatcher> commandDispatcher;
|
||||
privContent->GetRootCommandDispatcher(getter_AddRefs(commandDispatcher));
|
||||
|
||||
if (commandDispatcher)
|
||||
{
|
||||
nsCOMPtr<nsIDOMWindowInternal> focussedWindow;
|
||||
commandDispatcher->GetFocusedWindow(getter_AddRefs(focussedWindow));
|
||||
|
||||
if (focussedWindow.get() == contentInternal.get()) // now see if we are focussed
|
||||
{
|
||||
nsCOMPtr<nsISelectionController> selCon;
|
||||
editor->GetSelectionController(getter_AddRefs(selCon));
|
||||
|
||||
PRInt32 pixelWidth = 1;
|
||||
|
||||
static NS_DEFINE_CID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
|
||||
|
||||
nsCOMPtr<nsILookAndFeel> lookNFeel = do_GetService(kLookAndFeelCID);
|
||||
if (lookNFeel)
|
||||
lookNFeel->GetMetric(nsILookAndFeel::eMetric_MultiLineCaretWidth, pixelWidth);
|
||||
|
||||
selCon->SetCaretWidth(pixelWidth);
|
||||
selCon->SetCaretEnabled(PR_FALSE);
|
||||
selCon->SetCaretEnabled(PR_TRUE); // make damn sure it shows; the last SetVisible
|
||||
// may have happened when we didn't have focus.
|
||||
selCon->SetDisplaySelection(nsISelectionController::SELECTION_ON);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user