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

Unified Diff: third_party/WebKit/Source/core/inspector/InspectorInputAgent.cpp

Issue 1747383002: Convert Devtools protocol Input timestamp to monotonic clock (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address feedback Created 4 years, 9 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
« no previous file with comments | « third_party/WebKit/LayoutTests/inspector-protocol/input/eventTimestamp-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/inspector/InspectorInputAgent.cpp
diff --git a/third_party/WebKit/Source/core/inspector/InspectorInputAgent.cpp b/third_party/WebKit/Source/core/inspector/InspectorInputAgent.cpp
index e474f020579fa65cfc641314ff30f993eb0353cc..ab2f42d9e7074453f4a6c5e7c33981dbb088a679 100644
--- a/third_party/WebKit/Source/core/inspector/InspectorInputAgent.cpp
+++ b/third_party/WebKit/Source/core/inspector/InspectorInputAgent.cpp
@@ -69,6 +69,22 @@ unsigned GetEventModifiers(int modifiers)
return platformModifiers;
}
+// Convert given protocol timestamp which is in seconds since unix epoch to a
+// platform event timestamp which is ticks since platform start. This conversion
+// is an estimate because these two clocks respond differently to user setting
+// time and NTP adjustments. If timestamp is empty then returns current
+// monotonic timestamp.
+double GetEventTimeStamp(const blink::protocol::Maybe<double>& timestamp)
+{
+ // Take a snapshot of difference between two clocks on first run and use it
+ // for the duration of the application.
+ static double epochToMonotonicTimeDelta = currentTime() - monotonicallyIncreasingTime();
+ if (timestamp.isJust())
+ return timestamp.fromJust() - epochToMonotonicTimeDelta;
+
+ return monotonicallyIncreasingTime();
+}
+
class SyntheticInspectorTouchPoint : public blink::PlatformTouchPoint {
public:
SyntheticInspectorTouchPoint(int id, State state, const blink::IntPoint& screenPos, const blink::IntPoint& pos, int radiusX, int radiusY, double rotationAngle, double force)
@@ -134,7 +150,7 @@ void InspectorInputAgent::dispatchTouchEvent(ErrorString* error, const String& t
unsigned convertedModifiers = GetEventModifiers(modifiers.fromMaybe(0));
- SyntheticInspectorTouchEvent event(convertedType, convertedModifiers, timestamp.fromMaybe(currentTime()));
+ SyntheticInspectorTouchEvent event(convertedType, convertedModifiers, GetEventTimeStamp(timestamp));
int autoId = 0;
for (size_t i = 0; i < touchPoints->length(); ++i) {
« no previous file with comments | « third_party/WebKit/LayoutTests/inspector-protocol/input/eventTimestamp-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698