mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 768742 Fix a buggy process of compositionupdate event. NPOTDB DONTBUILD OS/2 Only. r=masayuki
1. compositionupdate must be fired before dispatching text event 2. compositionupdate must be fired only if a conversion string was changed
This commit is contained in:
parent
50383b94f4
commit
596005ae6e
@ -2489,6 +2489,8 @@ bool nsWindow::ImeResultString(HIMI himi)
|
||||
}
|
||||
|
||||
if (!mIsComposing) {
|
||||
mLastDispatchedCompositionString.Truncate();
|
||||
|
||||
nsCompositionEvent start(true, NS_COMPOSITION_START, this);
|
||||
InitEvent(start);
|
||||
DispatchWindowEvent(&start);
|
||||
@ -2502,16 +2504,27 @@ bool nsWindow::ImeResultString(HIMI himi)
|
||||
|
||||
delete pBuf;
|
||||
|
||||
nsAutoString compositionString(outBuf.Elements());
|
||||
|
||||
if (mLastDispatchedCompositionString != compositionString) {
|
||||
nsCompositionEvent update(true, NS_COMPOSITION_UPDATE, this);
|
||||
InitEvent(update);
|
||||
update.data = compositionString;
|
||||
mLastDispatchedCompositionString = compositionString;
|
||||
DispatchWindowEvent(&update);
|
||||
}
|
||||
|
||||
nsTextEvent text(true, NS_TEXT_TEXT, this);
|
||||
InitEvent(text);
|
||||
text.theText = outBuf.Elements();
|
||||
text.theText = compositionString;
|
||||
DispatchWindowEvent(&text);
|
||||
|
||||
nsCompositionEvent end(true, NS_COMPOSITION_END, this);
|
||||
InitEvent(end);
|
||||
end.data = text.theText;
|
||||
end.data = compositionString;
|
||||
DispatchWindowEvent(&end);
|
||||
mIsComposing = false;
|
||||
mLastDispatchedCompositionString.Truncate();
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -2539,6 +2552,8 @@ bool nsWindow::ImeConversionString(HIMI himi)
|
||||
}
|
||||
|
||||
if (!mIsComposing) {
|
||||
mLastDispatchedCompositionString.Truncate();
|
||||
|
||||
nsCompositionEvent start(true, NS_COMPOSITION_START, this);
|
||||
InitEvent(start);
|
||||
DispatchWindowEvent(&start);
|
||||
@ -2552,17 +2567,27 @@ bool nsWindow::ImeConversionString(HIMI himi)
|
||||
|
||||
delete pBuf;
|
||||
|
||||
nsAutoString compositionString(outBuf.Elements());
|
||||
|
||||
// Is a conversion string changed ?
|
||||
if (mLastDispatchedCompositionString != compositionString) {
|
||||
nsCompositionEvent update(true, NS_COMPOSITION_UPDATE, this);
|
||||
InitEvent(update);
|
||||
update.data = compositionString;
|
||||
mLastDispatchedCompositionString = compositionString;
|
||||
DispatchWindowEvent(&update);
|
||||
}
|
||||
|
||||
nsAutoTArray<nsTextRange, 4> textRanges;
|
||||
|
||||
// Is there a conversion string ?
|
||||
if (outBufLen) {
|
||||
if (!compositionString.IsEmpty()) {
|
||||
nsTextRange newRange;
|
||||
newRange.mStartOffset = 0;
|
||||
newRange.mEndOffset = outBufLen;
|
||||
newRange.mEndOffset = compositionString.Length();
|
||||
newRange.mRangeType = NS_TEXTRANGE_SELECTEDRAWTEXT;
|
||||
textRanges.AppendElement(newRange);
|
||||
|
||||
newRange.mStartOffset = outBufLen;
|
||||
newRange.mStartOffset = compositionString.Length();
|
||||
newRange.mEndOffset = newRange.mStartOffset;
|
||||
newRange.mRangeType = NS_TEXTRANGE_CARETPOSITION;
|
||||
textRanges.AppendElement(newRange);
|
||||
@ -2570,23 +2595,19 @@ bool nsWindow::ImeConversionString(HIMI himi)
|
||||
|
||||
nsTextEvent text(true, NS_TEXT_TEXT, this);
|
||||
InitEvent(text);
|
||||
text.theText = outBuf.Elements();
|
||||
text.theText = compositionString;
|
||||
text.rangeArray = textRanges.Elements();
|
||||
text.rangeCount = textRanges.Length();
|
||||
DispatchWindowEvent(&text);
|
||||
|
||||
if (outBufLen) {
|
||||
nsCompositionEvent update(true, NS_COMPOSITION_UPDATE, this);
|
||||
InitEvent(update);
|
||||
update.data = text.theText;
|
||||
DispatchWindowEvent(&update);
|
||||
} else { // IME conversion was canceled ?
|
||||
if (compositionString.IsEmpty()) { // IME conversion was canceled ?
|
||||
nsCompositionEvent end(true, NS_COMPOSITION_END, this);
|
||||
InitEvent(end);
|
||||
end.data = text.theText;
|
||||
end.data = compositionString;
|
||||
DispatchWindowEvent(&end);
|
||||
|
||||
mIsComposing = false;
|
||||
mLastDispatchedCompositionString.Truncate();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -271,6 +271,7 @@ protected:
|
||||
nsCOMPtr<imgIContainer> mCssCursorImg;// saved by SetCursor(imgIContainer*)
|
||||
nsRefPtr<gfxOS2Surface> mThebesSurface;
|
||||
bool mIsComposing;
|
||||
nsString mLastDispatchedCompositionString;
|
||||
#ifdef DEBUG_FOCUS
|
||||
int mWindowIdentifier; // a serial number for each new window
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user