зеркало из https://github.com/mozilla/pjs.git
Bug 226784 Caret display problems with Korean input methods in Windows r=VYV03354+ere, sr=roc
This commit is contained in:
Родитель
628c689c37
Коммит
dda7039b4e
|
@ -49,6 +49,9 @@
|
|||
class nsIPrivateTextRange : public nsISupports {
|
||||
public:
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IPRIVATETEXTRANGE_IID)
|
||||
|
||||
// Note that the range array may not specify a caret position; in that
|
||||
// case there will be no range of type TEXTRANGE_CARETPOSITION in the array.
|
||||
enum {
|
||||
TEXTRANGE_CARETPOSITION = 1,
|
||||
TEXTRANGE_RAWINPUT = 2,
|
||||
|
|
|
@ -865,6 +865,9 @@ public:
|
|||
const PRUnichar* theText;
|
||||
nsTextEventReply theReply;
|
||||
PRUint32 rangeCount;
|
||||
// Note that the range array may not specify a caret position; in that
|
||||
// case there will be no range of type NS_TEXTRANGE_CARETPOSITION in the
|
||||
// array.
|
||||
nsTextRangeArray rangeArray;
|
||||
PRBool isChar;
|
||||
};
|
||||
|
@ -1385,12 +1388,12 @@ enum nsDragDropEventStatus {
|
|||
|
||||
#define NS_VK_META nsIDOMKeyEvent::DOM_VK_META
|
||||
|
||||
// IME Constants -- keep in synch with nsIDOMTextRange.h
|
||||
#define NS_TEXTRANGE_CARETPOSITION 0x01
|
||||
#define NS_TEXTRANGE_RAWINPUT 0X02
|
||||
#define NS_TEXTRANGE_SELECTEDRAWTEXT 0x03
|
||||
#define NS_TEXTRANGE_CONVERTEDTEXT 0x04
|
||||
#define NS_TEXTRANGE_SELECTEDCONVERTEDTEXT 0x05
|
||||
// IME Constants -- keep in synch with nsIPrivateTextRange.h
|
||||
#define NS_TEXTRANGE_CARETPOSITION 0x01
|
||||
#define NS_TEXTRANGE_RAWINPUT 0x02
|
||||
#define NS_TEXTRANGE_SELECTEDRAWTEXT 0x03
|
||||
#define NS_TEXTRANGE_CONVERTEDTEXT 0x04
|
||||
#define NS_TEXTRANGE_SELECTEDCONVERTEDTEXT 0x05
|
||||
|
||||
inline PRBool NS_TargetUnfocusedEventToLastFocusedContent(nsEvent* aEvent)
|
||||
{
|
||||
|
|
|
@ -297,7 +297,11 @@ PRInt32 nsWindow::sIMEAttributeArraySize = 0;
|
|||
PRUint32* nsWindow::sIMECompClauseArray = NULL;
|
||||
PRInt32 nsWindow::sIMECompClauseArrayLength = 0;
|
||||
PRInt32 nsWindow::sIMECompClauseArraySize = 0;
|
||||
long nsWindow::sIMECursorPosition = 0;
|
||||
|
||||
// Some IMEs (e.g., the standard IME for Korean) don't have caret position,
|
||||
// then, we should not set caret position to text event.
|
||||
#define NO_IME_CARET -1
|
||||
long nsWindow::sIMECursorPosition = NO_IME_CARET;
|
||||
|
||||
RECT* nsWindow::sIMECompCharPos = nsnull;
|
||||
|
||||
|
@ -6686,7 +6690,7 @@ nsWindow::HandleTextEvent(HIMC hIMEContext, PRBool aCheckAttr)
|
|||
// Record previous composing char position
|
||||
// The cursor is always on the right char before it, but not necessarily on the
|
||||
// left of next char, as what happens in wrapping.
|
||||
if (sIMECursorPosition && sIMECompCharPos &&
|
||||
if (sIMECursorPosition > 0 && sIMECompCharPos &&
|
||||
sIMECursorPosition < IME_MAX_CHAR_POS) {
|
||||
sIMECompCharPos[sIMECursorPosition-1].right = cursorPosition.x;
|
||||
sIMECompCharPos[sIMECursorPosition-1].top = cursorPosition.y;
|
||||
|
@ -6823,11 +6827,11 @@ static PRUint32 PlatformToNSAttr(PRUint8 aAttr)
|
|||
return NS_TEXTRANGE_CARETPOSITION;
|
||||
}
|
||||
}
|
||||
//
|
||||
// This function converts the composition string (CGS_COMPSTR) into Unicode while mapping the
|
||||
// attribute (GCS_ATTR) string t
|
||||
|
||||
|
||||
void
|
||||
nsWindow::GetTextRangeList(PRUint32* textRangeListLengthResult,nsTextRangeArray* textRangeListResult)
|
||||
nsWindow::GetTextRangeList(PRUint32* aListLength,
|
||||
nsTextRangeArray* textRangeListResult)
|
||||
{
|
||||
NS_ASSERTION(sIMECompUnicode, "sIMECompUnicode is null");
|
||||
|
||||
|
@ -6840,39 +6844,25 @@ nsWindow::GetTextRangeList(PRUint32* textRangeListLengthResult,nsTextRangeArray*
|
|||
if (cursor > maxlen)
|
||||
cursor = maxlen;
|
||||
|
||||
//
|
||||
// figure out the ranges from the compclause string
|
||||
//
|
||||
if (sIMECompClauseArrayLength == 0) {
|
||||
*textRangeListLengthResult = 2;
|
||||
*textRangeListResult = new nsTextRange[2];
|
||||
// Some IMEs don't return clause array information, then, we assume that
|
||||
// all characters in the composition string are in one clause.
|
||||
*aListLength = 1;
|
||||
// need one more room for caret
|
||||
*textRangeListResult = new nsTextRange[*aListLength + 1];
|
||||
(*textRangeListResult)[0].mStartOffset = 0;
|
||||
(*textRangeListResult)[0].mEndOffset = maxlen;
|
||||
(*textRangeListResult)[0].mRangeType = NS_TEXTRANGE_RAWINPUT;
|
||||
(*textRangeListResult)[1].mStartOffset = cursor;
|
||||
(*textRangeListResult)[1].mEndOffset = cursor;
|
||||
(*textRangeListResult)[1].mRangeType = NS_TEXTRANGE_CARETPOSITION;
|
||||
} else {
|
||||
*textRangeListLengthResult = sIMECompClauseArrayLength;
|
||||
*aListLength = sIMECompClauseArrayLength - 1;
|
||||
|
||||
//
|
||||
// allocate the offset array
|
||||
//
|
||||
*textRangeListResult = new nsTextRange[*textRangeListLengthResult];
|
||||
// need one more room for caret
|
||||
*textRangeListResult = new nsTextRange[*aListLength + 1];
|
||||
|
||||
//
|
||||
// figure out the cursor position
|
||||
//
|
||||
(*textRangeListResult)[0].mStartOffset = cursor;
|
||||
(*textRangeListResult)[0].mEndOffset = cursor;
|
||||
(*textRangeListResult)[0].mRangeType = NS_TEXTRANGE_CARETPOSITION;
|
||||
|
||||
//
|
||||
// iterate over the attributes and convert them into unicode
|
||||
//
|
||||
// iterate over the attributes
|
||||
int lastOffset = 0;
|
||||
for(int i = 1; i < sIMECompClauseArrayLength; i++) {
|
||||
long current = sIMECompClauseArray[i];
|
||||
for (int i = 0; i < *aListLength; i++) {
|
||||
long current = sIMECompClauseArray[i + 1];
|
||||
NS_ASSERTION(current <= maxlen, "wrong offset");
|
||||
if(current > maxlen)
|
||||
current = maxlen;
|
||||
|
@ -6885,6 +6875,14 @@ nsWindow::GetTextRangeList(PRUint32* textRangeListLengthResult,nsTextRangeArray*
|
|||
lastOffset = current;
|
||||
} // for
|
||||
} // if else
|
||||
|
||||
if (cursor == NO_IME_CARET)
|
||||
return;
|
||||
|
||||
(*textRangeListResult)[*aListLength].mStartOffset = cursor;
|
||||
(*textRangeListResult)[*aListLength].mEndOffset = cursor;
|
||||
(*textRangeListResult)[*aListLength].mRangeType = NS_TEXTRANGE_CARETPOSITION;
|
||||
++(*aListLength);
|
||||
}
|
||||
|
||||
|
||||
|
@ -7150,12 +7148,23 @@ BOOL nsWindow::OnIMEComposition(LPARAM aGCS)
|
|||
//--------------------------------------------------------
|
||||
// 4. Get GCS_CURSOPOS
|
||||
//--------------------------------------------------------
|
||||
sIMECursorPosition = ::ImmGetCompositionStringW(hIMEContext, GCS_CURSORPOS, NULL, 0);
|
||||
// Some IMEs (e.g., the standard IME for Korean) don't have caret position.
|
||||
if (aGCS & GCS_CURSORPOS) {
|
||||
sIMECursorPosition =
|
||||
::ImmGetCompositionStringW(hIMEContext, GCS_CURSORPOS, NULL, 0);
|
||||
if (sIMECursorPosition < 0)
|
||||
sIMECursorPosition = NO_IME_CARET; // The result is error
|
||||
} else {
|
||||
sIMECursorPosition = NO_IME_CARET;
|
||||
}
|
||||
|
||||
NS_ASSERTION(sIMECursorPosition <= (long)sIMECompUnicode->Length(), "illegal pos");
|
||||
|
||||
#ifdef DEBUG_IME
|
||||
printf("sIMECursorPosition(Unicode): %d\n", sIMECursorPosition);
|
||||
if (aGCS & GCS_CURSORPOS)
|
||||
printf("sIMECursorPosition(Unicode): %d\n", sIMECursorPosition);
|
||||
else
|
||||
printf("sIMECursorPosition: None\n");
|
||||
#endif
|
||||
//--------------------------------------------------------
|
||||
// 5. Send the text event
|
||||
|
|
Загрузка…
Ссылка в новой задаче