#59405 IME candidate window position is not correct in text field on New card and To field

r = sfraser sr=kin a=blizzard
Handle the difference of cursor coordinate required by different platform.
nsICaret.h
nsCaret.cpp
nsEditor.cpp
nsPlaintextEditor.cpp
nsHTMLEditor.cpp
This commit is contained in:
shanjian%netscape.com 2001-04-19 22:46:29 +00:00
Родитель 6a048b1a8f
Коммит 7e501c5ca2
10 изменённых файлов: 28 добавлений и 30 удалений

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

@ -1893,7 +1893,7 @@ nsEditor::QueryComposition(nsTextEventReply* aReply)
if (NS_SUCCEEDED(result) && caretP) {
if (aReply) {
caretP->SetCaretDOMSelection(selection);
result = caretP->GetCaretCoordinates(nsICaret::eTopLevelWindowCoordinates, selection,
result = caretP->GetCaretCoordinates(nsICaret::eIMECoordinates, selection,
&(aReply->mCursorPosition), &(aReply->mCursorIsCollapsed));
}
}

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

@ -3404,7 +3404,7 @@ nsHTMLEditor::SetCompositionString(const nsAReadableString& aCompositionString,
if (!ps) return NS_ERROR_NOT_INITIALIZED;
ps->GetCaret(getter_AddRefs(caretP));
caretP->SetCaretDOMSelection(selection);
result = caretP->GetCaretCoordinates(nsICaret::eTopLevelWindowCoordinates, selection,
result = caretP->GetCaretCoordinates(nsICaret::eIMECoordinates, selection,
&(aReply->mCursorPosition), &(aReply->mCursorIsCollapsed));
// second part of 23558 fix:

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

@ -1886,19 +1886,8 @@ nsPlaintextEditor::SetCompositionString(const nsAReadableString& aCompositionStr
ps->GetCaret(getter_AddRefs(caretP));
caretP->SetCaretDOMSelection(selection);
// XXX: The following ifdef should really be pushed up into the
// IME front-end code, or down into the caret code. There was a
// suggestion that perhaps nsCaret::GetCaretCoordinates() should
// be modified so that we can pass in something like eIMECoordinates
// and let it decide what to return based on the platform we are
// running on.
#ifdef XP_MAC
caretP->GetCaretCoordinates(nsICaret::eTopLevelWindowCoordinates, selection,
caretP->GetCaretCoordinates(nsICaret::eIMECoordinates, selection,
&(aReply->mCursorPosition), &(aReply->mCursorIsCollapsed));
#else
caretP->GetCaretCoordinates(nsICaret::eRenderingViewCoordinates, selection,
&(aReply->mCursorPosition), &(aReply->mCursorIsCollapsed));
#endif
// second part of 23558 fix:
if (aCompositionString.IsEmpty())

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

@ -1893,7 +1893,7 @@ nsEditor::QueryComposition(nsTextEventReply* aReply)
if (NS_SUCCEEDED(result) && caretP) {
if (aReply) {
caretP->SetCaretDOMSelection(selection);
result = caretP->GetCaretCoordinates(nsICaret::eTopLevelWindowCoordinates, selection,
result = caretP->GetCaretCoordinates(nsICaret::eIMECoordinates, selection,
&(aReply->mCursorPosition), &(aReply->mCursorIsCollapsed));
}
}

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

@ -3404,7 +3404,7 @@ nsHTMLEditor::SetCompositionString(const nsAReadableString& aCompositionString,
if (!ps) return NS_ERROR_NOT_INITIALIZED;
ps->GetCaret(getter_AddRefs(caretP));
caretP->SetCaretDOMSelection(selection);
result = caretP->GetCaretCoordinates(nsICaret::eTopLevelWindowCoordinates, selection,
result = caretP->GetCaretCoordinates(nsICaret::eIMECoordinates, selection,
&(aReply->mCursorPosition), &(aReply->mCursorIsCollapsed));
// second part of 23558 fix:

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

@ -1886,19 +1886,8 @@ nsPlaintextEditor::SetCompositionString(const nsAReadableString& aCompositionStr
ps->GetCaret(getter_AddRefs(caretP));
caretP->SetCaretDOMSelection(selection);
// XXX: The following ifdef should really be pushed up into the
// IME front-end code, or down into the caret code. There was a
// suggestion that perhaps nsCaret::GetCaretCoordinates() should
// be modified so that we can pass in something like eIMECoordinates
// and let it decide what to return based on the platform we are
// running on.
#ifdef XP_MAC
caretP->GetCaretCoordinates(nsICaret::eTopLevelWindowCoordinates, selection,
caretP->GetCaretCoordinates(nsICaret::eIMECoordinates, selection,
&(aReply->mCursorPosition), &(aReply->mCursorIsCollapsed));
#else
caretP->GetCaretCoordinates(nsICaret::eRenderingViewCoordinates, selection,
&(aReply->mCursorPosition), &(aReply->mCursorIsCollapsed));
#endif
// second part of 23558 fix:
if (aCompositionString.IsEmpty())

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

@ -305,6 +305,15 @@ NS_IMETHODIMP nsCaret::GetCaretCoordinates(EViewCoordinates aRelativeToType, nsI
nsPoint viewOffset(0, 0);
nsRect clipRect;
nsIView *drawingView; // views are not refcounted
//#59405, on windows and unix, the coordinate for IME need to be view (nearest native window) related.
if (aRelativeToType == eIMECoordinates)
#ifdef XP_MAC
aRelativeToType = eTopLevelWindowCoordinates;
#else
aRelativeToType = eRenderingViewCoordinates;
#endif
GetViewForRendering(theFrame, aRelativeToType, viewOffset, clipRect, drawingView);
if (!drawingView)
return NS_ERROR_UNEXPECTED;

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

@ -45,7 +45,8 @@ public:
typedef enum EViewCoordinates {
eTopLevelWindowCoordinates,
eRenderingViewCoordinates,
eClosestViewCoordinates
eClosestViewCoordinates,
eIMECoordinates
} EViewCoordinates;
NS_IMETHOD Init(nsIPresShell *inPresShell) = 0;

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

@ -45,7 +45,8 @@ public:
typedef enum EViewCoordinates {
eTopLevelWindowCoordinates,
eRenderingViewCoordinates,
eClosestViewCoordinates
eClosestViewCoordinates,
eIMECoordinates
} EViewCoordinates;
NS_IMETHOD Init(nsIPresShell *inPresShell) = 0;

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

@ -305,6 +305,15 @@ NS_IMETHODIMP nsCaret::GetCaretCoordinates(EViewCoordinates aRelativeToType, nsI
nsPoint viewOffset(0, 0);
nsRect clipRect;
nsIView *drawingView; // views are not refcounted
//#59405, on windows and unix, the coordinate for IME need to be view (nearest native window) related.
if (aRelativeToType == eIMECoordinates)
#ifdef XP_MAC
aRelativeToType = eTopLevelWindowCoordinates;
#else
aRelativeToType = eRenderingViewCoordinates;
#endif
GetViewForRendering(theFrame, aRelativeToType, viewOffset, clipRect, drawingView);
if (!drawingView)
return NS_ERROR_UNEXPECTED;