1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_EVENTS_BLINK_BLINK_EVENT_UTIL_H_
#define UI_EVENTS_BLINK_BLINK_EVENT_UTIL_H_
#include <memory>
#include "build/build_config.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "third_party/blink/public/common/input/web_gesture_event.h"
#include "third_party/blink/public/common/input/web_input_event.h"
#include "third_party/blink/public/common/input/web_touch_event.h"
#include "ui/events/event_constants.h"
#include "ui/events/gesture_detection/motion_event.h"
#include "ui/events/types/event_type.h"
#include "ui/events/types/scroll_input_type.h"
#include "ui/events/types/scroll_types.h"
namespace gfx {
class PointF;
class Vector2dF;
}
namespace ui {
enum class DomCode;
class GestureEventAndroid;
struct GestureEventData;
struct GestureEventDetails;
class MotionEvent;
blink::WebTouchEvent CreateWebTouchEventFromMotionEvent(
const MotionEvent& event,
bool may_cause_scrolling,
bool hovering);
blink::WebGestureEvent CreateWebGestureEvent(const GestureEventDetails& details,
base::TimeTicks timestamp,
const gfx::PointF& location,
const gfx::PointF& raw_location,
int flags,
uint32_t unique_touch_event_id);
// Convenience wrapper for |CreateWebGestureEvent| using the supplied |data|.
blink::WebGestureEvent CreateWebGestureEventFromGestureEventData(
const GestureEventData& data);
int EventFlagsToWebEventModifiers(int flags);
std::unique_ptr<blink::WebInputEvent> ScaleWebInputEvent(
const blink::WebInputEvent& event,
float scale);
// Transforms coordinates and other properties of |event|, by
// 1) translating / shifting by |delta| and
// 2) scaling by |scale|.
// If |event| does not need to change, returns nullptr.
// Otherwise, returns the transformed version of |event|.
std::unique_ptr<blink::WebInputEvent> TranslateAndScaleWebInputEvent(
const blink::WebInputEvent& event,
const gfx::Vector2dF& delta,
float scale);
blink::WebInputEvent::Type ToWebMouseEventType(MotionEvent::Action action);
void SetWebPointerPropertiesFromMotionEventData(
blink::WebPointerProperties& webPointerProperties,
int pointer_id,
float pressure,
float orientation_rad,
float tilt_x,
float tilt_y,
float twist,
float tangential_pressure,
int android_buttons_changed,
MotionEvent::ToolType tool_type);
int WebEventModifiersToEventFlags(int modifiers);
float IfNanUseMaxFloat(float value);
blink::WebInputEvent::Modifiers DomCodeToWebInputEventModifiers(
ui::DomCode code);
bool IsContinuousGestureEvent(blink::WebInputEvent::Type);
EventPointerType WebPointerTypeToEventPointerType(
blink::WebPointerProperties::PointerType type);
inline const blink::WebGestureEvent& ToWebGestureEvent(
const blink::WebInputEvent& event) {
DCHECK(blink::WebInputEvent::IsGestureEventType(event.GetType()));
return static_cast<const blink::WebGestureEvent&>(event);
}
blink::WebGestureEvent ScrollBeginFromScrollUpdate(
const blink::WebGestureEvent& scroll_update);
#if defined(OS_ANDROID)
// Convenience method that converts an instance to blink event.
std::unique_ptr<blink::WebGestureEvent>
CreateWebGestureEventFromGestureEventAndroid(const GestureEventAndroid& event);
#endif
} // namespace ui
#endif // UI_EVENTS_BLINK_BLINK_EVENT_UTIL_H_
|