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

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: Rebase before splitting this CL. Created 5 years, 8 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
11 #include "base/android/jni_android.h" 11 #include "base/android/jni_android.h"
12 #include "base/android/jni_array.h"
12 #include "base/android/jni_string.h" 13 #include "base/android/jni_string.h"
13 #include "base/android/scoped_java_ref.h" 14 #include "base/android/scoped_java_ref.h"
14 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
15 #include "base/time/time.h" 16 #include "base/time/time.h"
16 #include "content/browser/frame_host/frame_tree.h" 17 #include "content/browser/frame_host/frame_tree.h"
17 #include "content/browser/frame_host/frame_tree_node.h" 18 #include "content/browser/frame_host/frame_tree_node.h"
18 #include "content/browser/frame_host/render_frame_host_impl.h" 19 #include "content/browser/frame_host/render_frame_host_impl.h"
19 #include "content/browser/renderer_host/render_view_host_delegate.h" 20 #include "content/browser/renderer_host/render_view_host_delegate.h"
20 #include "content/browser/renderer_host/render_view_host_impl.h" 21 #include "content/browser/renderer_host/render_view_host_impl.h"
21 #include "content/browser/renderer_host/render_widget_host_impl.h" 22 #include "content/browser/renderer_host/render_widget_host_impl.h"
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 void ImeAdapterAndroid::FocusedNodeChanged(bool is_editable_node) { 231 void ImeAdapterAndroid::FocusedNodeChanged(bool is_editable_node) {
231 base::android::ScopedJavaLocalRef<jobject> obj = 232 base::android::ScopedJavaLocalRef<jobject> obj =
232 java_ime_adapter_.get(AttachCurrentThread()); 233 java_ime_adapter_.get(AttachCurrentThread());
233 if (!obj.is_null()) { 234 if (!obj.is_null()) {
234 Java_ImeAdapter_focusedNodeChanged(AttachCurrentThread(), 235 Java_ImeAdapter_focusedNodeChanged(AttachCurrentThread(),
235 obj.obj(), 236 obj.obj(),
236 is_editable_node); 237 is_editable_node);
237 } 238 }
238 } 239 }
239 240
241 void ImeAdapterAndroid::SetCharacterBounds(
242 const std::vector<gfx::Rect>& character_bounds) {
243 JNIEnv* env = AttachCurrentThread();
244 base::android::ScopedJavaLocalRef<jobject> obj = java_ime_adapter_.get(env);
245 if (obj.is_null())
246 return;
247
248 const size_t coordinates_array_size = character_bounds.size() * 4;
249 scoped_ptr<float[]> coordinates_array(new float[coordinates_array_size]);
250 for (size_t i = 0; i < character_bounds.size(); ++i) {
251 const gfx::Rect& rect = character_bounds[i];
252 const size_t coordinates_array_index = i * 4;
253 coordinates_array[coordinates_array_index + 0] = rect.x();
254 coordinates_array[coordinates_array_index + 1] = rect.y();
255 coordinates_array[coordinates_array_index + 2] = rect.right();
256 coordinates_array[coordinates_array_index + 3] = rect.bottom();
257 }
258 Java_ImeAdapter_setCharacterBounds(
259 env,
260 obj.obj(),
261 base::android::ToJavaFloatArray(env,
262 coordinates_array.get(),
263 coordinates_array_size).obj());
264 }
265
240 void ImeAdapterAndroid::SetEditableSelectionOffsets(JNIEnv*, jobject, 266 void ImeAdapterAndroid::SetEditableSelectionOffsets(JNIEnv*, jobject,
241 int start, int end) { 267 int start, int end) {
242 RenderFrameHost* rfh = GetFocusedFrame(); 268 RenderFrameHost* rfh = GetFocusedFrame();
243 if (!rfh) 269 if (!rfh)
244 return; 270 return;
245 271
246 rfh->Send(new FrameMsg_SetEditableSelectionOffsets(rfh->GetRoutingID(), 272 rfh->Send(new FrameMsg_SetEditableSelectionOffsets(rfh->GetRoutingID(),
247 start, end)); 273 start, end));
248 } 274 }
249 275
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 WebContents* ImeAdapterAndroid::GetWebContents() { 357 WebContents* ImeAdapterAndroid::GetWebContents() {
332 RenderWidgetHostImpl* rwh = GetRenderWidgetHostImpl(); 358 RenderWidgetHostImpl* rwh = GetRenderWidgetHostImpl();
333 if (!rwh) 359 if (!rwh)
334 return NULL; 360 return NULL;
335 if (!rwh->IsRenderView()) 361 if (!rwh->IsRenderView())
336 return NULL; 362 return NULL;
337 return WebContents::FromRenderViewHost(RenderViewHost::From(rwh)); 363 return WebContents::FromRenderViewHost(RenderViewHost::From(rwh));
338 } 364 }
339 365
340 } // namespace content 366 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/ime_adapter_android.h ('k') | content/browser/renderer_host/render_process_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698