mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 489951 [TSF] Korean TIP's composition string looks like normal text r=VYV03354, sr=roc
This commit is contained in:
parent
14124b5b86
commit
a5daf397fd
@ -318,6 +318,8 @@ NS_IMETHODIMP IMETextTxn::CollapseTextSelection(void)
|
||||
|
||||
if(nsIPrivateTextRange::TEXTRANGE_CARETPOSITION == textRangeType)
|
||||
{
|
||||
NS_ASSERTION(selectionStart == selectionEnd,
|
||||
"nsEditor doesn't support wide caret");
|
||||
// Set the caret....
|
||||
result = selection->Collapse(mElement,
|
||||
mOffset+selectionStart);
|
||||
|
@ -865,11 +865,17 @@ struct nsTextRangeStyle
|
||||
|
||||
// Initialize all members, because nsTextRange instances may be compared by
|
||||
// memcomp.
|
||||
nsTextRangeStyle() :
|
||||
mDefinedStyles(DEFINED_NONE), mLineStyle(LINESTYLE_NONE),
|
||||
mIsBoldLine(PR_FALSE), mForegroundColor(NS_RGBA(0, 0, 0, 0)),
|
||||
mBackgroundColor(NS_RGBA(0, 0, 0, 0)), mUnderlineColor(NS_RGBA(0, 0, 0, 0))
|
||||
nsTextRangeStyle()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
void Clear()
|
||||
{
|
||||
mDefinedStyles = DEFINED_NONE;
|
||||
mLineStyle = LINESTYLE_NONE;
|
||||
mIsBoldLine = PR_FALSE;
|
||||
mForegroundColor = mBackgroundColor = mUnderlineColor = NS_RGBA(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
PRBool IsDefined() const { return mDefinedStyles != DEFINED_NONE; }
|
||||
@ -894,6 +900,12 @@ struct nsTextRangeStyle
|
||||
return (mDefinedStyles & DEFINED_UNDERLINE_COLOR) != 0;
|
||||
}
|
||||
|
||||
PRBool IsNoChangeStyle() const
|
||||
{
|
||||
return !IsForegroundColorDefined() && !IsBackgroundColorDefined() &&
|
||||
IsLineStyleDefined() && mLineStyle == LINESTYLE_NONE;
|
||||
}
|
||||
|
||||
PRBool Equals(const nsTextRangeStyle& aOther)
|
||||
{
|
||||
if (mDefinedStyles != aOther.mDefinedStyles)
|
||||
|
@ -701,12 +701,6 @@ nsTextStore::SendTextEventForCompositionString()
|
||||
|
||||
nsAutoTArray<nsTextRange, 4> textRanges;
|
||||
nsTextRange newRange;
|
||||
newRange.mStartOffset =
|
||||
PRUint32(mCompositionSelection.acpStart - mCompositionStart);
|
||||
newRange.mEndOffset =
|
||||
PRUint32(mCompositionSelection.acpEnd - mCompositionStart);
|
||||
newRange.mRangeType = NS_TEXTRANGE_CARETPOSITION;
|
||||
textRanges.AppendElement(newRange);
|
||||
// No matter if we have display attribute info or not,
|
||||
// we always pass in at least one range to NS_TEXT_TEXT
|
||||
newRange.mStartOffset = 0;
|
||||
@ -763,6 +757,39 @@ nsTextStore::SendTextEventForCompositionString()
|
||||
}
|
||||
}
|
||||
|
||||
// We need to hack for Korean Input System which is Korean standard TIP.
|
||||
// It sets no change style to IME selection (the selection is always only
|
||||
// one). So, the composition string looks like normal (or committed) string.
|
||||
// At this time, mCompositionSelection range is same as the composition
|
||||
// string range. Other applications set a wide caret which covers the
|
||||
// composition string, however, Gecko doesn't support the wide caret drawing
|
||||
// now (Gecko doesn't support XOR drawing), unfortunately. For now, we should
|
||||
// change the range style to undefined.
|
||||
if (mCompositionSelection.acpStart != mCompositionSelection.acpEnd &&
|
||||
textRanges.Length() == 1) {
|
||||
nsTextRange& range = textRanges[0];
|
||||
LONG start = PR_MIN(mCompositionSelection.acpStart,
|
||||
mCompositionSelection.acpEnd);
|
||||
LONG end = PR_MAX(mCompositionSelection.acpStart,
|
||||
mCompositionSelection.acpEnd);
|
||||
if (range.mStartOffset == start - mCompositionStart &&
|
||||
range.mEndOffset == end - mCompositionStart &&
|
||||
range.mRangeStyle.IsNoChangeStyle()) {
|
||||
range.mRangeStyle.Clear();
|
||||
// The looks of selected type is better than others.
|
||||
range.mRangeType = NS_TEXTRANGE_SELECTEDRAWTEXT;
|
||||
}
|
||||
}
|
||||
|
||||
// The caret position has to be collapsed.
|
||||
LONG caretPosition = PR_MAX(mCompositionSelection.acpStart,
|
||||
mCompositionSelection.acpEnd);
|
||||
caretPosition -= mCompositionStart;
|
||||
nsTextRange caretRange;
|
||||
caretRange.mStartOffset = caretRange.mEndOffset = PRUint32(caretPosition);
|
||||
caretRange.mRangeType = NS_TEXTRANGE_CARETPOSITION;
|
||||
textRanges.AppendElement(caretRange);
|
||||
|
||||
event.theText = mCompositionString;
|
||||
event.rangeArray = textRanges.Elements();
|
||||
event.rangeCount = textRanges.Length();
|
||||
|
Loading…
Reference in New Issue
Block a user