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

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

Issue 2336803003: Make SyntheticPointerAction to flush the pointer action sequence (Closed)
Patch Set: return invaid when index is out bound Created 4 years 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/renderer_host/input/synthetic_mouse_driver.h" 5 #include "content/browser/renderer_host/input/synthetic_mouse_driver.h"
6 6
7 #include "content/browser/renderer_host/input/synthetic_gesture_target.h" 7 #include "content/browser/renderer_host/input/synthetic_gesture_target.h"
8 8
9 namespace content { 9 namespace content {
10 10
11 SyntheticMouseDriver::SyntheticMouseDriver() {} 11 SyntheticMouseDriver::SyntheticMouseDriver() {}
12 12
13 SyntheticMouseDriver::~SyntheticMouseDriver() {} 13 SyntheticMouseDriver::~SyntheticMouseDriver() {}
14 14
15 void SyntheticMouseDriver::DispatchEvent(SyntheticGestureTarget* target, 15 void SyntheticMouseDriver::DispatchEvent(SyntheticGestureTarget* target,
16 const base::TimeTicks& timestamp) { 16 const base::TimeTicks& timestamp) {
17 mouse_event_.timeStampSeconds = ConvertTimestampToSeconds(timestamp); 17 mouse_event_.timeStampSeconds = ConvertTimestampToSeconds(timestamp);
18 target->DispatchInputEventToPlatform(mouse_event_); 18 target->DispatchInputEventToPlatform(mouse_event_);
19 } 19 }
20 20
21 int SyntheticMouseDriver::Press(float x, float y) { 21 void SyntheticMouseDriver::Press(float x, float y, int index) {
22 mouse_event_ = SyntheticWebMouseEventBuilder::Build( 22 mouse_event_ = SyntheticWebMouseEventBuilder::Build(
tdresser 2016/12/12 15:32:49 Why did we switch from returning the index to pass
tdresser 2016/12/13 14:37:43 Acknowledged.
23 blink::WebInputEvent::MouseDown, x, y, 0); 23 blink::WebInputEvent::MouseDown, x, y, 0);
24 mouse_event_.clickCount = 1; 24 mouse_event_.clickCount = 1;
25 return 0;
26 } 25 }
27 26
28 void SyntheticMouseDriver::Move(float x, float y, int index) { 27 void SyntheticMouseDriver::Move(float x, float y, int index) {
29 DCHECK_EQ(index, 0); 28 DCHECK_EQ(index, 0);
30 blink::WebMouseEvent::Button button = mouse_event_.button; 29 blink::WebMouseEvent::Button button = mouse_event_.button;
31 int click_count = mouse_event_.clickCount; 30 int click_count = mouse_event_.clickCount;
32 mouse_event_ = SyntheticWebMouseEventBuilder::Build( 31 mouse_event_ = SyntheticWebMouseEventBuilder::Build(
33 blink::WebInputEvent::MouseMove, x, y, 0); 32 blink::WebInputEvent::MouseMove, x, y, 0);
34 mouse_event_.button = button; 33 mouse_event_.button = button;
35 mouse_event_.clickCount = click_count; 34 mouse_event_.clickCount = click_count;
36 } 35 }
37 36
38 void SyntheticMouseDriver::Release(int index) { 37 void SyntheticMouseDriver::Release(int index) {
39 DCHECK_EQ(index, 0); 38 DCHECK_EQ(index, 0);
40 mouse_event_ = SyntheticWebMouseEventBuilder::Build( 39 mouse_event_ = SyntheticWebMouseEventBuilder::Build(
41 blink::WebInputEvent::MouseUp, mouse_event_.x, mouse_event_.y, 0); 40 blink::WebInputEvent::MouseUp, mouse_event_.x, mouse_event_.y, 0);
42 mouse_event_.clickCount = 1; 41 mouse_event_.clickCount = 1;
43 } 42 }
44 43
45 bool SyntheticMouseDriver::UserInputCheck( 44 bool SyntheticMouseDriver::UserInputCheck(
46 const SyntheticPointerActionParams& params) const { 45 const SyntheticPointerActionParams& params) const {
47 if (params.gesture_source_type != SyntheticGestureParams::MOUSE_INPUT) 46 if (params.gesture_source_type() != SyntheticGestureParams::MOUSE_INPUT)
48 return false; 47 return false;
49 48
50 if (params.pointer_action_type() == 49 if (params.pointer_action_type() ==
51 SyntheticPointerActionParams::PointerActionType::NOT_INITIALIZED) { 50 SyntheticPointerActionParams::PointerActionType::NOT_INITIALIZED) {
52 return false; 51 return false;
53 } 52 }
54 53
55 if (params.pointer_action_type() == 54 if (params.pointer_action_type() ==
56 SyntheticPointerActionParams::PointerActionType::PRESS && 55 SyntheticPointerActionParams::PointerActionType::PRESS &&
57 mouse_event_.clickCount > 0) { 56 mouse_event_.clickCount > 0) {
58 return false; 57 return false;
59 } 58 }
60 59
61 if (params.pointer_action_type() == 60 if (params.pointer_action_type() ==
62 SyntheticPointerActionParams::PointerActionType::RELEASE && 61 SyntheticPointerActionParams::PointerActionType::RELEASE &&
63 mouse_event_.clickCount <= 0) { 62 mouse_event_.clickCount <= 0) {
64 return false; 63 return false;
65 } 64 }
66 65
67 return true; 66 return true;
68 } 67 }
69 68
70 } // namespace content 69 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698