Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / ui / events / gesture_event_details.cc
blob3f478e5aaabce15848e5b1fe6f733e689ad9e994
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
3 // found in the LICENSE file.
5 #include "ui/events/gesture_event_details.h"
7 namespace ui {
9 GestureEventDetails::GestureEventDetails()
10 : type_(ET_UNKNOWN), touch_points_(0), oldest_touch_id_(-1) {
13 GestureEventDetails::GestureEventDetails(ui::EventType type,
14 float delta_x,
15 float delta_y)
16 : type_(type), touch_points_(1), oldest_touch_id_(0) {
17 DCHECK_GE(type, ET_GESTURE_TYPE_START);
18 DCHECK_LE(type, ET_GESTURE_TYPE_END);
19 switch (type_) {
20 case ui::ET_GESTURE_SCROLL_BEGIN:
21 data.scroll_begin.x_hint = delta_x;
22 data.scroll_begin.y_hint = delta_y;
23 break;
25 case ui::ET_GESTURE_SCROLL_UPDATE:
26 data.scroll_update.x = delta_x;
27 data.scroll_update.y = delta_y;
28 break;
30 case ui::ET_SCROLL_FLING_START:
31 data.fling_velocity.x = delta_x;
32 data.fling_velocity.y = delta_y;
33 break;
35 case ui::ET_GESTURE_TWO_FINGER_TAP:
36 data.first_finger_enclosing_rectangle.width = delta_x;
37 data.first_finger_enclosing_rectangle.height = delta_y;
38 break;
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;
45 case ui::ET_GESTURE_SWIPE:
46 data.swipe.left = delta_x < 0;
47 data.swipe.right = delta_x > 0;
48 data.swipe.up = delta_y < 0;
49 data.swipe.down = delta_y > 0;
50 break;
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;
59 default:
60 if (delta_x != 0.f || delta_y != 0.f) {
61 DLOG(WARNING) << "A gesture event (" << type << ") had unknown data: ("
62 << delta_x << "," << delta_y;
64 break;
68 GestureEventDetails::Details::Details() {
69 memset(this, 0, sizeof(Details));
72 } // namespace ui