OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef UI_EVENTS_BLINK_BLINK_EVENT_UTIL_H_ | 5 #ifndef UI_EVENTS_BLINK_BLINK_EVENT_UTIL_H_ |
6 #define UI_EVENTS_BLINK_BLINK_EVENT_UTIL_H_ | 6 #define UI_EVENTS_BLINK_BLINK_EVENT_UTIL_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "third_party/WebKit/public/platform/WebGestureEvent.h" | |
10 #include "third_party/WebKit/public/platform/WebInputEvent.h" | 11 #include "third_party/WebKit/public/platform/WebInputEvent.h" |
11 #include "ui/events/gesture_detection/motion_event.h" | 12 #include "ui/events/gesture_detection/motion_event.h" |
12 | 13 |
13 namespace blink { | 14 namespace blink { |
14 class WebGestureEvent; | |
15 class WebInputEvent; | |
16 class WebTouchEvent; | 15 class WebTouchEvent; |
17 } | 16 } |
18 | 17 |
19 namespace gfx { | 18 namespace gfx { |
20 class PointF; | 19 class PointF; |
21 class Vector2d; | 20 class Vector2d; |
22 } | 21 } |
23 | 22 |
24 namespace ui { | 23 namespace ui { |
25 enum class DomCode; | 24 enum class DomCode; |
26 struct GestureEventData; | 25 struct GestureEventData; |
27 struct GestureEventDetails; | 26 struct GestureEventDetails; |
28 class MotionEvent; | 27 class MotionEvent; |
29 | 28 |
30 bool CanCoalesce(const blink::WebInputEvent& event_to_coalesce, | 29 bool CanCoalesce(const blink::WebInputEvent& event_to_coalesce, |
31 const blink::WebInputEvent& event); | 30 const blink::WebInputEvent& event); |
32 | 31 |
33 void Coalesce(const blink::WebInputEvent& event_to_coalesce, | 32 void Coalesce(const blink::WebInputEvent& event_to_coalesce, |
34 blink::WebInputEvent* event); | 33 blink::WebInputEvent* event); |
35 | 34 |
35 bool IsCompatibleScrollorPinch(const blink::WebGestureEvent& new_event, | |
36 const blink::WebGestureEvent& event_in_queue); | |
37 | |
38 // Coalesces 3 GestureScroll/PinchUpdate into 2 events. | |
39 // Returns <GestureScrollUpdate, GesturePinchUpdate>. | |
40 std::pair<blink::WebGestureEvent, blink::WebGestureEvent> | |
41 CoalesceScrollAndPinch(const blink::WebGestureEvent* second_last_event, | |
42 const blink::WebGestureEvent& last_event, | |
43 const blink::WebGestureEvent& new_event); | |
44 | |
36 blink::WebTouchEvent CreateWebTouchEventFromMotionEvent( | 45 blink::WebTouchEvent CreateWebTouchEventFromMotionEvent( |
37 const MotionEvent& event, | 46 const MotionEvent& event, |
38 bool may_cause_scrolling); | 47 bool may_cause_scrolling); |
39 | 48 |
40 blink::WebGestureEvent CreateWebGestureEvent(const GestureEventDetails& details, | 49 blink::WebGestureEvent CreateWebGestureEvent(const GestureEventDetails& details, |
41 base::TimeTicks timestamp, | 50 base::TimeTicks timestamp, |
42 const gfx::PointF& location, | 51 const gfx::PointF& location, |
43 const gfx::PointF& raw_location, | 52 const gfx::PointF& raw_location, |
44 int flags, | 53 int flags, |
45 uint32_t unique_touch_event_id); | 54 uint32_t unique_touch_event_id); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
77 | 86 |
78 int WebEventModifiersToEventFlags(int modifiers); | 87 int WebEventModifiersToEventFlags(int modifiers); |
79 | 88 |
80 blink::WebInputEvent::Modifiers DomCodeToWebInputEventModifiers( | 89 blink::WebInputEvent::Modifiers DomCodeToWebInputEventModifiers( |
81 ui::DomCode code); | 90 ui::DomCode code); |
82 | 91 |
83 bool IsGestureScollOrPinch(blink::WebInputEvent::Type); | 92 bool IsGestureScollOrPinch(blink::WebInputEvent::Type); |
84 | 93 |
85 bool IsContinuousGestureEvent(blink::WebInputEvent::Type); | 94 bool IsContinuousGestureEvent(blink::WebInputEvent::Type); |
86 | 95 |
96 inline const blink::WebGestureEvent* ToWebGestureEvent( | |
tdresser
2016/12/13 17:18:19
The asymmetry of these methods is a bit tricky. Co
chongz
2016/12/13 18:55:45
Removed the pointer version.
However I'm not enti
| |
97 const blink::WebInputEvent* event) { | |
98 DCHECK(!event || IsGestureScollOrPinch(event->type)); | |
99 return static_cast<const blink::WebGestureEvent*>(event); | |
100 } | |
101 | |
102 inline const blink::WebGestureEvent& ToWebGestureEvent( | |
103 const blink::WebInputEvent& event) { | |
104 DCHECK(IsGestureScollOrPinch(event.type)); | |
105 return static_cast<const blink::WebGestureEvent&>(event); | |
106 } | |
107 | |
87 } // namespace ui | 108 } // namespace ui |
88 | 109 |
89 #endif // UI_EVENTS_BLINK_BLINK_EVENT_UTIL_H_ | 110 #endif // UI_EVENTS_BLINK_BLINK_EVENT_UTIL_H_ |
OLD | NEW |