Modified: trunk/Source/WebKit2/ChangeLog (101790 => 101791)
--- trunk/Source/WebKit2/ChangeLog 2011-12-02 14:44:42 UTC (rev 101790)
+++ trunk/Source/WebKit2/ChangeLog 2011-12-02 14:45:44 UTC (rev 101791)
@@ -1,3 +1,21 @@
+2011-12-02 Andras Becsi <[email protected]>
+
+ [Qt] [WK2] Use input event timestamps in WebEvents if available
+ https://bugs.webkit.org/show_bug.cgi?id=73647
+
+ Reviewed by Simon Hausmann.
+
+ Qt5 input events already have a native timestamp, use this timestamp
+ in WebEventFactory instead of WTF::currentTime if it is available.
+
+ * Shared/qt/WebEventFactoryQt.cpp:
+ (WebKit::currentTimeForEvent):
+ (WebKit::WebEventFactory::createWebMouseEvent):
+ (WebKit::WebEventFactory::createWebWheelEvent):
+ (WebKit::WebEventFactory::createWebKeyboardEvent):
+ (WebKit::WebEventFactory::createWebTouchEvent):
+ * Shared/qt/WebEventFactoryQt.h:
+
2011-12-02 Jesus Sanchez-Palencia <[email protected]>
[Qt][WK2] Split the QtWebPageProxy into PageClient and QtPageProxy
Modified: trunk/Source/WebKit2/Shared/qt/WebEventFactoryQt.cpp (101790 => 101791)
--- trunk/Source/WebKit2/Shared/qt/WebEventFactoryQt.cpp 2011-12-02 14:44:42 UTC (rev 101790)
+++ trunk/Source/WebKit2/Shared/qt/WebEventFactoryQt.cpp 2011-12-02 14:45:44 UTC (rev 101791)
@@ -39,6 +39,18 @@
namespace WebKit {
+static inline double currentTimeForEvent(const QInputEvent* event)
+{
+ ASSERT(event);
+
+ // Use the input event timestamps if they are available.
+ // These timestamps are in milliseconds, thus convert them to seconds.
+ if (event->timestamp())
+ return static_cast<double>(event->timestamp()) / 1000;
+
+ return WTF::currentTime();
+}
+
static WebMouseEvent::Button mouseButtonForEvent(QMouseEvent *event)
{
if (event->button() == Qt::LeftButton || (event->buttons() & Qt::LeftButton))
@@ -104,7 +116,7 @@
float deltaY = event->pos().y() - lastPos.y();
int clickCount = eventClickCount;
WebEvent::Modifiers modifiers = modifiersForEvent(event->modifiers());
- double timestamp = WTF::currentTime();
+ double timestamp = currentTimeForEvent(event);
lastPos.set(event->localPos().x(), event->localPos().y());
return WebMouseEvent(type, button, event->localPos().toPoint(), event->screenPos().toPoint(), deltaX, deltaY, 0.0f, clickCount, modifiers, timestamp);
@@ -118,7 +130,7 @@
float wheelTicksY = 0;
WebWheelEvent::Granularity granularity = WebWheelEvent::ScrollByPixelWheelEvent;
WebEvent::Modifiers modifiers = modifiersForEvent(e->modifiers());
- double timestamp = WTF::currentTime();
+ double timestamp = currentTimeForEvent(e);
// A delta that is not mod 120 indicates a device that is sending
// fine-resolution scroll events, so use the delta as number of wheel ticks
@@ -156,7 +168,7 @@
int nativeVirtualKeyCode = event->nativeVirtualKey();
int macCharCode = 0;
WebEvent::Modifiers modifiers = modifiersForEvent(event->modifiers());
- double timestamp = WTF::currentTime();
+ double timestamp = currentTimeForEvent(event);
return WebKeyboardEvent(type, text, unmodifiedText, keyIdentifier, windowsVirtualKeyCode, nativeVirtualKeyCode, macCharCode, isAutoRepeat, isKeypad, isSystemKey, modifiers, timestamp);
}
@@ -168,7 +180,7 @@
WebPlatformTouchPoint::TouchPointState state = static_cast<WebPlatformTouchPoint::TouchPointState>(0);
unsigned int id;
WebEvent::Modifiers modifiers = modifiersForEvent(event->modifiers());
- double timestamp = WTF::currentTime();
+ double timestamp = currentTimeForEvent(event);
const QList<QTouchEvent::TouchPoint>& points = event->touchPoints();