Commit 3ebcc7c9 authored by aurimas@chromium.org's avatar aurimas@chromium.org

Adding a call to clear text composition on tap.

Adding a call to clear text composition on tap gestures and also changing
the places where the text updates get sent back to the browser.

BUG=167127


Review URL: https://chromiumcodereview.appspot.com/11741036

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@175712 0039d316-1c4b-4281-b951-d872f2087c98
parent 5e641315
......@@ -324,7 +324,7 @@ class ImeAdapter {
@CalledByNative
private void cancelComposition() {
if (mInputConnection != null) {
mInputConnection.cancelComposition();
mInputConnection.restartInput();
}
}
......@@ -546,13 +546,6 @@ class ImeAdapter {
return;
}
// When a programmatic change has been made to the editable field, both the start
// and end positions for the composition will equal zero. In this case we cancel the
// active composition in the editor as this no longer is relevant.
if (textUnchanged && compositionStart == 0 && compositionEnd == 0) {
cancelComposition();
}
if (!textUnchanged) {
editable.replace(0, editable.length(), text);
}
......@@ -566,6 +559,13 @@ class ImeAdapter {
getInputMethodManager().updateSelection(mInternalView,
selectionStart, selectionEnd, compositionStart, compositionEnd);
}
// When WebKit changes the editable field, both the start and the end positions for
// the composition will be set to -1. In this case we have to call restart input
// for the IME to update its state.
if (textUnchanged && compositionStart == -1 && compositionEnd == -1) {
restartInput();
}
}
@Override
......@@ -586,7 +586,7 @@ class ImeAdapter {
public boolean performEditorAction(int actionCode) {
switch (actionCode) {
case EditorInfo.IME_ACTION_NEXT:
cancelComposition();
restartInput();
// Send TAB key event
long timeStampMs = System.currentTimeMillis();
mImeAdapter.sendSyntheticKeyEvent(
......@@ -687,11 +687,10 @@ class ImeAdapter {
}
/**
* Informs the InputMethodManager and InputMethodSession (i.e. the IME) that there
* is no longer a current composition. Note this differs from finishComposingText, which
* is called by the IME when it wants to end a composition.
* Informs the InputMethodManager and InputMethodSession (i.e. the IME) that the text
* state is no longer what the IME has and that it needs to be updated.
*/
void cancelComposition() {
void restartInput() {
getInputMethodManager().restartInput(mInternalView);
}
......
......@@ -4700,6 +4700,7 @@ void RenderViewImpl::SyncSelectionIfRequired() {
selection_text_offset_ = offset;
selection_range_ = range;
Send(new ViewHostMsg_SelectionChanged(routing_id_, text, offset, range));
UpdateTextInputState(SHOW_IME_IF_NEEDED);
}
}
......
......@@ -631,6 +631,10 @@ void RenderWidget::OnHandleInputEvent(const WebKit::WebInputEvent* input_event,
prevent_default = prevent_default || WillHandleGestureEvent(gesture_event);
}
if (input_event->type == WebInputEvent::GestureTap ||
input_event->type == WebInputEvent::GestureLongPress)
resetInputMethod();
bool processed = prevent_default;
if (input_event->type != WebInputEvent::Char || !suppress_next_char_events_) {
suppress_next_char_events_ = false;
......@@ -1297,7 +1301,6 @@ void RenderWidget::willBeginCompositorFrame() {
// The following two can result in further layout and possibly
// enable GPU acceleration so they need to be called before any painting
// is done.
UpdateTextInputState(DO_NOT_SHOW_IME);
UpdateSelectionBounds();
WillInitiatePaint();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment