fixe for 23558: windows ime bug - typing escape in ime can cause selection to move to top of document

r=mjudge, ftang;  a=rickg


git-svn-id: svn://10.0.0.236/trunk@61699 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
jfrancis%netscape.com
2000-02-25 23:50:17 +00:00
parent 1d3ed8f57f
commit 84db9f724e
2 changed files with 30 additions and 0 deletions

View File

@@ -4473,6 +4473,15 @@ nsHTMLEditor::SetCompositionString(const nsString& aCompositionString, nsIPrivat
return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsICaret> caretP;
// workaround for windows ime bug 23558: we get every ime event twice.
// for escape keypress, this causes an empty string to be passed
// twice, which freaks out the editor. This is to detect and aviod that
// situation:
if (aCompositionString.IsEmpty() && !mIMETextNode)
{
return NS_OK;
}
nsCOMPtr<nsIDOMSelection> selection;
nsresult result = GetSelection(getter_AddRefs(selection));
if (NS_FAILED(result)) return result;
@@ -4490,6 +4499,12 @@ nsHTMLEditor::SetCompositionString(const nsString& aCompositionString, nsIPrivat
ps->GetCaret(getter_AddRefs(caretP));
caretP->GetWindowRelativeCoordinates(aReply->mCursorPosition,aReply->mCursorIsCollapsed);
// second part of 23558 fix:
if (aCompositionString.IsEmpty())
{
mIMETextNode = nsnull;
}
return result;
}

View File

@@ -4473,6 +4473,15 @@ nsHTMLEditor::SetCompositionString(const nsString& aCompositionString, nsIPrivat
return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsICaret> caretP;
// workaround for windows ime bug 23558: we get every ime event twice.
// for escape keypress, this causes an empty string to be passed
// twice, which freaks out the editor. This is to detect and aviod that
// situation:
if (aCompositionString.IsEmpty() && !mIMETextNode)
{
return NS_OK;
}
nsCOMPtr<nsIDOMSelection> selection;
nsresult result = GetSelection(getter_AddRefs(selection));
if (NS_FAILED(result)) return result;
@@ -4490,6 +4499,12 @@ nsHTMLEditor::SetCompositionString(const nsString& aCompositionString, nsIPrivat
ps->GetCaret(getter_AddRefs(caretP));
caretP->GetWindowRelativeCoordinates(aReply->mCursorPosition,aReply->mCursorIsCollapsed);
// second part of 23558 fix:
if (aCompositionString.IsEmpty())
{
mIMETextNode = nsnull;
}
return result;
}