Bug 543789 part.6 Implement DOM3 composition event on Android r=dougt+smaug

This commit is contained in:
Masayuki Nakano 2011-09-22 18:17:40 +09:00
Родитель f2ba260f84
Коммит f18bb9935c
2 изменённых файлов: 18 добавлений и 0 удалений

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

@ -1632,12 +1632,15 @@ nsWindow::OnIMEEvent(AndroidGeckoEvent *ae)
ALOGIME("IME: IME_COMPOSITION_END");
nsCompositionEvent event(PR_TRUE, NS_COMPOSITION_END, this);
InitEvent(event, nsnull);
event.data = mIMELastDispatchedComposingText;
mIMELastDispatchedComposingText.Truncate();
DispatchEvent(&event);
}
return;
case AndroidGeckoEvent::IME_COMPOSITION_BEGIN:
{
ALOGIME("IME: IME_COMPOSITION_BEGIN");
mIMELastDispatchedComposingText.Truncate();
nsCompositionEvent event(PR_TRUE, NS_COMPOSITION_START, this);
InitEvent(event, nsnull);
DispatchEvent(&event);
@ -1659,6 +1662,20 @@ nsWindow::OnIMEEvent(AndroidGeckoEvent *ae)
event.rangeArray = mIMERanges.Elements();
event.rangeCount = mIMERanges.Length();
if (mIMEComposing &&
event.theText != mIMELastDispatchedComposingText) {
nsCompositionEvent compositionUpdate(PR_TRUE,
NS_COMPOSITION_UPDATE,
this);
InitEvent(compositionUpdate, nsnull);
compositionUpdate.data = event.theText;
mIMELastDispatchedComposingText = event.theText;
DispatchEvent(&compositionUpdate);
// XXX We must check whether this widget is destroyed or not
// before dispatching next event. However, Android's
// nsWindow has never checked it...
}
ALOGIME("IME: IME_SET_TEXT: l=%u, r=%u",
event.theText.Length(), mIMERanges.Length());

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

@ -199,6 +199,7 @@ protected:
PRBool mIMEComposing;
nsString mIMEComposingText;
nsString mIMELastDispatchedComposingText;
nsAutoTArray<nsTextRange, 4> mIMERanges;
IMEContext mIMEContext;