Bug 449955 – Remove #ifdef of nsCaret.cpp for IME r+sr=roc

This commit is contained in:
Masayuki Nakano 2008-08-13 10:55:39 +09:00
parent 78b08dae0c
commit d504a8c50f
6 changed files with 43 additions and 35 deletions

View File

@ -1984,7 +1984,7 @@ nsEditor::QueryComposition(nsTextEventReply* aReply)
nsIView *view = nsnull;
result =
caretP->GetCaretCoordinates(nsCaret::eIMECoordinates,
caretP->GetCaretCoordinates(nsCaret::eRenderingViewCoordinates,
selection,
&(aReply->mCursorPosition),
&(aReply->mCursorIsCollapsed),

View File

@ -1737,7 +1737,7 @@ nsPlaintextEditor::SetCompositionString(const nsAString& aCompositionString, nsI
if (caretP)
{
nsIView *view = nsnull;
result = caretP->GetCaretCoordinates(nsCaret::eIMECoordinates,
result = caretP->GetCaretCoordinates(nsCaret::eRenderingViewCoordinates,
selection,
&(aReply->mCursorPosition),
&(aReply->mCursorIsCollapsed),

View File

@ -900,22 +900,6 @@ void nsCaret::GetViewForRendering(nsIFrame *caretFrame,
if (!caretFrame || !outRenderingView)
return;
// XXX by Masayuki Nakano:
// This code is not good. This is adhoc approach.
// Our best approach is to use the event fired widget related view.
// But if we do so, we need large change for editor and this.
if (coordType == eIMECoordinates) {
#if defined(XP_MACOSX) || defined(XP_WIN)
// #59405 and #313918, on Mac and Windows, the coordinate for IME need to be
// root view related.
coordType = eTopLevelWindowCoordinates;
#else
// #59405, on unix, the coordinate for IME need to be view
// (nearest native window) related.
coordType = eRenderingViewCoordinates;
#endif
}
*outRenderingView = nsnull;
if (outRelativeView)
*outRelativeView = nsnull;

View File

@ -63,8 +63,7 @@ class nsCaret : public nsISelectionListener
enum EViewCoordinates {
eTopLevelWindowCoordinates,
eRenderingViewCoordinates,
eClosestViewCoordinates,
eIMECoordinates
eClosestViewCoordinates
};
public:

View File

@ -6447,7 +6447,9 @@ nsWindow::HandleTextEvent(HIMC hIMEContext,PRBool aCheckAttr)
if (event.theReply.mCursorPosition.width || event.theReply.mCursorPosition.height)
{
nsRect cursorPosition;
ResolveIMECaretPos(this, event.theReply.mCursorPosition, cursorPosition);
ResolveIMECaretPos(event.theReply.mReferenceWidget,
event.theReply.mCursorPosition,
this, cursorPosition);
CANDIDATEFORM candForm;
candForm.dwIndex = 0;
candForm.dwStyle = CFS_EXCLUDE;
@ -6522,7 +6524,9 @@ nsWindow::HandleStartComposition(HIMC hIMEContext)
if (event.theReply.mCursorPosition.width || event.theReply.mCursorPosition.height)
{
nsRect cursorPosition;
ResolveIMECaretPos(this, event.theReply.mCursorPosition, cursorPosition);
ResolveIMECaretPos(event.theReply.mReferenceWidget,
event.theReply.mCursorPosition,
this, cursorPosition);
candForm.dwIndex = 0;
candForm.dwStyle = CFS_CANDIDATEPOS;
candForm.ptCurrentPos.x = cursorPosition.x + IME_X_OFFSET;
@ -7136,7 +7140,7 @@ PRBool nsWindow::OnIMEQueryCharPosition(LPARAM aData, LRESULT *oResult)
}
nsRect screenRect;
ResolveIMECaretPos(nsnull, r, screenRect);
ResolveIMECaretPos(GetTopLevelWindow(), r, nsnull, screenRect);
pCharPosition->pt.x = screenRect.x;
pCharPosition->pt.y = screenRect.y;
@ -7151,17 +7155,21 @@ PRBool nsWindow::OnIMEQueryCharPosition(LPARAM aData, LRESULT *oResult)
//==========================================================================
void
nsWindow::ResolveIMECaretPos(nsWindow* aClient,
nsRect& aEventResult,
nsRect& aResult)
nsWindow::ResolveIMECaretPos(nsIWidget* aReferenceWidget,
nsRect& aCursorRect,
nsIWidget* aNewOriginWidget,
nsRect& aOutRect)
{
// RootView coordinates -> Screen coordinates
GetTopLevelWindow()->WidgetToScreen(aEventResult, aResult);
// if aClient is nsnull, returns screen coordinates
if (!aClient)
aOutRect = aCursorRect;
if (aReferenceWidget == aNewOriginWidget)
return;
// screen coordinates -> client coordinates
aClient->ScreenToWidget(aResult, aResult);
if (aReferenceWidget)
aReferenceWidget->WidgetToScreen(aOutRect, aOutRect);
if (aNewOriginWidget)
aNewOriginWidget->ScreenToWidget(aOutRect, aOutRect);
}
//==========================================================================

View File

@ -327,9 +327,26 @@ protected:
BOOL OnIMEQueryCharPosition(LPARAM aData, LRESULT *oResult);
void GetCompositionString(HIMC aHIMC, DWORD aIndex, nsString* aStrUnicode);
void ResolveIMECaretPos(nsWindow* aClient,
nsRect& aEventResult,
nsRect& aResult);
/**
* ResolveIMECaretPos
* Convert the caret rect of a composition event to another widget's
* coordinate system.
*
* @param aReferenceWidget The origin widget of aCursorRect.
* Typically, this is mReferenceWidget of the
* composing events. If the aCursorRect is in screen
* coordinates, set nsnull.
* @param aCursorRect The cursor rect.
* @param aNewOriginWidget aOutRect will be in this widget's coordinates. If
* this is nsnull, aOutRect will be in screen
* coordinates.
* @param aOutRect The converted cursor rect.
*/
void ResolveIMECaretPos(nsIWidget* aReferenceWidget,
nsRect& aCursorRect,
nsIWidget* aNewOriginWidget,
nsRect& aOutRect);
virtual PRBool DispatchKeyEvent(PRUint32 aEventType, WORD aCharCode,
const nsTArray<nsAlternativeCharCode>* aAlternativeChars,