Bug 1058136 - Properly send text change notifications for composition text; r=cpeterson

This commit is contained in:
Jim Chen 2014-09-04 14:38:18 -04:00
parent 0567c72b22
commit 9e657ce31e
2 changed files with 15 additions and 9 deletions

View File

@ -708,12 +708,6 @@ final class GeckoEditable
getConstantName(Action.class, "TYPE_", action.mType) + ")");
}
switch (action.mType) {
case Action.TYPE_COMPOSE_TEXT:
// Compositions don't trigger text change notification, so notify manually.
onTextChange(action.mSequence, action.mStart, action.mEnd,
action.mStart + action.mSequence.length());
break;
case Action.TYPE_SET_SELECTION:
final int len = mText.length();
final int curStart = Selection.getSelectionStart(mText);
@ -941,7 +935,8 @@ final class GeckoEditable
if (!mActionQueue.isEmpty()) {
final Action action = mActionQueue.peek();
if (action.mType == Action.TYPE_REPLACE_TEXT &&
if ((action.mType == Action.TYPE_REPLACE_TEXT ||
action.mType == Action.TYPE_COMPOSE_TEXT) &&
start <= action.mStart &&
action.mStart + action.mSequence.length() <= newEnd) {

View File

@ -1867,6 +1867,18 @@ nsWindow::OnIMEEvent(AndroidGeckoEvent *ae)
WidgetTextEvent event(true, NS_TEXT_TEXT, this);
InitEvent(event, nullptr);
event.theText = ae->Characters();
if (ae->Action() == AndroidGeckoEvent::IME_COMPOSE_TEXT) {
// Because we're leaving the composition open, we need to
// include proper text ranges to make the editor happy.
TextRange range;
range.mStartOffset = 0;
range.mEndOffset = event.theText.Length();
range.mRangeType = NS_TEXTRANGE_RAWINPUT;
event.mRanges = new TextRangeArray();
event.mRanges->AppendElement(range);
}
DispatchEvent(&event);
}
@ -1877,10 +1889,9 @@ nsWindow::OnIMEEvent(AndroidGeckoEvent *ae)
InitEvent(event, nullptr);
event.data = ae->Characters();
DispatchEvent(&event);
FlushIMEChanges();
}
FlushIMEChanges();
mozilla::widget::android::GeckoAppShell::NotifyIME(
AndroidBridge::NOTIFY_IME_REPLY_EVENT);
}