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

Side by Side Diff: ui/events/gesture_event_details.cc

Issue 258803002: Remove unclamped delta and velocity values from GestureEventDetails. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « ui/events/gesture_event_details.h ('k') | ui/events/gestures/gesture_sequence.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "ui/events/gesture_event_details.h" 5 #include "ui/events/gesture_event_details.h"
6 6
7 namespace ui { 7 namespace ui {
8 8
9 GestureEventDetails::GestureEventDetails() : type_(ET_UNKNOWN) {} 9 GestureEventDetails::GestureEventDetails() : type_(ET_UNKNOWN) {}
10 10
11 GestureEventDetails::GestureEventDetails(ui::EventType type, 11 GestureEventDetails::GestureEventDetails(ui::EventType type,
12 float delta_x, 12 float delta_x,
13 float delta_y) 13 float delta_y)
14 : type_(type), 14 : type_(type),
15 touch_points_(1) { 15 touch_points_(1) {
16 switch (type_) { 16 switch (type_) {
17 case ui::ET_GESTURE_SCROLL_BEGIN: 17 case ui::ET_GESTURE_SCROLL_BEGIN:
18 data.scroll_begin.x_hint = delta_x; 18 data.scroll_begin.x_hint = delta_x;
19 data.scroll_begin.y_hint = delta_y; 19 data.scroll_begin.y_hint = delta_y;
20 break; 20 break;
21 21
22 case ui::ET_GESTURE_SCROLL_UPDATE: 22 case ui::ET_GESTURE_SCROLL_UPDATE:
23 data.scroll_update.x = delta_x; 23 data.scroll_update.x = delta_x;
24 data.scroll_update.y = delta_y; 24 data.scroll_update.y = delta_y;
25 data.scroll_update.x_ordinal = delta_x;
26 data.scroll_update.y_ordinal = delta_y;
27 break; 25 break;
28 26
29 case ui::ET_SCROLL_FLING_START: 27 case ui::ET_SCROLL_FLING_START:
30 data.fling_velocity.x = delta_x; 28 data.fling_velocity.x = delta_x;
31 data.fling_velocity.y = delta_y; 29 data.fling_velocity.y = delta_y;
32 data.fling_velocity.x_ordinal = delta_x;
33 data.fling_velocity.y_ordinal = delta_y;
34 break; 30 break;
35 31
36 case ui::ET_GESTURE_TWO_FINGER_TAP: 32 case ui::ET_GESTURE_TWO_FINGER_TAP:
37 data.first_finger_enclosing_rectangle.width = delta_x; 33 data.first_finger_enclosing_rectangle.width = delta_x;
38 data.first_finger_enclosing_rectangle.height = delta_y; 34 data.first_finger_enclosing_rectangle.height = delta_y;
39 break; 35 break;
40 36
41 case ui::ET_GESTURE_PINCH_UPDATE: 37 case ui::ET_GESTURE_PINCH_UPDATE:
42 data.scale = delta_x; 38 data.scale = delta_x;
43 CHECK_EQ(0.f, delta_y) << "Unknown data in delta_y for pinch"; 39 CHECK_EQ(0.f, delta_y) << "Unknown data in delta_y for pinch";
(...skipping 15 matching lines...) Expand all
59 55
60 default: 56 default:
61 if (delta_x != 0.f || delta_y != 0.f) { 57 if (delta_x != 0.f || delta_y != 0.f) {
62 DLOG(WARNING) << "A gesture event (" << type << ") had unknown data: (" 58 DLOG(WARNING) << "A gesture event (" << type << ") had unknown data: ("
63 << delta_x << "," << delta_y; 59 << delta_x << "," << delta_y;
64 } 60 }
65 break; 61 break;
66 } 62 }
67 } 63 }
68 64
69 GestureEventDetails::GestureEventDetails(ui::EventType type,
70 float delta_x,
71 float delta_y,
72 float delta_x_ordinal,
73 float delta_y_ordinal)
74 : type_(type),
75 touch_points_(1) {
76 CHECK(type == ui::ET_GESTURE_SCROLL_UPDATE ||
77 type == ui::ET_SCROLL_FLING_START);
78 switch (type_) {
79 case ui::ET_GESTURE_SCROLL_UPDATE:
80 data.scroll_update.x = delta_x;
81 data.scroll_update.y = delta_y;
82 data.scroll_update.x_ordinal = delta_x_ordinal;
83 data.scroll_update.y_ordinal = delta_y_ordinal;
84 break;
85
86 case ui::ET_SCROLL_FLING_START:
87 data.fling_velocity.x = delta_x;
88 data.fling_velocity.y = delta_y;
89 data.fling_velocity.x_ordinal = delta_x_ordinal;
90 data.fling_velocity.y_ordinal = delta_y_ordinal;
91 break;
92
93 default:
94 break;
95 }
96 }
97
98 GestureEventDetails::Details::Details() { 65 GestureEventDetails::Details::Details() {
99 memset(this, 0, sizeof(Details)); 66 memset(this, 0, sizeof(Details));
100 } 67 }
101 68
102 } // namespace ui 69 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/gesture_event_details.h ('k') | ui/events/gestures/gesture_sequence.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698