Improve YouCompleteMe handling of Blink header without source files.
[chromium-blink-merge.git] / ui / events / gesture_event_details.cc
blob4026d06ecdb752476a501ca975bcd0f07feb82f4
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() : type_(ET_UNKNOWN) {}
11 GestureEventDetails::GestureEventDetails(ui::EventType type,
12 float delta_x,
13 float delta_y)
14 : type_(type),
15 touch_points_(1) {
16 DCHECK_GE(type, ET_GESTURE_TYPE_START);
17 DCHECK_LE(type, ET_GESTURE_TYPE_END);
18 switch (type_) {
19 case ui::ET_GESTURE_SCROLL_BEGIN:
20 data.scroll_begin.x_hint = delta_x;
21 data.scroll_begin.y_hint = delta_y;
22 break;
24 case ui::ET_GESTURE_SCROLL_UPDATE:
25 data.scroll_update.x = delta_x;
26 data.scroll_update.y = delta_y;
27 break;
29 case ui::ET_SCROLL_FLING_START:
30 data.fling_velocity.x = delta_x;
31 data.fling_velocity.y = delta_y;
32 break;
34 case ui::ET_GESTURE_TWO_FINGER_TAP:
35 data.first_finger_enclosing_rectangle.width = delta_x;
36 data.first_finger_enclosing_rectangle.height = delta_y;
37 break;
39 case ui::ET_GESTURE_PINCH_UPDATE:
40 data.scale = delta_x;
41 CHECK_EQ(0.f, delta_y) << "Unknown data in delta_y for pinch";
42 break;
44 case ui::ET_GESTURE_SWIPE:
45 data.swipe.left = delta_x < 0;
46 data.swipe.right = delta_x > 0;
47 data.swipe.up = delta_y < 0;
48 data.swipe.down = delta_y > 0;
49 break;
51 case ui::ET_GESTURE_TAP:
52 case ui::ET_GESTURE_DOUBLE_TAP:
53 case ui::ET_GESTURE_TAP_UNCONFIRMED:
54 data.tap_count = static_cast<int>(delta_x);
55 CHECK_EQ(0.f, delta_y) << "Unknown data in delta_y for tap.";
56 break;
58 default:
59 if (delta_x != 0.f || delta_y != 0.f) {
60 DLOG(WARNING) << "A gesture event (" << type << ") had unknown data: ("
61 << delta_x << "," << delta_y;
63 break;
67 GestureEventDetails::Details::Details() {
68 memset(this, 0, sizeof(Details));
71 } // namespace ui