зеркало из https://github.com/mozilla/pjs.git
Bug 543789 part.5 Implement DOM3 composition event on Mac r=smichaud+smaug
This commit is contained in:
Родитель
c3e2fd4836
Коммит
f2ba260f84
|
@ -946,6 +946,9 @@ protected:
|
|||
private:
|
||||
// If mIsIMEComposing is true, the composition string is stored here.
|
||||
NSString* mIMECompositionString;
|
||||
// mLastDispatchedCompositionString stores the lastest dispatched composition
|
||||
// string by compositionupdate event.
|
||||
nsString mLastDispatchedCompositionString;
|
||||
|
||||
NSRange mMarkedRange;
|
||||
|
||||
|
|
|
@ -1941,6 +1941,24 @@ IMEInputHandler::DispatchTextEvent(const nsString& aText,
|
|||
textEvent.rangeArray = textRanges.Elements();
|
||||
textEvent.rangeCount = textRanges.Length();
|
||||
|
||||
if (textEvent.theText != mLastDispatchedCompositionString) {
|
||||
nsCompositionEvent compositionUpdate(PR_TRUE, NS_COMPOSITION_UPDATE,
|
||||
mWidget);
|
||||
compositionUpdate.time = textEvent.time;
|
||||
compositionUpdate.data = textEvent.theText;
|
||||
mLastDispatchedCompositionString = textEvent.theText;
|
||||
DispatchEvent(compositionUpdate);
|
||||
if (mIsInFocusProcessing || Destroyed()) {
|
||||
PR_LOG(gLog, PR_LOG_ALWAYS,
|
||||
("%p IMEInputHandler::DispatchTextEvent, compositionupdate causes "
|
||||
"aborting the composition, mIsInFocusProcessing=%s, Destryoed()=%s",
|
||||
this, TrueOrFalse(mIsInFocusProcessing), TrueOrFalse(Destroyed())));
|
||||
if (Destroyed()) {
|
||||
return PR_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return DispatchEvent(textEvent);
|
||||
}
|
||||
|
||||
|
@ -2010,6 +2028,7 @@ IMEInputHandler::InsertTextAsCommittingComposition(
|
|||
|
||||
nsCompositionEvent compEnd(PR_TRUE, NS_COMPOSITION_END, mWidget);
|
||||
InitCompositionEvent(compEnd);
|
||||
compEnd.data = mLastDispatchedCompositionString;
|
||||
DispatchEvent(compEnd);
|
||||
if (Destroyed()) {
|
||||
PR_LOG(gLog, PR_LOG_ALWAYS,
|
||||
|
@ -2087,6 +2106,7 @@ IMEInputHandler::SetMarkedText(NSAttributedString* aAttrString,
|
|||
if (doCommit) {
|
||||
nsCompositionEvent compEnd(PR_TRUE, NS_COMPOSITION_END, mWidget);
|
||||
InitCompositionEvent(compEnd);
|
||||
compEnd.data = mLastDispatchedCompositionString;
|
||||
DispatchEvent(compEnd);
|
||||
if (Destroyed()) {
|
||||
PR_LOG(gLog, PR_LOG_ALWAYS,
|
||||
|
@ -2436,6 +2456,8 @@ IMEInputHandler::OnStartIMEComposition()
|
|||
NS_ASSERTION(!mIsIMEComposing, "There is a composition already");
|
||||
mIsIMEComposing = PR_TRUE;
|
||||
|
||||
mLastDispatchedCompositionString.Truncate();
|
||||
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK;
|
||||
}
|
||||
|
||||
|
@ -2479,6 +2501,8 @@ IMEInputHandler::OnEndIMEComposition()
|
|||
mIMECompositionString = nsnull;
|
||||
}
|
||||
|
||||
mLastDispatchedCompositionString.Truncate();
|
||||
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче