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

Unified Diff: third_party/WebKit/Source/web/WebInputEventConversion.cpp

Issue 2542693002: Use WTF::TimeTicks to represent timestamp in Platform/Core event types (Closed)
Patch Set: Don't fix bug in this patch Created 4 years 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: third_party/WebKit/Source/web/WebInputEventConversion.cpp
diff --git a/third_party/WebKit/Source/web/WebInputEventConversion.cpp b/third_party/WebKit/Source/web/WebInputEventConversion.cpp
index 8fb0a7e4020d757b35c12de850361604bbb929ab..c22339df3873cf991afc19ad218d9b37b8df3ddb 100644
--- a/third_party/WebKit/Source/web/WebInputEventConversion.cpp
+++ b/third_party/WebKit/Source/web/WebInputEventConversion.cpp
@@ -65,6 +65,14 @@ FloatSize scaleSizeToWindow(const Widget* widget, FloatSize size) {
scaleDeltaToWindow(widget, size.height()));
}
+TimeTicks toTimeTicks(double eventTimeStampSeconds) {
+ return TimeTicks() + TimeDelta::FromSecondsD(eventTimeStampSeconds);
esprehn 2016/12/06 22:14:19 Can you add a method to TimeTicks for FromSeconds(
+}
+
+double toSeconds(TimeTicks ticks) {
+ return (ticks - TimeTicks()).InSecondsF();
esprehn 2016/12/06 22:14:19 Why does TimeTicks not have a ToSecondsF() method
+}
+
// This method converts from the renderer's coordinate space into Blink's root
// frame coordinate space. It's somewhat unique in that it takes into account
// DevTools emulation, which applies a scale and offset in the root layer (see
@@ -203,7 +211,7 @@ PlatformMouseEventBuilder::PlatformMouseEventBuilder(Widget* widget,
scaleDeltaToWindow(widget, e.movementY));
m_modifiers = e.modifiers;
- m_timestamp = e.timeStampSeconds;
+ m_timestamp = toTimeTicks(e.timeStampSeconds);
m_clickCount = e.clickCount;
m_pointerProperties = static_cast<WebPointerProperties>(e);
@@ -251,7 +259,7 @@ PlatformWheelEventBuilder::PlatformWheelEventBuilder(
m_type = PlatformEvent::Wheel;
- m_timestamp = e.timeStampSeconds;
+ m_timestamp = toTimeTicks(e.timeStampSeconds);
m_modifiers = e.modifiers;
m_dispatchType = toPlatformDispatchType(e.dispatchType);
@@ -375,7 +383,7 @@ PlatformGestureEventBuilder::PlatformGestureEventBuilder(
m_position = widget->convertFromRootFrame(flooredIntPoint(
convertHitPointToRootFrame(widget, FloatPoint(e.x, e.y))));
m_globalPosition = IntPoint(e.globalX, e.globalY);
- m_timestamp = e.timeStampSeconds;
+ m_timestamp = toTimeTicks(e.timeStampSeconds);
m_modifiers = e.modifiers;
switch (e.sourceDevice) {
case WebGestureDeviceTouchpad:
@@ -463,7 +471,7 @@ PlatformTouchEventBuilder::PlatformTouchEventBuilder(
const WebTouchEvent& event) {
m_type = toPlatformTouchEventType(event.type);
m_modifiers = event.modifiers;
- m_timestamp = event.timeStampSeconds;
+ m_timestamp = toTimeTicks(event.timeStampSeconds);
m_causesScrollingIfUncanceled = event.movedBeyondSlopRegion;
m_touchStartOrFirstTouchMove = event.touchStartOrFirstTouchMove;
@@ -494,7 +502,7 @@ static void updateWebMouseEventFromCoreMouseEvent(
const Widget* widget,
const LayoutItem layoutItem,
WebMouseEvent& webEvent) {
- webEvent.timeStampSeconds = event.platformTimeStamp();
+ webEvent.timeStampSeconds = toSeconds(event.platformTimeStamp());
webEvent.modifiers = event.modifiers();
FrameView* view = widget ? toFrameView(widget->parent()) : 0;
@@ -597,7 +605,7 @@ WebMouseEventBuilder::WebMouseEventBuilder(const Widget* widget,
else
return;
- timeStampSeconds = event.platformTimeStamp();
+ timeStampSeconds = toSeconds(event.platformTimeStamp());
modifiers = event.modifiers();
// The mouse event co-ordinates should be generated from the co-ordinates of
@@ -672,7 +680,7 @@ WebKeyboardEventBuilder::WebKeyboardEventBuilder(const KeyboardEvent& event) {
return; // Skip all other keyboard events.
modifiers = event.modifiers();
- timeStampSeconds = event.platformTimeStamp();
+ timeStampSeconds = toSeconds(event.platformTimeStamp());
windowsKeyCode = event.keyCode();
}
@@ -746,7 +754,7 @@ WebTouchEventBuilder::WebTouchEventBuilder(const LayoutItem layoutItem,
return;
}
- timeStampSeconds = event.platformTimeStamp();
+ timeStampSeconds = toSeconds(event.platformTimeStamp());
modifiers = event.modifiers();
dispatchType = event.cancelable() ? WebInputEvent::Blocking
: WebInputEvent::EventNonBlocking;
@@ -811,7 +819,7 @@ WebGestureEventBuilder::WebGestureEventBuilder(const LayoutItem layoutItem,
data.tap.tapCount = 1;
}
- timeStampSeconds = event.platformTimeStamp();
+ timeStampSeconds = toSeconds(event.platformTimeStamp());
modifiers = event.modifiers();
globalX = event.screenX();

Powered by Google App Engine
This is Rietveld 408576698