blob: 86b9940b096a8b948d76e50f5e59ec2adaa4ce1f [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
lanwei988a23452017-01-18 21:42:1425 void Press(float x,
26 float y,
27 int index,
28 SyntheticPointerActionParams::Button button =
29 SyntheticPointerActionParams::Button::LEFT) override;
lanwei1060f1f2016-11-28 23:00:3130 void Move(float x, float y, int index) override;
lanwei988a23452017-01-18 21:42:1431 void Release(int index,
32 SyntheticPointerActionParams::Button button =
33 SyntheticPointerActionParams::Button::LEFT) override;
lanwei1060f1f2016-11-28 23:00:3134
35 bool UserInputCheck(
36 const SyntheticPointerActionParams& params) const override;
37
38 private:
lanwei3df2fbb2016-12-21 22:10:0239 using IndexMap = std::array<int, blink::WebTouchEvent::kTouchesLengthCap>;
40
Lan Wei09742f442018-07-31 17:45:4241 void ResetIndexMap();
42 int GetIndexFromMap(int value) const;
43
lanwei1060f1f2016-11-28 23:00:3144 SyntheticWebTouchEvent touch_event_;
lanwei3df2fbb2016-12-21 22:10:0245 IndexMap index_map_;
46
lanwei1060f1f2016-11-28 23:00:3147 DISALLOW_COPY_AND_ASSIGN(SyntheticTouchDriver);
48};
49
50} // namespace content
51
52#endif // CONTENT_COMMON_INPUT_SYNTHETIC_TOUCH_DRIVER_H_