OLD | NEW |
---|---|
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/android/ime_adapter_android.h" | 5 #include "content/browser/android/ime_adapter_android.h" |
6 | 6 |
7 #include <android/input.h> | 7 #include <android/input.h> |
8 #include <algorithm> | 8 #include <algorithm> |
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_array.h" |
13 #include "base/android/jni_string.h" | 13 #include "base/android/jni_string.h" |
14 #include "base/android/scoped_java_ref.h" | 14 #include "base/android/scoped_java_ref.h" |
15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
17 #include "content/browser/frame_host/interstitial_page_impl.h" | 17 #include "content/browser/frame_host/interstitial_page_impl.h" |
18 #include "content/browser/frame_host/render_frame_host_impl.h" | 18 #include "content/browser/frame_host/render_frame_host_impl.h" |
19 #include "content/browser/renderer_host/render_view_host_delegate.h" | 19 #include "content/browser/renderer_host/render_view_host_delegate.h" |
20 #include "content/browser/renderer_host/render_widget_host_impl.h" | 20 #include "content/browser/renderer_host/render_widget_host_impl.h" |
21 #include "content/browser/renderer_host/render_widget_host_view_android.h" | 21 #include "content/browser/renderer_host/render_widget_host_view_android.h" |
22 #include "content/browser/web_contents/web_contents_impl.h" | 22 #include "content/browser/web_contents/web_contents_impl.h" |
23 #include "content/common/frame_messages.h" | |
23 #include "content/common/input_messages.h" | 24 #include "content/common/input_messages.h" |
24 #include "content/common/view_messages.h" | 25 #include "content/common/view_messages.h" |
25 #include "content/public/browser/browser_thread.h" | 26 #include "content/public/browser/browser_thread.h" |
26 #include "content/public/browser/native_web_keyboard_event.h" | 27 #include "content/public/browser/native_web_keyboard_event.h" |
27 #include "content/public/browser/web_contents.h" | 28 #include "content/public/browser/web_contents.h" |
28 #include "jni/ImeAdapter_jni.h" | 29 #include "jni/ImeAdapter_jni.h" |
29 #include "third_party/WebKit/public/platform/WebInputEvent.h" | 30 #include "third_party/WebKit/public/platform/WebInputEvent.h" |
30 #include "third_party/WebKit/public/platform/WebTextInputType.h" | 31 #include "third_party/WebKit/public/platform/WebTextInputType.h" |
31 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" | 32 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" |
32 | 33 |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
296 } | 297 } |
297 | 298 |
298 void ImeAdapterAndroid::FocusedNodeChanged(bool is_editable_node) { | 299 void ImeAdapterAndroid::FocusedNodeChanged(bool is_editable_node) { |
299 JNIEnv* env = AttachCurrentThread(); | 300 JNIEnv* env = AttachCurrentThread(); |
300 ScopedJavaLocalRef<jobject> obj = java_ime_adapter_.get(env); | 301 ScopedJavaLocalRef<jobject> obj = java_ime_adapter_.get(env); |
301 if (!obj.is_null()) { | 302 if (!obj.is_null()) { |
302 Java_ImeAdapter_focusedNodeChanged(env, obj, is_editable_node); | 303 Java_ImeAdapter_focusedNodeChanged(env, obj, is_editable_node); |
303 } | 304 } |
304 } | 305 } |
305 | 306 |
307 void ImeAdapterAndroid::AdvanceFocusInForm(JNIEnv* env, | |
308 const JavaParamRef<jobject>& obj, | |
309 jboolean forward) { | |
310 RenderFrameHost* rfh = GetFocusedFrame(); | |
311 if (!rfh) | |
312 return; | |
313 | |
314 rfh->Send(new FrameMsg_AdvanceFocusInForm(rfh->GetRoutingID(), forward)); | |
EhsanK
2017/04/25 22:43:08
Is it important if this message arrives out of ord
AKVT
2017/04/26 10:33:04
If that's a problematic situation, could you help
EhsanK
2017/04/26 21:31:59
I suggest making the IPC an InputMsg instead. I am
AKVT
2017/04/27 15:07:02
Thank you for your suggestion. I will wait for res
| |
315 } | |
316 | |
306 void ImeAdapterAndroid::SetEditableSelectionOffsets( | 317 void ImeAdapterAndroid::SetEditableSelectionOffsets( |
307 JNIEnv*, | 318 JNIEnv*, |
308 const JavaParamRef<jobject>&, | 319 const JavaParamRef<jobject>&, |
309 int start, | 320 int start, |
310 int end) { | 321 int end) { |
311 RenderFrameHost* rfh = GetFocusedFrame(); | 322 RenderFrameHost* rfh = GetFocusedFrame(); |
312 if (!rfh) | 323 if (!rfh) |
313 return; | 324 return; |
314 | 325 |
315 rfh->Send(new InputMsg_SetEditableSelectionOffsets(rfh->GetRoutingID(), start, | 326 rfh->Send(new InputMsg_SetEditableSelectionOffsets(rfh->GetRoutingID(), start, |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
434 Java_ImeAdapter_populateUnderlinesFromSpans( | 445 Java_ImeAdapter_populateUnderlinesFromSpans( |
435 env, obj, text, reinterpret_cast<jlong>(&underlines)); | 446 env, obj, text, reinterpret_cast<jlong>(&underlines)); |
436 | 447 |
437 // Sort spans by |.startOffset|. | 448 // Sort spans by |.startOffset|. |
438 std::sort(underlines.begin(), underlines.end()); | 449 std::sort(underlines.begin(), underlines.end()); |
439 | 450 |
440 return underlines; | 451 return underlines; |
441 } | 452 } |
442 | 453 |
443 } // namespace content | 454 } // namespace content |
OLD | NEW |