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

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

Issue 565583005: Clean up GestureEventDetails constructors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « ui/events/gesture_event_details.h ('k') | ui/events/test/event_generator.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() 9 GestureEventDetails::GestureEventDetails()
10 : type_(ET_UNKNOWN), touch_points_(0), oldest_touch_id_(-1) { 10 : type_(ET_UNKNOWN), touch_points_(0), oldest_touch_id_(-1) {
11 } 11 }
12 12
13 GestureEventDetails::GestureEventDetails(ui::EventType type)
14 : type_(type), touch_points_(1), oldest_touch_id_(0) {
15 DCHECK_GE(type, ET_GESTURE_TYPE_START);
16 DCHECK_LE(type, ET_GESTURE_TYPE_END);
tdresser 2014/09/12 12:35:27 I think it would be worth DCHECKING that this isn'
17 }
18
13 GestureEventDetails::GestureEventDetails(ui::EventType type, 19 GestureEventDetails::GestureEventDetails(ui::EventType type,
14 float delta_x, 20 float delta_x,
15 float delta_y) 21 float delta_y)
16 : type_(type), touch_points_(1), oldest_touch_id_(0) { 22 : type_(type), touch_points_(1), oldest_touch_id_(0) {
jdduke (slow) 2014/09/11 23:37:56 I wonder why oldest_touch_id_ is 0 here (and in th
tdresser 2014/09/12 12:35:27 Yeah, we should always initialize it to -1.
lanwei 2014/09/12 14:58:52 Done.
lanwei 2014/09/12 14:58:52 Done.
17 DCHECK_GE(type, ET_GESTURE_TYPE_START); 23 DCHECK_GE(type, ET_GESTURE_TYPE_START);
18 DCHECK_LE(type, ET_GESTURE_TYPE_END); 24 DCHECK_LE(type, ET_GESTURE_TYPE_END);
19 switch (type_) { 25 switch (type_) {
20 case ui::ET_GESTURE_SCROLL_BEGIN: 26 case ui::ET_GESTURE_SCROLL_BEGIN:
21 data.scroll_begin.x_hint = delta_x; 27 data.scroll_begin.x_hint = delta_x;
22 data.scroll_begin.y_hint = delta_y; 28 data.scroll_begin.y_hint = delta_y;
23 break; 29 break;
24 30
25 case ui::ET_GESTURE_SCROLL_UPDATE: 31 case ui::ET_GESTURE_SCROLL_UPDATE:
26 data.scroll_update.x = delta_x; 32 data.scroll_update.x = delta_x;
27 data.scroll_update.y = delta_y; 33 data.scroll_update.y = delta_y;
28 break; 34 break;
29 35
30 case ui::ET_SCROLL_FLING_START: 36 case ui::ET_SCROLL_FLING_START:
31 data.fling_velocity.x = delta_x; 37 data.fling_velocity.x = delta_x;
32 data.fling_velocity.y = delta_y; 38 data.fling_velocity.y = delta_y;
33 break; 39 break;
34 40
35 case ui::ET_GESTURE_TWO_FINGER_TAP: 41 case ui::ET_GESTURE_TWO_FINGER_TAP:
36 data.first_finger_enclosing_rectangle.width = delta_x; 42 data.first_finger_enclosing_rectangle.width = delta_x;
37 data.first_finger_enclosing_rectangle.height = delta_y; 43 data.first_finger_enclosing_rectangle.height = delta_y;
38 break; 44 break;
39 45
40 case ui::ET_GESTURE_PINCH_UPDATE:
41 data.scale = delta_x;
42 CHECK_EQ(0.f, delta_y) << "Unknown data in delta_y for pinch";
43 break;
44
45 case ui::ET_GESTURE_SWIPE: 46 case ui::ET_GESTURE_SWIPE:
46 data.swipe.left = delta_x < 0; 47 data.swipe.left = delta_x < 0;
47 data.swipe.right = delta_x > 0; 48 data.swipe.right = delta_x > 0;
48 data.swipe.up = delta_y < 0; 49 data.swipe.up = delta_y < 0;
49 data.swipe.down = delta_y > 0; 50 data.swipe.down = delta_y > 0;
50 break; 51 break;
51 52
52 case ui::ET_GESTURE_TAP:
53 case ui::ET_GESTURE_DOUBLE_TAP:
54 case ui::ET_GESTURE_TAP_UNCONFIRMED:
55 data.tap_count = static_cast<int>(delta_x);
56 CHECK_EQ(0.f, delta_y) << "Unknown data in delta_y for tap.";
57 break;
58
59 default: 53 default:
60 if (delta_x != 0.f || delta_y != 0.f) { 54 NOTREACHED();
61 DLOG(WARNING) << "A gesture event (" << type << ") had unknown data: ("
62 << delta_x << "," << delta_y;
63 }
64 break;
65 } 55 }
66 } 56 }
67 57
68 GestureEventDetails::Details::Details() { 58 GestureEventDetails::Details::Details() {
69 memset(this, 0, sizeof(Details)); 59 memset(this, 0, sizeof(Details));
70 } 60 }
71 61
72 } // namespace ui 62 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/gesture_event_details.h ('k') | ui/events/test/event_generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698