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 { ...@@ -324,7 +324,7 @@ class ImeAdapter {
@CalledByNative @CalledByNative
private void cancelComposition() { private void cancelComposition() {
if (mInputConnection != null) { if (mInputConnection != null) {
mInputConnection.cancelComposition(); mInputConnection.restartInput();
} }
} }
...@@ -546,13 +546,6 @@ class ImeAdapter { ...@@ -546,13 +546,6 @@ class ImeAdapter {
return; 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) { if (!textUnchanged) {
editable.replace(0, editable.length(), text); editable.replace(0, editable.length(), text);
} }
...@@ -566,6 +559,13 @@ class ImeAdapter { ...@@ -566,6 +559,13 @@ class ImeAdapter {
getInputMethodManager().updateSelection(mInternalView, getInputMethodManager().updateSelection(mInternalView,
selectionStart, selectionEnd, compositionStart, compositionEnd); 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 @Override
...@@ -586,7 +586,7 @@ class ImeAdapter { ...@@ -586,7 +586,7 @@ class ImeAdapter {
public boolean performEditorAction(int actionCode) { public boolean performEditorAction(int actionCode) {
switch (actionCode) { switch (actionCode) {
case EditorInfo.IME_ACTION_NEXT: case EditorInfo.IME_ACTION_NEXT:
cancelComposition(); restartInput();
// Send TAB key event // Send TAB key event
long timeStampMs = System.currentTimeMillis(); long timeStampMs = System.currentTimeMillis();
mImeAdapter.sendSyntheticKeyEvent( mImeAdapter.sendSyntheticKeyEvent(
...@@ -687,11 +687,10 @@ class ImeAdapter { ...@@ -687,11 +687,10 @@ class ImeAdapter {
} }
/** /**
* Informs the InputMethodManager and InputMethodSession (i.e. the IME) that there * Informs the InputMethodManager and InputMethodSession (i.e. the IME) that the text
* is no longer a current composition. Note this differs from finishComposingText, which * state is no longer what the IME has and that it needs to be updated.
* is called by the IME when it wants to end a composition.
*/ */
void cancelComposition() { void restartInput() {
getInputMethodManager().restartInput(mInternalView); getInputMethodManager().restartInput(mInternalView);
} }
......
...@@ -4700,6 +4700,7 @@ void RenderViewImpl::SyncSelectionIfRequired() { ...@@ -4700,6 +4700,7 @@ void RenderViewImpl::SyncSelectionIfRequired() {
selection_text_offset_ = offset; selection_text_offset_ = offset;
selection_range_ = range; selection_range_ = range;
Send(new ViewHostMsg_SelectionChanged(routing_id_, text, offset, 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, ...@@ -631,6 +631,10 @@ void RenderWidget::OnHandleInputEvent(const WebKit::WebInputEvent* input_event,
prevent_default = prevent_default || WillHandleGestureEvent(gesture_event); prevent_default = prevent_default || WillHandleGestureEvent(gesture_event);
} }
if (input_event->type == WebInputEvent::GestureTap ||
input_event->type == WebInputEvent::GestureLongPress)
resetInputMethod();
bool processed = prevent_default; bool processed = prevent_default;
if (input_event->type != WebInputEvent::Char || !suppress_next_char_events_) { if (input_event->type != WebInputEvent::Char || !suppress_next_char_events_) {
suppress_next_char_events_ = false; suppress_next_char_events_ = false;
...@@ -1297,7 +1301,6 @@ void RenderWidget::willBeginCompositorFrame() { ...@@ -1297,7 +1301,6 @@ void RenderWidget::willBeginCompositorFrame() {
// The following two can result in further layout and possibly // The following two can result in further layout and possibly
// enable GPU acceleration so they need to be called before any painting // enable GPU acceleration so they need to be called before any painting
// is done. // is done.
UpdateTextInputState(DO_NOT_SHOW_IME);
UpdateSelectionBounds(); UpdateSelectionBounds();
WillInitiatePaint(); 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