| 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/render_frame_host_impl.h" | 17 #include "content/browser/frame_host/render_frame_host_impl.h" |
| 18 #include "content/browser/renderer_host/render_view_host_delegate.h" | 18 #include "content/browser/renderer_host/render_view_host_delegate.h" |
| 19 #include "content/browser/renderer_host/render_widget_host_impl.h" | 19 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 20 #include "content/browser/renderer_host/render_widget_host_view_android.h" | 20 #include "content/browser/renderer_host/render_widget_host_view_android.h" |
| 21 #include "content/common/frame_messages.h" |
| 21 #include "content/common/input_messages.h" | 22 #include "content/common/input_messages.h" |
| 22 #include "content/common/view_messages.h" | 23 #include "content/common/view_messages.h" |
| 23 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
| 24 #include "content/public/browser/native_web_keyboard_event.h" | 25 #include "content/public/browser/native_web_keyboard_event.h" |
| 25 #include "content/public/browser/web_contents.h" | 26 #include "content/public/browser/web_contents.h" |
| 26 #include "jni/ImeAdapter_jni.h" | 27 #include "jni/ImeAdapter_jni.h" |
| 27 #include "third_party/WebKit/public/platform/WebInputEvent.h" | 28 #include "third_party/WebKit/public/platform/WebInputEvent.h" |
| 28 #include "third_party/WebKit/public/platform/WebTextInputType.h" | 29 #include "third_party/WebKit/public/platform/WebTextInputType.h" |
| 29 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" | 30 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" |
| 30 | 31 |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 } | 278 } |
| 278 | 279 |
| 279 void ImeAdapterAndroid::FocusedNodeChanged(bool is_editable_node) { | 280 void ImeAdapterAndroid::FocusedNodeChanged(bool is_editable_node) { |
| 280 JNIEnv* env = AttachCurrentThread(); | 281 JNIEnv* env = AttachCurrentThread(); |
| 281 ScopedJavaLocalRef<jobject> obj = java_ime_adapter_.get(env); | 282 ScopedJavaLocalRef<jobject> obj = java_ime_adapter_.get(env); |
| 282 if (!obj.is_null()) { | 283 if (!obj.is_null()) { |
| 283 Java_ImeAdapter_focusedNodeChanged(env, obj, is_editable_node); | 284 Java_ImeAdapter_focusedNodeChanged(env, obj, is_editable_node); |
| 284 } | 285 } |
| 285 } | 286 } |
| 286 | 287 |
| 288 void ImeAdapterAndroid::AdvanceFocusInForm(JNIEnv* env, |
| 289 const JavaParamRef<jobject>& obj, |
| 290 jint focus_type) { |
| 291 RenderFrameHost* rfh = GetFocusedFrame(); |
| 292 if (!rfh) |
| 293 return; |
| 294 |
| 295 rfh->Send(new FrameMsg_AdvanceFocusInForm( |
| 296 rfh->GetRoutingID(), static_cast<blink::WebFocusType>(focus_type))); |
| 297 } |
| 298 |
| 287 void ImeAdapterAndroid::SetEditableSelectionOffsets( | 299 void ImeAdapterAndroid::SetEditableSelectionOffsets( |
| 288 JNIEnv*, | 300 JNIEnv*, |
| 289 const JavaParamRef<jobject>&, | 301 const JavaParamRef<jobject>&, |
| 290 int start, | 302 int start, |
| 291 int end) { | 303 int end) { |
| 292 RenderFrameHost* rfh = GetFocusedFrame(); | 304 RenderFrameHost* rfh = GetFocusedFrame(); |
| 293 if (!rfh) | 305 if (!rfh) |
| 294 return; | 306 return; |
| 295 | 307 |
| 296 rfh->Send(new InputMsg_SetEditableSelectionOffsets(rfh->GetRoutingID(), start, | 308 rfh->Send(new InputMsg_SetEditableSelectionOffsets(rfh->GetRoutingID(), start, |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 Java_ImeAdapter_populateUnderlinesFromSpans( | 427 Java_ImeAdapter_populateUnderlinesFromSpans( |
| 416 env, obj, text, reinterpret_cast<jlong>(&underlines)); | 428 env, obj, text, reinterpret_cast<jlong>(&underlines)); |
| 417 | 429 |
| 418 // Sort spans by |.startOffset|. | 430 // Sort spans by |.startOffset|. |
| 419 std::sort(underlines.begin(), underlines.end()); | 431 std::sort(underlines.begin(), underlines.end()); |
| 420 | 432 |
| 421 return underlines; | 433 return underlines; |
| 422 } | 434 } |
| 423 | 435 |
| 424 } // namespace content | 436 } // namespace content |
| OLD | NEW |