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

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

Issue 699333003: Support InputMethodManager#updateCursorAnchorInfo for Android 5.0 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move the core logic into Java side Created 5 years, 10 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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 void ImeAdapterAndroid::FocusedNodeChanged(bool is_editable_node) { 230 void ImeAdapterAndroid::FocusedNodeChanged(bool is_editable_node) {
231 base::android::ScopedJavaLocalRef<jobject> obj = 231 base::android::ScopedJavaLocalRef<jobject> obj =
232 java_ime_adapter_.get(AttachCurrentThread()); 232 java_ime_adapter_.get(AttachCurrentThread());
233 if (!obj.is_null()) { 233 if (!obj.is_null()) {
234 Java_ImeAdapter_focusedNodeChanged(AttachCurrentThread(), 234 Java_ImeAdapter_focusedNodeChanged(AttachCurrentThread(),
235 obj.obj(), 235 obj.obj(),
236 is_editable_node); 236 is_editable_node);
237 } 237 }
238 } 238 }
239 239
240 void ImeAdapterAndroid::SetCharacterBounds(
241 const std::vector<gfx::Rect>& character_bounds) {
242 JNIEnv* env = AttachCurrentThread();
243 base::android::ScopedJavaLocalRef<jobject> obj = java_ime_adapter_.get(env);
244 if (obj.is_null())
245 return;
246
247 const size_t coordinates_array_size = character_bounds.size() * 4;
248 base::android::ScopedJavaLocalRef<jfloatArray> coordinates_dest_array(
249 env, env->NewFloatArray(coordinates_array_size));
250 if (coordinates_dest_array.is_null())
251 return;
252
253 scoped_ptr<jfloat[]> coordinates_array(new jfloat[coordinates_array_size]);
254 for (size_t i = 0; i < character_bounds.size(); ++i) {
255 const gfx::Rect& rect = character_bounds[i];
256 const size_t coordinates_array_index = i * 4;
257 coordinates_array[coordinates_array_index + 0] = rect.x();
258 coordinates_array[coordinates_array_index + 1] = rect.y();
259 coordinates_array[coordinates_array_index + 2] = rect.right();
260 coordinates_array[coordinates_array_index + 3] = rect.bottom();
261 }
262 // TODO(yukawa): Consider to move this to base/android/jni_array.h
263 env->SetFloatArrayRegion(coordinates_dest_array.obj(), 0,
jdduke (slow) 2015/02/09 17:01:17 Should we add a |ToJavaFloatArray| in base/android
yukawa 2015/02/10 17:24:54 Done.
264 coordinates_array_size, coordinates_array.get());
265 base::android::CheckException(env);
266 Java_ImeAdapter_setCharacterBounds(env, obj.obj(),
267 coordinates_dest_array.obj());
268 }
269
240 void ImeAdapterAndroid::SetEditableSelectionOffsets(JNIEnv*, jobject, 270 void ImeAdapterAndroid::SetEditableSelectionOffsets(JNIEnv*, jobject,
241 int start, int end) { 271 int start, int end) {
242 RenderFrameHost* rfh = GetFocusedFrame(); 272 RenderFrameHost* rfh = GetFocusedFrame();
243 if (!rfh) 273 if (!rfh)
244 return; 274 return;
245 275
246 rfh->Send(new FrameMsg_SetEditableSelectionOffsets(rfh->GetRoutingID(), 276 rfh->Send(new FrameMsg_SetEditableSelectionOffsets(rfh->GetRoutingID(),
247 start, end)); 277 start, end));
248 } 278 }
249 279
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 WebContents* ImeAdapterAndroid::GetWebContents() { 361 WebContents* ImeAdapterAndroid::GetWebContents() {
332 RenderWidgetHostImpl* rwh = GetRenderWidgetHostImpl(); 362 RenderWidgetHostImpl* rwh = GetRenderWidgetHostImpl();
333 if (!rwh) 363 if (!rwh)
334 return NULL; 364 return NULL;
335 if (!rwh->IsRenderView()) 365 if (!rwh->IsRenderView())
336 return NULL; 366 return NULL;
337 return WebContents::FromRenderViewHost(RenderViewHost::From(rwh)); 367 return WebContents::FromRenderViewHost(RenderViewHost::From(rwh));
338 } 368 }
339 369
340 } // namespace content 370 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698