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

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: Created 4 years, 7 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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 // ImeSetComposition are relative to the start of the composition. 206 // ImeSetComposition are relative to the start of the composition.
207 if (new_cursor_pos > 0) 207 if (new_cursor_pos > 0)
208 new_cursor_pos = text16.length() + new_cursor_pos - 1; 208 new_cursor_pos = text16.length() + new_cursor_pos - 1;
209 209
210 rwhi->ImeSetComposition(text16, underlines, gfx::Range::InvalidRange(), 210 rwhi->ImeSetComposition(text16, underlines, gfx::Range::InvalidRange(),
211 new_cursor_pos, new_cursor_pos); 211 new_cursor_pos, new_cursor_pos);
212 } 212 }
213 213
214 void ImeAdapterAndroid::CommitText(JNIEnv* env, 214 void ImeAdapterAndroid::CommitText(JNIEnv* env,
215 const JavaParamRef<jobject>&, 215 const JavaParamRef<jobject>&,
216 const JavaParamRef<jstring>& text_str) { 216 const JavaParamRef<jstring>& text_str,
217 int new_cursor_pos) {
217 RenderWidgetHostImpl* rwhi = GetRenderWidgetHostImpl(); 218 RenderWidgetHostImpl* rwhi = GetRenderWidgetHostImpl();
218 if (!rwhi) 219 if (!rwhi)
219 return; 220 return;
220 221
221 base::string16 text16 = ConvertJavaStringToUTF16(env, text_str); 222 base::string16 text16 = ConvertJavaStringToUTF16(env, text_str);
222 rwhi->ImeConfirmComposition(text16, gfx::Range::InvalidRange(), false); 223 rwhi->ImeConfirmComposition(text16, gfx::Range::InvalidRange(), false,
224 new_cursor_pos);
223 } 225 }
224 226
225 void ImeAdapterAndroid::FinishComposingText(JNIEnv* env, 227 void ImeAdapterAndroid::FinishComposingText(JNIEnv* env,
226 const JavaParamRef<jobject>&) { 228 const JavaParamRef<jobject>&) {
227 RenderWidgetHostImpl* rwhi = GetRenderWidgetHostImpl(); 229 RenderWidgetHostImpl* rwhi = GetRenderWidgetHostImpl();
228 if (!rwhi) 230 if (!rwhi)
229 return; 231 return;
230 232
231 rwhi->ImeConfirmComposition(base::string16(), gfx::Range::InvalidRange(), 233 rwhi->ImeConfirmComposition(base::string16(), gfx::Range::InvalidRange(),
232 true); 234 true);
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 } 368 }
367 369
368 WebContents* ImeAdapterAndroid::GetWebContents() { 370 WebContents* ImeAdapterAndroid::GetWebContents() {
369 RenderWidgetHostImpl* rwh = GetRenderWidgetHostImpl(); 371 RenderWidgetHostImpl* rwh = GetRenderWidgetHostImpl();
370 if (!rwh) 372 if (!rwh)
371 return nullptr; 373 return nullptr;
372 return WebContents::FromRenderViewHost(RenderViewHost::From(rwh)); 374 return WebContents::FromRenderViewHost(RenderViewHost::From(rwh));
373 } 375 }
374 376
375 } // namespace content 377 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698