Commit 6bda2b55 authored by tsniatowski's avatar tsniatowski Committed by Commit bot

Fix android key event timestamps

Pass a Java long to C++ as a jlong type, not a C++ long which can have a
different size to avoid broken / negative event timestamp values.
ImeAdapter's Java side uses "long" in SendKeyEvent, so the C++ side must
use a jlong or int64_t, and not a C++ long. Otherwise things don't work
well when system uptime is over 2^31ms (~25 days).

Additionally, do not do an extra divide-by-1000 when the used helper
function will do the milliseconds to seconds conversion already, so the
timestamps are correctly measured in milliseconds.

The resulting keyboard event timestamps end up nicely sane and positive,
and no longer clamped to 0 in PerformanceBase.cpp.

BUG=701726
R=aelias@chromium.org

Review-Url: https://codereview.chromium.org/2755453004
Cr-Commit-Position: refs/heads/master@{#457369}
parent da5f02c7
...@@ -46,7 +46,7 @@ NativeWebKeyboardEvent NativeWebKeyboardEventFromKeyEvent( ...@@ -46,7 +46,7 @@ NativeWebKeyboardEvent NativeWebKeyboardEventFromKeyEvent(
const base::android::JavaRef<jobject>& java_key_event, const base::android::JavaRef<jobject>& java_key_event,
int type, int type,
int modifiers, int modifiers,
long time_ms, jlong time_ms,
int key_code, int key_code,
int scan_code, int scan_code,
bool is_system_key, bool is_system_key,
...@@ -123,14 +123,14 @@ bool ImeAdapterAndroid::SendKeyEvent( ...@@ -123,14 +123,14 @@ bool ImeAdapterAndroid::SendKeyEvent(
const JavaParamRef<jobject>& original_key_event, const JavaParamRef<jobject>& original_key_event,
int type, int type,
int modifiers, int modifiers,
long time_ms, jlong time_ms,
int key_code, int key_code,
int scan_code, int scan_code,
bool is_system_key, bool is_system_key,
int unicode_char) { int unicode_char) {
NativeWebKeyboardEvent event = NativeWebKeyboardEventFromKeyEvent( NativeWebKeyboardEvent event = NativeWebKeyboardEventFromKeyEvent(
env, original_key_event, type, modifiers, env, original_key_event, type, modifiers, time_ms, key_code, scan_code,
time_ms / 1000.0, key_code, scan_code, is_system_key, unicode_char); is_system_key, unicode_char);
rwhva_->SendKeyEvent(event); rwhva_->SendKeyEvent(event);
return true; return true;
} }
......
...@@ -43,7 +43,7 @@ class CONTENT_EXPORT ImeAdapterAndroid { ...@@ -43,7 +43,7 @@ class CONTENT_EXPORT ImeAdapterAndroid {
const base::android::JavaParamRef<jobject>& original_key_event, const base::android::JavaParamRef<jobject>& original_key_event,
int type, int type,
int modifiers, int modifiers,
long event_time, jlong time_ms,
int key_code, int key_code,
int scan_code, int scan_code,
bool is_system_key, bool is_system_key,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment