mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-09 05:14:24 +00:00
Bug 315457 IME candidate list is positioned to wrong position if the editor is on frame page r+sr=roc
This commit is contained in:
parent
2b3e96d5a2
commit
24eee73105
@ -6370,15 +6370,17 @@ nsWindow::HandleTextEvent(HIMC hIMEContext,PRBool aCheckAttr)
|
||||
//
|
||||
if (event.theReply.mCursorPosition.width || event.theReply.mCursorPosition.height)
|
||||
{
|
||||
nsRect cursorPosition;
|
||||
ResolveIMECaretPos(this, event.theReply.mCursorPosition, cursorPosition);
|
||||
CANDIDATEFORM candForm;
|
||||
candForm.dwIndex = 0;
|
||||
candForm.dwStyle = CFS_EXCLUDE;
|
||||
candForm.ptCurrentPos.x = event.theReply.mCursorPosition.x;
|
||||
candForm.ptCurrentPos.y = event.theReply.mCursorPosition.y;
|
||||
candForm.ptCurrentPos.x = cursorPosition.x;
|
||||
candForm.ptCurrentPos.y = cursorPosition.y;
|
||||
candForm.rcArea.right = candForm.rcArea.left = candForm.ptCurrentPos.x;
|
||||
candForm.rcArea.top = candForm.ptCurrentPos.y;
|
||||
candForm.rcArea.bottom = candForm.ptCurrentPos.y +
|
||||
event.theReply.mCursorPosition.height;
|
||||
cursorPosition.height;
|
||||
|
||||
if (gPinYinIMECaretCreated)
|
||||
{
|
||||
@ -6402,18 +6404,18 @@ nsWindow::HandleTextEvent(HIMC hIMEContext,PRBool aCheckAttr)
|
||||
// left of next char, as what happens in wrapping.
|
||||
if (sIMECursorPosition && sIMECompCharPos &&
|
||||
sIMECursorPosition < IME_MAX_CHAR_POS) {
|
||||
sIMECompCharPos[sIMECursorPosition-1].right = event.theReply.mCursorPosition.x;
|
||||
sIMECompCharPos[sIMECursorPosition-1].top = event.theReply.mCursorPosition.y;
|
||||
sIMECompCharPos[sIMECursorPosition-1].bottom = event.theReply.mCursorPosition.YMost();
|
||||
if (sIMECompCharPos[sIMECursorPosition-1].top != event.theReply.mCursorPosition.y) {
|
||||
sIMECompCharPos[sIMECursorPosition-1].right = cursorPosition.x;
|
||||
sIMECompCharPos[sIMECursorPosition-1].top = cursorPosition.y;
|
||||
sIMECompCharPos[sIMECursorPosition-1].bottom = cursorPosition.YMost();
|
||||
if (sIMECompCharPos[sIMECursorPosition-1].top != cursorPosition.y) {
|
||||
// wrapping, invalidate left position
|
||||
sIMECompCharPos[sIMECursorPosition-1].left = -1;
|
||||
}
|
||||
sIMECompCharPos[sIMECursorPosition].left = event.theReply.mCursorPosition.x;
|
||||
sIMECompCharPos[sIMECursorPosition].top = event.theReply.mCursorPosition.y;
|
||||
sIMECompCharPos[sIMECursorPosition].bottom = event.theReply.mCursorPosition.YMost();
|
||||
sIMECompCharPos[sIMECursorPosition].left = cursorPosition.x;
|
||||
sIMECompCharPos[sIMECursorPosition].top = cursorPosition.y;
|
||||
sIMECompCharPos[sIMECursorPosition].bottom = cursorPosition.YMost();
|
||||
}
|
||||
sIMECaretHeight = event.theReply.mCursorPosition.height;
|
||||
sIMECaretHeight = cursorPosition.height;
|
||||
} else {
|
||||
// for some reason we don't know yet, theReply may contain invalid result
|
||||
// need more debugging in nsCaret to find out the reason
|
||||
@ -6449,11 +6451,13 @@ nsWindow::HandleStartComposition(HIMC hIMEContext)
|
||||
//
|
||||
if (event.theReply.mCursorPosition.width || event.theReply.mCursorPosition.height)
|
||||
{
|
||||
nsRect cursorPosition;
|
||||
ResolveIMECaretPos(this, event.theReply.mCursorPosition, cursorPosition);
|
||||
candForm.dwIndex = 0;
|
||||
candForm.dwStyle = CFS_CANDIDATEPOS;
|
||||
candForm.ptCurrentPos.x = event.theReply.mCursorPosition.x + IME_X_OFFSET;
|
||||
candForm.ptCurrentPos.y = event.theReply.mCursorPosition.y + IME_Y_OFFSET +
|
||||
event.theReply.mCursorPosition.height;
|
||||
candForm.ptCurrentPos.x = cursorPosition.x + IME_X_OFFSET;
|
||||
candForm.ptCurrentPos.y = cursorPosition.y + IME_Y_OFFSET +
|
||||
cursorPosition.height;
|
||||
candForm.rcArea.right = 0;
|
||||
candForm.rcArea.left = 0;
|
||||
candForm.rcArea.top = 0;
|
||||
@ -6473,11 +6477,11 @@ nsWindow::HandleStartComposition(HIMC hIMEContext)
|
||||
sIMECompCharPos = (RECT*)PR_MALLOC(IME_MAX_CHAR_POS*sizeof(RECT));
|
||||
if (sIMECompCharPos) {
|
||||
memset(sIMECompCharPos, -1, sizeof(RECT)*IME_MAX_CHAR_POS);
|
||||
sIMECompCharPos[0].left = event.theReply.mCursorPosition.x;
|
||||
sIMECompCharPos[0].top = event.theReply.mCursorPosition.y;
|
||||
sIMECompCharPos[0].bottom = event.theReply.mCursorPosition.YMost();
|
||||
sIMECompCharPos[0].left = cursorPosition.x;
|
||||
sIMECompCharPos[0].top = cursorPosition.y;
|
||||
sIMECompCharPos[0].bottom = cursorPosition.YMost();
|
||||
}
|
||||
sIMECaretHeight = event.theReply.mCursorPosition.height;
|
||||
sIMECaretHeight = cursorPosition.height;
|
||||
} else {
|
||||
// for some reason we don't know yet, theReply may contain invalid result
|
||||
// need more debugging in nsCaret to find out the reason
|
||||
@ -7191,8 +7195,8 @@ PRBool nsWindow::OnIMEQueryCharPosition(LPARAM aData, LRESULT *oResult, PRBool a
|
||||
}
|
||||
NS_RELEASE(event.widget);
|
||||
|
||||
nsRect screenRect, widgetRect(event.theReply.mCaretRect);
|
||||
WidgetToScreen(widgetRect, screenRect);
|
||||
nsRect screenRect;
|
||||
ResolveIMECaretPos(nsnull, event.theReply.mCaretRect, screenRect);
|
||||
pCharPosition->pt.x = screenRect.x;
|
||||
pCharPosition->pt.y = screenRect.y;
|
||||
|
||||
@ -7250,6 +7254,22 @@ PRBool nsWindow::OnIMEQueryCharPosition(LPARAM aData, LRESULT *oResult, PRBool a
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
void
|
||||
nsWindow::ResolveIMECaretPos(nsWindow* aClient,
|
||||
nsRect& aEventResult,
|
||||
nsRect& aResult)
|
||||
{
|
||||
// RootView coordinates -> Screen coordinates
|
||||
nsCOMPtr<nsWindow> topWindow = getter_AddRefs(GetTopLevelWindow());
|
||||
topWindow->WidgetToScreen(aEventResult, aResult);
|
||||
// if aClient is nsnull, returns screen coordinates
|
||||
if (!aClient)
|
||||
return;
|
||||
// screen coordinates -> client coordinates
|
||||
aClient->ScreenToWidget(aResult, aResult);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
BOOL nsWindow::OnIMESelect(BOOL aSelected, WORD aLangID)
|
||||
{
|
||||
|
@ -317,6 +317,9 @@ protected:
|
||||
BOOL OnIMEQueryCharPosition(LPARAM aData, LRESULT *oResult, PRBool aUseUnicode);
|
||||
|
||||
void GetCompositionString(HIMC aHIMC, DWORD aIndex, nsString* aStrUnicode, nsCString* aStrAnsi);
|
||||
void ResolveIMECaretPos(nsWindow* aClient,
|
||||
nsRect& aEventResult,
|
||||
nsRect& aResult);
|
||||
|
||||
virtual PRBool DispatchKeyEvent(PRUint32 aEventType, WORD aCharCode, UINT aVirtualCharCode,
|
||||
LPARAM aKeyCode, PRUint32 aFlags = 0);
|
||||
|
Loading…
Reference in New Issue
Block a user