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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 | 150 |
151 ScopedJavaLocalRef<jstring> jstring_text = | 151 ScopedJavaLocalRef<jstring> jstring_text = |
152 ConvertUTF8ToJavaString(env, state.value); | 152 ConvertUTF8ToJavaString(env, state.value); |
153 Java_ImeAdapter_updateState(env, obj, static_cast<int>(state.type), | 153 Java_ImeAdapter_updateState(env, obj, static_cast<int>(state.type), |
154 state.flags, state.mode, state.show_ime_if_needed, | 154 state.flags, state.mode, state.show_ime_if_needed, |
155 jstring_text, state.selection_start, | 155 jstring_text, state.selection_start, |
156 state.selection_end, state.composition_start, | 156 state.selection_end, state.composition_start, |
157 state.composition_end, state.reply_to_request); | 157 state.composition_end, state.reply_to_request); |
158 } | 158 } |
159 | 159 |
| 160 void ImeAdapterAndroid::UpdateFrameInfo( |
| 161 const gfx::SelectionBound& selection_start, |
| 162 float dip_scale, |
| 163 float content_offset_ypix) { |
| 164 JNIEnv* env = AttachCurrentThread(); |
| 165 ScopedJavaLocalRef<jobject> obj = java_ime_adapter_.get(env); |
| 166 if (obj.is_null()) |
| 167 return; |
| 168 |
| 169 // The CursorAnchorInfo API in Android only supports zero width selection |
| 170 // bounds. |
| 171 const jboolean has_insertion_marker = |
| 172 selection_start.type() == gfx::SelectionBound::CENTER; |
| 173 const jboolean is_insertion_marker_visible = selection_start.visible(); |
| 174 const jfloat insertion_marker_horizontal = |
| 175 has_insertion_marker ? selection_start.edge_top().x() : 0.0f; |
| 176 const jfloat insertion_marker_top = |
| 177 has_insertion_marker ? selection_start.edge_top().y() : 0.0f; |
| 178 const jfloat insertion_marker_bottom = |
| 179 has_insertion_marker ? selection_start.edge_bottom().y() : 0.0f; |
| 180 |
| 181 Java_ImeAdapter_updateFrameInfo( |
| 182 env, obj, dip_scale, content_offset_ypix, has_insertion_marker, |
| 183 is_insertion_marker_visible, insertion_marker_horizontal, |
| 184 insertion_marker_top, insertion_marker_bottom); |
| 185 } |
| 186 |
160 bool ImeAdapterAndroid::SendKeyEvent( | 187 bool ImeAdapterAndroid::SendKeyEvent( |
161 JNIEnv* env, | 188 JNIEnv* env, |
162 const JavaParamRef<jobject>&, | 189 const JavaParamRef<jobject>&, |
163 const JavaParamRef<jobject>& original_key_event, | 190 const JavaParamRef<jobject>& original_key_event, |
164 int type, | 191 int type, |
165 int modifiers, | 192 int modifiers, |
166 jlong time_ms, | 193 jlong time_ms, |
167 int key_code, | 194 int key_code, |
168 int scan_code, | 195 int scan_code, |
169 bool is_system_key, | 196 bool is_system_key, |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 Java_ImeAdapter_populateUnderlinesFromSpans( | 415 Java_ImeAdapter_populateUnderlinesFromSpans( |
389 env, obj, text, reinterpret_cast<jlong>(&underlines)); | 416 env, obj, text, reinterpret_cast<jlong>(&underlines)); |
390 | 417 |
391 // Sort spans by |.startOffset|. | 418 // Sort spans by |.startOffset|. |
392 std::sort(underlines.begin(), underlines.end()); | 419 std::sort(underlines.begin(), underlines.end()); |
393 | 420 |
394 return underlines; | 421 return underlines; |
395 } | 422 } |
396 | 423 |
397 } // namespace content | 424 } // namespace content |
OLD | NEW |