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

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

Issue 1589953005: Support InputMethodManager#updateCursorAnchorInfo for Android 5.0 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed #36. Added ImeLollipopTest for IMMEDIATE case. Created 4 years, 9 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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 int start, 258 int start,
258 int end) { 259 int end) {
259 RenderFrameHost* rfh = GetFocusedFrame(); 260 RenderFrameHost* rfh = GetFocusedFrame();
260 if (!rfh) 261 if (!rfh)
261 return; 262 return;
262 263
263 rfh->Send(new FrameMsg_SetEditableSelectionOffsets(rfh->GetRoutingID(), 264 rfh->Send(new FrameMsg_SetEditableSelectionOffsets(rfh->GetRoutingID(),
264 start, end)); 265 start, end));
265 } 266 }
266 267
268 void ImeAdapterAndroid::SetCharacterBounds(
269 const std::vector<gfx::RectF>& character_bounds) {
270 JNIEnv* env = AttachCurrentThread();
271 base::android::ScopedJavaLocalRef<jobject> obj = java_ime_adapter_.get(env);
272 if (obj.is_null())
273 return;
274
275 const size_t coordinates_array_size = character_bounds.size() * 4;
276 scoped_ptr<float[]> coordinates_array(new float[coordinates_array_size]);
277 for (size_t i = 0; i < character_bounds.size(); ++i) {
278 const gfx::RectF& rect = character_bounds[i];
279 const size_t coordinates_array_index = i * 4;
280 coordinates_array[coordinates_array_index + 0] = rect.x();
281 coordinates_array[coordinates_array_index + 1] = rect.y();
282 coordinates_array[coordinates_array_index + 2] = rect.right();
283 coordinates_array[coordinates_array_index + 3] = rect.bottom();
284 }
285 Java_ImeAdapter_setCharacterBounds(
286 env,
287 obj.obj(),
288 base::android::ToJavaFloatArray(env,
289 coordinates_array.get(),
290 coordinates_array_size).obj());
291 }
292
267 void ImeAdapterAndroid::SetComposingRegion(JNIEnv*, 293 void ImeAdapterAndroid::SetComposingRegion(JNIEnv*,
268 const JavaParamRef<jobject>&, 294 const JavaParamRef<jobject>&,
269 int start, 295 int start,
270 int end) { 296 int end) {
271 RenderFrameHost* rfh = GetFocusedFrame(); 297 RenderFrameHost* rfh = GetFocusedFrame();
272 if (!rfh) 298 if (!rfh)
273 return; 299 return;
274 300
275 std::vector<blink::WebCompositionUnderline> underlines; 301 std::vector<blink::WebCompositionUnderline> underlines;
276 underlines.push_back(blink::WebCompositionUnderline( 302 underlines.push_back(blink::WebCompositionUnderline(
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 } 357 }
332 358
333 WebContents* ImeAdapterAndroid::GetWebContents() { 359 WebContents* ImeAdapterAndroid::GetWebContents() {
334 RenderWidgetHostImpl* rwh = GetRenderWidgetHostImpl(); 360 RenderWidgetHostImpl* rwh = GetRenderWidgetHostImpl();
335 if (!rwh) 361 if (!rwh)
336 return nullptr; 362 return nullptr;
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

Powered by Google App Engine
This is Rietveld 408576698