Bug 974560 - Send compositionupdate event for each text event; r=cpeterson

This commit is contained in:
Jim Chen 2014-02-24 12:27:58 -05:00
parent f7ed0b9c3b
commit 4be6092e7d

View File

@ -1708,12 +1708,9 @@ nsWindow::OnKeyEvent(AndroidGeckoEvent *ae)
msg = NS_KEY_UP; msg = NS_KEY_UP;
break; break;
case AKEY_EVENT_ACTION_MULTIPLE: case AKEY_EVENT_ACTION_MULTIPLE:
{ // Keys with multiple action are handled in Java,
WidgetTextEvent event(true, NS_TEXT_TEXT, this); // and we should never see one here
event.theText.Assign(ae->Characters()); MOZ_CRASH("Cannot handle key with multiple action");
DispatchEvent(&event);
}
return;
default: default:
ALOG("Unknown key action event!"); ALOG("Unknown key action event!");
return; return;
@ -1910,6 +1907,12 @@ nsWindow::OnIMEEvent(AndroidGeckoEvent *ae)
InitEvent(event, nullptr); InitEvent(event, nullptr);
DispatchEvent(&event); DispatchEvent(&event);
} }
{
WidgetCompositionEvent event(true, NS_COMPOSITION_UPDATE, this);
InitEvent(event, nullptr);
event.data = ae->Characters();
DispatchEvent(&event);
}
{ {
WidgetTextEvent event(true, NS_TEXT_TEXT, this); WidgetTextEvent event(true, NS_TEXT_TEXT, this);
InitEvent(event, nullptr); InitEvent(event, nullptr);
@ -2032,17 +2035,13 @@ nsWindow::OnIMEEvent(AndroidGeckoEvent *ae)
InitEvent(event, nullptr); InitEvent(event, nullptr);
DispatchEvent(&event); DispatchEvent(&event);
} }
{
if (mIMEComposing &&
event.theText != mIMEComposingText) {
WidgetCompositionEvent compositionUpdate(true, WidgetCompositionEvent compositionUpdate(true,
NS_COMPOSITION_UPDATE, NS_COMPOSITION_UPDATE,
this); this);
InitEvent(compositionUpdate, nullptr); InitEvent(compositionUpdate, nullptr);
compositionUpdate.data = event.theText; compositionUpdate.data = event.theText;
DispatchEvent(&compositionUpdate); DispatchEvent(&compositionUpdate);
if (Destroyed())
return;
} }
#ifdef DEBUG_ANDROID_IME #ifdef DEBUG_ANDROID_IME
@ -2126,6 +2125,11 @@ nsWindow::NotifyIME(const IMENotification& aIMENotification)
if (mIMEComposing) { if (mIMEComposing) {
nsRefPtr<nsWindow> kungFuDeathGrip(this); nsRefPtr<nsWindow> kungFuDeathGrip(this);
WidgetCompositionEvent updateEvent(true, NS_COMPOSITION_UPDATE,
this);
InitEvent(updateEvent, nullptr);
DispatchEvent(&updateEvent);
WidgetTextEvent textEvent(true, NS_TEXT_TEXT, this); WidgetTextEvent textEvent(true, NS_TEXT_TEXT, this);
InitEvent(textEvent, nullptr); InitEvent(textEvent, nullptr);
DispatchEvent(&textEvent); DispatchEvent(&textEvent);