blob: 71d49bf6e3bb58f9cce44bbae7f4818f09a9f7e4 [file] [log] [blame]
Avi Drissman4e1b7bc32022-09-15 14:03:501// Copyright 2015 The Chromium Authors
lanwei1060f1f2016-11-28 23:00:312// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_SYNTHETIC_TOUCH_DRIVER_H_
6#define CONTENT_BROWSER_RENDERER_HOST_INPUT_SYNTHETIC_TOUCH_DRIVER_H_
7
David Bertonie79d5222023-11-07 20:23:438#include <map>
9
10#include "base/memory/weak_ptr.h"
lanwei1060f1f2016-11-28 23:00:3111#include "content/browser/renderer_host/input/synthetic_pointer_driver.h"
Dave Tapuska6db16e32020-06-09 13:58:0612#include "third_party/blink/public/common/input/synthetic_web_input_event_builders.h"
lanwei1060f1f2016-11-28 23:00:3113
14namespace content {
15
David Bertonie79d5222023-11-07 20:23:4316class SyntheticTouchDriver final : public SyntheticPointerDriver {
lanwei1060f1f2016-11-28 23:00:3117 public:
18 SyntheticTouchDriver();
Dave Tapuska6db16e32020-06-09 13:58:0619 explicit SyntheticTouchDriver(blink::SyntheticWebTouchEvent touch_event);
Peter Boström828b9022021-09-21 02:28:4320
21 SyntheticTouchDriver(const SyntheticTouchDriver&) = delete;
22 SyntheticTouchDriver& operator=(const SyntheticTouchDriver&) = delete;
23
lanwei1060f1f2016-11-28 23:00:3124 ~SyntheticTouchDriver() override;
25
26 void DispatchEvent(SyntheticGestureTarget* target,
27 const base::TimeTicks& timestamp) override;
28
Lan Wei34e7e982019-02-11 21:18:1829 void Press(
30 float x,
31 float y,
32 int index,
33 SyntheticPointerActionParams::Button button =
34 SyntheticPointerActionParams::Button::LEFT,
35 int key_modifiers = 0,
36 float width = 40.f,
37 float height = 40.f,
38 float rotation_angle = 0.f,
Lan Wei34bf2c42021-04-14 17:42:5839 float force = 0.5,
40 float tangential_pressure = 0.f,
41 int tilt_x = 0,
42 int tilt_y = 0,
Lan Wei34e7e982019-02-11 21:18:1843 const base::TimeTicks& timestamp = base::TimeTicks::Now()) override;
Lan Wei3b538d72019-02-01 15:33:3144 void Move(float x,
45 float y,
46 int index,
47 int key_modifiers = 0,
48 float width = 40.f,
49 float height = 40.f,
50 float rotation_angle = 0.f,
Lan Wei34bf2c42021-04-14 17:42:5851 float force = 0.5,
52 float tangential_pressure = 0.f,
53 int tilt_x = 0,
Steve Kobes1fc813d2021-07-21 15:02:4154 int tilt_y = 0,
55 SyntheticPointerActionParams::Button button =
56 SyntheticPointerActionParams::Button::NO_BUTTON) override;
lanwei988a23452017-01-18 21:42:1457 void Release(int index,
58 SyntheticPointerActionParams::Button button =
Lan Wei53239962019-01-29 17:38:1359 SyntheticPointerActionParams::Button::LEFT,
60 int key_modifiers = 0) override;
Lan Wei9c6f1242019-02-11 23:01:3061 void Cancel(int index = 0,
62 SyntheticPointerActionParams::Button button =
63 SyntheticPointerActionParams::Button::LEFT,
64 int key_modifiers = 0) override;
Lan Wei095958dc2019-01-30 18:11:1365 void Leave(int index = 0) override;
lanwei1060f1f2016-11-28 23:00:3166
67 bool UserInputCheck(
68 const SyntheticPointerActionParams& params) const override;
69
David Bertonie79d5222023-11-07 20:23:4370 base::WeakPtr<SyntheticPointerDriver> AsWeakPtr() override;
71
lanwei1060f1f2016-11-28 23:00:3172 private:
Lan Weiae5352b92018-09-17 18:18:5973 using PointerIdIndexMap = std::map<int, int>;
lanwei3df2fbb2016-12-21 22:10:0274
Lan Weiae5352b92018-09-17 18:18:5975 void ResetPointerIdIndexMap();
Lan Wei09742f442018-07-31 17:45:4276 int GetIndexFromMap(int value) const;
77
Dave Tapuska6db16e32020-06-09 13:58:0678 blink::SyntheticWebTouchEvent touch_event_;
Lan Weiae5352b92018-09-17 18:18:5979 PointerIdIndexMap pointer_id_map_;
David Bertonie79d5222023-11-07 20:23:4380 base::WeakPtrFactory<SyntheticTouchDriver> weak_ptr_factory_{this};
lanwei1060f1f2016-11-28 23:00:3181};
82
83} // namespace content
84
Lei Zhang02a0ad72021-04-21 05:26:0885#endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_SYNTHETIC_TOUCH_DRIVER_H_