| 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() : 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 int SyntheticMouseDriver::Press(int index, |
| 22 float x, |
| 23 float y, |
| 24 SyntheticGestureTarget* target, |
| 25 const base::TimeTicks& timestamp) { |
| 26 mouse_event_ = SyntheticWebMouseEventBuilder::Build( |
| 27 blink::WebInputEvent::MouseDown, x, y, 0); |
| 28 mouse_event_.clickCount = 1; |
| 29 mouse_index_ = 0; |
| 30 return 0; |
| 31 } |
| 32 |
| 33 void SyntheticMouseDriver::Move(int index, |
| 34 float x, |
| 35 float y, |
| 36 SyntheticGestureTarget* target, |
| 37 const base::TimeTicks& timestamp) { |
| 38 blink::WebMouseEvent::Button button = mouse_event_.button; |
| 39 int click_count = mouse_event_.clickCount; |
| 40 mouse_event_ = SyntheticWebMouseEventBuilder::Build( |
| 41 blink::WebInputEvent::MouseMove, x, y, 0); |
| 42 mouse_event_.button = button; |
| 43 mouse_event_.clickCount = click_count; |
| 44 } |
| 45 |
| 46 void SyntheticMouseDriver::Release(int index, |
| 47 SyntheticGestureTarget* target, |
| 48 const base::TimeTicks& timestamp) { |
| 49 mouse_event_ = SyntheticWebMouseEventBuilder::Build( |
| 50 blink::WebInputEvent::MouseUp, mouse_event_.x, mouse_event_.y, 0); |
| 51 mouse_event_.clickCount = 1; |
| 52 mouse_index_ = -1; |
| 53 } |
| 54 |
| 55 SyntheticGestureParams::GestureSourceType SyntheticMouseDriver::SourceType() |
| 56 const { |
| 57 return SyntheticGestureParams::MOUSE_INPUT; |
| 58 } |
| 59 |
| 60 int SyntheticMouseDriver::GetPointIndex(int index) const { |
| 61 return mouse_index_; |
| 62 } |
| 63 |
| 64 } // namespace content |
| OLD | NEW |