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; | |
|
tdresser
2016/11/12 19:50:55
Currently, if you double click, we'll continue set
lanwei
2016/11/14 04:20:54
I thought if you create a mouse press, release, pr
| |
| 25 return -1; | |
| 26 } | |
| 27 | |
| 28 void SyntheticMouseDriver::Move(float x, float y, int index) { | |
| 29 DCHECK_EQ(index, -1); | |
| 30 blink::WebMouseEvent::Button button = mouse_event_.button; | |
| 31 int click_count = mouse_event_.clickCount; | |
| 32 mouse_event_ = SyntheticWebMouseEventBuilder::Build( | |
| 33 blink::WebInputEvent::MouseMove, x, y, 0); | |
| 34 mouse_event_.button = button; | |
| 35 mouse_event_.clickCount = click_count; | |
| 36 } | |
| 37 | |
| 38 void SyntheticMouseDriver::Release(int index) { | |
| 39 DCHECK_EQ(index, -1); | |
| 40 mouse_event_ = SyntheticWebMouseEventBuilder::Build( | |
| 41 blink::WebInputEvent::MouseUp, mouse_event_.x, mouse_event_.y, 0); | |
| 42 mouse_event_.clickCount = 1; | |
| 43 } | |
| 44 | |
| 45 bool SyntheticMouseDriver::UserInputCheck( | |
| 46 const SyntheticPointerActionParams& params) const { | |
| 47 DCHECK_EQ(params.index(), -1); | |
| 48 | |
| 49 if (params.gesture_source_type != SyntheticGestureParams::MOUSE_INPUT) | |
| 50 return false; | |
| 51 | |
| 52 if (params.pointer_action_type() == | |
| 53 SyntheticPointerActionParams::PointerActionType::NOT_INITIALIZED) { | |
| 54 return false; | |
| 55 } | |
| 56 | |
| 57 if (params.pointer_action_type() == | |
| 58 SyntheticPointerActionParams::PointerActionType::PRESS && | |
| 59 mouse_event_.clickCount > 0) { | |
| 60 return false; | |
| 61 } | |
| 62 | |
| 63 if (params.pointer_action_type() == | |
| 64 SyntheticPointerActionParams::PointerActionType::RELEASE && | |
| 65 mouse_event_.clickCount <= 0) { | |
| 66 return false; | |
| 67 } | |
| 68 | |
| 69 return true; | |
| 70 } | |
| 71 | |
| 72 } // namespace content | |
| OLD | NEW |