| OLD | NEW |
| 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() : last_modifiers_(0) {} | 11 SyntheticMouseDriver::SyntheticMouseDriver() : last_modifiers_(0) { |
| 12 mouse_event_.pointerType = blink::WebPointerProperties::PointerType::Mouse; |
| 13 } |
| 12 | 14 |
| 13 SyntheticMouseDriver::~SyntheticMouseDriver() {} | 15 SyntheticMouseDriver::~SyntheticMouseDriver() {} |
| 14 | 16 |
| 15 void SyntheticMouseDriver::DispatchEvent(SyntheticGestureTarget* target, | 17 void SyntheticMouseDriver::DispatchEvent(SyntheticGestureTarget* target, |
| 16 const base::TimeTicks& timestamp) { | 18 const base::TimeTicks& timestamp) { |
| 17 mouse_event_.setTimeStampSeconds(ConvertTimestampToSeconds(timestamp)); | 19 mouse_event_.setTimeStampSeconds(ConvertTimestampToSeconds(timestamp)); |
| 18 target->DispatchInputEventToPlatform(mouse_event_); | 20 target->DispatchInputEventToPlatform(mouse_event_); |
| 19 } | 21 } |
| 20 | 22 |
| 21 void SyntheticMouseDriver::Press(float x, | 23 void SyntheticMouseDriver::Press(float x, |
| 22 float y, | 24 float y, |
| 23 int index, | 25 int index, |
| 24 SyntheticPointerActionParams::Button button) { | 26 SyntheticPointerActionParams::Button button) { |
| 25 DCHECK_EQ(index, 0); | 27 DCHECK_EQ(index, 0); |
| 26 int modifiers = | 28 int modifiers = |
| 27 SyntheticPointerActionParams::GetWebMouseEventModifier(button); | 29 SyntheticPointerActionParams::GetWebMouseEventModifier(button); |
| 28 mouse_event_ = SyntheticWebMouseEventBuilder::Build( | 30 mouse_event_ = SyntheticWebMouseEventBuilder::Build( |
| 29 blink::WebInputEvent::MouseDown, x, y, modifiers | last_modifiers_); | 31 blink::WebInputEvent::MouseDown, x, y, modifiers | last_modifiers_, |
| 32 mouse_event_.pointerType); |
| 30 mouse_event_.clickCount = 1; | 33 mouse_event_.clickCount = 1; |
| 31 mouse_event_.button = | 34 mouse_event_.button = |
| 32 SyntheticPointerActionParams::GetWebMouseEventButton(button); | 35 SyntheticPointerActionParams::GetWebMouseEventButton(button); |
| 33 last_modifiers_ = modifiers | last_modifiers_; | 36 last_modifiers_ = modifiers | last_modifiers_; |
| 34 } | 37 } |
| 35 | 38 |
| 36 void SyntheticMouseDriver::Move(float x, float y, int index) { | 39 void SyntheticMouseDriver::Move(float x, float y, int index) { |
| 37 DCHECK_EQ(index, 0); | 40 DCHECK_EQ(index, 0); |
| 38 blink::WebMouseEvent::Button button = mouse_event_.button; | 41 blink::WebMouseEvent::Button button = mouse_event_.button; |
| 39 int click_count = mouse_event_.clickCount; | 42 int click_count = mouse_event_.clickCount; |
| 40 mouse_event_ = SyntheticWebMouseEventBuilder::Build( | 43 mouse_event_ = SyntheticWebMouseEventBuilder::Build( |
| 41 blink::WebInputEvent::MouseMove, x, y, last_modifiers_); | 44 blink::WebInputEvent::MouseMove, x, y, last_modifiers_, |
| 45 mouse_event_.pointerType); |
| 42 mouse_event_.button = button; | 46 mouse_event_.button = button; |
| 43 mouse_event_.clickCount = click_count; | 47 mouse_event_.clickCount = click_count; |
| 44 } | 48 } |
| 45 | 49 |
| 46 void SyntheticMouseDriver::Release( | 50 void SyntheticMouseDriver::Release( |
| 47 int index, | 51 int index, |
| 48 SyntheticPointerActionParams::Button button) { | 52 SyntheticPointerActionParams::Button button) { |
| 49 DCHECK_EQ(index, 0); | 53 DCHECK_EQ(index, 0); |
| 50 mouse_event_ = SyntheticWebMouseEventBuilder::Build( | 54 mouse_event_ = SyntheticWebMouseEventBuilder::Build( |
| 51 blink::WebInputEvent::MouseUp, mouse_event_.x, mouse_event_.y, | 55 blink::WebInputEvent::MouseUp, mouse_event_.x, mouse_event_.y, |
| 52 last_modifiers_); | 56 last_modifiers_, mouse_event_.pointerType); |
| 53 mouse_event_.clickCount = 1; | 57 mouse_event_.clickCount = 1; |
| 54 mouse_event_.button = | 58 mouse_event_.button = |
| 55 SyntheticPointerActionParams::GetWebMouseEventButton(button); | 59 SyntheticPointerActionParams::GetWebMouseEventButton(button); |
| 56 last_modifiers_ = | 60 last_modifiers_ = |
| 57 last_modifiers_ & | 61 last_modifiers_ & |
| 58 (~SyntheticPointerActionParams::GetWebMouseEventModifier(button)); | 62 (~SyntheticPointerActionParams::GetWebMouseEventModifier(button)); |
| 59 } | 63 } |
| 60 | 64 |
| 61 bool SyntheticMouseDriver::UserInputCheck( | 65 bool SyntheticMouseDriver::UserInputCheck( |
| 62 const SyntheticPointerActionParams& params) const { | 66 const SyntheticPointerActionParams& params) const { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 79 if (params.pointer_action_type() == | 83 if (params.pointer_action_type() == |
| 80 SyntheticPointerActionParams::PointerActionType::RELEASE && | 84 SyntheticPointerActionParams::PointerActionType::RELEASE && |
| 81 mouse_event_.clickCount <= 0) { | 85 mouse_event_.clickCount <= 0) { |
| 82 return false; | 86 return false; |
| 83 } | 87 } |
| 84 | 88 |
| 85 return true; | 89 return true; |
| 86 } | 90 } |
| 87 | 91 |
| 88 } // namespace content | 92 } // namespace content |
| OLD | NEW |