Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(241)

Side by Side Diff: content/browser/renderer_host/input/synthetic_mouse_driver.cc

Issue 2478423002: Rename SyntheticPointer to SyntheticPointerDriver (Closed)
Patch Set: Move valid user input in SyntheticPointerDriver Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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 #include "content/browser/renderer_host/input/synthetic_mouse_driver.h"
6
7 #include "content/browser/renderer_host/input/synthetic_gesture_target.h"
8
9 namespace content {
10
11 SyntheticMouseDriver::SyntheticMouseDriver() : mouse_index_(-1) {}
12
13 SyntheticMouseDriver::~SyntheticMouseDriver() {}
14
15 void SyntheticMouseDriver::DispatchEvent(SyntheticGestureTarget* target,
16 const base::TimeTicks& timestamp) {
17 mouse_event_.timeStampSeconds = ConvertTimestampToSeconds(timestamp);
18 target->DispatchInputEventToPlatform(mouse_event_);
19 }
20
21 void SyntheticMouseDriver::Press(float x, float y, int index) {
tdresser 2016/11/08 15:16:34 Can we just get rid of the index completely, and u
22 mouse_event_ = SyntheticWebMouseEventBuilder::Build(
23 blink::WebInputEvent::MouseDown, x, y, 0);
24 mouse_event_.clickCount = 1;
25 mouse_index_ = 0;
26 }
27
28 void SyntheticMouseDriver::Move(float x, float y, int index) {
29 blink::WebMouseEvent::Button button = mouse_event_.button;
30 int click_count = mouse_event_.clickCount;
31 mouse_event_ = SyntheticWebMouseEventBuilder::Build(
32 blink::WebInputEvent::MouseMove, x, y, 0);
33 mouse_event_.button = button;
34 mouse_event_.clickCount = click_count;
35 }
36
37 void SyntheticMouseDriver::Release(int index) {
38 mouse_event_ = SyntheticWebMouseEventBuilder::Build(
39 blink::WebInputEvent::MouseUp, mouse_event_.x, mouse_event_.y, 0);
40 mouse_event_.clickCount = 1;
41 mouse_index_ = -1;
42 }
43
44 bool SyntheticMouseDriver::UserInputCheck(
45 const SyntheticPointerActionParams& params) const {
46 if (params.index() != 0) {
47 return false;
48 }
49
50 if (params.gesture_source_type != SyntheticGestureParams::MOUSE_INPUT)
51 return false;
52
53 if (params.pointer_action_type() ==
54 SyntheticPointerActionParams::PointerActionType::PRESS &&
55 GetPointIndex(params.index()) >= 0) {
56 return false;
57 }
58
59 if (params.pointer_action_type() ==
60 SyntheticPointerActionParams::PointerActionType::RELEASE &&
61 GetPointIndex(params.index()) < 0) {
62 return false;
63 }
64
65 return true;
66 }
67
68 int SyntheticMouseDriver::GetPointIndex(int index) const {
69 return mouse_index_;
70 }
71
72 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698