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

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

Issue 256593003: Also pass unclamped delta and velocity values to GestureEventDetails. (DEPRECATED) (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
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:
23 data.scroll_update.x = delta_x;
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;
28
29 case ui::ET_SCROLL_FLING_START:
sadrul 2014/04/25 12:13:14 Do NOTREACHED() for SCROLL_UPDATE and SCROLL_FLING
30 data.fling_velocity.x = delta_x;
31 data.fling_velocity.y = delta_y;
32 data.fling_velocity.x_ordinal = delta_x;
33 data.fling_velocity.y_ordinal = delta_y;
34 break;
35
36 case ui::ET_GESTURE_TWO_FINGER_TAP: 22 case ui::ET_GESTURE_TWO_FINGER_TAP:
37 data.first_finger_enclosing_rectangle.width = delta_x; 23 data.first_finger_enclosing_rectangle.width = delta_x;
38 data.first_finger_enclosing_rectangle.height = delta_y; 24 data.first_finger_enclosing_rectangle.height = delta_y;
39 break; 25 break;
40 26
41 case ui::ET_GESTURE_PINCH_UPDATE: 27 case ui::ET_GESTURE_PINCH_UPDATE:
42 data.scale = delta_x; 28 data.scale = delta_x;
43 CHECK_EQ(0.f, delta_y) << "Unknown data in delta_y for pinch"; 29 CHECK_EQ(0.f, delta_y) << "Unknown data in delta_y for pinch";
44 break; 30 break;
45 31
46 case ui::ET_GESTURE_MULTIFINGER_SWIPE: 32 case ui::ET_GESTURE_MULTIFINGER_SWIPE:
47 data.swipe.left = delta_x < 0; 33 data.swipe.left = delta_x < 0;
48 data.swipe.right = delta_x > 0; 34 data.swipe.right = delta_x > 0;
49 data.swipe.up = delta_y < 0; 35 data.swipe.up = delta_y < 0;
50 data.swipe.down = delta_y > 0; 36 data.swipe.down = delta_y > 0;
51 break; 37 break;
52 38
53 case ui::ET_GESTURE_TAP: 39 case ui::ET_GESTURE_TAP:
54 case ui::ET_GESTURE_DOUBLE_TAP: 40 case ui::ET_GESTURE_DOUBLE_TAP:
55 case ui::ET_GESTURE_TAP_UNCONFIRMED: 41 case ui::ET_GESTURE_TAP_UNCONFIRMED:
56 data.tap_count = static_cast<int>(delta_x); 42 data.tap_count = static_cast<int>(delta_x);
57 CHECK_EQ(0.f, delta_y) << "Unknown data in delta_y for tap."; 43 CHECK_EQ(0.f, delta_y) << "Unknown data in delta_y for tap.";
58 break; 44 break;
59 45
60 default: 46 default:
61 if (delta_x != 0.f || delta_y != 0.f) { 47 DCHECK(!delta_x && !delta_y) "A gesture event ("
62 DLOG(WARNING) << "A gesture event (" << type << ") had unknown data: (" 48 << type << ") had unknown data: (" << delta_x << "," << delta_y
63 << delta_x << "," << delta_y; 49 << ")";
64 }
65 break; 50 break;
66 } 51 }
67 } 52 }
68 53
69 GestureEventDetails::GestureEventDetails(ui::EventType type, 54 GestureEventDetails::GestureEventDetails(ui::EventType type,
70 float delta_x, 55 float delta_x,
71 float delta_y, 56 float delta_y,
72 float delta_x_ordinal, 57 float delta_x_ordinal,
73 float delta_y_ordinal) 58 float delta_y_ordinal)
74 : type_(type), 59 : type_(type),
75 touch_points_(1) { 60 touch_points_(1) {
76 CHECK(type == ui::ET_GESTURE_SCROLL_UPDATE || 61 CHECK(type == ui::ET_GESTURE_SCROLL_UPDATE ||
77 type == ui::ET_SCROLL_FLING_START); 62 type == ui::ET_SCROLL_FLING_START);
78 switch (type_) { 63 switch (type_) {
79 case ui::ET_GESTURE_SCROLL_UPDATE: 64 case ui::ET_GESTURE_SCROLL_UPDATE:
80 data.scroll_update.x = delta_x; 65 data.scroll_update.x = delta_x;
81 data.scroll_update.y = delta_y; 66 data.scroll_update.y = delta_y;
82 data.scroll_update.x_ordinal = delta_x_ordinal; 67 data.scroll_update.x_ordinal = delta_x_ordinal;
83 data.scroll_update.y_ordinal = delta_y_ordinal; 68 data.scroll_update.y_ordinal = delta_y_ordinal;
84 break; 69 break;
85 70
86 case ui::ET_SCROLL_FLING_START: 71 case ui::ET_SCROLL_FLING_START:
87 data.fling_velocity.x = delta_x; 72 data.fling_velocity.x = delta_x;
88 data.fling_velocity.y = delta_y; 73 data.fling_velocity.y = delta_y;
89 data.fling_velocity.x_ordinal = delta_x_ordinal; 74 data.fling_velocity.x_ordinal = delta_x_ordinal;
90 data.fling_velocity.y_ordinal = delta_y_ordinal; 75 data.fling_velocity.y_ordinal = delta_y_ordinal;
91 break; 76 break;
92 77
93 default: 78 default:
94 break; 79 break;
jdduke (slow) 2014/04/24 19:58:53 Should we move the CHECK above to the default case
95 } 80 }
96 } 81 }
97 82
98 GestureEventDetails::Details::Details() { 83 GestureEventDetails::Details::Details() {
99 memset(this, 0, sizeof(Details)); 84 memset(this, 0, sizeof(Details));
100 } 85 }
101 86
102 } // namespace ui 87 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698