Use high resolution timestamp for event time
https://bugs.webkit.org/show_bug.cgi?id=154246
<rdar://problem/34333304>
Reviewed by Ryosuke Niwa.
LayoutTests/imported/w3c:
Rebaseline WPT test now that more checks are passing.
* web-platform-tests/dom/events/Event-timestamp-high-resolution-expected.txt:
Source/WebCore:
Have event.timeStamp return a DOMHighResTimeStamp instead of a DOMResTimeStamp. It now
has better precision, is monotonic and is relative to PerformanceTiming.navigationStart.
This is as per:
- https://dom.spec.whatwg.org/#interface-event
Chrome, Firefox and Edge all already ship this so the compatibility risk should be low.
Also use WallTime / MonotonicTime instead of double type for clarity.
Test: imported/w3c/web-platform-tests/dom/events/Event-timestamp-high-resolution.html
* WebCore.xcodeproj/project.pbxproj:
* dom/DOMHighResTimeStamp.h: Copied from Source/WebKit/Shared/WebTouchEvent.cpp.
* dom/Element.cpp:
(WebCore::Element::dispatchMouseForceWillBegin):
* dom/Event.cpp:
(WebCore::Event::Event):
(WebCore::Event::timeStampForBindings const):
* dom/Event.h:
(WebCore::Event::timeStamp const):
* dom/Event.idl:
* dom/KeyboardEvent.cpp:
(WebCore::KeyboardEvent::KeyboardEvent):
* dom/MouseEvent.cpp:
(WebCore::MouseEvent::create):
(WebCore::MouseEvent::MouseEvent):
* dom/MouseEvent.h:
* dom/MouseRelatedEvent.cpp:
(WebCore::MouseRelatedEvent::MouseRelatedEvent):
* dom/MouseRelatedEvent.h:
* dom/SimulatedClick.cpp:
* dom/TouchEvent.cpp:
(WebCore::TouchEvent::TouchEvent):
* dom/UIEvent.cpp:
(WebCore::UIEvent::UIEvent):
* dom/UIEvent.h:
* dom/UIEventWithKeyState.h:
(WebCore::UIEventWithKeyState::UIEventWithKeyState):
* dom/WheelEvent.cpp:
(WebCore::WheelEvent::WheelEvent):
* html/TypeAhead.cpp:
(WebCore::TypeAhead::TypeAhead):
(WebCore::TypeAhead::handleEvent):
* html/TypeAhead.h:
* page/AutoscrollController.cpp:
(WebCore::AutoscrollController::AutoscrollController):
(WebCore::AutoscrollController::updateDragAndDrop):
(WebCore::AutoscrollController::autoscrollTimerFired):
* page/AutoscrollController.h:
* page/ContextMenuController.cpp:
(WebCore::ContextMenuController::showContextMenuAt):
* page/DragController.cpp:
(WebCore::createMouseEvent):
* page/EventHandler.cpp:
(WebCore::EventHandler::dispatchDragEvent):
(WebCore::EventHandler::sendContextMenuEventForKey):
(WebCore::EventHandler::fakeMouseMoveEventTimerFired):
* page/EventHandler.h:
* page/Performance.cpp:
(WebCore::Performance::now const):
(WebCore::Performance::relativeTimeFromTimeOriginInReducedResolution const):
* page/Performance.h:
* page/ios/EventHandlerIOS.mm:
(WebCore::EventHandler::tryToBeginDataInteractionAtPoint):
* page/win/EventHandlerWin.cpp:
* platform/PlatformEvent.h:
(WebCore::PlatformEvent::timestamp const):
(WebCore::PlatformEvent::PlatformEvent):
* platform/PlatformKeyboardEvent.h:
(WebCore::PlatformKeyboardEvent::PlatformKeyboardEvent):
* platform/PlatformMouseEvent.h:
(WebCore::PlatformMouseEvent::PlatformMouseEvent):
* platform/PlatformWheelEvent.h:
(WebCore::PlatformWheelEvent::PlatformWheelEvent):
* platform/cocoa/ScrollController.mm:
(WebCore::ScrollController::handleWheelEvent):
* platform/glib/EventHandlerGLib.cpp:
* platform/gtk/ScrollAnimatorGtk.cpp:
(WebCore::ScrollAnimatorGtk::computeVelocity):
(WebCore::ScrollAnimatorGtk::handleWheelEvent):
* platform/ios/PlatformEventFactoryIOS.mm:
(WebCore::PlatformMouseEventBuilder::PlatformMouseEventBuilder):
(WebCore::PlatformWheelEventBuilder::PlatformWheelEventBuilder):
(WebCore::PlatformKeyboardEventBuilder::PlatformKeyboardEventBuilder):
(WebCore::PlatformTouchEventBuilder::PlatformTouchEventBuilder):
* platform/mac/PlatformEventFactoryMac.h:
* platform/mac/PlatformEventFactoryMac.mm:
(WebCore::eventTimeStampSince1970):
Source/WebKit:
Use WallTime / MonotonicTime instead of double type for clarity.
* Shared/WebCoreArgumentCoders.cpp:
(IPC::ArgumentCoder<WallTime>::encode):
(IPC::ArgumentCoder<WallTime>::decode):
* Shared/WebCoreArgumentCoders.h:
* Shared/WebEvent.cpp:
(WebKit::WebEvent::WebEvent):
* Shared/WebEvent.h:
(WebKit::WebEvent::timestamp const):
(WebKit::WebTouchEvent::WebTouchEvent):
* Shared/WebKeyboardEvent.cpp:
(WebKit::WebKeyboardEvent::WebKeyboardEvent):
* Shared/WebMouseEvent.cpp:
(WebKit::WebMouseEvent::WebMouseEvent):
* Shared/WebTouchEvent.cpp:
(WebKit::WebTouchEvent::WebTouchEvent):
* Shared/WebWheelEvent.cpp:
(WebKit::WebWheelEvent::WebWheelEvent):
* Shared/gtk/WebEventFactory.cpp:
(WebKit::WebEventFactory::createWebMouseEvent):
(WebKit::WebEventFactory::createWebWheelEvent):
(WebKit::WebEventFactory::createWebKeyboardEvent):
(WebKit::WebEventFactory::createWebTouchEvent):
* Shared/ios/NativeWebTouchEventIOS.mm:
(WebKit::NativeWebTouchEvent::NativeWebTouchEvent):
* Shared/ios/WebIOSEventFactory.mm:
(WebIOSEventFactory::createWebKeyboardEvent):
* Shared/mac/NativeWebGestureEventMac.mm:
(WebKit::NativeWebGestureEvent::NativeWebGestureEvent):
* Shared/mac/WebEventFactory.mm:
(WebKit::WebEventFactory::createWebMouseEvent):
(WebKit::WebEventFactory::createWebWheelEvent):
(WebKit::WebEventFactory::createWebKeyboardEvent):
* Shared/mac/WebGestureEvent.h:
(WebKit::WebGestureEvent::WebGestureEvent):
* Shared/wpe/WebEventFactory.cpp:
(WebKit::WebEventFactory::createWebKeyboardEvent):
(WebKit::WebEventFactory::createWebMouseEvent):
(WebKit::WebEventFactory::createWebWheelEvent):
(WebKit::WebEventFactory::createWebTouchEvent):
* WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:
(WKBundlePageSimulateMouseDown):
(WKBundlePageSimulateMouseUp):
(WKBundlePageSimulateMouseMotion):
* WebProcess/Plugins/PDF/PDFPlugin.mm:
(WebKit::PDFPlugin::showContextMenuAtPoint):
* WebProcess/Plugins/PluginView.cpp:
(WebKit::PluginView::createWebEvent const):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::navigateToPDFLinkWithSimulatedClick):
(WebKit::WebPage::contextMenuAtPointInWindow):
(WebKit::WebPage::dragEnded):
(WebKit::WebPage::simulateMouseDown):
(WebKit::WebPage::simulateMouseUp):
(WebKit::WebPage::simulateMouseMotion):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::handleSyntheticClick):
(WebKit::WebPage::completeSyntheticClick):
(WebKit::WebPage::requestAdditionalItemsForDragSession):
(WebKit::WebPage::inspectorNodeSearchMovedToPosition):
Source/WebKitLegacy/ios:
Use WallTime / MonotonicTime instead of double type for clarity.
* WebView/WebPDFViewPlaceholder.mm:
(-[WebPDFViewPlaceholder simulateClickOnLinkToURL:]):
Source/WebKitLegacy/mac:
Use WallTime / MonotonicTime instead of double type for clarity.
* DOM/DOMEvent.mm:
(-[DOMEvent timeStamp]):
* WebView/WebFrame.mm:
(-[WebFrame _dragSourceEndedAt:operation:]):
* WebView/WebPDFView.mm:
(-[WebPDFView PDFViewWillClickOnLink:withURL:]):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@222392 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/dom/Event.h b/Source/WebCore/dom/Event.h
index 9edb3af..c5d4d41 100644
--- a/Source/WebCore/dom/Event.h
+++ b/Source/WebCore/dom/Event.h
@@ -23,11 +23,12 @@
#pragma once
-#include "DOMTimeStamp.h"
+#include "DOMHighResTimeStamp.h"
#include "EventInit.h"
#include "EventInterfaces.h"
#include "ExceptionOr.h"
#include "ScriptWrappable.h"
+#include <wtf/MonotonicTime.h>
#include <wtf/RefCounted.h>
#include <wtf/TypeCasts.h>
#include <wtf/text/AtomicString.h>
@@ -96,7 +97,8 @@
bool cancelable() const { return m_cancelable; }
WEBCORE_EXPORT bool composed() const;
- DOMTimeStamp timeStamp() const { return m_createTime; }
+ DOMHighResTimeStamp timeStampForBindings(ScriptExecutionContext&) const;
+ MonotonicTime timeStamp() const { return m_createTime; }
void setEventPath(const EventPath& path) { m_eventPath = &path; }
void clearEventPath() { m_eventPath = nullptr; }
@@ -170,7 +172,7 @@
protected:
Event(IsTrusted = IsTrusted::No);
WEBCORE_EXPORT Event(const AtomicString& type, bool canBubble, bool cancelable);
- Event(const AtomicString& type, bool canBubble, bool cancelable, double timestamp);
+ Event(const AtomicString& type, bool canBubble, bool cancelable, MonotonicTime timestamp);
Event(const AtomicString& type, const EventInit&, IsTrusted);
virtual void receivedTarget();
@@ -195,7 +197,7 @@
RefPtr<EventTarget> m_currentTarget;
const EventPath* m_eventPath { nullptr };
RefPtr<EventTarget> m_target;
- DOMTimeStamp m_createTime;
+ MonotonicTime m_createTime;
RefPtr<Event> m_underlyingEvent;
};