blob: fb28bc8e89eb07a3a132dcd2c58422c2fadecf6f [file] [log] [blame]
lanwei1060f1f2016-11-28 23:00:311// Copyright 2015 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.
4
5#ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_SYNTHETIC_TOUCH_DRIVER_H_
6#define CONTENT_BROWSER_RENDERER_HOST_INPUT_SYNTHETIC_TOUCH_DRIVER_H_
7
8#include <array>
9#include "base/macros.h"
10#include "content/browser/renderer_host/input/synthetic_pointer_driver.h"
11#include "content/common/content_export.h"
12#include "content/common/input/synthetic_web_input_event_builders.h"
13
14namespace content {
15
16class CONTENT_EXPORT SyntheticTouchDriver : public SyntheticPointerDriver {
17 public:
18 SyntheticTouchDriver();
19 explicit SyntheticTouchDriver(SyntheticWebTouchEvent touch_event);
20 ~SyntheticTouchDriver() override;
21
22 void DispatchEvent(SyntheticGestureTarget* target,
23 const base::TimeTicks& timestamp) override;
24
Lan Wei34e7e982019-02-11 21:18:1825 void Press(
26 float x,
27 float y,
28 int index,
29 SyntheticPointerActionParams::Button button =
30 SyntheticPointerActionParams::Button::LEFT,
31 int key_modifiers = 0,
32 float width = 40.f,
33 float height = 40.f,
34 float rotation_angle = 0.f,
35 float force = 1.f,
36 const base::TimeTicks& timestamp = base::TimeTicks::Now()) override;
Lan Wei3b538d72019-02-01 15:33:3137 void Move(float x,
38 float y,
39 int index,
40 int key_modifiers = 0,
41 float width = 40.f,
42 float height = 40.f,
43 float rotation_angle = 0.f,
44 float force = 1.f) override;
lanwei988a23452017-01-18 21:42:1445 void Release(int index,
46 SyntheticPointerActionParams::Button button =
Lan Wei53239962019-01-29 17:38:1347 SyntheticPointerActionParams::Button::LEFT,
48 int key_modifiers = 0) override;
Lan Wei095958dc2019-01-30 18:11:1349 void Cancel(int index = 0) override;
50 void Leave(int index = 0) override;
lanwei1060f1f2016-11-28 23:00:3151
52 bool UserInputCheck(
53 const SyntheticPointerActionParams& params) const override;
54
55 private:
Lan Weiae5352b92018-09-17 18:18:5956 using PointerIdIndexMap = std::map<int, int>;
lanwei3df2fbb2016-12-21 22:10:0257
Lan Weiae5352b92018-09-17 18:18:5958 void ResetPointerIdIndexMap();
Lan Wei09742f442018-07-31 17:45:4259 int GetIndexFromMap(int value) const;
60
lanwei1060f1f2016-11-28 23:00:3161 SyntheticWebTouchEvent touch_event_;
Lan Weiae5352b92018-09-17 18:18:5962 PointerIdIndexMap pointer_id_map_;
lanwei3df2fbb2016-12-21 22:10:0263
lanwei1060f1f2016-11-28 23:00:3164 DISALLOW_COPY_AND_ASSIGN(SyntheticTouchDriver);
65};
66
67} // namespace content
68
69#endif // CONTENT_COMMON_INPUT_SYNTHETIC_TOUCH_DRIVER_H_