Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1452)

Unified Diff: content/browser/renderer_host/input/touch_emulator.cc

Issue 250923005: Touch emulator: overwrite timestamps from mouse event with current time. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed jdduke's comment Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/input/touch_emulator.cc
diff --git a/content/browser/renderer_host/input/touch_emulator.cc b/content/browser/renderer_host/input/touch_emulator.cc
index 42b43106c7861847092ca29d19443a0b0cdce726..ac000eb31a19b5f7f0edcb290517f44ea7e6e658 100644
--- a/content/browser/renderer_host/input/touch_emulator.cc
+++ b/content/browser/renderer_host/input/touch_emulator.cc
@@ -316,7 +316,7 @@ void TouchEmulator::PinchEnd(const WebGestureEvent& event) {
client_->ForwardGestureEvent(pinch_event_);
}
-void TouchEmulator::FillPinchEvent(const WebInputEvent& event) {
+void TouchEmulator::FillPinchEvent(const WebGestureEvent& event) {
pinch_event_.timeStampSeconds = event.timeStampSeconds;
pinch_event_.modifiers = event.modifiers;
pinch_event_.sourceDevice = blink::WebGestureEvent::Touchscreen;
@@ -361,6 +361,16 @@ bool TouchEmulator::FillTouchEventAndPoint(const WebMouseEvent& mouse_event) {
WebTouchEventTraits::ResetTypeAndTouchStates(
eventType, mouse_event.timeStampSeconds, &touch_event_);
+ // On some platforms mouse event's timestamp does not necessarily relate to
+ // the system time at all, so use base::TimeTicks::HighResNow() if possible,
+ // or base::TimeTicks::Now() otherwise.
+ base::TimeTicks now;
+ if (base::TimeTicks::IsHighResNowFastAndReliable())
+ now = base::TimeTicks::HighResNow();
+ else
+ now = base::TimeTicks::Now();
+ touch_event_.timeStampSeconds = (now - base::TimeTicks()).InSecondsF();
+
WebTouchPoint& point = touch_event_.touches[0];
point.id = 0;
point.radiusX = point.radiusY = 1.f;
« no previous file with comments | « content/browser/renderer_host/input/touch_emulator.h ('k') | content/browser/renderer_host/input/touch_emulator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698