Chromium Code Reviews| OLD | NEW |
|---|---|
| (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() {} | |
| 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 int SyntheticMouseDriver::Press(float x, float y) { | |
| 22 mouse_event_ = SyntheticWebMouseEventBuilder::Build( | |
| 23 blink::WebInputEvent::MouseDown, x, y, 0); | |
| 24 mouse_event_.clickCount = 1; | |
| 25 return -1; | |
| 26 } | |
| 27 | |
| 28 void SyntheticMouseDriver::Move(float x, float y, int index) { | |
|
tdresser
2016/11/10 14:58:31
DCHECK that index is -1?
lanwei
2016/11/10 19:45:22
I added a check in the params.index() for mouse, a
| |
| 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) { | |
|
tdresser
2016/11/10 14:58:31
DCHECK that index is -1?
lanwei
2016/11/10 19:45:22
Done.
| |
| 38 mouse_event_ = SyntheticWebMouseEventBuilder::Build( | |
| 39 blink::WebInputEvent::MouseUp, mouse_event_.x, mouse_event_.y, 0); | |
| 40 mouse_event_.clickCount = 1; | |
| 41 } | |
| 42 | |
| 43 bool SyntheticMouseDriver::UserInputCheck( | |
| 44 const SyntheticPointerActionParams& params) const { | |
|
tdresser
2016/11/10 14:58:31
Ensure index is -1?
lanwei
2016/11/10 19:45:22
Done.
| |
| 45 if (params.gesture_source_type != SyntheticGestureParams::MOUSE_INPUT) | |
| 46 return false; | |
| 47 | |
| 48 if (params.pointer_action_type() == | |
| 49 SyntheticPointerActionParams::PointerActionType::NOT_INITIALIZED) { | |
| 50 return false; | |
| 51 } | |
| 52 | |
| 53 if (params.pointer_action_type() == | |
| 54 SyntheticPointerActionParams::PointerActionType::PRESS && | |
| 55 mouse_event_.clickCount > 0) { | |
| 56 return false; | |
| 57 } | |
| 58 | |
| 59 if (params.pointer_action_type() == | |
| 60 SyntheticPointerActionParams::PointerActionType::RELEASE && | |
| 61 mouse_event_.clickCount <= 0) { | |
| 62 return false; | |
| 63 } | |
| 64 | |
| 65 return true; | |
| 66 } | |
| 67 | |
| 68 } // namespace content | |
| OLD | NEW |