Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/input/motion_event_android.h" | 5 #include "content/browser/renderer_host/input/motion_event_android.h" |
| 6 | 6 |
| 7 #include <android/input.h> | 7 #include <android/input.h> |
| 8 #include <cmath> | |
|
Mark Mentovai
2015/04/08 18:04:37
Leave a blank line between C system headers and C+
Mateusz Szymański
2015/04/09 07:32:51
Done.
| |
| 8 | 9 |
| 9 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
| 10 #include "base/float_util.h" | |
| 11 #include "jni/MotionEvent_jni.h" | 11 #include "jni/MotionEvent_jni.h" |
| 12 #include "ui/events/event_constants.h" | 12 #include "ui/events/event_constants.h" |
| 13 | 13 |
| 14 using base::android::AttachCurrentThread; | 14 using base::android::AttachCurrentThread; |
| 15 using namespace JNI_MotionEvent; | 15 using namespace JNI_MotionEvent; |
| 16 | 16 |
| 17 namespace content { | 17 namespace content { |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 MotionEventAndroid::Action FromAndroidAction(int android_action) { | 20 MotionEventAndroid::Action FromAndroidAction(int android_action) { |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 85 if ((meta_state & AMETA_CAPS_LOCK_ON) != 0) | 85 if ((meta_state & AMETA_CAPS_LOCK_ON) != 0) |
| 86 flags |= ui::EF_CAPS_LOCK_DOWN; | 86 flags |= ui::EF_CAPS_LOCK_DOWN; |
| 87 return flags; | 87 return flags; |
| 88 } | 88 } |
| 89 | 89 |
| 90 base::TimeTicks FromAndroidTime(int64 time_ms) { | 90 base::TimeTicks FromAndroidTime(int64 time_ms) { |
| 91 return base::TimeTicks() + base::TimeDelta::FromMilliseconds(time_ms); | 91 return base::TimeTicks() + base::TimeDelta::FromMilliseconds(time_ms); |
| 92 } | 92 } |
| 93 | 93 |
| 94 float ToValidFloat(float x) { | 94 float ToValidFloat(float x) { |
| 95 if (base::IsNaN(x)) | 95 if (std::isnan(x)) |
| 96 return 0.f; | 96 return 0.f; |
| 97 | 97 |
| 98 // Wildly large orientation values have been observed in the wild after device | 98 // Wildly large orientation values have been observed in the wild after device |
| 99 // rotation. There's not much we can do in that case other than simply | 99 // rotation. There's not much we can do in that case other than simply |
| 100 // sanitize results beyond an absurd and arbitrary threshold. | 100 // sanitize results beyond an absurd and arbitrary threshold. |
| 101 if (std::abs(x) > 1e5f) | 101 if (std::abs(x) > 1e5f) |
| 102 return 0.f; | 102 return 0.f; |
| 103 | 103 |
| 104 return x; | 104 return x; |
| 105 } | 105 } |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 332 result.tool_type = FromAndroidToolType(pointer.tool_type); | 332 result.tool_type = FromAndroidToolType(pointer.tool_type); |
| 333 return result; | 333 return result; |
| 334 } | 334 } |
| 335 | 335 |
| 336 // static | 336 // static |
| 337 bool MotionEventAndroid::RegisterMotionEventAndroid(JNIEnv* env) { | 337 bool MotionEventAndroid::RegisterMotionEventAndroid(JNIEnv* env) { |
| 338 return JNI_MotionEvent::RegisterNativesImpl(env); | 338 return JNI_MotionEvent::RegisterNativesImpl(env); |
| 339 } | 339 } |
| 340 | 340 |
| 341 } // namespace content | 341 } // namespace content |
| OLD | NEW |