Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1424)

Unified Diff: content/browser/renderer_host/ime_adapter_android.cc

Issue 1999423002: tyrbot test for commitText (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: SetHasCompositionTextToTrue Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/ime_adapter_android.cc
diff --git a/content/browser/renderer_host/ime_adapter_android.cc b/content/browser/renderer_host/ime_adapter_android.cc
index 98048d1b26f7ce91f37d69ed4443f1d9172fe5f6..8107f74abb50360e5d92d723a107c32c659a8b14 100644
--- a/content/browser/renderer_host/ime_adapter_android.cc
+++ b/content/browser/renderer_host/ime_adapter_android.cc
@@ -143,7 +143,7 @@ void ImeAdapterAndroid::SetComposingText(JNIEnv* env,
const JavaParamRef<jobject>& obj,
const JavaParamRef<jobject>& text,
const JavaParamRef<jstring>& text_str,
- int new_cursor_pos) {
+ int relative_cursor_pos) {
RenderWidgetHostImpl* rwhi = GetRenderWidgetHostImpl();
if (!rwhi)
return;
@@ -165,25 +165,35 @@ void ImeAdapterAndroid::SetComposingText(JNIEnv* env,
// Sort spans by |.startOffset|.
std::sort(underlines.begin(), underlines.end());
- // new_cursor_position is as described in the Android API for
+ // relative_cursor_pos is as described in the Android API for
// InputConnection#setComposingText, whereas the parameters for
// ImeSetComposition are relative to the start of the composition.
- if (new_cursor_pos > 0)
- new_cursor_pos = text16.length() + new_cursor_pos - 1;
+ if (relative_cursor_pos > 0)
+ relative_cursor_pos = text16.length() + relative_cursor_pos - 1;
rwhi->ImeSetComposition(text16, underlines, gfx::Range::InvalidRange(),
- new_cursor_pos, new_cursor_pos);
+ relative_cursor_pos, relative_cursor_pos);
}
void ImeAdapterAndroid::CommitText(JNIEnv* env,
const JavaParamRef<jobject>&,
- const JavaParamRef<jstring>& text_str) {
+ const JavaParamRef<jstring>& text_str,
+ int relative_cursor_pos) {
RenderWidgetHostImpl* rwhi = GetRenderWidgetHostImpl();
if (!rwhi)
return;
base::string16 text16 = ConvertJavaStringToUTF16(env, text_str);
- rwhi->ImeConfirmComposition(text16, gfx::Range::InvalidRange(), false);
+
+ // relative_cursor_pos is as described in the Android API for
+ // InputConnection#commitText, whereas the parameters for
+ // ImeConfirmComposition are relative to the end of the composition.
+ if (relative_cursor_pos > 0)
+ relative_cursor_pos--;
+ else
+ relative_cursor_pos -= text16.length();
+
+ rwhi->ImeCommitText(text16, gfx::Range::InvalidRange(), relative_cursor_pos);
}
void ImeAdapterAndroid::FinishComposingText(JNIEnv* env,
@@ -192,8 +202,7 @@ void ImeAdapterAndroid::FinishComposingText(JNIEnv* env,
if (!rwhi)
return;
- rwhi->ImeConfirmComposition(base::string16(), gfx::Range::InvalidRange(),
- true);
+ rwhi->ImeFinishComposingText(true);
}
void ImeAdapterAndroid::AttachImeAdapter(
« no previous file with comments | « content/browser/renderer_host/ime_adapter_android.h ('k') | content/browser/renderer_host/render_widget_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698