| 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 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 | 63 |
| 64 bool RegisterImeAdapter(JNIEnv* env) { | 64 bool RegisterImeAdapter(JNIEnv* env) { |
| 65 return RegisterNativesImpl(env); | 65 return RegisterNativesImpl(env); |
| 66 } | 66 } |
| 67 | 67 |
| 68 jlong Init(JNIEnv* env, | 68 jlong Init(JNIEnv* env, |
| 69 const JavaParamRef<jobject>& obj, | 69 const JavaParamRef<jobject>& obj, |
| 70 const JavaParamRef<jobject>& jweb_contents) { | 70 const JavaParamRef<jobject>& jweb_contents) { |
| 71 WebContents* web_contents = WebContents::FromJavaWebContents(jweb_contents); | 71 WebContents* web_contents = WebContents::FromJavaWebContents(jweb_contents); |
| 72 DCHECK(web_contents); | 72 DCHECK(web_contents); |
| 73 return reinterpret_cast<intptr_t>( | 73 auto* ime_adapter = new ImeAdapterAndroid(env, obj, web_contents); |
| 74 new ImeAdapterAndroid(env, obj, web_contents)); | 74 ime_adapter->Initialize(); |
| 75 return reinterpret_cast<intptr_t>(ime_adapter); |
| 75 } | 76 } |
| 76 | 77 |
| 77 // Callback from Java to convert BackgroundColorSpan data to a | 78 // Callback from Java to convert BackgroundColorSpan data to a |
| 78 // blink::WebCompositionUnderline instance, and append it to |underlines_ptr|. | 79 // blink::WebCompositionUnderline instance, and append it to |underlines_ptr|. |
| 79 void AppendBackgroundColorSpan(JNIEnv*, | 80 void AppendBackgroundColorSpan(JNIEnv*, |
| 80 const JavaParamRef<jclass>&, | 81 const JavaParamRef<jclass>&, |
| 81 jlong underlines_ptr, | 82 jlong underlines_ptr, |
| 82 jint start, | 83 jint start, |
| 83 jint end, | 84 jint end, |
| 84 jint background_color) { | 85 jint background_color) { |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 Java_ImeAdapter_populateUnderlinesFromSpans( | 388 Java_ImeAdapter_populateUnderlinesFromSpans( |
| 388 env, obj, text, reinterpret_cast<jlong>(&underlines)); | 389 env, obj, text, reinterpret_cast<jlong>(&underlines)); |
| 389 | 390 |
| 390 // Sort spans by |.startOffset|. | 391 // Sort spans by |.startOffset|. |
| 391 std::sort(underlines.begin(), underlines.end()); | 392 std::sort(underlines.begin(), underlines.end()); |
| 392 | 393 |
| 393 return underlines; | 394 return underlines; |
| 394 } | 395 } |
| 395 | 396 |
| 396 } // namespace content | 397 } // namespace content |
| OLD | NEW |