OLD | NEW |
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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 // ImeSetComposition are relative to the start of the composition. | 170 // ImeSetComposition are relative to the start of the composition. |
171 if (new_cursor_pos > 0) | 171 if (new_cursor_pos > 0) |
172 new_cursor_pos = text16.length() + new_cursor_pos - 1; | 172 new_cursor_pos = text16.length() + new_cursor_pos - 1; |
173 | 173 |
174 rwhi->ImeSetComposition(text16, underlines, gfx::Range::InvalidRange(), | 174 rwhi->ImeSetComposition(text16, underlines, gfx::Range::InvalidRange(), |
175 new_cursor_pos, new_cursor_pos); | 175 new_cursor_pos, new_cursor_pos); |
176 } | 176 } |
177 | 177 |
178 void ImeAdapterAndroid::CommitText(JNIEnv* env, | 178 void ImeAdapterAndroid::CommitText(JNIEnv* env, |
179 const JavaParamRef<jobject>&, | 179 const JavaParamRef<jobject>&, |
180 const JavaParamRef<jstring>& text_str) { | 180 const JavaParamRef<jstring>& text_str, |
| 181 int new_cursor_pos) { |
181 RenderWidgetHostImpl* rwhi = GetRenderWidgetHostImpl(); | 182 RenderWidgetHostImpl* rwhi = GetRenderWidgetHostImpl(); |
182 if (!rwhi) | 183 if (!rwhi) |
183 return; | 184 return; |
184 | 185 |
185 base::string16 text16 = ConvertJavaStringToUTF16(env, text_str); | 186 base::string16 text16 = ConvertJavaStringToUTF16(env, text_str); |
186 rwhi->ImeConfirmComposition(text16, gfx::Range::InvalidRange(), false); | 187 rwhi->ImeConfirmComposition(text16, gfx::Range::InvalidRange(), false, |
| 188 new_cursor_pos); |
187 } | 189 } |
188 | 190 |
189 void ImeAdapterAndroid::FinishComposingText(JNIEnv* env, | 191 void ImeAdapterAndroid::FinishComposingText(JNIEnv* env, |
190 const JavaParamRef<jobject>&) { | 192 const JavaParamRef<jobject>&) { |
191 RenderWidgetHostImpl* rwhi = GetRenderWidgetHostImpl(); | 193 RenderWidgetHostImpl* rwhi = GetRenderWidgetHostImpl(); |
192 if (!rwhi) | 194 if (!rwhi) |
193 return; | 195 return; |
194 | 196 |
195 rwhi->ImeConfirmComposition(base::string16(), gfx::Range::InvalidRange(), | 197 rwhi->ImeConfirmComposition(base::string16(), gfx::Range::InvalidRange(), |
196 true); | 198 true); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 } | 340 } |
339 | 341 |
340 WebContents* ImeAdapterAndroid::GetWebContents() { | 342 WebContents* ImeAdapterAndroid::GetWebContents() { |
341 RenderWidgetHostImpl* rwh = GetRenderWidgetHostImpl(); | 343 RenderWidgetHostImpl* rwh = GetRenderWidgetHostImpl(); |
342 if (!rwh) | 344 if (!rwh) |
343 return nullptr; | 345 return nullptr; |
344 return WebContents::FromRenderViewHost(RenderViewHost::From(rwh)); | 346 return WebContents::FromRenderViewHost(RenderViewHost::From(rwh)); |
345 } | 347 } |
346 | 348 |
347 } // namespace content | 349 } // namespace content |
OLD | NEW |