Bug 285974 Crash when we use ATOK on the other of editor[@ nsWindow::OnIMEQueryCharPosition]

patch by masayuki@d-toybox.com r=timeless sr=roc
This commit is contained in:
timeless%mozdev.org 2005-03-18 06:17:59 +00:00
Родитель c9ed31bf55
Коммит 10c1d75093
3 изменённых файлов: 16 добавлений и 1 удалений

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

@ -2211,7 +2211,8 @@ nsEditor::GetQueryCaretRect(nsQueryCaretRectEventReply* aReply)
PRBool cursorIsCollapsed;
rv = caretP->GetCaretCoordinates(nsICaret::eIMECoordinates, selection,
&aReply->mCaretRect, &cursorIsCollapsed, nsnull);
if (NS_SUCCEEDED(rv))
aReply->mRectIsValid = PR_TRUE;
return rv;
}

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

@ -735,9 +735,11 @@ struct nsReconversionEvent : public nsInputEvent
struct nsQueryCaretRectEventReply {
nsQueryCaretRectEventReply()
: mRectIsValid(PR_FALSE)
{
}
PRBool mRectIsValid;
nsRect mCaretRect;
};

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

@ -6963,6 +6963,11 @@ PRBool nsWindow::OnIMEQueryCharPosition(LPARAM aData, LRESULT *oResult, PRBool a
nsQueryCaretRectEvent event(NS_QUERYCARETRECT, this);
InitEvent(event, &point);
DispatchWindowEvent(&event);
// The active widget doesn't support this event.
if (!event.theReply.mRectIsValid) {
*oResult = FALSE;
return PR_FALSE;
}
NS_RELEASE(event.widget);
nsRect screenRect, widgetRect(event.theReply.mCaretRect);
@ -6978,6 +6983,13 @@ PRBool nsWindow::OnIMEQueryCharPosition(LPARAM aData, LRESULT *oResult, PRBool a
return PR_TRUE;
}
// If the char positions are not cached, we should not return the values by LPARAM.
// Because in this case, the active widget is not editor.
if (!sIMECompCharPos) {
*oResult = FALSE;
return PR_FALSE;
}
long charPosition;
if (aUseUnicode || pCharPosition->dwCharPos == 0) {
if (pCharPosition->dwCharPos > sIMECompUnicode->Length()) {