blob: 40445caad923449ab7b69a772725c3d14e382f43 [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 Wei9c6f1242019-02-11 23:01:3049 void Cancel(int index = 0,
50 SyntheticPointerActionParams::Button button =
51 SyntheticPointerActionParams::Button::LEFT,
52 int key_modifiers = 0) override;
Lan Wei095958dc2019-01-30 18:11:1353 void Leave(int index = 0) override;
lanwei1060f1f2016-11-28 23:00:3154
55 bool UserInputCheck(
56 const SyntheticPointerActionParams& params) const override;
57
58 private:
Lan Weiae5352b92018-09-17 18:18:5959 using PointerIdIndexMap = std::map<int, int>;
lanwei3df2fbb2016-12-21 22:10:0260
Lan Weiae5352b92018-09-17 18:18:5961 void ResetPointerIdIndexMap();
Lan Wei09742f442018-07-31 17:45:4262 int GetIndexFromMap(int value) const;
63
lanwei1060f1f2016-11-28 23:00:3164 SyntheticWebTouchEvent touch_event_;
Lan Weiae5352b92018-09-17 18:18:5965 PointerIdIndexMap pointer_id_map_;
lanwei3df2fbb2016-12-21 22:10:0266
lanwei1060f1f2016-11-28 23:00:3167 DISALLOW_COPY_AND_ASSIGN(SyntheticTouchDriver);
68};
69
70} // namespace content
71
72#endif // CONTENT_COMMON_INPUT_SYNTHETIC_TOUCH_DRIVER_H_