| 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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 } | 196 } |
| 197 // Sort spans by |.startOffset|. | 197 // Sort spans by |.startOffset|. |
| 198 std::sort(underlines.begin(), underlines.end()); | 198 std::sort(underlines.begin(), underlines.end()); |
| 199 | 199 |
| 200 // new_cursor_position is as described in the Android API for | 200 // new_cursor_position is as described in the Android API for |
| 201 // InputConnection#setComposingText, whereas the parameters for | 201 // InputConnection#setComposingText, whereas the parameters for |
| 202 // ImeSetComposition are relative to the start of the composition. | 202 // ImeSetComposition are relative to the start of the composition. |
| 203 if (new_cursor_pos > 0) | 203 if (new_cursor_pos > 0) |
| 204 new_cursor_pos = text16.length() + new_cursor_pos - 1; | 204 new_cursor_pos = text16.length() + new_cursor_pos - 1; |
| 205 | 205 |
| 206 rwhi->ImeSetComposition(text16, underlines, new_cursor_pos, new_cursor_pos); | 206 rwhi->ImeSetComposition(text16, underlines, gfx::Range::InvalidRange(), |
| 207 new_cursor_pos, new_cursor_pos); |
| 207 } | 208 } |
| 208 | 209 |
| 209 void ImeAdapterAndroid::CommitText(JNIEnv* env, | 210 void ImeAdapterAndroid::CommitText(JNIEnv* env, |
| 210 const JavaParamRef<jobject>&, | 211 const JavaParamRef<jobject>&, |
| 211 const JavaParamRef<jstring>& text_str) { | 212 const JavaParamRef<jstring>& text_str) { |
| 212 RenderWidgetHostImpl* rwhi = GetRenderWidgetHostImpl(); | 213 RenderWidgetHostImpl* rwhi = GetRenderWidgetHostImpl(); |
| 213 if (!rwhi) | 214 if (!rwhi) |
| 214 return; | 215 return; |
| 215 | 216 |
| 216 base::string16 text16 = ConvertJavaStringToUTF16(env, text_str); | 217 base::string16 text16 = ConvertJavaStringToUTF16(env, text_str); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 } | 321 } |
| 321 | 322 |
| 322 WebContents* ImeAdapterAndroid::GetWebContents() { | 323 WebContents* ImeAdapterAndroid::GetWebContents() { |
| 323 RenderWidgetHostImpl* rwh = GetRenderWidgetHostImpl(); | 324 RenderWidgetHostImpl* rwh = GetRenderWidgetHostImpl(); |
| 324 if (!rwh) | 325 if (!rwh) |
| 325 return nullptr; | 326 return nullptr; |
| 326 return WebContents::FromRenderViewHost(RenderViewHost::From(rwh)); | 327 return WebContents::FromRenderViewHost(RenderViewHost::From(rwh)); |
| 327 } | 328 } |
| 328 | 329 |
| 329 } // namespace content | 330 } // namespace content |
| OLD | NEW |