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

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

Issue 2755453004: Fix android key event timestamps (Closed)
Patch Set: event_time -> time_ms Created 3 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
« no previous file with comments | « content/browser/renderer_host/ime_adapter_android.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
(...skipping 28 matching lines...) Expand all
39 // |java_key_event| is used to maintain a globalref for KeyEvent. 39 // |java_key_event| is used to maintain a globalref for KeyEvent.
40 // |type| will determine the WebInputEvent type. 40 // |type| will determine the WebInputEvent type.
41 // type, |modifiers|, |time_ms|, |key_code|, |unicode_char| is used to create 41 // type, |modifiers|, |time_ms|, |key_code|, |unicode_char| is used to create
42 // WebKeyboardEvent. |key_code| is also needed ad need to treat the enter key 42 // WebKeyboardEvent. |key_code| is also needed ad need to treat the enter key
43 // as a key press of character \r. 43 // as a key press of character \r.
44 NativeWebKeyboardEvent NativeWebKeyboardEventFromKeyEvent( 44 NativeWebKeyboardEvent NativeWebKeyboardEventFromKeyEvent(
45 JNIEnv* env, 45 JNIEnv* env,
46 const base::android::JavaRef<jobject>& java_key_event, 46 const base::android::JavaRef<jobject>& java_key_event,
47 int type, 47 int type,
48 int modifiers, 48 int modifiers,
49 long time_ms, 49 jlong time_ms,
50 int key_code, 50 int key_code,
51 int scan_code, 51 int scan_code,
52 bool is_system_key, 52 bool is_system_key,
53 int unicode_char) { 53 int unicode_char) {
54 return NativeWebKeyboardEvent(env, java_key_event, 54 return NativeWebKeyboardEvent(env, java_key_event,
55 static_cast<blink::WebInputEvent::Type>(type), 55 static_cast<blink::WebInputEvent::Type>(type),
56 modifiers, time_ms / 1000.0, key_code, 56 modifiers, time_ms / 1000.0, key_code,
57 scan_code, unicode_char, is_system_key); 57 scan_code, unicode_char, is_system_key);
58 } 58 }
59 59
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 if (!obj.is_null()) 116 if (!obj.is_null())
117 Java_ImeAdapter_detach(env, obj); 117 Java_ImeAdapter_detach(env, obj);
118 } 118 }
119 119
120 bool ImeAdapterAndroid::SendKeyEvent( 120 bool ImeAdapterAndroid::SendKeyEvent(
121 JNIEnv* env, 121 JNIEnv* env,
122 const JavaParamRef<jobject>&, 122 const JavaParamRef<jobject>&,
123 const JavaParamRef<jobject>& original_key_event, 123 const JavaParamRef<jobject>& original_key_event,
124 int type, 124 int type,
125 int modifiers, 125 int modifiers,
126 long time_ms, 126 jlong time_ms,
127 int key_code, 127 int key_code,
128 int scan_code, 128 int scan_code,
129 bool is_system_key, 129 bool is_system_key,
130 int unicode_char) { 130 int unicode_char) {
131 NativeWebKeyboardEvent event = NativeWebKeyboardEventFromKeyEvent( 131 NativeWebKeyboardEvent event = NativeWebKeyboardEventFromKeyEvent(
132 env, original_key_event, type, modifiers, 132 env, original_key_event, type, modifiers, time_ms, key_code, scan_code,
133 time_ms / 1000.0, key_code, scan_code, is_system_key, unicode_char); 133 is_system_key, unicode_char);
134 rwhva_->SendKeyEvent(event); 134 rwhva_->SendKeyEvent(event);
135 return true; 135 return true;
136 } 136 }
137 137
138 void ImeAdapterAndroid::SetComposingText(JNIEnv* env, 138 void ImeAdapterAndroid::SetComposingText(JNIEnv* env,
139 const JavaParamRef<jobject>& obj, 139 const JavaParamRef<jobject>& obj,
140 const JavaParamRef<jobject>& text, 140 const JavaParamRef<jobject>& text,
141 const JavaParamRef<jstring>& text_str, 141 const JavaParamRef<jstring>& text_str,
142 int relative_cursor_pos) { 142 int relative_cursor_pos) {
143 RenderWidgetHostImpl* rwhi = GetFocusedWidget(); 143 RenderWidgetHostImpl* rwhi = GetFocusedWidget();
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 Java_ImeAdapter_populateUnderlinesFromSpans( 355 Java_ImeAdapter_populateUnderlinesFromSpans(
356 env, obj, text, reinterpret_cast<jlong>(&underlines)); 356 env, obj, text, reinterpret_cast<jlong>(&underlines));
357 357
358 // Sort spans by |.startOffset|. 358 // Sort spans by |.startOffset|.
359 std::sort(underlines.begin(), underlines.end()); 359 std::sort(underlines.begin(), underlines.end());
360 360
361 return underlines; 361 return underlines;
362 } 362 }
363 363
364 } // namespace content 364 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/ime_adapter_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698