summaryrefslogtreecommitdiffstats
path: root/content/browser/renderer_host/input/touch_emulator.cc
diff options
context:
space:
mode:
Diffstat (limited to 'content/browser/renderer_host/input/touch_emulator.cc')
-rw-r--r--content/browser/renderer_host/input/touch_emulator.cc46
1 files changed, 23 insertions, 23 deletions
diff --git a/content/browser/renderer_host/input/touch_emulator.cc b/content/browser/renderer_host/input/touch_emulator.cc
index 785935f..42b4310 100644
--- a/content/browser/renderer_host/input/touch_emulator.cc
+++ b/content/browser/renderer_host/input/touch_emulator.cc
@@ -6,6 +6,7 @@
#include "content/browser/renderer_host/input/motion_event_web.h"
#include "content/browser/renderer_host/input/web_input_event_util.h"
+#include "content/common/input/web_touch_event_traits.h"
#include "content/public/common/content_client.h"
#include "content/public/common/content_switches.h"
#include "grit/content_resources.h"
@@ -261,10 +262,10 @@ void TouchEmulator::CancelTouch() {
if (!touch_active_)
return;
- touch_event_.timeStampSeconds =
- (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF();
- touch_event_.type = WebInputEvent::TouchCancel;
- touch_event_.touches[0].state = WebTouchPoint::StateCancelled;
+ WebTouchEventTraits::ResetTypeAndTouchStates(
+ WebInputEvent::TouchCancel,
+ (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF(),
+ &touch_event_);
touch_active_ = false;
if (gesture_provider_.OnTouchEvent(MotionEventWeb(touch_event_)))
client_->ForwardTouchEvent(touch_event_);
@@ -339,9 +340,26 @@ bool TouchEmulator::FillTouchEventAndPoint(const WebMouseEvent& mouse_event) {
return false;
}
+ WebInputEvent::Type eventType;
+ switch (mouse_event.type) {
+ case WebInputEvent::MouseDown:
+ eventType = WebInputEvent::TouchStart;
+ touch_active_ = true;
+ break;
+ case WebInputEvent::MouseMove:
+ eventType = WebInputEvent::TouchMove;
+ break;
+ case WebInputEvent::MouseUp:
+ eventType = WebInputEvent::TouchEnd;
+ break;
+ default:
+ eventType = WebInputEvent::Undefined;
+ NOTREACHED();
+ }
touch_event_.touchesLength = 1;
- touch_event_.timeStampSeconds = mouse_event.timeStampSeconds;
touch_event_.modifiers = mouse_event.modifiers;
+ WebTouchEventTraits::ResetTypeAndTouchStates(
+ eventType, mouse_event.timeStampSeconds, &touch_event_);
WebTouchPoint& point = touch_event_.touches[0];
point.id = 0;
@@ -353,24 +371,6 @@ bool TouchEmulator::FillTouchEventAndPoint(const WebMouseEvent& mouse_event) {
point.position.y = mouse_event.y;
point.screenPosition.y = mouse_event.globalY;
- switch (mouse_event.type) {
- case WebInputEvent::MouseDown:
- touch_event_.type = WebInputEvent::TouchStart;
- touch_active_ = true;
- point.state = WebTouchPoint::StatePressed;
- break;
- case WebInputEvent::MouseMove:
- touch_event_.type = WebInputEvent::TouchMove;
- point.state = WebTouchPoint::StateMoved;
- break;
- case WebInputEvent::MouseUp:
- touch_event_.type = WebInputEvent::TouchEnd;
- touch_active_ = false;
- point.state = WebTouchPoint::StateReleased;
- break;
- default:
- NOTREACHED();
- }
return true;
}