Redragging over empty text field doesn't show drag caret, except for the last text field. bug 390228, r+sr=roc a=dbaron

This commit is contained in:
mrbkap@gmail.com 2007-08-13 14:33:25 -07:00
parent e8ef7a1329
commit f055907b89
3 changed files with 14 additions and 4 deletions

View File

@ -523,9 +523,9 @@ nsTextEditorDragListener::DragGesture(nsIDOMEvent* aDragEvent)
nsresult
nsTextEditorDragListener::DragEnter(nsIDOMEvent* aDragEvent)
{
nsCOMPtr<nsIPresShell> presShell = do_QueryReferent(mPresShell);
if (!mCaret)
{
nsCOMPtr<nsIPresShell> presShell = do_QueryReferent(mPresShell);
if (presShell)
{
mCaret = do_CreateInstance("@mozilla.org/layout/caret;1");
@ -539,7 +539,11 @@ nsTextEditorDragListener::DragEnter(nsIDOMEvent* aDragEvent)
mCaretDrawn = PR_FALSE;
}
}
else if (presShell)
{
presShell->SetCaret(mCaret);
}
return DragOver(aDragEvent);
}

View File

@ -373,7 +373,7 @@ NS_IMETHODIMP nsCaret::EraseCaret()
{
if (mDrawn) {
DrawCaret(PR_TRUE);
if (mReadOnly) {
if (mReadOnly && mBlinkRate) {
// If readonly we don't have a blink timer set, so caret won't
// be redrawn automatically. We need to force the caret to get
// redrawn right after the paint
@ -399,7 +399,12 @@ NS_IMETHODIMP nsCaret::DrawAtPosition(nsIDOMNode* aNode, PRInt32 aOffset)
if (!frameSelection)
return NS_ERROR_FAILURE;
bidiLevel = frameSelection->GetCaretBidiLevel();
// DrawAtPosition is used by consumers who want us to stay drawn where they
// tell us. Setting mBlinkRate to 0 tells us to not set a timer to erase
// ourselves, our consumer will take care of that.
mBlinkRate = 0;
// XXX we need to do more work here to get the correct hint.
nsresult rv = DrawAtPositionWithHint(aNode, aOffset,
nsFrameSelection::HINTLEFT,

View File

@ -124,6 +124,7 @@ public:
* To avoid drawing glitches, you should call EraseCaret()
* after each call to DrawAtPosition().
*
* Note: This call breaks the caret's ability to blink at all.
**/
NS_IMETHOD DrawAtPosition(nsIDOMNode* aNode, PRInt32 aOffset) = 0;