lanwei | 1060f1f | 2016-11-28 23:00:31 | [diff] [blame] | 1 | // 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 | |
| 14 | namespace content { |
| 15 | |
| 16 | class 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 Wei | 34e7e98 | 2019-02-11 21:18:18 | [diff] [blame] | 25 | 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 Wei | 3b538d7 | 2019-02-01 15:33:31 | [diff] [blame] | 37 | 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; |
lanwei | 988a2345 | 2017-01-18 21:42:14 | [diff] [blame] | 45 | void Release(int index, |
| 46 | SyntheticPointerActionParams::Button button = |
Lan Wei | 5323996 | 2019-01-29 17:38:13 | [diff] [blame] | 47 | SyntheticPointerActionParams::Button::LEFT, |
| 48 | int key_modifiers = 0) override; |
Lan Wei | 9c6f124 | 2019-02-11 23:01:30 | [diff] [blame^] | 49 | void Cancel(int index = 0, |
| 50 | SyntheticPointerActionParams::Button button = |
| 51 | SyntheticPointerActionParams::Button::LEFT, |
| 52 | int key_modifiers = 0) override; |
Lan Wei | 095958dc | 2019-01-30 18:11:13 | [diff] [blame] | 53 | void Leave(int index = 0) override; |
lanwei | 1060f1f | 2016-11-28 23:00:31 | [diff] [blame] | 54 | |
| 55 | bool UserInputCheck( |
| 56 | const SyntheticPointerActionParams& params) const override; |
| 57 | |
| 58 | private: |
Lan Wei | ae5352b9 | 2018-09-17 18:18:59 | [diff] [blame] | 59 | using PointerIdIndexMap = std::map<int, int>; |
lanwei | 3df2fbb | 2016-12-21 22:10:02 | [diff] [blame] | 60 | |
Lan Wei | ae5352b9 | 2018-09-17 18:18:59 | [diff] [blame] | 61 | void ResetPointerIdIndexMap(); |
Lan Wei | 09742f44 | 2018-07-31 17:45:42 | [diff] [blame] | 62 | int GetIndexFromMap(int value) const; |
| 63 | |
lanwei | 1060f1f | 2016-11-28 23:00:31 | [diff] [blame] | 64 | SyntheticWebTouchEvent touch_event_; |
Lan Wei | ae5352b9 | 2018-09-17 18:18:59 | [diff] [blame] | 65 | PointerIdIndexMap pointer_id_map_; |
lanwei | 3df2fbb | 2016-12-21 22:10:02 | [diff] [blame] | 66 | |
lanwei | 1060f1f | 2016-11-28 23:00:31 | [diff] [blame] | 67 | DISALLOW_COPY_AND_ASSIGN(SyntheticTouchDriver); |
| 68 | }; |
| 69 | |
| 70 | } // namespace content |
| 71 | |
| 72 | #endif // CONTENT_COMMON_INPUT_SYNTHETIC_TOUCH_DRIVER_H_ |