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

This commit is contained in:
jfrancis%netscape.com 2000-02-25 23:50:17 +00:00
Родитель 579e3b88f4
Коммит e6db193491
2 изменённых файлов: 30 добавлений и 0 удалений

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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;
}