mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
Restore the right caret in all cases. bug 395888, r+sr+a=roc
This commit is contained in:
parent
1b90d225e1
commit
9513b53050
@ -524,25 +524,21 @@ nsresult
|
||||
nsTextEditorDragListener::DragEnter(nsIDOMEvent* aDragEvent)
|
||||
{
|
||||
nsCOMPtr<nsIPresShell> presShell = do_QueryReferent(mPresShell);
|
||||
if (!presShell)
|
||||
return NS_OK;
|
||||
|
||||
if (!mCaret)
|
||||
{
|
||||
if (presShell)
|
||||
mCaret = do_CreateInstance("@mozilla.org/layout/caret;1");
|
||||
if (mCaret)
|
||||
{
|
||||
mCaret = do_CreateInstance("@mozilla.org/layout/caret;1");
|
||||
if (mCaret)
|
||||
{
|
||||
mCaret->Init(presShell);
|
||||
mCaret->SetCaretReadOnly(PR_TRUE);
|
||||
|
||||
mOtherCaret = presShell->SetCaret(mCaret);
|
||||
}
|
||||
mCaretDrawn = PR_FALSE;
|
||||
mCaret->Init(presShell);
|
||||
mCaret->SetCaretReadOnly(PR_TRUE);
|
||||
}
|
||||
mCaretDrawn = PR_FALSE;
|
||||
}
|
||||
else if (presShell)
|
||||
{
|
||||
presShell->SetCaret(mCaret);
|
||||
}
|
||||
|
||||
presShell->SetCaret(mCaret);
|
||||
|
||||
return DragOver(aDragEvent);
|
||||
}
|
||||
@ -644,11 +640,8 @@ nsTextEditorDragListener::DragDrop(nsIDOMEvent* aMouseEvent)
|
||||
nsCOMPtr<nsIPresShell> presShell = do_QueryReferent(mPresShell);
|
||||
if (presShell)
|
||||
{
|
||||
NS_ASSERTION(mOtherCaret, "Where'd my other caret go?");
|
||||
mCaret = presShell->SetCaret(mOtherCaret);
|
||||
presShell->RestoreCaret();
|
||||
}
|
||||
|
||||
mOtherCaret = mCaret = nsnull;
|
||||
}
|
||||
|
||||
if (!mEditor)
|
||||
|
@ -237,7 +237,6 @@ protected:
|
||||
nsWeakPtr mPresShell;
|
||||
|
||||
nsCOMPtr<nsICaret> mCaret;
|
||||
nsCOMPtr<nsICaret> mOtherCaret;
|
||||
PRBool mCaretDrawn;
|
||||
};
|
||||
|
||||
|
@ -102,10 +102,10 @@ class gfxContext;
|
||||
typedef short SelectionType;
|
||||
typedef PRUint32 nsFrameState;
|
||||
|
||||
// D93B931B-D5EF-4D3C-AB99-444176963464
|
||||
// 4BE324F2-FB22-47CD-A653-19C70EE55E3F
|
||||
#define NS_IPRESSHELL_IID \
|
||||
{ 0xd93b931b, 0xd5ef, 0x4d3c, \
|
||||
{ 0xab, 0x99, 0x44, 0x41, 0x76, 0x96, 0x34, 0x64 } }
|
||||
{ 0x4BE324F2, 0xFB22, 0x47CD, \
|
||||
{ 0xA6, 0x53, 0x19, 0xC7, 0x0E, 0xE5, 0x5E, 0x3F } }
|
||||
|
||||
// Constants for ScrollContentIntoView() function
|
||||
#define NS_PRESSHELL_SCROLL_TOP 0
|
||||
@ -495,9 +495,15 @@ public:
|
||||
NS_IMETHOD_(void) MaybeInvalidateCaretPosition() = 0;
|
||||
|
||||
/**
|
||||
* Set the current caret to a new caret. Returns the old caret.
|
||||
* Set the current caret to a new caret. To undo this, call RestoreCaret.
|
||||
*/
|
||||
virtual already_AddRefed<nsICaret> SetCaret(nsICaret *aNewCaret) = 0;
|
||||
virtual void SetCaret(nsICaret *aNewCaret) = 0;
|
||||
|
||||
/**
|
||||
* Restore the caret to the original caret that this pres shell was created
|
||||
* with.
|
||||
*/
|
||||
virtual void RestoreCaret() = 0;
|
||||
|
||||
/**
|
||||
* Should the images have borders etc. Actual visual effects are determined
|
||||
|
@ -917,7 +917,8 @@ public:
|
||||
NS_IMETHOD SetCaretReadOnly(PRBool aReadOnly);
|
||||
NS_IMETHOD GetCaretEnabled(PRBool *aOutEnabled);
|
||||
NS_IMETHOD SetCaretVisibilityDuringSelection(PRBool aVisibility);
|
||||
virtual already_AddRefed<nsICaret> SetCaret(nsICaret *aNewCaret);
|
||||
virtual void SetCaret(nsICaret *aNewCaret);
|
||||
virtual void RestoreCaret();
|
||||
|
||||
NS_IMETHOD SetSelectionFlags(PRInt16 aInEnable);
|
||||
NS_IMETHOD GetSelectionFlags(PRInt16 *aOutEnable);
|
||||
@ -1130,6 +1131,7 @@ protected:
|
||||
nsCOMArray<nsIContent> mCurrentEventContentStack;
|
||||
|
||||
nsCOMPtr<nsICaret> mCaret;
|
||||
nsCOMPtr<nsICaret> mOriginalCaret;
|
||||
PRInt16 mSelectionFlags;
|
||||
FrameArena mFrameArena;
|
||||
StackArena mStackArena;
|
||||
@ -1498,6 +1500,7 @@ PresShell::Init(nsIDocument* aDocument,
|
||||
if (NS_SUCCEEDED(err))
|
||||
{
|
||||
mCaret->Init(this);
|
||||
mOriginalCaret = mCaret;
|
||||
}
|
||||
|
||||
//SetCaretEnabled(PR_TRUE); // make it show in browser windows
|
||||
@ -2616,12 +2619,14 @@ NS_IMETHODIMP_(void) PresShell::MaybeInvalidateCaretPosition()
|
||||
}
|
||||
}
|
||||
|
||||
already_AddRefed<nsICaret> PresShell::SetCaret(nsICaret *aNewCaret)
|
||||
void PresShell::SetCaret(nsICaret *aNewCaret)
|
||||
{
|
||||
nsICaret *oldCaret = nsnull;
|
||||
mCaret.swap(oldCaret);
|
||||
mCaret = aNewCaret;
|
||||
return oldCaret;
|
||||
}
|
||||
|
||||
void PresShell::RestoreCaret()
|
||||
{
|
||||
mCaret = mOriginalCaret;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP PresShell::SetCaretEnabled(PRBool aInEnable)
|
||||
|
Loading…
Reference in New Issue
Block a user