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

Side by Side Diff: content/browser/renderer_host/ime_adapter_android.cc

Issue 1995333002: Handle newCursorPosition correctly for Android's commitText() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: adjust selection in confirmCompositionOrInsertText() Created 4 years, 4 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/renderer_host/ime_adapter_android.h" 5 #include "content/browser/renderer_host/ime_adapter_android.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <android/input.h> 8 #include <android/input.h>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 // ImeSetComposition are relative to the start of the composition. 205 // ImeSetComposition are relative to the start of the composition.
206 if (new_cursor_pos > 0) 206 if (new_cursor_pos > 0)
207 new_cursor_pos = text16.length() + new_cursor_pos - 1; 207 new_cursor_pos = text16.length() + new_cursor_pos - 1;
208 208
209 rwhi->ImeSetComposition(text16, underlines, gfx::Range::InvalidRange(), 209 rwhi->ImeSetComposition(text16, underlines, gfx::Range::InvalidRange(),
210 new_cursor_pos, new_cursor_pos); 210 new_cursor_pos, new_cursor_pos);
211 } 211 }
212 212
213 void ImeAdapterAndroid::CommitText(JNIEnv* env, 213 void ImeAdapterAndroid::CommitText(JNIEnv* env,
214 const JavaParamRef<jobject>&, 214 const JavaParamRef<jobject>&,
215 const JavaParamRef<jstring>& text_str) { 215 const JavaParamRef<jstring>& text_str,
216 int new_cursor_pos) {
216 RenderWidgetHostImpl* rwhi = GetRenderWidgetHostImpl(); 217 RenderWidgetHostImpl* rwhi = GetRenderWidgetHostImpl();
217 if (!rwhi) 218 if (!rwhi)
218 return; 219 return;
219 220
220 base::string16 text16 = ConvertJavaStringToUTF16(env, text_str); 221 base::string16 text16 = ConvertJavaStringToUTF16(env, text_str);
221 rwhi->ImeConfirmComposition(text16, gfx::Range::InvalidRange(), false); 222 rwhi->ImeConfirmComposition(text16, gfx::Range::InvalidRange(), false,
223 new_cursor_pos);
222 } 224 }
223 225
224 void ImeAdapterAndroid::FinishComposingText(JNIEnv* env, 226 void ImeAdapterAndroid::FinishComposingText(JNIEnv* env,
225 const JavaParamRef<jobject>&) { 227 const JavaParamRef<jobject>&) {
226 RenderWidgetHostImpl* rwhi = GetRenderWidgetHostImpl(); 228 RenderWidgetHostImpl* rwhi = GetRenderWidgetHostImpl();
227 if (!rwhi) 229 if (!rwhi)
228 return; 230 return;
229 231
230 rwhi->ImeConfirmComposition(base::string16(), gfx::Range::InvalidRange(), 232 rwhi->ImeConfirmComposition(base::string16(), gfx::Range::InvalidRange(),
231 true); 233 true);
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 } 379 }
378 380
379 WebContents* ImeAdapterAndroid::GetWebContents() { 381 WebContents* ImeAdapterAndroid::GetWebContents() {
380 RenderWidgetHostImpl* rwh = GetRenderWidgetHostImpl(); 382 RenderWidgetHostImpl* rwh = GetRenderWidgetHostImpl();
381 if (!rwh) 383 if (!rwh)
382 return nullptr; 384 return nullptr;
383 return WebContents::FromRenderViewHost(RenderViewHost::From(rwh)); 385 return WebContents::FromRenderViewHost(RenderViewHost::From(rwh));
384 } 386 }
385 387
386 } // namespace content 388 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698