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

Unified Diff: ui/events/event.cc

Issue 800163005: Fixed ui::TouchEvent rotation angle out-of-bound issue. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tweaked ui:TouchEvent angle range, added unittests. Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: ui/events/event.cc
diff --git a/ui/events/event.cc b/ui/events/event.cc
index 4c252d63639e476003615c17eeda5f79c6caed09..c29d053494ff7ae461cace792feb545aa320ef1e 100644
--- a/ui/events/event.cc
+++ b/ui/events/event.cc
@@ -535,6 +535,7 @@ TouchEvent::TouchEvent(const base::NativeEvent& native_event)
1);
latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
+ fixRotationAngle();
if (type() == ET_TOUCH_PRESSED)
IncrementTouchIdRefCount(native_event);
@@ -573,6 +574,7 @@ TouchEvent::TouchEvent(EventType type,
force_(force),
may_cause_scrolling_(false) {
latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
+ fixRotationAngle();
}
TouchEvent::~TouchEvent() {
@@ -601,6 +603,13 @@ void TouchEvent::DisableSynchronousHandling() {
static_cast<EventResult>(result() | ER_DISABLE_SYNC_HANDLING));
}
+void TouchEvent::fixRotationAngle() {
+ if (rotation_angle_ < 0)
tdresser 2015/01/20 16:40:38 Might be easier to just while (rotation_angle_ <
mustaq 2015/01/21 16:43:10 Done but I am not sure if the minor performance ga
mustaq 2015/01/21 16:54:30 Taking my objection back after simplifying the cod
+ rotation_angle_ = fmod(rotation_angle_, 180) + 180;
+ else if (rotation_angle_ >= 180)
+ rotation_angle_ = fmod(rotation_angle_, 180);
+}
+
////////////////////////////////////////////////////////////////////////////////
// KeyEvent
« no previous file with comments | « ui/events/event.h ('k') | ui/events/event_unittest.cc » ('j') | ui/events/event_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698