Use high resolution timestamp for event time
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Sep 2017 17:13:06 +0000 (17:13 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Sep 2017 17:13:06 +0000 (17:13 +0000)
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: https://svn.webkit.org/repository/webkit/trunk@222392 268f45cc-cd09-0410-ab3c-d52691b4dbfc

80 files changed:
LayoutTests/TestExpectations
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-timestamp-high-resolution-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/dom/DOMHighResTimeStamp.h [new file with mode: 0644]
Source/WebCore/dom/Element.cpp
Source/WebCore/dom/Event.cpp
Source/WebCore/dom/Event.h
Source/WebCore/dom/Event.idl
Source/WebCore/dom/KeyboardEvent.cpp
Source/WebCore/dom/MouseEvent.cpp
Source/WebCore/dom/MouseEvent.h
Source/WebCore/dom/MouseRelatedEvent.cpp
Source/WebCore/dom/MouseRelatedEvent.h
Source/WebCore/dom/SimulatedClick.cpp
Source/WebCore/dom/TouchEvent.cpp
Source/WebCore/dom/UIEvent.cpp
Source/WebCore/dom/UIEvent.h
Source/WebCore/dom/UIEventWithKeyState.h
Source/WebCore/dom/WheelEvent.cpp
Source/WebCore/html/TypeAhead.cpp
Source/WebCore/html/TypeAhead.h
Source/WebCore/page/AutoscrollController.cpp
Source/WebCore/page/AutoscrollController.h
Source/WebCore/page/ContextMenuController.cpp
Source/WebCore/page/DragController.cpp
Source/WebCore/page/EventHandler.cpp
Source/WebCore/page/EventHandler.h
Source/WebCore/page/Performance.cpp
Source/WebCore/page/Performance.h
Source/WebCore/page/ios/EventHandlerIOS.mm
Source/WebCore/page/win/EventHandlerWin.cpp
Source/WebCore/platform/PlatformEvent.h
Source/WebCore/platform/PlatformKeyboardEvent.h
Source/WebCore/platform/PlatformMouseEvent.h
Source/WebCore/platform/PlatformWheelEvent.h
Source/WebCore/platform/cocoa/ScrollController.mm
Source/WebCore/platform/glib/EventHandlerGLib.cpp
Source/WebCore/platform/gtk/PlatformKeyboardEventGtk.cpp
Source/WebCore/platform/gtk/PlatformMouseEventGtk.cpp
Source/WebCore/platform/gtk/PlatformWheelEventGtk.cpp
Source/WebCore/platform/gtk/ScrollAnimatorGtk.cpp
Source/WebCore/platform/ios/PlatformEventFactoryIOS.mm
Source/WebCore/platform/mac/PlatformEventFactoryMac.h
Source/WebCore/platform/mac/PlatformEventFactoryMac.mm
Source/WebCore/platform/win/KeyEventWin.cpp
Source/WebCore/platform/win/PlatformMouseEventWin.cpp
Source/WebCore/platform/win/WheelEventWin.cpp
Source/WebKit/ChangeLog
Source/WebKit/Shared/WebCoreArgumentCoders.cpp
Source/WebKit/Shared/WebCoreArgumentCoders.h
Source/WebKit/Shared/WebEvent.cpp
Source/WebKit/Shared/WebEvent.h
Source/WebKit/Shared/WebKeyboardEvent.cpp
Source/WebKit/Shared/WebMouseEvent.cpp
Source/WebKit/Shared/WebTouchEvent.cpp
Source/WebKit/Shared/WebWheelEvent.cpp
Source/WebKit/Shared/gtk/WebEventFactory.cpp
Source/WebKit/Shared/ios/NativeWebTouchEventIOS.mm
Source/WebKit/Shared/ios/WebIOSEventFactory.mm
Source/WebKit/Shared/mac/NativeWebGestureEventMac.mm
Source/WebKit/Shared/mac/WebEventFactory.mm
Source/WebKit/Shared/mac/WebGestureEvent.h
Source/WebKit/Shared/wpe/WebEventFactory.cpp
Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp
Source/WebKit/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMEvent.cpp
Source/WebKit/WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp
Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm
Source/WebKit/WebProcess/Plugins/PluginView.cpp
Source/WebKit/WebProcess/WebPage/WebPage.cpp
Source/WebKit/WebProcess/WebPage/WebPage.h
Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm
Source/WebKitLegacy/ios/ChangeLog
Source/WebKitLegacy/ios/WebView/WebPDFViewPlaceholder.mm
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/DOM/DOMEvent.mm
Source/WebKitLegacy/mac/WebView/WebFrame.mm
Source/WebKitLegacy/mac/WebView/WebPDFView.mm
Source/WebKitLegacy/win/WebDropSource.cpp

index c08e6ce58d8ebd1896b9c12aea6ab4fef368df3d..ca0fcddb440aa29a5152da9db0a9e7e2765a692c 100644 (file)
@@ -176,7 +176,6 @@ imported/w3c/web-platform-tests/css/css-ui-3/text-overflow-012.html [ ImageOnlyF
 imported/w3c/web-platform-tests/css/css-ui-3/text-overflow-015.html [ ImageOnlyFailure ]
 imported/w3c/web-platform-tests/css/css-ui-3/text-overflow-017.html [ ImageOnlyFailure ]
 imported/w3c/web-platform-tests/css/css-ui-3/text-overflow-021.html [ ImageOnlyFailure ]
-imported/w3c/web-platform-tests/dom/events/Event-timestamp-high-resolution.html [ Failure ]
 imported/w3c/web-platform-tests/dom/nodes/Document-constructor-svg.svg [ Timeout ]
 imported/w3c/web-platform-tests/fetch/security/dangling-markup-mitigation.tentative.html [ Pass Failure ]
 imported/w3c/web-platform-tests/hr-time/timeOrigin.html [ Failure ]
index 91cc8b9e32b2902a103a928a66e900ea0e2eacab..082327ec2629c8c5818f2a35ff1d12a0931decb7 100644 (file)
@@ -1,3 +1,15 @@
+2017-09-22  Chris Dumez  <cdumez@apple.com>
+
+        Use high resolution timestamp for event time
+        https://bugs.webkit.org/show_bug.cgi?id=154246
+        <rdar://problem/34333304>
+
+        Reviewed by Ryosuke Niwa.
+
+        Rebaseline WPT test now that more checks are passing.
+
+        * web-platform-tests/dom/events/Event-timestamp-high-resolution-expected.txt:
+
 2017-09-22  Zan Dobersek  <zdobersek@igalia.com>
 
         Unreviewed WPE gardening. Updating the WPT EME idlharness.html
index f47fa3d6f567e4e98b128012825d62d1886cee3f..2f08b485d45a6eb587e97fe4d6ae5eabfd573c91 100644 (file)
@@ -1,7 +1,7 @@
 
-FAIL Constructed MouseEvent timestamp should be high resolution and have the same time origin as performance.now() assert_less_than_equal: Event timestamp should be less than performance.now() timestamp taken after its creation expected a number less than or equal to 523.8000000000001 but got 1505770152566
-FAIL Constructed KeyboardEvent timestamp should be high resolution and have the same time origin as performance.now() assert_less_than_equal: Event timestamp should be less than performance.now() timestamp taken after its creation expected a number less than or equal to 524.4 but got 1505770152566
-FAIL Constructed WheelEvent timestamp should be high resolution and have the same time origin as performance.now() assert_less_than_equal: Event timestamp should be less than performance.now() timestamp taken after its creation expected a number less than or equal to 524.5000000000001 but got 1505770152566
-FAIL Constructed GamepadEvent timestamp should be high resolution and have the same time origin as performance.now() Not enough arguments
-FAIL Constructed FocusEvent timestamp should be high resolution and have the same time origin as performance.now() assert_less_than_equal: Event timestamp should be less than performance.now() timestamp taken after its creation expected a number less than or equal to 524.6 but got 1505770152566
+PASS Constructed MouseEvent timestamp should be high resolution and have the same time origin as performance.now() 
+PASS Constructed KeyboardEvent timestamp should be high resolution and have the same time origin as performance.now() 
+PASS Constructed WheelEvent timestamp should be high resolution and have the same time origin as performance.now() 
+PASS Constructed GamepadEvent timestamp should be high resolution and have the same time origin as performance.now() 
+PASS Constructed FocusEvent timestamp should be high resolution and have the same time origin as performance.now() 
 
index 648350c103692dbbc6f8ea825dbd1b9be9a7f0bc..04c1fecbe17809cd34f0057ffb8b22aa38d1b0d4 100644 (file)
@@ -1,3 +1,101 @@
+2017-09-22  Chris Dumez  <cdumez@apple.com>
+
+        Use high resolution timestamp for event time
+        https://bugs.webkit.org/show_bug.cgi?id=154246
+        <rdar://problem/34333304>
+
+        Reviewed by Ryosuke Niwa.
+
+        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):
+
 2017-09-22  Nael Ouedraogo  <nael.ouedraogo@crf.canon.fr>
 
         [GTK] HTMLMediaElement resize event not fired when video size changes
index 1cb12bf1e89d76d4f4235cc38994491e796a4557..0f1445e6370f06e635c37a97ca650a8ed486e623 100644 (file)
                460BB6161D0A1BF000221812 /* Base64Utilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 460BB6141D0A1BEC00221812 /* Base64Utilities.h */; settings = {ATTRIBUTES = (Private, ); }; };
                460CBF351D4BCD0E0092E88E /* JSDOMWindowProperties.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 460CBF331D4BCCFE0092E88E /* JSDOMWindowProperties.cpp */; };
                460CBF361D4BCD0E0092E88E /* JSDOMWindowProperties.h in Headers */ = {isa = PBXBuildFile; fileRef = 460CBF341D4BCCFE0092E88E /* JSDOMWindowProperties.h */; };
+               46218ACB1F72D64E00574FBE /* DOMHighResTimeStamp.h in Headers */ = {isa = PBXBuildFile; fileRef = 46E016AD1F72D61E00282B2C /* DOMHighResTimeStamp.h */; settings = {ATTRIBUTES = (Private, ); }; };
                4634592C1AC2271000ECB71C /* PowerObserverMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4634592B1AC2271000ECB71C /* PowerObserverMac.cpp */; };
                463EB6221B8789E00096ED51 /* TagCollection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 463EB6201B8789CB0096ED51 /* TagCollection.cpp */; };
                463EB6231B8789E00096ED51 /* TagCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = 463EB6211B8789CB0096ED51 /* TagCollection.h */; };
                46DFF4971DC2601300B80B48 /* ShadowRootMode.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ShadowRootMode.idl; sourceTree = "<group>"; };
                46DFF4991DC261F900B80B48 /* JSShadowRootMode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSShadowRootMode.cpp; sourceTree = "<group>"; };
                46DFF49A1DC261F900B80B48 /* JSShadowRootMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSShadowRootMode.h; sourceTree = "<group>"; };
+               46E016AD1F72D61E00282B2C /* DOMHighResTimeStamp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMHighResTimeStamp.h; sourceTree = "<group>"; };
                46EBEA011B7D4D5D00BE4941 /* CollectionTraversal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CollectionTraversal.h; sourceTree = "<group>"; };
                46EFAF0D1E5FB9C200E7F34B /* LowPowerModeNotifierIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LowPowerModeNotifierIOS.mm; sourceTree = "<group>"; };
                46EFAF0F1E5FB9E100E7F34B /* LowPowerModeNotifier.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LowPowerModeNotifier.cpp; sourceTree = "<group>"; };
                                BC60D6E80D28D83400B9918F /* DOMException.h */,
                                BC60D6EB0D28D99900B9918F /* DOMException.idl */,
                                BC9A6141146859D9006057FD /* DOMExceptions.in */,
+                               46E016AD1F72D61E00282B2C /* DOMHighResTimeStamp.h */,
                                A8185F3609765765005826D9 /* DOMImplementation.cpp */,
                                A8185F3309765765005826D9 /* DOMImplementation.h */,
                                93EEC1E909C2877700C515D1 /* DOMImplementation.idl */,
                                BC60D6E90D28D83400B9918F /* DOMException.h in Headers */,
                                8399470C1F50B63E00E9D86B /* DOMFileSystem.h in Headers */,
                                2ED609BD1145B07100C8684E /* DOMFormData.h in Headers */,
+                               46218ACB1F72D64E00574FBE /* DOMHighResTimeStamp.h in Headers */,
                                A8185F3B09765766005826D9 /* DOMImplementation.h in Headers */,
                                E3C99A091DC3D41C00794AD3 /* DOMJITCheckDOM.h in Headers */,
                                E3150EA71DA7219300194012 /* DOMJITHelpers.h in Headers */,
diff --git a/Source/WebCore/dom/DOMHighResTimeStamp.h b/Source/WebCore/dom/DOMHighResTimeStamp.h
new file mode 100644 (file)
index 0000000..11b6786
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+namespace WebCore {
+
+using DOMHighResTimeStamp = double;
+
+}
index 1135c947900ed32d4db8623edd619144eef1a381..3cc45835ee8fa11ec969b3a56747b67ebb24ac04 100644 (file)
@@ -2525,7 +2525,7 @@ bool Element::dispatchMouseForceWillBegin()
     if (!frame)
         return false;
 
-    PlatformMouseEvent platformMouseEvent { frame->eventHandler().lastKnownMousePosition(), frame->eventHandler().lastKnownMouseGlobalPosition(), NoButton, PlatformEvent::NoType, 1, false, false, false, false, WTF::currentTime(), ForceAtClick, NoTap };
+    PlatformMouseEvent platformMouseEvent { frame->eventHandler().lastKnownMousePosition(), frame->eventHandler().lastKnownMouseGlobalPosition(), NoButton, PlatformEvent::NoType, 1, false, false, false, false, WallTime::now(), ForceAtClick, NoTap };
     auto mouseForceWillBeginEvent = MouseEvent::create(eventNames().webkitmouseforcewillbeginEvent, document().defaultView(), platformMouseEvent, 0, nullptr);
     mouseForceWillBeginEvent->setTarget(this);
     dispatchEvent(mouseForceWillBeginEvent);
index 870595184e13413a2e25ee073c7e538b58ca649e..b97d0038fdf9a75b64da3151dfd8136232251a04 100644 (file)
 #include "config.h"
 #include "Event.h"
 
+#include "DOMWindow.h"
+#include "Document.h"
 #include "EventNames.h"
 #include "EventPath.h"
 #include "EventTarget.h"
+#include "Performance.h"
 #include "UserGestureIndicator.h"
+#include "WorkerGlobalScope.h"
 #include <wtf/CurrentTime.h>
 
 namespace WebCore {
 
 Event::Event(IsTrusted isTrusted)
     : m_isTrusted(isTrusted == IsTrusted::Yes)
-    , m_createTime(convertSecondsToDOMTimeStamp(currentTime()))
+    , m_createTime(MonotonicTime::now())
 {
 }
 
@@ -43,17 +47,17 @@ Event::Event(const AtomicString& eventType, bool canBubbleArg, bool cancelableAr
     , m_canBubble(canBubbleArg)
     , m_cancelable(cancelableArg)
     , m_isTrusted(true)
-    , m_createTime(convertSecondsToDOMTimeStamp(currentTime()))
+    , m_createTime(MonotonicTime::now())
 {
 }
 
-Event::Event(const AtomicString& eventType, bool canBubbleArg, bool cancelableArg, double timestamp)
+Event::Event(const AtomicString& eventType, bool canBubbleArg, bool cancelableArg, MonotonicTime timestamp)
     : m_type(eventType)
     , m_isInitialized(true)
     , m_canBubble(canBubbleArg)
     , m_cancelable(cancelableArg)
     , m_isTrusted(true)
-    , m_createTime(convertSecondsToDOMTimeStamp(timestamp))
+    , m_createTime(timestamp)
 {
 }
 
@@ -64,7 +68,7 @@ Event::Event(const AtomicString& eventType, const EventInit& initializer, IsTrus
     , m_cancelable(initializer.cancelable)
     , m_composed(initializer.composed)
     , m_isTrusted(isTrusted == IsTrusted::Yes)
-    , m_createTime(convertSecondsToDOMTimeStamp(currentTime()))
+    , m_createTime(MonotonicTime::now())
 {
 }
 
@@ -216,4 +220,18 @@ void Event::setUnderlyingEvent(Event* underlyingEvent)
     m_underlyingEvent = underlyingEvent;
 }
 
+DOMHighResTimeStamp Event::timeStampForBindings(ScriptExecutionContext& context) const
+{
+    Performance* performance = nullptr;
+    if (is<WorkerGlobalScope>(context))
+        performance = &downcast<WorkerGlobalScope>(context).performance();
+    else if (auto* window = downcast<Document>(context).domWindow())
+        performance = window->performance();
+
+    if (!performance)
+        return 0;
+
+    return performance->relativeTimeFromTimeOriginInReducedResolution(m_createTime);
+}
+
 } // namespace WebCore
index 9edb3af31ecff55a077250c5df9dbc9d3451c8d2..c5d4d41d637811f2242e7590cb478c733699f81b 100644 (file)
 
 #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 @@ public:
     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 @@ public:
 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 @@ private:
     RefPtr<EventTarget> m_currentTarget;
     const EventPath* m_eventPath { nullptr };
     RefPtr<EventTarget> m_target;
-    DOMTimeStamp m_createTime;
+    MonotonicTime m_createTime;
 
     RefPtr<Event> m_underlyingEvent;
 };
index 533f31cc8d5fc02caa34335109597b8ab5498715..87ae1fb49c25a2b864a3e2278c3ff5fd31916095 100644 (file)
@@ -18,6 +18,8 @@
  * Boston, MA 02110-1301, USA.
  */
 
+typedef double DOMHighResTimeStamp;
+
 [
     Constructor(DOMString type, optional EventInit eventInitDict),
     CustomToJSObject,
@@ -48,7 +50,7 @@
     [EnabledAtRuntime=ShadowDOM] readonly attribute boolean composed;
 
     [Unforgeable] readonly attribute boolean isTrusted;
-    readonly attribute DOMTimeStamp timeStamp;
+    [CallWith=ScriptExecutionContext, ImplementedAs=timeStampForBindings] readonly attribute DOMHighResTimeStamp timeStamp;
 
     void initEvent(DOMString type, optional boolean bubbles = false, optional boolean cancelable = false); // Historical.
 
index 2bd931fc480087efd350b4d18f0f1e08ddb2f1af..4804c1d05e56b788c64ae372a21f7ed446f3744e 100644 (file)
@@ -95,7 +95,7 @@ KeyboardEvent::KeyboardEvent() = default;
 
 KeyboardEvent::KeyboardEvent(const PlatformKeyboardEvent& key, DOMWindow* view)
     : UIEventWithKeyState(eventTypeForKeyboardEventType(key.type())
-        , true, true, key.timestamp(), view, 0, key.ctrlKey(), key.altKey(), key.shiftKey()
+        , true, true, key.timestamp().approximateMonotonicTime(), view, 0, key.ctrlKey(), key.altKey(), key.shiftKey()
         , key.metaKey(), false, key.modifiers().contains(PlatformEvent::Modifier::CapsLockKey))
     , m_keyEvent(std::make_unique<PlatformKeyboardEvent>(key))
 #if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
index eb76d6af91f956d23d46751d3d3f66f7d65dfd8a..3c785a7a4466a502382cee712db8ec2dfcd6ca1d 100644 (file)
@@ -34,7 +34,6 @@
 #include "JSEventTargetCustom.h"
 #include "PlatformMouseEvent.h"
 #include "RuntimeApplicationChecks.h"
-#include <wtf/CurrentTime.h>
 
 namespace WebCore {
 
@@ -51,7 +50,7 @@ Ref<MouseEvent> MouseEvent::create(const AtomicString& eventType, DOMWindow* vie
     bool isCancelable = eventType != eventNames().mousemoveEvent && !isMouseEnterOrLeave;
     bool canBubble = !isMouseEnterOrLeave;
 
-    return MouseEvent::create(eventType, canBubble, isCancelable, event.timestamp(), view,
+    return MouseEvent::create(eventType, canBubble, isCancelable, event.timestamp().approximateMonotonicTime(), view,
         detail, event.globalPosition().x(), event.globalPosition().y(), event.position().x(), event.position().y(),
 #if ENABLE(POINTER_LOCK)
         event.movementDelta().x(), event.movementDelta().y(),
@@ -60,7 +59,7 @@ Ref<MouseEvent> MouseEvent::create(const AtomicString& eventType, DOMWindow* vie
         relatedTarget, event.force(), event.syntheticClickType());
 }
 
-Ref<MouseEvent> MouseEvent::create(const AtomicString& type, bool canBubble, bool cancelable, double timestamp, DOMWindow* view, int detail, int screenX, int screenY, int pageX, int pageY,
+Ref<MouseEvent> MouseEvent::create(const AtomicString& type, bool canBubble, bool cancelable, MonotonicTime timestamp, DOMWindow* view, int detail, int screenX, int screenY, int pageX, int pageY,
 #if ENABLE(POINTER_LOCK)
     int movementX, int movementY,
 #endif
@@ -83,7 +82,7 @@ MouseEvent::MouseEvent()
 {
 }
 
-MouseEvent::MouseEvent(const AtomicString& eventType, bool canBubble, bool cancelable, double timestamp, DOMWindow* view, int detail, const IntPoint& screenLocation, const IntPoint& windowLocation,
+MouseEvent::MouseEvent(const AtomicString& eventType, bool canBubble, bool cancelable, MonotonicTime timestamp, DOMWindow* view, int detail, const IntPoint& screenLocation, const IntPoint& windowLocation,
 #if ENABLE(POINTER_LOCK)
         const IntPoint& movementDelta,
 #endif
@@ -103,7 +102,7 @@ MouseEvent::MouseEvent(const AtomicString& eventType, bool canBubble, bool cance
 }
 
 MouseEvent::MouseEvent(const AtomicString& eventType, bool canBubble, bool cancelable, DOMWindow* view, int detail, const IntPoint& screenLocation, const IntPoint& clientLocation, bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, unsigned short button, unsigned short syntheticClickType, EventTarget* relatedTarget)
-    : MouseRelatedEvent(eventType, canBubble, cancelable, WTF::currentTime(), view, detail, screenLocation, { },
+    : MouseRelatedEvent(eventType, canBubble, cancelable, MonotonicTime::now(), view, detail, screenLocation, { },
 #if ENABLE(POINTER_LOCK)
         { },
 #endif
index e30082bd3af6a4ae5ab7396d1d196fe4b0901489..5f1c03a451b3cb5689a7b3c76f9829f93dbc1778 100644 (file)
@@ -33,7 +33,7 @@ class PlatformMouseEvent;
 
 class MouseEvent : public MouseRelatedEvent {
 public:
-    WEBCORE_EXPORT static Ref<MouseEvent> create(const AtomicString& type, bool canBubble, bool cancelable, double timestamp, DOMWindow*, int detail, int screenX, int screenY, int pageX, int pageY,
+    WEBCORE_EXPORT static Ref<MouseEvent> create(const AtomicString& type, bool canBubble, bool cancelable, MonotonicTime timestamp, DOMWindow*, int detail, int screenX, int screenY, int pageX, int pageY,
 #if ENABLE(POINTER_LOCK)
         int movementX, int movementY,
 #endif
@@ -71,7 +71,7 @@ public:
     int which() const final;
 
 protected:
-    MouseEvent(const AtomicString& type, bool canBubble, bool cancelable, double timestamp, DOMWindow*,
+    MouseEvent(const AtomicString& type, bool canBubble, bool cancelable, MonotonicTime timestamp, DOMWindow*,
         int detail, const IntPoint& screenLocation, const IntPoint& windowLocation,
 #if ENABLE(POINTER_LOCK)
         const IntPoint& movementDelta,
index eba9a7a92aeb1b4203424ba698962968593d3f48..6915e9c307697d390e3c3b8ab7893108ac2a2f4a 100644 (file)
@@ -32,7 +32,7 @@
 
 namespace WebCore {
 
-MouseRelatedEvent::MouseRelatedEvent(const AtomicString& eventType, bool canBubble, bool cancelable, double timestamp, DOMWindow* DOMWindow,
+MouseRelatedEvent::MouseRelatedEvent(const AtomicString& eventType, bool canBubble, bool cancelable, MonotonicTime timestamp, DOMWindow* DOMWindow,
                                      int detail, const IntPoint& screenLocation, const IntPoint& windowLocation,
 #if ENABLE(POINTER_LOCK)
                                      const IntPoint& movementDelta,
index 80a730a208af9415201a528d34870b9663a91d0e..e35d293c4114f0593f3c9eddeafb3202d0010f8c 100644 (file)
@@ -73,7 +73,7 @@ public:
 
 protected:
     MouseRelatedEvent() = default;
-    MouseRelatedEvent(const AtomicString& type, bool canBubble, bool cancelable, double timestamp, DOMWindow*,
+    MouseRelatedEvent(const AtomicString& type, bool canBubble, bool cancelable, MonotonicTime timestamp, DOMWindow*,
         int detail, const IntPoint& screenLocation, const IntPoint& windowLocation,
 #if ENABLE(POINTER_LOCK)
         const IntPoint& movementDelta,
index 6fb3b4d7f72362fa7e9b720e542bc46fb752cb60..4549368be927872b99be017d1b8e068318b780cf 100644 (file)
@@ -46,7 +46,7 @@ public:
 
 private:
     SimulatedMouseEvent(const AtomicString& eventType, DOMWindow* view, RefPtr<Event>&& underlyingEvent, Element& target, SimulatedClickSource source)
-        : MouseEvent(eventType, true, true, underlyingEvent ? underlyingEvent->timeStamp() : currentTime(), view, 0, { }, { },
+        : MouseEvent(eventType, true, true, underlyingEvent ? underlyingEvent->timeStamp() : MonotonicTime::now(), view, 0, { }, { },
 #if ENABLE(POINTER_LOCK)
             { },
 #endif
index f5cec7cc40cb7292942e40a3b9bb0f99a402829d..873f2964bd43bc9b33e0ba775029adb32ac82a0b 100644 (file)
@@ -31,7 +31,6 @@
 #include "TouchEvent.h"
 
 #include "EventDispatcher.h"
-#include <wtf/CurrentTime.h>
 
 namespace WebCore {
 
@@ -43,7 +42,7 @@ TouchEvent::TouchEvent(TouchList* touches, TouchList* targetTouches,
         TouchList* changedTouches, const AtomicString& type, 
         DOMWindow* view, int screenX, int screenY, int pageX, int pageY,
         bool ctrlKey, bool altKey, bool shiftKey, bool metaKey)
-    : MouseRelatedEvent(type, true, true, currentTime(), view, 0, IntPoint(screenX, screenY),
+    : MouseRelatedEvent(type, true, true, MonotonicTime::now(), view, 0, IntPoint(screenX, screenY),
                         IntPoint(pageX, pageY),
 #if ENABLE(POINTER_LOCK)
                         IntPoint(0, 0),
index 4cb2239ec5be0da80d9dd18f0ee4e427022ea594..e815af97afe4d08e5ec0b77f313cab6af89bf9e8 100644 (file)
@@ -39,7 +39,7 @@ UIEvent::UIEvent(const AtomicString& eventType, bool canBubbleArg, bool cancelab
 {
 }
 
-UIEvent::UIEvent(const AtomicString& eventType, bool canBubbleArg, bool cancelableArg, double timestamp, DOMWindow* viewArg, int detailArg)
+UIEvent::UIEvent(const AtomicString& eventType, bool canBubbleArg, bool cancelableArg, MonotonicTime timestamp, DOMWindow* viewArg, int detailArg)
     : Event(eventType, canBubbleArg, cancelableArg, timestamp)
     , m_view(viewArg)
     , m_detail(detailArg)
index 973d73ef3fa3353c0f7963ca0fa8e1e7856ad7cb..baa731fcf81eebaf23153da51ba0aeafd2455fac 100644 (file)
@@ -66,7 +66,7 @@ public:
 protected:
     UIEvent();
     UIEvent(const AtomicString& type, bool canBubble, bool cancelable, DOMWindow*, int detail);
-    UIEvent(const AtomicString& type, bool canBubble, bool cancelable, double timestamp, DOMWindow*, int detail);
+    UIEvent(const AtomicString& type, bool canBubble, bool cancelable, MonotonicTime timestamp, DOMWindow*, int detail);
     UIEvent(const AtomicString&, const UIEventInit&, IsTrusted);
 
 private:
index bfea387c212c251ad51f070be36be44581624de2..0a8e4031248d6f7265442e5bf80012ba30cccdeb 100644 (file)
@@ -49,7 +49,7 @@ protected:
     {
     }
 
-    UIEventWithKeyState(const AtomicString& type, bool canBubble, bool cancelable, double timestamp, DOMWindow* view,
+    UIEventWithKeyState(const AtomicString& type, bool canBubble, bool cancelable, MonotonicTime timestamp, DOMWindow* view,
         int detail, bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, bool altGraphKey, bool capsLockKey)
             : UIEvent(type, canBubble, cancelable, timestamp, view, detail)
             , m_ctrlKey(ctrlKey)
index 530e6b0119292892a6d8a49ce278b573f6f37084..80db05a155288b95e3820a287f919baadbd2509a 100644 (file)
@@ -50,7 +50,7 @@ WheelEvent::WheelEvent(const AtomicString& type, const Init& initializer, IsTrus
 }
 
 WheelEvent::WheelEvent(const PlatformWheelEvent& event, DOMWindow* view)
-    : MouseEvent(eventNames().wheelEvent, true, true, event.timestamp(), view, 0, event.globalPosition(), event.position()
+    : MouseEvent(eventNames().wheelEvent, true, true, event.timestamp().approximateMonotonicTime(), view, 0, event.globalPosition(), event.position()
 #if ENABLE(POINTER_LOCK)
         , { }
 #endif
index d26f57d849a6bae059686b5d29494800be5a7388..f1ecb7cd60fe0da2486f875fafb223a3753d4253 100644 (file)
@@ -37,12 +37,11 @@ namespace WebCore {
 
 TypeAhead::TypeAhead(TypeAheadDataSource* dataSource)
     : m_dataSource(dataSource)
-    , m_lastTypeTime(0)
     , m_repeatingChar(0)
 {
 }
 
-static const DOMTimeStamp typeAheadTimeout = 1000;
+static const Seconds typeAheadTimeout { 1_s };
 
 static String stripLeadingWhiteSpace(const String& string)
 {
@@ -63,7 +62,7 @@ int TypeAhead::handleEvent(KeyboardEvent* event, MatchModeFlags matchMode)
         return -1;
 
     int optionCount = m_dataSource->optionCount();
-    DOMTimeStamp delta = event->timeStamp() - m_lastTypeTime;
+    Seconds delta = event->timeStamp() - m_lastTypeTime;
     m_lastTypeTime = event->timeStamp();
 
     UChar c = event->charCode();
index 610ac78288b760247977bf2e2382cca2e22bda89..046c001e571745f7be1f9e4627c6f74de6ac258f 100644 (file)
@@ -25,7 +25,7 @@
 
 #pragma once
 
-#include "DOMTimeStamp.h"
+#include <wtf/MonotonicTime.h>
 #include <wtf/text/StringBuilder.h>
 #include <wtf/text/WTFString.h>
 
@@ -58,7 +58,7 @@ public:
 
 private:
     TypeAheadDataSource* m_dataSource;
-    DOMTimeStamp m_lastTypeTime;
+    MonotonicTime m_lastTypeTime;
     UChar m_repeatingChar;
     StringBuilder m_buffer;
 };
index e3996fded50c5b3e64d241231ce426f45d87e5e5..e5287c0cb2370126aee9f4f5cf833a809adbc5c6 100644 (file)
 #include "RenderView.h"
 #include "ScrollView.h"
 #include "Settings.h"
-#include <wtf/CurrentTime.h>
 
 namespace WebCore {
 
 // Delay time in second for start autoscroll if pointer is in border edge of scrollable element.
-static const double autoscrollDelay = 0.2;
+static const Seconds autoscrollDelay { 200_ms };
 
 // When the autoscroll or the panScroll is triggered when do the scroll every 50ms to make it smooth.
 static const Seconds autoscrollInterval { 50_ms };
@@ -59,7 +58,6 @@ AutoscrollController::AutoscrollController()
     : m_autoscrollTimer(*this, &AutoscrollController::autoscrollTimerFired)
     , m_autoscrollRenderer(nullptr)
     , m_autoscrollType(NoAutoscroll)
-    , m_dragAndDropAutoscrollStartTime(0)
 {
 }
 
@@ -140,7 +138,7 @@ void AutoscrollController::updateAutoscrollRenderer()
     m_autoscrollRenderer = is<RenderBox>(renderer) ? downcast<RenderBox>(renderer) : nullptr;
 }
 
-void AutoscrollController::updateDragAndDrop(Node* dropTargetNode, const IntPoint& eventPosition, double eventTime)
+void AutoscrollController::updateDragAndDrop(Node* dropTargetNode, const IntPoint& eventPosition, WallTime eventTime)
 {
     if (!dropTargetNode) {
         stopAutoscrollTimer();
@@ -241,7 +239,7 @@ void AutoscrollController::autoscrollTimerFired()
     Frame& frame = m_autoscrollRenderer->frame();
     switch (m_autoscrollType) {
     case AutoscrollForDragAndDrop:
-        if (WTF::currentTime() - m_dragAndDropAutoscrollStartTime > autoscrollDelay)
+        if (WallTime::now() - m_dragAndDropAutoscrollStartTime > autoscrollDelay)
             m_autoscrollRenderer->autoscroll(m_dragAndDropAutoscrollReferencePosition);
         break;
     case AutoscrollForSelection: {
index 3cd9dbf3379cb777a8aabc75bb83b9671361cf64..71360ba44ddc94514f6942d46bdb8f0f8d06be32 100644 (file)
@@ -27,6 +27,7 @@
 
 #include "IntPoint.h"
 #include "Timer.h"
+#include <wtf/WallTime.h>
 
 namespace WebCore {
 
@@ -59,7 +60,7 @@ public:
     void startAutoscrollForSelection(RenderObject*);
     void stopAutoscrollTimer(bool rendererIsBeingDestroyed = false);
     void updateAutoscrollRenderer();
-    void updateDragAndDrop(Node* targetNode, const IntPoint& eventPosition, double eventTime);
+    void updateDragAndDrop(Node* targetNode, const IntPoint& eventPosition, WallTime eventTime);
 #if ENABLE(PAN_SCROLLING)
     void didPanScrollStart();
     void didPanScrollStop();
@@ -79,7 +80,7 @@ private:
     RenderBox* m_autoscrollRenderer;
     AutoscrollType m_autoscrollType;
     IntPoint m_dragAndDropAutoscrollReferencePosition;
-    double m_dragAndDropAutoscrollStartTime;
+    WallTime m_dragAndDropAutoscrollStartTime;
 #if ENABLE(PAN_SCROLLING)
     IntPoint m_panScrollStartPos;
 #endif
index 8011c42d603a1dd92696f37e614109da8926fbf7..322b4923ffb2427c2b85a9c6d5d1c71e0c605649 100644 (file)
@@ -68,6 +68,7 @@
 #include "UserTypingGestureIndicator.h"
 #include "WindowFeatures.h"
 #include "markup.h"
+#include <wtf/WallTime.h>
 #include <wtf/unicode/CharacterNames.h>
 
 using namespace WTF;
@@ -1440,7 +1441,7 @@ void ContextMenuController::showContextMenuAt(Frame& frame, const IntPoint& clic
     clearContextMenu();
     
     // Simulate a click in the middle of the accessibility object.
-    PlatformMouseEvent mouseEvent(clickPoint, clickPoint, RightButton, PlatformEvent::MousePressed, 1, false, false, false, false, currentTime(), ForceAtClick, NoTap);
+    PlatformMouseEvent mouseEvent(clickPoint, clickPoint, RightButton, PlatformEvent::MousePressed, 1, false, false, false, false, WallTime::now(), ForceAtClick, NoTap);
     frame.eventHandler().handleMousePressEvent(mouseEvent);
     bool handled = frame.eventHandler().sendContextMenuEvent(mouseEvent);
     if (handled)
index ef566795aad0bd04338bd38df66045dfa9f63646..3f8a206b5559647c08e2b51ba5c6cfedaa6584d5 100644 (file)
@@ -128,7 +128,7 @@ static PlatformMouseEvent createMouseEvent(const DragData& dragData)
 
     return PlatformMouseEvent(dragData.clientPosition(), dragData.globalPosition(),
                               LeftButton, PlatformEvent::MouseMoved, 0, shiftKey, ctrlKey, altKey,
-                              metaKey, currentTime(), ForceAtClick, NoTap);
+                              metaKey, WallTime::now(), ForceAtClick, NoTap);
 }
 
 DragController::DragController(Page& page, DragClient& client)
index 5c848afd9b01d1ae339f46ced4a24588d3f70e3a..ef069c47e746b81344e929cf774e2934d4a44796 100644 (file)
@@ -135,7 +135,7 @@ const int ImageDragHysteresis = 5;
 const int TextDragHysteresis = 3;
 const int GeneralDragHysteresis = 3;
 #if PLATFORM(COCOA)
-const double EventHandler::TextDragDelay = 0.15;
+const Seconds EventHandler::TextDragDelay { 150_ms };
 #endif
 #endif // ENABLE(DRAG_SUPPORT)
 
@@ -2190,7 +2190,7 @@ bool EventHandler::dispatchDragEvent(const AtomicString& eventType, Element& dra
 
     view->disableLayerFlushThrottlingTemporarilyForInteraction();
     Ref<MouseEvent> me = MouseEvent::create(eventType,
-        true, true, event.timestamp(), m_frame.document()->defaultView(),
+        true, true, event.timestamp().approximateMonotonicTime(), m_frame.document()->defaultView(),
         0, event.globalPosition().x(), event.globalPosition().y(), event.position().x(), event.position().y(),
 #if ENABLE(POINTER_LOCK)
         event.movementDelta().x(), event.movementDelta().y(),
@@ -2939,7 +2939,7 @@ bool EventHandler::sendContextMenuEventForKey()
     PlatformEvent::Type eventType = PlatformEvent::MousePressed;
 #endif
 
-    PlatformMouseEvent platformMouseEvent(position, globalPosition, RightButton, eventType, 1, false, false, false, false, WTF::currentTime(), ForceAtClick, NoTap);
+    PlatformMouseEvent platformMouseEvent(position, globalPosition, RightButton, eventType, 1, false, false, false, false, WallTime::now(), ForceAtClick, NoTap);
 
     return sendContextMenuEvent(platformMouseEvent);
 }
@@ -3021,7 +3021,7 @@ void EventHandler::fakeMouseMoveEventTimerFired()
     bool altKey;
     bool metaKey;
     PlatformKeyboardEvent::getCurrentModifierState(shiftKey, ctrlKey, altKey, metaKey);
-    PlatformMouseEvent fakeMouseMoveEvent(m_lastKnownMousePosition, m_lastKnownMouseGlobalPosition, NoButton, PlatformEvent::MouseMoved, 0, shiftKey, ctrlKey, altKey, metaKey, currentTime(), 0, NoTap);
+    PlatformMouseEvent fakeMouseMoveEvent(m_lastKnownMousePosition, m_lastKnownMouseGlobalPosition, NoButton, PlatformEvent::MouseMoved, 0, shiftKey, ctrlKey, altKey, metaKey, WallTime::now(), 0, NoTap);
     mouseMoved(fakeMouseMoveEvent);
 }
 #endif // !ENABLE(IOS_TOUCH_EVENTS)
index 6663c8f2a89d3f22c3bef62b097c46aedbf67663..a0aa535f5a5d8ca81175a891015b6e9bbf487984 100644 (file)
@@ -323,7 +323,7 @@ public:
 private:
 #if ENABLE(DRAG_SUPPORT)
     static DragState& dragState();
-    static const double TextDragDelay;
+    static const Seconds TextDragDelay;
     Ref<DataTransfer> createDraggingDataTransfer() const;
 #endif
 
@@ -564,7 +564,7 @@ private:
     IntPoint m_lastKnownMousePosition;
     IntPoint m_lastKnownMouseGlobalPosition;
     IntPoint m_mouseDownPos; // In our view's coords.
-    double m_mouseDownTimestamp { 0 };
+    WallTime m_mouseDownTimestamp;
     PlatformMouseEvent m_mouseDown;
 
 #if PLATFORM(COCOA)
index 1afa36459131317a02635890ed1beaee1d4e4e9a..6c52aaf9a64c25ac50497fba806d67087d04893d 100644 (file)
@@ -69,7 +69,7 @@ void Performance::contextDestroyed()
     ContextDestructionObserver::contextDestroyed();
 }
 
-double Performance::now() const
+DOMHighResTimeStamp Performance::now() const
 {
     Seconds now = MonotonicTime::now() - m_timeOrigin;
     return reduceTimeResolution(now).milliseconds();
@@ -82,6 +82,12 @@ Seconds Performance::reduceTimeResolution(Seconds seconds)
     return Seconds(reduced);
 }
 
+DOMHighResTimeStamp Performance::relativeTimeFromTimeOriginInReducedResolution(MonotonicTime timestamp) const
+{
+    Seconds seconds = timestamp - m_timeOrigin;
+    return reduceTimeResolution(seconds).milliseconds();
+}
+
 PerformanceNavigation* Performance::navigation()
 {
     if (!is<Document>(scriptExecutionContext()))
index 9a60ec0ab2ca58b7f10c4b8db9cff612109d585d..438a0012e283a6cb3c34d60c165d77c29d15943e 100644 (file)
@@ -33,6 +33,7 @@
 #pragma once
 
 #include "ContextDestructionObserver.h"
+#include "DOMHighResTimeStamp.h"
 #include "EventTarget.h"
 #include "ExceptionOr.h"
 #include "GenericTaskQueue.h"
@@ -56,7 +57,7 @@ public:
     static Ref<Performance> create(ScriptExecutionContext& context, MonotonicTime timeOrigin) { return adoptRef(*new Performance(context, timeOrigin)); }
     ~Performance();
 
-    double now() const;
+    DOMHighResTimeStamp now() const;
 
     PerformanceNavigation* navigation();
     PerformanceTiming* timing();
@@ -82,6 +83,8 @@ public:
 
     static Seconds reduceTimeResolution(Seconds);
 
+    DOMHighResTimeStamp relativeTimeFromTimeOriginInReducedResolution(MonotonicTime) const;
+
     ScriptExecutionContext* scriptExecutionContext() const final { return ContextDestructionObserver::scriptExecutionContext(); }
 
     using RefCounted::ref;
index 8f0fb4e2eaba3dd96ceeb4438f8f3b039958b142..9f9758bf35017ebb4b5d2d71b20d7e8d99caac9b 100644 (file)
@@ -587,8 +587,8 @@ bool EventHandler::tryToBeginDataInteractionAtPoint(const IntPoint& clientPositi
     IntPoint adjustedClientPosition = roundedIntPoint(adjustedClientPositionAsFloatPoint);
     IntPoint adjustedGlobalPosition = protectedFrame->view()->windowToContents(adjustedClientPosition);
 
-    PlatformMouseEvent syntheticMousePressEvent(adjustedClientPosition, adjustedGlobalPosition, LeftButton, PlatformEvent::MousePressed, 1, false, false, false, false, currentTime(), 0, NoTap);
-    PlatformMouseEvent syntheticMouseMoveEvent(adjustedClientPosition, adjustedGlobalPosition, LeftButton, PlatformEvent::MouseMoved, 0, false, false, false, false, currentTime(), 0, NoTap);
+    PlatformMouseEvent syntheticMousePressEvent(adjustedClientPosition, adjustedGlobalPosition, LeftButton, PlatformEvent::MousePressed, 1, false, false, false, false, WallTime::now(), 0, NoTap);
+    PlatformMouseEvent syntheticMouseMoveEvent(adjustedClientPosition, adjustedGlobalPosition, LeftButton, PlatformEvent::MouseMoved, 0, false, false, false, false, WallTime::now(), 0, NoTap);
 
     HitTestRequest request(HitTestRequest::Active | HitTestRequest::DisallowUserAgentShadowContent);
     auto documentPoint = protectedFrame->view() ? protectedFrame->view()->windowToContents(syntheticMouseMoveEvent.position()) : syntheticMouseMoveEvent.position();
index dcec034dfec3b61c51cadf2772a567590afcdf24..42106a68ffbd81ac107f50b90786b7e09e08327c 100644 (file)
@@ -48,7 +48,7 @@
 namespace WebCore {
 
 #if ENABLE(DRAG_SUPPORT)
-const double EventHandler::TextDragDelay = 0.0;
+const Seconds EventHandler::TextDragDelay { 0_s };
 #endif
 
 bool EventHandler::passMousePressEventToSubframe(MouseEventWithHitTestResults& mev, Frame* subframe)
index 5cb478471d66a8ec96a548df4908e587e81d85e7..52cb9c87402f07102df638b151082d787a13b8d7 100644 (file)
@@ -26,6 +26,7 @@
 #pragma once
 
 #include <wtf/OptionSet.h>
+#include <wtf/WallTime.h>
 
 namespace WebCore {
 
@@ -86,29 +87,27 @@ public:
 
     OptionSet<Modifier> modifiers() const { return m_modifiers; }
 
-    double timestamp() const { return m_timestamp; }
+    WallTime timestamp() const { return m_timestamp; }
 
 protected:
     PlatformEvent()
         : m_type(NoType)
-        , m_timestamp(0)
     {
     }
 
     explicit PlatformEvent(Type type)
         : m_type(type)
-        , m_timestamp(0)
     {
     }
 
-    PlatformEvent(Type type, OptionSet<Modifier> modifiers, double timestamp)
+    PlatformEvent(Type type, OptionSet<Modifier> modifiers, WallTime timestamp)
         : m_type(type)
         , m_modifiers(modifiers)
         , m_timestamp(timestamp)
     {
     }
 
-    PlatformEvent(Type type, bool shiftKey, bool ctrlKey, bool altKey, bool metaKey, double timestamp)
+    PlatformEvent(Type type, bool shiftKey, bool ctrlKey, bool altKey, bool metaKey, WallTime timestamp)
         : m_type(type)
         , m_timestamp(timestamp)
     {
@@ -130,7 +129,7 @@ protected:
 
     unsigned m_type;
     OptionSet<Modifier> m_modifiers;
-    double m_timestamp;
+    WallTime m_timestamp;
 };
 
 } // namespace WebCore
index 87ba57608df57bfd8ba40b78c0d96434d087c30a..97d03af92ad3812be5e9ce1394b85cc2cc7a65f6 100644 (file)
@@ -72,7 +72,7 @@ namespace WebCore {
 #if ENABLE(KEYBOARD_CODE_ATTRIBUTE)
         const String& code,
 #endif
-        const String& keyIdentifier, int windowsVirtualKeyCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, OptionSet<Modifier> modifiers, double timestamp)
+        const String& keyIdentifier, int windowsVirtualKeyCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, OptionSet<Modifier> modifiers, WallTime timestamp)
             : PlatformEvent(type, modifiers, timestamp)
             , m_text(text)
             , m_unmodifiedText(unmodifiedText)
index 104f5397092a907a1e985387dfb3d2adb7287a71..a4e7d58924c0d2c2c42413f4f2ec2ec6fccb2bf9 100644 (file)
@@ -61,7 +61,7 @@ const double ForceAtForceClick = 2;
         }
 
         PlatformMouseEvent(const IntPoint& position, const IntPoint& globalPosition, MouseButton button, PlatformEvent::Type type,
-                           int clickCount, bool shiftKey, bool ctrlKey, bool altKey, bool metaKey, double timestamp, double force, SyntheticClickType syntheticClickType)
+                           int clickCount, bool shiftKey, bool ctrlKey, bool altKey, bool metaKey, WallTime timestamp, double force, SyntheticClickType syntheticClickType)
             : PlatformEvent(type, shiftKey, ctrlKey, altKey, metaKey, timestamp)
             , m_position(position)
             , m_globalPosition(globalPosition)
index 6d458bef4b804f52bde294d1679b1613fc902480..29588210c83883f4db7d90c16fe4bdcaf9bf197c 100644 (file)
@@ -70,7 +70,7 @@ public:
     }
 
     PlatformWheelEvent(IntPoint position, IntPoint globalPosition, float deltaX, float deltaY, float wheelTicksX, float wheelTicksY, PlatformWheelEventGranularity granularity, bool shiftKey, bool ctrlKey, bool altKey, bool metaKey)
-        : PlatformEvent(PlatformEvent::Wheel, shiftKey, ctrlKey, altKey, metaKey, 0)
+        : PlatformEvent(PlatformEvent::Wheel, shiftKey, ctrlKey, altKey, metaKey, { })
         , m_position(position)
         , m_globalPosition(globalPosition)
         , m_deltaX(deltaX)
index d379e2474d166654a4c129cccb0f1ede3e6325e3..0b2b28180c443636b549badc55bcfba9abe455ec 100644 (file)
@@ -179,14 +179,14 @@ bool ScrollController::handleWheelEvent(const PlatformWheelEvent& wheelEvent)
     if (!m_momentumScrollInProgress && (momentumPhase == PlatformWheelEventPhaseBegan || momentumPhase == PlatformWheelEventPhaseChanged))
         m_momentumScrollInProgress = true;
 
-    CFTimeInterval timeDelta = wheelEvent.timestamp() - m_lastMomentumScrollTimestamp;
+    CFTimeInterval timeDelta = wheelEvent.timestamp().secondsSinceEpoch().value() - m_lastMomentumScrollTimestamp;
     if (m_inScrollGesture || m_momentumScrollInProgress) {
         if (m_lastMomentumScrollTimestamp && timeDelta > 0 && timeDelta < scrollVelocityZeroingTimeout) {
             m_momentumVelocity.setWidth(eventCoalescedDeltaX / (float)timeDelta);
             m_momentumVelocity.setHeight(eventCoalescedDeltaY / (float)timeDelta);
-            m_lastMomentumScrollTimestamp = wheelEvent.timestamp();
+            m_lastMomentumScrollTimestamp = wheelEvent.timestamp().secondsSinceEpoch().value();
         } else {
-            m_lastMomentumScrollTimestamp = wheelEvent.timestamp();
+            m_lastMomentumScrollTimestamp = wheelEvent.timestamp().secondsSinceEpoch().value();
             m_momentumVelocity = FloatSize();
         }
 
index bfa4c6c10e4b19e5051008235690bf3ab7704e98..a5e6853ae2dc6101f1d6c7a2bceada1b30690d31 100644 (file)
@@ -49,7 +49,7 @@
 namespace WebCore {
 
 #if ENABLE(DRAG_SUPPORT)
-const double EventHandler::TextDragDelay = 0.0;
+const Seconds EventHandler::TextDragDelay { 0_s };
 #endif
 
 bool EventHandler::tabsToAllFormControls(KeyboardEvent&) const
index d9b95a97ddb9761fd3c076af8aa796d63f1359b5..4fc13becc3ab2d61aed44b9fe8c2a1718e0f1f16 100644 (file)
@@ -1259,7 +1259,7 @@ static OptionSet<PlatformEvent::Modifier> modifiersForGdkKeyEvent(GdkEventKey* e
 
 // Keep this in sync with the other platform event constructors
 PlatformKeyboardEvent::PlatformKeyboardEvent(GdkEventKey* event, const CompositionResults& compositionResults)
-    : PlatformEvent(eventTypeForGdkKeyEvent(event), modifiersForGdkKeyEvent(event), currentTime())
+    : PlatformEvent(eventTypeForGdkKeyEvent(event), modifiersForGdkKeyEvent(event), WallTime::now())
     , m_text(compositionResults.simpleString.length() ? compositionResults.simpleString : singleCharacterString(event->keyval))
     , m_unmodifiedText(m_text)
     , m_key(keyValueForGdkKeyCode(event->keyval))
index b6924856cb8b03ce68991e42f5d53a31ad6e578d..ec91afeef7a5bf1da05e9492bab026c4dd0a9a80 100644 (file)
@@ -38,7 +38,7 @@ namespace WebCore {
 // Keep this in sync with the other platform event constructors
 PlatformMouseEvent::PlatformMouseEvent(GdkEventButton* event)
 {
-    m_timestamp = event->time;
+    m_timestamp = WallTime::fromRawSeconds(event->time);
     m_position = IntPoint((int)event->x, (int)event->y);
     m_globalPosition = IntPoint((int)event->x_root, (int)event->y_root);
     m_button = NoButton;
@@ -87,7 +87,7 @@ PlatformMouseEvent::PlatformMouseEvent(GdkEventButton* event)
 
 PlatformMouseEvent::PlatformMouseEvent(GdkEventMotion* motion)
 {
-    m_timestamp = motion->time;
+    m_timestamp = WallTime::fromRawSeconds(motion->time);
     m_position = IntPoint((int)motion->x, (int)motion->y);
     m_globalPosition = IntPoint((int)motion->x_root, (int)motion->y_root);
     m_button = NoButton;
index 3b0e5906fcd502cf9c5d7dcaa9ec7a2d9ac23c8e..4e6d792520c48471778c9933ea6254921470af70 100644 (file)
@@ -33,7 +33,7 @@
 #include "Scrollbar.h"
 #include <gdk/gdk.h>
 #include <gtk/gtk.h>
-#include <wtf/CurrentTime.h>
+#include <wtf/WallTime.h>
 
 namespace WebCore {
 
@@ -43,7 +43,7 @@ PlatformWheelEvent::PlatformWheelEvent(GdkEventScroll* event)
     static const float delta = 1;
 
     m_type = PlatformEvent::Wheel;
-    m_timestamp = currentTime();
+    m_timestamp = WallTime::now();
 
     if (event->state & GDK_SHIFT_MASK)
         m_modifiers |= Modifier::ShiftKey;
index c2aa9dc01f767eea98e313a864a6a2782ba8f04b..43df2303fd87110d00189975c99a1febc443b243 100644 (file)
@@ -112,8 +112,8 @@ FloatPoint ScrollAnimatorGtk::computeVelocity()
     if (m_scrollHistory.isEmpty())
         return { };
 
-    double first = m_scrollHistory[0].timestamp();
-    double last = m_scrollHistory.rbegin()->timestamp();
+    auto first = m_scrollHistory[0].timestamp();
+    auto last = m_scrollHistory.rbegin()->timestamp();
 
     if (last == first)
         return { };
@@ -124,7 +124,7 @@ FloatPoint ScrollAnimatorGtk::computeVelocity()
 
     m_scrollHistory.clear();
 
-    return FloatPoint(accumDelta.x() * -1000 / (last - first), accumDelta.y() * -1000 / (last - first));
+    return FloatPoint(accumDelta.x() * -1000 / (last - first).value(), accumDelta.y() * -1000 / (last - first).value());
 }
 
 bool ScrollAnimatorGtk::handleWheelEvent(const PlatformWheelEvent& event)
@@ -132,7 +132,7 @@ bool ScrollAnimatorGtk::handleWheelEvent(const PlatformWheelEvent& event)
     m_kineticAnimation->stop();
 
     m_scrollHistory.removeAllMatching([&event] (PlatformWheelEvent& otherEvent) -> bool {
-        return Seconds::fromMilliseconds(event.timestamp() - otherEvent.timestamp()) > scrollCaptureThreshold;
+        return (event.timestamp() - otherEvent.timestamp()) > scrollCaptureThreshold;
     });
 
     if (event.isEndOfNonMomentumScroll()) {
index 062f9823771bdfa36029e25689f3d8f163923146..48c840332b89bfa926101760b7fb081c210d5463 100644 (file)
@@ -32,7 +32,7 @@
 #import "WAKAppKitStubs.h"
 #import "WebEvent.h"
 #import "WindowsKeyboardCodes.h"
-#import <wtf/CurrentTime.h>
+#import <wtf/WallTime.h>
 
 namespace WebCore {
 
@@ -85,7 +85,7 @@ public:
     PlatformMouseEventBuilder(WebEvent *event)
     {
         m_type = mouseEventType(event);
-        m_timestamp = currentTime();
+        m_timestamp = WallTime::now();
 
         m_position = pointForEvent(event);
         m_globalPosition = globalPointForEvent(event);
@@ -106,7 +106,7 @@ public:
         ASSERT(event.type == WebEventScrollWheel);
 
         m_type = PlatformEvent::Wheel;
-        m_timestamp = currentTime();
+        m_timestamp = WallTime::now();
 
         m_position = pointForEvent(event);
         m_globalPosition = globalPointForEvent(event);
@@ -369,7 +369,7 @@ public:
 
         m_type = (event.type == WebEventKeyUp ? PlatformEvent::KeyUp : PlatformEvent::KeyDown);
         m_modifiers = modifiersForEvent(event);
-        m_timestamp = currentTime();
+        m_timestamp = WallTime::now();
 
         m_text = event.characters;
         m_unmodifiedText = event.charactersIgnoringModifiers;
@@ -475,7 +475,7 @@ public:
     {
         m_type = touchEventType(event);
         m_modifiers = modifiersForEvent(event);
-        m_timestamp = event.timestamp;
+        m_timestamp = WallTime::fromRawSeconds(event.timestamp);
 
         m_gestureScale = event.gestureScale;
         m_gestureRotation = event.gestureRotation;
@@ -496,7 +496,7 @@ public:
     PlatformTouchEventBuilder(PlatformEvent::Type type, IntPoint location)
     {
         m_type = type;
-        m_timestamp = currentTime();
+        m_timestamp = WallTime::now();
         
         m_gestureScale = 1;
         m_gestureRotation = 0;
index d20a2d8ee90f4c1867b96e594921959c4f6c026f..c40ec21f12a178df88e9bf2904a0d7fd7795b926 100644 (file)
@@ -48,7 +48,7 @@ WEBCORE_EXPORT int windowsKeyCodeForKeyEvent(NSEvent *);
 WEBCORE_EXPORT String keyIdentifierForKeyEvent(NSEvent *);
 WEBCORE_EXPORT String keyForKeyEvent(NSEvent *);
 WEBCORE_EXPORT String codeForKeyEvent(NSEvent *);
-WEBCORE_EXPORT double eventTimeStampSince1970(NSEvent *);
+WEBCORE_EXPORT WallTime eventTimeStampSince1970(NSEvent *);
     
 WEBCORE_EXPORT void getWheelEventDeltas(NSEvent *, float& deltaX, float& deltaY, BOOL& continuous);
 WEBCORE_EXPORT UInt8 keyCharForEvent(NSEvent *);
index 2b18224f8349ffbb6e3c18a8d1541545d9c2ab62..7941cd6c4dd2828c6d6f739c0b252a4798c56990 100644 (file)
@@ -39,6 +39,7 @@
 #import <pal/spi/mac/NSEventSPI.h>
 #import <pal/spi/mac/NSMenuSPI.h>
 #import <wtf/ASCIICType.h>
+#import <wtf/WallTime.h>
 
 namespace WebCore {
 
@@ -617,9 +618,9 @@ static CFTimeInterval cachedStartupTimeIntervalSince1970()
     return systemStartupTime;
 }
 
-double eventTimeStampSince1970(NSEvent* event)
+WallTime eventTimeStampSince1970(NSEvent* event)
 {
-    return static_cast<double>(cachedStartupTimeIntervalSince1970() + [event timestamp]);
+    return WallTime::fromRawSeconds(static_cast<double>(cachedStartupTimeIntervalSince1970() + [event timestamp]));
 }
 
 static inline bool isKeyUpEvent(NSEvent *event)
index 6555aef098fdb0d03084241ec78f18d241030c4a..62ccac3b885127e26c0c9ec5ee7a27c734f61b49 100644 (file)
@@ -220,7 +220,7 @@ static inline String singleCharacterString(UChar c)
 }
 
 PlatformKeyboardEvent::PlatformKeyboardEvent(HWND, WPARAM code, LPARAM keyData, Type type, bool systemKey)
-    : PlatformEvent(type, GetKeyState(VK_SHIFT) & HIGH_BIT_MASK_SHORT, GetKeyState(VK_CONTROL) & HIGH_BIT_MASK_SHORT, GetKeyState(VK_MENU) & HIGH_BIT_MASK_SHORT, false, ::GetTickCount() * 0.001)
+    : PlatformEvent(type, GetKeyState(VK_SHIFT) & HIGH_BIT_MASK_SHORT, GetKeyState(VK_CONTROL) & HIGH_BIT_MASK_SHORT, GetKeyState(VK_MENU) & HIGH_BIT_MASK_SHORT, false, WallTime::fromRawSeconds(::GetTickCount() * 0.001))
     , m_text((type == PlatformEvent::Char) ? singleCharacterString(code) : String())
     , m_unmodifiedText((type == PlatformEvent::Char) ? singleCharacterString(code) : String())
     , m_keyIdentifier((type == PlatformEvent::Char) ? String() : keyIdentifierForWindowsKeyCode(code))
index 000fd3ac33185582419932d5c257f68e9366676d..ea247c9e6c58f42fef4dfaa312caddea0a86c1bc 100644 (file)
@@ -81,7 +81,7 @@ static PlatformEvent::Type messageToEventType(UINT message)
 }
 
 PlatformMouseEvent::PlatformMouseEvent(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, bool didActivateWebView)
-    : PlatformEvent(messageToEventType(message), wParam & MK_SHIFT, wParam & MK_CONTROL, GetKeyState(VK_MENU) & HIGH_BIT_MASK_SHORT, GetKeyState(VK_MENU) & HIGH_BIT_MASK_SHORT, currentTime())
+    : PlatformEvent(messageToEventType(message), wParam & MK_SHIFT, wParam & MK_CONTROL, GetKeyState(VK_MENU) & HIGH_BIT_MASK_SHORT, GetKeyState(VK_MENU) & HIGH_BIT_MASK_SHORT, WallTime::now())
     , m_position(positionForEvent(hWnd, lParam))
     , m_globalPosition(globalPositionForEvent(hWnd, lParam))
     , m_clickCount(0)
index 9ef248bc74f6d505eeb7ed672be93fe3875c5128..6dbea20e462f04cb70a7fd358515986c8a86b08d 100644 (file)
@@ -73,7 +73,7 @@ static int verticalScrollLines()
 }
 
 PlatformWheelEvent::PlatformWheelEvent(HWND hWnd, const FloatSize& delta, const FloatPoint& location)
-    : PlatformEvent(PlatformEvent::Wheel, false, false, false, false, ::GetTickCount() * 0.001)
+    : PlatformEvent(PlatformEvent::Wheel, false, false, false, false, WallTime::fromRawSeconds(::GetTickCount() * 0.001))
     , m_directionInvertedFromDevice(false)
 {
     m_deltaX = delta.width();
@@ -95,7 +95,7 @@ PlatformWheelEvent::PlatformWheelEvent(HWND hWnd, const FloatSize& delta, const
 }
 
 PlatformWheelEvent::PlatformWheelEvent(HWND hWnd, WPARAM wParam, LPARAM lParam, bool isMouseHWheel)
-    : PlatformEvent(PlatformEvent::Wheel, wParam & MK_SHIFT, wParam & MK_CONTROL, GetKeyState(VK_MENU) & HIGH_BIT_MASK_SHORT, GetKeyState(VK_MENU) & HIGH_BIT_MASK_SHORT, ::GetTickCount() * 0.001)
+    : PlatformEvent(PlatformEvent::Wheel, wParam & MK_SHIFT, wParam & MK_CONTROL, GetKeyState(VK_MENU) & HIGH_BIT_MASK_SHORT, GetKeyState(VK_MENU) & HIGH_BIT_MASK_SHORT, WallTime::fromRawSeconds(::GetTickCount() * 0.001))
     , m_position(positionForEvent(hWnd, lParam))
     , m_globalPosition(globalPositionForEvent(hWnd, lParam))
     , m_directionInvertedFromDevice(false)
index 9513c226ba9c9d9398da77ab2b1666aff14357ec..ff8af395708339003a4081215d5c2d6ab739cd00 100644 (file)
@@ -1,3 +1,74 @@
+2017-09-22  Chris Dumez  <cdumez@apple.com>
+
+        Use high resolution timestamp for event time
+        https://bugs.webkit.org/show_bug.cgi?id=154246
+        <rdar://problem/34333304>
+
+        Reviewed by Ryosuke Niwa.
+
+        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):
+
 2017-09-22  Fujii Hironori  <Hironori.Fujii@sony.com>
 
         [GTK] Web Inspector: Can't load three.js
index e7d41c71039d193642b129a228d9ed90af185538..aa9980c34247c6ea89f9559a2df95a4f28c191e1 100644 (file)
@@ -75,6 +75,7 @@
 #include <pal/SessionID.h>
 #include <wtf/MonotonicTime.h>
 #include <wtf/Seconds.h>
+#include <wtf/WallTime.h>
 #include <wtf/text/CString.h>
 #include <wtf/text/StringHash.h>
 
@@ -160,6 +161,21 @@ bool ArgumentCoder<MonotonicTime>::decode(Decoder& decoder, MonotonicTime& time)
     return true;
 }
 
+void ArgumentCoder<WallTime>::encode(Encoder& encoder, const WallTime& time)
+{
+    encoder << time.secondsSinceEpoch().value();
+}
+
+bool ArgumentCoder<WallTime>::decode(Decoder& decoder, WallTime& time)
+{
+    double value;
+    if (!decoder.decode(value))
+        return false;
+
+    time = WallTime::fromRawSeconds(value);
+    return true;
+}
+
 void ArgumentCoder<Seconds>::encode(Encoder& encoder, const Seconds& seconds)
 {
     encoder << seconds.value();
index 5b5fd3974134a9d4a99449b5b997598639124c6e..08c38390b84ce48741cd44fe141ee56b84b92c43 100644 (file)
@@ -43,6 +43,7 @@
 namespace WTF {
 class MonotonicTime;
 class Seconds;
+class WallTime;
 }
 
 namespace WebCore {
@@ -162,6 +163,11 @@ template<> struct ArgumentCoder<WTF::MonotonicTime> {
     static bool decode(Decoder&, WTF::MonotonicTime&);
 };
 
+template<> struct ArgumentCoder<WTF::WallTime> {
+    static void encode(Encoder&, const WTF::WallTime&);
+    static bool decode(Decoder&, WTF::WallTime&);
+};
+
 template<> struct ArgumentCoder<WTF::Seconds> {
     static void encode(Encoder&, const WTF::Seconds&);
     static bool decode(Decoder&, WTF::Seconds&);
index 507bc166289ed5e26246fb9c5b7e707e802d19bc..5a086f97b8394a8c884ff60ff7957facde5df57f 100644 (file)
 
 #include "Decoder.h"
 #include "Encoder.h"
+#include "WebCoreArgumentCoders.h"
 
 namespace WebKit {
 
 WebEvent::WebEvent()
     : m_type(static_cast<uint32_t>(NoType))
     , m_modifiers(0)
-    , m_timestamp(0)
 {
 }
 
-WebEvent::WebEvent(Type type, Modifiers modifiers, double timestamp)
+WebEvent::WebEvent(Type type, Modifiers modifiers, WallTime timestamp)
     : m_type(type)
     , m_modifiers(modifiers)
     , m_timestamp(timestamp)
index 210186dc0fdc0f6620542badaac2a63dc8bf3e21..2d459f6a106f681af88a375e3ee65f5b2be3978a 100644 (file)
@@ -34,6 +34,7 @@
 #include <WebCore/FloatSize.h>
 #include <WebCore/IntPoint.h>
 #include <WebCore/IntSize.h>
+#include <wtf/WallTime.h>
 #include <wtf/text/WTFString.h>
 
 namespace IPC {
@@ -104,12 +105,12 @@ public:
 
     Modifiers modifiers() const { return static_cast<Modifiers>(m_modifiers); }
 
-    double timestamp() const { return m_timestamp; }
+    WallTime timestamp() const { return m_timestamp; }
 
 protected:
     WebEvent();
 
-    WebEvent(Type, Modifiers, double timestamp);
+    WebEvent(Type, Modifiers, WallTime timestamp);
 
     void encode(IPC::Encoder&) const;
     static bool decode(IPC::Decoder&, WebEvent&);
@@ -117,7 +118,7 @@ protected:
 private:
     uint32_t m_type; // Type
     uint32_t m_modifiers; // Modifiers
-    double m_timestamp;
+    WallTime m_timestamp;
 };
 
 // FIXME: Move this class to its own header file.
@@ -135,9 +136,9 @@ public:
     WebMouseEvent();
 
 #if PLATFORM(MAC)
-    WebMouseEvent(Type, Button, const WebCore::IntPoint& position, const WebCore::IntPoint& globalPosition, float deltaX, float deltaY, float deltaZ, int clickCount, Modifiers, double timestamp, double force, SyntheticClickType = NoTap, int eventNumber = -1, int menuType = 0);
+    WebMouseEvent(Type, Button, const WebCore::IntPoint& position, const WebCore::IntPoint& globalPosition, float deltaX, float deltaY, float deltaZ, int clickCount, Modifiers, WallTime timestamp, double force, SyntheticClickType = NoTap, int eventNumber = -1, int menuType = 0);
 #else
-    WebMouseEvent(Type, Button, const WebCore::IntPoint& position, const WebCore::IntPoint& globalPosition, float deltaX, float deltaY, float deltaZ, int clickCount, Modifiers, double timestamp, double force = 0, SyntheticClickType = NoTap);
+    WebMouseEvent(Type, Button, const WebCore::IntPoint& position, const WebCore::IntPoint& globalPosition, float deltaX, float deltaY, float deltaZ, int clickCount, Modifiers, WallTime timestamp, double force = 0, SyntheticClickType = NoTap);
 #endif
 
     Button button() const { return static_cast<Button>(m_button); }
@@ -197,11 +198,11 @@ public:
 
     WebWheelEvent() { }
 
-    WebWheelEvent(Type, const WebCore::IntPoint& position, const WebCore::IntPoint& globalPosition, const WebCore::FloatSize& delta, const WebCore::FloatSize& wheelTicks, Granularity, Modifiers, double timestamp);
+    WebWheelEvent(Type, const WebCore::IntPoint& position, const WebCore::IntPoint& globalPosition, const WebCore::FloatSize& delta, const WebCore::FloatSize& wheelTicks, Granularity, Modifiers, WallTime timestamp);
 #if PLATFORM(COCOA)
-    WebWheelEvent(Type, const WebCore::IntPoint& position, const WebCore::IntPoint& globalPosition, const WebCore::FloatSize& delta, const WebCore::FloatSize& wheelTicks, Granularity, bool directionInvertedFromDevice, Phase, Phase momentumPhase, bool hasPreciseScrollingDeltas, uint32_t scrollCount, const WebCore::FloatSize& unacceleratedScrollingDelta, Modifiers, double timestamp);
+    WebWheelEvent(Type, const WebCore::IntPoint& position, const WebCore::IntPoint& globalPosition, const WebCore::FloatSize& delta, const WebCore::FloatSize& wheelTicks, Granularity, bool directionInvertedFromDevice, Phase, Phase momentumPhase, bool hasPreciseScrollingDeltas, uint32_t scrollCount, const WebCore::FloatSize& unacceleratedScrollingDelta, Modifiers, WallTime timestamp);
 #elif PLATFORM(GTK)
-    WebWheelEvent(Type, const WebCore::IntPoint& position, const WebCore::IntPoint& globalPosition, const WebCore::FloatSize& delta, const WebCore::FloatSize& wheelTicks, Phase, Phase momentumPhase, Granularity, Modifiers, double timestamp);
+    WebWheelEvent(Type, const WebCore::IntPoint& position, const WebCore::IntPoint& globalPosition, const WebCore::FloatSize& delta, const WebCore::FloatSize& wheelTicks, Phase, Phase momentumPhase, Granularity, Modifiers, WallTime timestamp);
 #endif
 
     const WebCore::IntPoint position() const { return m_position; }
@@ -250,13 +251,13 @@ public:
     ~WebKeyboardEvent();
 
 #if USE(APPKIT)
-    WebKeyboardEvent(Type, const String& text, const String& unmodifiedText, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, int macCharCode, bool handledByInputMethod, const Vector<WebCore::KeypressCommand>&, bool isAutoRepeat, bool isKeypad, bool isSystemKey, Modifiers, double timestamp);
+    WebKeyboardEvent(Type, const String& text, const String& unmodifiedText, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, int macCharCode, bool handledByInputMethod, const Vector<WebCore::KeypressCommand>&, bool isAutoRepeat, bool isKeypad, bool isSystemKey, Modifiers, WallTime timestamp);
 #elif PLATFORM(GTK)
-    WebKeyboardEvent(Type, const String& text, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool handledByInputMethod, Vector<String>&& commands, bool isKeypad, Modifiers, double timestamp);
+    WebKeyboardEvent(Type, const String& text, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool handledByInputMethod, Vector<String>&& commands, bool isKeypad, Modifiers, WallTime timestamp);
 #elif PLATFORM(IOS)
-    WebKeyboardEvent(Type, const String& text, const String& unmodifiedText, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, int macCharCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, Modifiers, double timestamp);
+    WebKeyboardEvent(Type, const String& text, const String& unmodifiedText, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, int macCharCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, Modifiers, WallTime timestamp);
 #else
-    WebKeyboardEvent(Type, const String& text, const String& unmodifiedText, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, int macCharCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, Modifiers, double timestamp);
+    WebKeyboardEvent(Type, const String& text, const String& unmodifiedText, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, int macCharCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, Modifiers, WallTime timestamp);
 #endif
 
     const String& text() const { return m_text; }
@@ -382,7 +383,7 @@ private:
 class WebTouchEvent : public WebEvent {
 public:
     WebTouchEvent() { }
-    WebTouchEvent(WebEvent::Type type, Modifiers modifiers, double timestamp, const Vector<WebPlatformTouchPoint>& touchPoints, WebCore::IntPoint position, bool isPotentialTap, bool isGesture, float gestureScale, float gestureRotation)
+    WebTouchEvent(WebEvent::Type type, Modifiers modifiers, WallTime timestamp, const Vector<WebPlatformTouchPoint>& touchPoints, WebCore::IntPoint position, bool isPotentialTap, bool isGesture, float gestureScale, float gestureRotation)
         : WebEvent(type, modifiers, timestamp)
         , m_touchPoints(touchPoints)
         , m_position(position)
@@ -471,7 +472,7 @@ private:
 class WebTouchEvent : public WebEvent {
 public:
     WebTouchEvent() { }
-    WebTouchEvent(Type, Vector<WebPlatformTouchPoint>&&, Modifiers, double timestamp);
+    WebTouchEvent(Type, Vector<WebPlatformTouchPoint>&&, Modifiers, WallTime timestamp);
 
     const Vector<WebPlatformTouchPoint>& touchPoints() const { return m_touchPoints; }
 
index eb4771fda5368e7fad2ad2f174c4472b526a26fc..0cf27199621cf6deda0ea4ed6603a9196e1cee77 100644 (file)
@@ -37,7 +37,7 @@ WebKeyboardEvent::WebKeyboardEvent()
 
 #if USE(APPKIT)
 
-WebKeyboardEvent::WebKeyboardEvent(Type type, const String& text, const String& unmodifiedText, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, int macCharCode, bool handledByInputMethod, const Vector<WebCore::KeypressCommand>& commands, bool isAutoRepeat, bool isKeypad, bool isSystemKey, Modifiers modifiers, double timestamp)
+WebKeyboardEvent::WebKeyboardEvent(Type type, const String& text, const String& unmodifiedText, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, int macCharCode, bool handledByInputMethod, const Vector<WebCore::KeypressCommand>& commands, bool isAutoRepeat, bool isKeypad, bool isSystemKey, Modifiers modifiers, WallTime timestamp)
     : WebEvent(type, modifiers, timestamp)
     , m_text(text)
     , m_unmodifiedText(unmodifiedText)
@@ -62,7 +62,7 @@ WebKeyboardEvent::WebKeyboardEvent(Type type, const String& text, const String&
 
 #elif PLATFORM(GTK)
 
-WebKeyboardEvent::WebKeyboardEvent(Type type, const String& text, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool handledByInputMethod, Vector<String>&& commands, bool isKeypad, Modifiers modifiers, double timestamp)
+WebKeyboardEvent::WebKeyboardEvent(Type type, const String& text, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool handledByInputMethod, Vector<String>&& commands, bool isKeypad, Modifiers modifiers, WallTime timestamp)
     : WebEvent(type, modifiers, timestamp)
     , m_text(text)
     , m_unmodifiedText(text)
@@ -83,7 +83,7 @@ WebKeyboardEvent::WebKeyboardEvent(Type type, const String& text, const String&
 
 #elif PLATFORM(IOS)
 
-WebKeyboardEvent::WebKeyboardEvent(Type type, const String& text, const String& unmodifiedText, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, int macCharCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, Modifiers modifiers, double timestamp)
+WebKeyboardEvent::WebKeyboardEvent(Type type, const String& text, const String& unmodifiedText, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, int macCharCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, Modifiers modifiers, WallTime timestamp)
     : WebEvent(type, modifiers, timestamp)
     , m_text(text)
     , m_unmodifiedText(unmodifiedText)
@@ -106,7 +106,7 @@ WebKeyboardEvent::WebKeyboardEvent(Type type, const String& text, const String&
 
 #else
 
-WebKeyboardEvent::WebKeyboardEvent(Type type, const String& text, const String& unmodifiedText, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, int macCharCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, Modifiers modifiers, double timestamp)
+WebKeyboardEvent::WebKeyboardEvent(Type type, const String& text, const String& unmodifiedText, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, int macCharCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, Modifiers modifiers, WallTime timestamp)
     : WebEvent(type, modifiers, timestamp)
     , m_text(text)
     , m_unmodifiedText(unmodifiedText)
index 8da8d3fe83360a570fdc47238279f19daa05f389..0f77fae3d0df78b753dec589f085c76eafbfb821 100644 (file)
@@ -47,9 +47,9 @@ WebMouseEvent::WebMouseEvent()
 }
 
 #if PLATFORM(MAC)
-WebMouseEvent::WebMouseEvent(Type type, Button button, const IntPoint& position, const IntPoint& globalPosition, float deltaX, float deltaY, float deltaZ, int clickCount, Modifiers modifiers, double timestamp, double force, SyntheticClickType syntheticClickType, int eventNumber, int menuType)
+WebMouseEvent::WebMouseEvent(Type type, Button button, const IntPoint& position, const IntPoint& globalPosition, float deltaX, float deltaY, float deltaZ, int clickCount, Modifiers modifiers, WallTime timestamp, double force, SyntheticClickType syntheticClickType, int eventNumber, int menuType)
 #else
-WebMouseEvent::WebMouseEvent(Type type, Button button, const IntPoint& position, const IntPoint& globalPosition, float deltaX, float deltaY, float deltaZ, int clickCount, Modifiers modifiers, double timestamp, double force, SyntheticClickType syntheticClickType)
+WebMouseEvent::WebMouseEvent(Type type, Button button, const IntPoint& position, const IntPoint& globalPosition, float deltaX, float deltaY, float deltaZ, int clickCount, Modifiers modifiers, WallTime timestamp, double force, SyntheticClickType syntheticClickType)
 #endif
     : WebEvent(type, modifiers, timestamp)
     , m_button(button)
index b9aacbaf6e7d07ad9c97f33f53003452bd792caf..7aea0e73d9c556a62777137d42723b071eddea1e 100644 (file)
@@ -32,7 +32,7 @@
 
 namespace WebKit {
 
-WebTouchEvent::WebTouchEvent(WebEvent::Type type, Vector<WebPlatformTouchPoint>&& touchPoints, Modifiers modifiers, double timestamp)
+WebTouchEvent::WebTouchEvent(WebEvent::Type type, Vector<WebPlatformTouchPoint>&& touchPoints, Modifiers modifiers, WallTime timestamp)
     : WebEvent(type, modifiers, timestamp)
     , m_touchPoints(WTFMove(touchPoints))
 {
index 13fe48de99d98dc9f6eaabf6f8452cfab144d24d..4e13e896521c34c8e1bc3c73cc8f23a52459f7ef 100644 (file)
@@ -32,7 +32,7 @@ using namespace WebCore;
 
 namespace WebKit {    
 
-WebWheelEvent::WebWheelEvent(Type type, const IntPoint& position, const IntPoint& globalPosition, const FloatSize& delta, const FloatSize& wheelTicks, Granularity granularity, Modifiers modifiers, double timestamp)
+WebWheelEvent::WebWheelEvent(Type type, const IntPoint& position, const IntPoint& globalPosition, const FloatSize& delta, const FloatSize& wheelTicks, Granularity granularity, Modifiers modifiers, WallTime timestamp)
     : WebEvent(type, modifiers, timestamp)
     , m_position(position)
     , m_globalPosition(globalPosition)
@@ -50,7 +50,7 @@ WebWheelEvent::WebWheelEvent(Type type, const IntPoint& position, const IntPoint
 }
 
 #if PLATFORM(COCOA)
-WebWheelEvent::WebWheelEvent(Type type, const IntPoint& position, const IntPoint& globalPosition, const FloatSize& delta, const FloatSize& wheelTicks, Granularity granularity, bool directionInvertedFromDevice, Phase phase, Phase momentumPhase, bool hasPreciseScrollingDeltas, uint32_t scrollCount, const WebCore::FloatSize& unacceleratedScrollingDelta, Modifiers modifiers, double timestamp)
+WebWheelEvent::WebWheelEvent(Type type, const IntPoint& position, const IntPoint& globalPosition, const FloatSize& delta, const FloatSize& wheelTicks, Granularity granularity, bool directionInvertedFromDevice, Phase phase, Phase momentumPhase, bool hasPreciseScrollingDeltas, uint32_t scrollCount, const WebCore::FloatSize& unacceleratedScrollingDelta, Modifiers modifiers, WallTime timestamp)
     : WebEvent(type, modifiers, timestamp)
     , m_position(position)
     , m_globalPosition(globalPosition)
@@ -67,7 +67,7 @@ WebWheelEvent::WebWheelEvent(Type type, const IntPoint& position, const IntPoint
     ASSERT(isWheelEventType(type));
 }
 #elif PLATFORM(GTK)
-WebWheelEvent::WebWheelEvent(Type type, const IntPoint& position, const IntPoint& globalPosition, const FloatSize& delta, const FloatSize& wheelTicks, Phase phase, Phase momentumPhase, Granularity granularity, Modifiers modifiers, double timestamp)
+WebWheelEvent::WebWheelEvent(Type type, const IntPoint& position, const IntPoint& globalPosition, const FloatSize& delta, const FloatSize& wheelTicks, Phase phase, Phase momentumPhase, Granularity granularity, Modifiers modifiers, WallTime timestamp)
     : WebEvent(type, modifiers, timestamp)
     , m_position(position)
     , m_globalPosition(globalPosition)
index 68d6d38859a02073e98a7c8a7ee626e309add5db..bcea329d2283ca984566637a1d8d75d516084a8c 100644 (file)
@@ -140,7 +140,7 @@ WebMouseEvent WebEventFactory::createWebMouseEvent(const GdkEvent* event, int cu
                          0 /* deltaZ */,
                          currentClickCount,
                          modifiersForEvent(event),
-                         gdk_event_get_time(event));
+                         WallTime::fromRawSeconds(gdk_event_get_time(event)));
 }
 
 WebWheelEvent WebEventFactory::createWebWheelEvent(const GdkEvent* event)
@@ -210,7 +210,7 @@ WebWheelEvent WebEventFactory::createWebWheelEvent(const GdkEvent* event, WebWhe
         momentumPhase,
         WebWheelEvent::ScrollByPixelWheelEvent,
         modifiersForEvent(event),
-        gdk_event_get_time(event));
+        WallTime::fromRawSeconds(gdk_event_get_time(event)));
 }
 
 WebKeyboardEvent WebEventFactory::createWebKeyboardEvent(const GdkEvent* event, const WebCore::CompositionResults& compositionResults, Vector<String>&& commands)
@@ -227,7 +227,7 @@ WebKeyboardEvent WebEventFactory::createWebKeyboardEvent(const GdkEvent* event,
         WTFMove(commands),
         isGdkKeyCodeFromKeyPad(event->key.keyval),
         modifiersForEvent(event),
-        gdk_event_get_time(event));
+        WallTime::fromRawSeconds(gdk_event_get_time(event)));
 }
 
 #if ENABLE(TOUCH_EVENTS)
@@ -249,7 +249,7 @@ WebTouchEvent WebEventFactory::createWebTouchEvent(const GdkEvent* event, Vector
         ASSERT_NOT_REACHED();
     }
 
-    return WebTouchEvent(type, WTFMove(touchPoints), modifiersForEvent(event), gdk_event_get_time(event));
+    return WebTouchEvent(type, WTFMove(touchPoints), modifiersForEvent(event), WallTime::fromRawSeconds(gdk_event_get_time(event)));
 #else
     return WebTouchEvent();
 #endif // GTK_API_VERSION_2
index 68e0e6cafdf5dc55af87da8383a17f53fb196cd5..7fc777e1f20f8289a1945f38befcd696e02fafab 100644 (file)
@@ -122,7 +122,7 @@ NativeWebTouchEvent::NativeWebTouchEvent(const _UIWebTouchEvent* event)
     : WebTouchEvent(
         webEventTypeForUIWebTouchEventType(event->type),
         static_cast<Modifiers>(0),
-        event->timestamp,
+        WallTime::fromRawSeconds(event->timestamp),
         extractWebTouchPoint(event),
         positionForCGPoint(event->locationInDocumentCoordinates),
 #if defined UI_WEB_TOUCH_EVENT_HAS_IS_POTENTIAL_TAP && UI_WEB_TOUCH_EVENT_HAS_IS_POTENTIAL_TAP
index 4e0259bdae71754756bfa2a3e69ac985f073a85e..90fbc28a678385560c8c93e86c6137031034bc7a 100644 (file)
@@ -85,7 +85,7 @@ WebKit::WebKeyboardEvent WebIOSEventFactory::createWebKeyboardEvent(::WebEvent *
         unmodifiedText = text;
     }
 
-    return WebKit::WebKeyboardEvent(type, text, unmodifiedText, key, code, keyIdentifier, windowsVirtualKeyCode, nativeVirtualKeyCode, macCharCode, autoRepeat, isKeypad, isSystemKey, modifiers, timestamp);
+    return WebKit::WebKeyboardEvent(type, text, unmodifiedText, key, code, keyIdentifier, windowsVirtualKeyCode, nativeVirtualKeyCode, macCharCode, autoRepeat, isKeypad, isSystemKey, modifiers, WallTime::fromRawSeconds(timestamp));
 }
 
 #endif // PLATFORM(IOS)
index 3b55ce8092fda3ca2a986203e0182b656519a238..0c45bffb1f64a42df5e38c6f29ddeefdc49d8cc9 100644 (file)
@@ -31,7 +31,7 @@
 #import "WebEvent.h"
 #import "WebGestureEvent.h"
 #import <WebCore/IntPoint.h>
-#import <wtf/CurrentTime.h>
+#import <WebCore/PlatformEventFactoryMac.h>
 
 namespace WebKit {
 
@@ -63,7 +63,7 @@ NativeWebGestureEvent::NativeWebGestureEvent(NSEvent *event, NSView *view)
     : WebGestureEvent(
         webEventTypeForNSEvent(event),
         static_cast<Modifiers>(0),
-        event.timestamp,
+        WebCore::eventTimeStampSince1970(event),
         WebCore::IntPoint(pointForEvent(event, view)),
         event.type == NSEventTypeMagnify ? event.magnification : 0,
         event.type == NSEventTypeRotate ? event.rotation : 0)
index 0db3be8c6474c7632985fe3ea2215b48c6afc05b..9d85594a366c65df2fcd17f3d085f13e1d613eb9 100644 (file)
@@ -360,7 +360,7 @@ WebMouseEvent WebEventFactory::createWebMouseEvent(NSEvent *event, NSEvent *last
     float deltaZ = [event deltaZ];
     int clickCount = clickCountForEvent(event);
     WebEvent::Modifiers modifiers = modifiersForEvent(event);
-    double timestamp = eventTimeStampSince1970(event);
+    auto timestamp = eventTimeStampSince1970(event);
     int eventNumber = [event eventNumber];
     int menuTypeForEvent = typeForEvent(event);
 
@@ -418,7 +418,7 @@ WebWheelEvent WebEventFactory::createWebWheelEvent(NSEvent *event, NSView *windo
     }
 
     WebEvent::Modifiers modifiers           = modifiersForEvent(event);
-    double timestamp                        = eventTimeStampSince1970(event);
+    auto timestamp                          = eventTimeStampSince1970(event);
     
     return WebWheelEvent(WebEvent::Wheel, IntPoint(position), IntPoint(globalPosition), FloatSize(deltaX, deltaY), FloatSize(wheelTicksX, wheelTicksY), granularity, directionInvertedFromDevice, phase, momentumPhase, hasPreciseScrollingDeltas, scrollCount, unacceleratedScrollingDelta, modifiers, timestamp);
 }
@@ -438,7 +438,7 @@ WebKeyboardEvent WebEventFactory::createWebKeyboardEvent(NSEvent *event, bool ha
     bool isKeypad                   = isKeypadEvent(event);
     bool isSystemKey                = false; // SystemKey is always false on the Mac.
     WebEvent::Modifiers modifiers   = modifiersForEvent(event);
-    double timestamp                = eventTimeStampSince1970(event);
+    auto timestamp                  = eventTimeStampSince1970(event);
 
     // Always use 13 for Enter/Return -- we don't want to use AppKit's different character for Enter.
     if (windowsVirtualKeyCode == VK_RETURN) {
index bc68ba527a5ec82d308b830f6bebe8c0f200c394..b6f9c68db03a5a5fbb695b2bc1cc314e8c55c28a 100644 (file)
@@ -45,7 +45,7 @@ namespace WebKit {
 class WebGestureEvent : public WebEvent {
 public:
     WebGestureEvent() { }
-    WebGestureEvent(WebEvent::Type type, Modifiers modifiers, double timestamp, WebCore::IntPoint position, float gestureScale, float gestureRotation)
+    WebGestureEvent(WebEvent::Type type, Modifiers modifiers, WallTime timestamp, WebCore::IntPoint position, float gestureScale, float gestureRotation)
         : WebEvent(type, modifiers, timestamp)
         , m_position(position)
         , m_gestureScale(gestureScale)
index e0ac6ef85a94a72b22eede070689c72f5ceef976..94741306633a83a94e40dc80e45b99d99e5b17a4 100644 (file)
@@ -81,7 +81,7 @@ WebKeyboardEvent WebEventFactory::createWebKeyboardEvent(struct wpe_input_keyboa
         singleCharacterString, singleCharacterString, identifierString,
         wpe_input_windows_key_code_for_key_event(wpe_input_key_mapper_get_singleton(), event),
         event->keyCode, 0, false, false, false,
-        modifiersForEvent(event), event->time);
+        modifiersForEvent(event), WallTime::fromRawSeconds(event->time));
 }
 
 WebMouseEvent WebEventFactory::createWebMouseEvent(struct wpe_input_pointer_event* event, float deviceScaleFactor)
@@ -119,7 +119,7 @@ WebMouseEvent WebEventFactory::createWebMouseEvent(struct wpe_input_pointer_even
     WebCore::IntPoint position(event->x, event->y);
     position.scale(1 / deviceScaleFactor);
     return WebMouseEvent(type, button, position, position,
-        0, 0, 0, clickCount, static_cast<WebEvent::Modifiers>(0), event->time);
+        0, 0, 0, clickCount, static_cast<WebEvent::Modifiers>(0), WallTime::fromRawSeconds(event->time));
 }
 
 WebWheelEvent WebEventFactory::createWebWheelEvent(struct wpe_input_axis_event* event, float deviceScaleFactor)
@@ -154,7 +154,7 @@ WebWheelEvent WebEventFactory::createWebWheelEvent(struct wpe_input_axis_event*
     WebCore::IntPoint position(event->x, event->y);
     position.scale(1 / deviceScaleFactor);
     return WebWheelEvent(WebEvent::Wheel, position, position,
-        delta, wheelTicks, WebWheelEvent::ScrollByPixelWheelEvent, static_cast<WebEvent::Modifiers>(0), event->time);
+        delta, wheelTicks, WebWheelEvent::ScrollByPixelWheelEvent, static_cast<WebEvent::Modifiers>(0), WallTime::fromRawSeconds(event->time));
 }
 
 static WebKit::WebPlatformTouchPoint::TouchPointState stateForTouchPoint(int mainEventId, const struct wpe_input_touch_event_raw* point)
@@ -209,7 +209,7 @@ WebTouchEvent WebEventFactory::createWebTouchEvent(struct wpe_input_touch_event*
                 pointCoordinates, pointCoordinates));
     }
 
-    return WebTouchEvent(type, WTFMove(touchPoints), WebEvent::Modifiers(0), event->time);
+    return WebTouchEvent(type, WTFMove(touchPoints), WebEvent::Modifiers(0), WallTime::fromRawSeconds(event->time));
 }
 
 } // namespace WebKit
index 5df3dfc3e6e20b4f39b1df5984445af618d4c0bf..07edabfb6fc7ffcaf2f076558ffa4c509a825304 100644 (file)
@@ -478,17 +478,17 @@ void WKBundlePageForceRepaint(WKBundlePageRef page)
 
 void WKBundlePageSimulateMouseDown(WKBundlePageRef page, int button, WKPoint position, int clickCount, WKEventModifiers modifiers, double time)
 {
-    toImpl(page)->simulateMouseDown(button, toIntPoint(position), clickCount, modifiers, time);
+    toImpl(page)->simulateMouseDown(button, toIntPoint(position), clickCount, modifiers, WallTime::fromRawSeconds(time));
 }
 
 void WKBundlePageSimulateMouseUp(WKBundlePageRef page, int button, WKPoint position, int clickCount, WKEventModifiers modifiers, double time)
 {
-    toImpl(page)->simulateMouseUp(button, toIntPoint(position), clickCount, modifiers, time);
+    toImpl(page)->simulateMouseUp(button, toIntPoint(position), clickCount, modifiers, WallTime::fromRawSeconds(time));
 }
 
 void WKBundlePageSimulateMouseMotion(WKBundlePageRef page, WKPoint position, double time)
 {
-    toImpl(page)->simulateMouseMotion(toIntPoint(position), time);
+    toImpl(page)->simulateMouseMotion(toIntPoint(position), WallTime::fromRawSeconds(time));
 }
 
 uint64_t WKBundlePageGetRenderTreeSize(WKBundlePageRef pageRef)
index 2618fe6c2ef8566ee273c6a738f03106c622299b..e7ed7d844c6ae656ccc7c937016c73deec932c3e 100644 (file)
@@ -361,7 +361,7 @@ guint32 webkit_dom_event_get_time_stamp(WebKitDOMEvent* self)
     WebCore::JSMainThreadNullState state;
     g_return_val_if_fail(WEBKIT_DOM_IS_EVENT(self), 0);
     WebCore::Event* item = WebKit::core(self);
-    guint32 result = item->timeStamp();
+    guint32 result = item->timeStamp().approximateWallTime().secondsSinceEpoch().milliseconds();
     return result;
 }
 
index db245ccd4fb67229ac192a3e1ad0d7092fa853c2..9a51634bde06d84cc9a4b5cd833c3484a78a8194 100644 (file)
@@ -321,9 +321,9 @@ static inline void initializeXEvent(XEvent& event)
     event.xany.window = 0;
 }
 
-static inline uint64_t xTimeStamp(double timestampInSeconds)
+static inline uint64_t xTimeStamp(WallTime timestamp)
 {
-    return timestampInSeconds * 1000;
+    return timestamp.secondsSinceEpoch().milliseconds();
 }
 
 static inline unsigned xKeyModifiers(const WebEvent& event)
index afcffa51745b25b9e740428307faced548decaa1..86fe36b1ffd8ad0cefe25ad4d7e8ca4518c6a89a 100644 (file)
@@ -1576,7 +1576,7 @@ bool PDFPlugin::showContextMenuAtPoint(const IntPoint& point)
 {
     FrameView* frameView = webFrame()->coreFrame()->view();
     IntPoint contentsPoint = frameView->contentsToRootView(point);
-    WebMouseEvent event(WebEvent::MouseDown, WebMouseEvent::RightButton, contentsPoint, contentsPoint, 0, 0, 0, 1, static_cast<WebEvent::Modifiers>(0), monotonicallyIncreasingTime(), WebCore::ForceAtClick);
+    WebMouseEvent event(WebEvent::MouseDown, WebMouseEvent::RightButton, contentsPoint, contentsPoint, 0, 0, 0, 1, static_cast<WebEvent::Modifiers>(0), WallTime::now(), WebCore::ForceAtClick);
     return handleContextMenuEvent(event);
 }
 
index a648f7eabfebeed0a6e75e86c62e0b4a2c1ccd53..ecd567fcc3c5de52a50a828f6e6845358123f297 100644 (file)
@@ -897,7 +897,7 @@ std::unique_ptr<WebEvent> PluginView::createWebEvent(MouseEvent& event) const
     if (event.metaKey())
         modifiers |= WebEvent::MetaKey;
 
-    return std::make_unique<WebMouseEvent>(type, button, m_plugin->convertToRootView(IntPoint(event.offsetX(), event.offsetY())), event.screenLocation(), 0, 0, 0, clickCount, static_cast<WebEvent::Modifiers>(modifiers), 0, 0);
+    return std::make_unique<WebMouseEvent>(type, button, m_plugin->convertToRootView(IntPoint(event.offsetX(), event.offsetY())), event.screenLocation(), 0, 0, 0, clickCount, static_cast<WebEvent::Modifiers>(modifiers), WallTime { }, 0);
 }
 
 void PluginView::handleEvent(Event& event)
index 0eabe65990d917e1d91d91e2b9e4fb30d842b15a..ff8bb98040501c19200403ce4f49b3598224b7ba 100644 (file)
@@ -1281,7 +1281,7 @@ void WebPage::navigateToPDFLinkWithSimulatedClick(const String& url, IntPoint do
         return;
 
     const int singleClick = 1;
-    RefPtr<MouseEvent> mouseEvent = MouseEvent::create(eventNames().clickEvent, true, true, currentTime(), nullptr, singleClick, screenPoint.x(), screenPoint.y(), documentPoint.x(), documentPoint.y(),
+    RefPtr<MouseEvent> mouseEvent = MouseEvent::create(eventNames().clickEvent, true, true, MonotonicTime::now(), nullptr, singleClick, screenPoint.x(), screenPoint.y(), documentPoint.x(), documentPoint.y(),
 #if ENABLE(POINTER_LOCK)
         0, 0,
 #endif
@@ -2145,11 +2145,11 @@ WebContextMenu* WebPage::contextMenuAtPointInWindow(const IntPoint& point)
     corePage()->contextMenuController().clearContextMenu();
 
     // Simulate a mouse click to generate the correct menu.
-    PlatformMouseEvent mousePressEvent(point, point, RightButton, PlatformEvent::MousePressed, 1, false, false, false, false, currentTime(), WebCore::ForceAtClick, WebCore::NoTap);
+    PlatformMouseEvent mousePressEvent(point, point, RightButton, PlatformEvent::MousePressed, 1, false, false, false, false, WallTime::now(), WebCore::ForceAtClick, WebCore::NoTap);
     corePage()->userInputBridge().handleMousePressEvent(mousePressEvent);
     bool handled = corePage()->userInputBridge().handleContextMenuEvent(mousePressEvent, corePage()->mainFrame());
     auto* menu = handled ? contextMenu() : nullptr;
-    PlatformMouseEvent mouseReleaseEvent(point, point, RightButton, PlatformEvent::MouseReleased, 1, false, false, false, false, currentTime(), WebCore::ForceAtClick, WebCore::NoTap);
+    PlatformMouseEvent mouseReleaseEvent(point, point, RightButton, PlatformEvent::MouseReleased, 1, false, false, false, false, WallTime::now(), WebCore::ForceAtClick, WebCore::NoTap);
     corePage()->userInputBridge().handleMouseReleaseEvent(mouseReleaseEvent);
 
     return menu;
@@ -3674,7 +3674,7 @@ void WebPage::dragEnded(WebCore::IntPoint clientPosition, WebCore::IntPoint glob
     if (!view)
         return;
     // FIXME: These are fake modifier keys here, but they should be real ones instead.
-    PlatformMouseEvent event(adjustedClientPosition, adjustedGlobalPosition, LeftButton, PlatformEvent::MouseMoved, 0, false, false, false, false, currentTime(), 0, WebCore::NoTap);
+    PlatformMouseEvent event(adjustedClientPosition, adjustedGlobalPosition, LeftButton, PlatformEvent::MouseMoved, 0, false, false, false, false, WallTime::now(), 0, WebCore::NoTap);
     m_page->mainFrame().eventHandler().dragSourceEndedAt(event, (DragOperation)operation);
 
     send(Messages::WebPageProxy::DidEndDragging());
@@ -4670,17 +4670,17 @@ void WebPage::handleAlternativeTextUIResult(const String& result)
 }
 #endif
 
-void WebPage::simulateMouseDown(int button, WebCore::IntPoint position, int clickCount, WKEventModifiers modifiers, double time)
+void WebPage::simulateMouseDown(int button, WebCore::IntPoint position, int clickCount, WKEventModifiers modifiers, WallTime time)
 {
     mouseEvent(WebMouseEvent(WebMouseEvent::MouseDown, static_cast<WebMouseEvent::Button>(button), position, position, 0, 0, 0, clickCount, static_cast<WebMouseEvent::Modifiers>(modifiers), time, WebCore::ForceAtClick, WebMouseEvent::NoTap));
 }
 
-void WebPage::simulateMouseUp(int button, WebCore::IntPoint position, int clickCount, WKEventModifiers modifiers, double time)
+void WebPage::simulateMouseUp(int button, WebCore::IntPoint position, int clickCount, WKEventModifiers modifiers, WallTime time)
 {
     mouseEvent(WebMouseEvent(WebMouseEvent::MouseUp, static_cast<WebMouseEvent::Button>(button), position, position, 0, 0, 0, clickCount, static_cast<WebMouseEvent::Modifiers>(modifiers), time, WebCore::ForceAtClick, WebMouseEvent::NoTap));
 }
 
-void WebPage::simulateMouseMotion(WebCore::IntPoint position, double time)
+void WebPage::simulateMouseMotion(WebCore::IntPoint position, WallTime time)
 {
     mouseEvent(WebMouseEvent(WebMouseEvent::MouseMove, WebMouseEvent::NoButton, position, position, 0, 0, 0, 0, WebMouseEvent::Modifiers(), time, 0, WebMouseEvent::NoTap));
 }
index 43154a614b93c137d72749b411bd59729bb7bbb7..bb1f5126d6bf4299a39679e251d381ae44dd7484 100644 (file)
@@ -66,6 +66,7 @@
 #include <wtf/RefPtr.h>
 #include <wtf/RunLoop.h>
 #include <wtf/Seconds.h>
+#include <wtf/WallTime.h>
 #include <wtf/text/WTFString.h>
 
 #if HAVE(ACCESSIBILITY) && PLATFORM(GTK)
@@ -806,9 +807,9 @@ public:
 #endif
 
     // For testing purpose.
-    void simulateMouseDown(int button, WebCore::IntPoint, int clickCount, WKEventModifiers, double time);
-    void simulateMouseUp(int button, WebCore::IntPoint, int clickCount, WKEventModifiers, double time);
-    void simulateMouseMotion(WebCore::IntPoint, double time);
+    void simulateMouseDown(int button, WebCore::IntPoint, int clickCount, WKEventModifiers, WallTime);
+    void simulateMouseUp(int button, WebCore::IntPoint, int clickCount, WKEventModifiers, WallTime);
+    void simulateMouseMotion(WebCore::IntPoint, WallTime);
 
 #if ENABLE(CONTEXT_MENUS)
     void contextMenuShowing() { m_isShowingContextMenu = true; }
index bcdb0bf06a0ca9c39ff5f3c5b4a52545612bc051..dbafa15f87ba4077a7a75faddf385df424388be6 100644 (file)
@@ -529,7 +529,7 @@ void WebPage::handleSyntheticClick(Node* nodeRespondingToClick, const WebCore::F
 
     WKBeginObservingContentChanges(true);
 
-    mainframe.eventHandler().mouseMoved(PlatformMouseEvent(roundedAdjustedPoint, roundedAdjustedPoint, NoButton, PlatformEvent::MouseMoved, 0, false, false, false, false, currentTime(), WebCore::ForceAtClick, WebCore::NoTap));
+    mainframe.eventHandler().mouseMoved(PlatformMouseEvent(roundedAdjustedPoint, roundedAdjustedPoint, NoButton, PlatformEvent::MouseMoved, 0, false, false, false, false, WallTime::now(), WebCore::ForceAtClick, WebCore::NoTap));
     mainframe.document()->updateStyleIfNeeded();
 
     WKStopObservingContentChanges();
@@ -581,11 +581,11 @@ void WebPage::completeSyntheticClick(Node* nodeRespondingToClick, const WebCore:
     bool tapWasHandled = false;
     m_lastInteractionLocation = roundedAdjustedPoint;
 
-    tapWasHandled |= mainframe.eventHandler().handleMousePressEvent(PlatformMouseEvent(roundedAdjustedPoint, roundedAdjustedPoint, LeftButton, PlatformEvent::MousePressed, 1, false, false, false, false, currentTime(), WebCore::ForceAtClick, syntheticClickType));
+    tapWasHandled |= mainframe.eventHandler().handleMousePressEvent(PlatformMouseEvent(roundedAdjustedPoint, roundedAdjustedPoint, LeftButton, PlatformEvent::MousePressed, 1, false, false, false, false, WallTime::now(), WebCore::ForceAtClick, syntheticClickType));
     if (m_isClosed)
         return;
 
-    tapWasHandled |= mainframe.eventHandler().handleMouseReleaseEvent(PlatformMouseEvent(roundedAdjustedPoint, roundedAdjustedPoint, LeftButton, PlatformEvent::MouseReleased, 1, false, false, false, false, currentTime(), WebCore::ForceAtClick, syntheticClickType));
+    tapWasHandled |= mainframe.eventHandler().handleMouseReleaseEvent(PlatformMouseEvent(roundedAdjustedPoint, roundedAdjustedPoint, LeftButton, PlatformEvent::MouseReleased, 1, false, false, false, false, WallTime::now(), WebCore::ForceAtClick, syntheticClickType));
     if (m_isClosed)
         return;
 
@@ -637,7 +637,7 @@ void WebPage::requestAdditionalItemsForDragSession(const IntPoint& clientPositio
     // To augment the platform drag session with additional items, end the current drag session and begin a new drag session with the new drag item.
     // This process is opaque to the UI process, which still maintains the old drag item in its drag session. Similarly, this persistent drag session
     // is opaque to the web process, which only sees that the current drag has ended, and that a new one is beginning.
-    PlatformMouseEvent event(clientPosition, globalPosition, LeftButton, PlatformEvent::MouseMoved, 0, false, false, false, false, currentTime(), 0, NoTap);
+    PlatformMouseEvent event(clientPosition, globalPosition, LeftButton, PlatformEvent::MouseMoved, 0, false, false, false, false, WallTime::now(), 0, NoTap);
     m_page->dragController().dragEnded();
     m_page->mainFrame().eventHandler().dragSourceEndedAt(event, DragOperationNone, MayExtendDragSession::Yes);
 
@@ -803,7 +803,7 @@ void WebPage::inspectorNodeSearchMovedToPosition(const FloatPoint& position)
     IntPoint adjustedPoint = roundedIntPoint(position);
     Frame& mainframe = m_page->mainFrame();
 
-    mainframe.eventHandler().mouseMoved(PlatformMouseEvent(adjustedPoint, adjustedPoint, NoButton, PlatformEvent::MouseMoved, 0, false, false, false, false, 0, 0, WebCore::NoTap));
+    mainframe.eventHandler().mouseMoved(PlatformMouseEvent(adjustedPoint, adjustedPoint, NoButton, PlatformEvent::MouseMoved, 0, false, false, false, false, { }, 0, WebCore::NoTap));
     mainframe.document()->updateStyleIfNeeded();
 }
 
index 6c419b0d0825c2f4ea03edd5a52ee7f826d30edf..27c52ca6b0a5cc40ada66e15be2ff2e1ef869eac 100644 (file)
@@ -1,3 +1,16 @@
+2017-09-22  Chris Dumez  <cdumez@apple.com>
+
+        Use high resolution timestamp for event time
+        https://bugs.webkit.org/show_bug.cgi?id=154246
+        <rdar://problem/34333304>
+
+        Reviewed by Ryosuke Niwa.
+
+        Use WallTime / MonotonicTime instead of double type for clarity.
+
+        * WebView/WebPDFViewPlaceholder.mm:
+        (-[WebPDFViewPlaceholder simulateClickOnLinkToURL:]):
+
 2017-08-09  Yoshiaki Jitsukawa  <Yoshiaki.Jitsukawa@sony.com>
 
         [PAL] Move spi/cocoa and spi/cg directories into PAL
index 48ae9f79cb92440524a7fff49db05c6a9e1433f6..c915fe4d867e22713cfd451e32d8379f983c1cd1 100644 (file)
@@ -48,7 +48,7 @@
 #import <WebKitLegacy/WebNSViewExtras.h>
 #import <WebKitLegacy/WebPDFDocumentExtras.h>
 #import <WebKitLegacy/WebViewPrivate.h>
-#import <wtf/CurrentTime.h>
+#import <wtf/MonotonicTime.h>
 #import <wtf/SoftLinking.h>
 #import <wtf/Vector.h>
 
@@ -479,7 +479,7 @@ static const float PAGE_HEIGHT_INSET = 4.0f * 2.0f;
         return;
 
     // Construct an event to simulate a click.
-    RefPtr<Event> event = MouseEvent::create(eventNames().clickEvent, true, true, currentTime(), 0, 1, 0, 0, 0, 0,
+    RefPtr<Event> event = MouseEvent::create(eventNames().clickEvent, true, true, MonotonicTime::now(), 0, 1, 0, 0, 0, 0,
 #if ENABLE(POINTER_LOCK)
         0, 0,
 #endif
index 57bf645a231a9508d54dd9c033b60e1abc92f49e..10fc16683f73ef311eb15b98d9adcdaab27931f5 100644 (file)
@@ -1,3 +1,20 @@
+2017-09-22  Chris Dumez  <cdumez@apple.com>
+
+        Use high resolution timestamp for event time
+        https://bugs.webkit.org/show_bug.cgi?id=154246
+        <rdar://problem/34333304>
+
+        Reviewed by Ryosuke Niwa.
+
+        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:]):
+
 2017-09-21  Ryosuke Niwa  <rniwa@webkit.org>
 
         Enable dataTransfer.items on macOS and iOS
index 95f84dd25a843aebba422d3bdc80d14fa308f21a..321a7f01681f21a48669cd983ed54571084f71aa 100644 (file)
@@ -97,7 +97,7 @@
 - (DOMTimeStamp)timeStamp
 {
     WebCore::JSMainThreadNullState state;
-    return IMPL->timeStamp();
+    return IMPL->timeStamp().approximateWallTime().secondsSinceEpoch().milliseconds();
 }
 
 - (BOOL)defaultPrevented
index 0016c0a42c030bb3ebc4f4d1aa5dc7ee1dc76145..f34d6959d4cae1537d5261c418f047d38224b9a4 100644 (file)
@@ -964,7 +964,7 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
         return;
     // FIXME: These are fake modifier keys here, but they should be real ones instead.
     PlatformMouseEvent event(IntPoint(windowLoc), IntPoint(globalPoint(windowLoc, [view->platformWidget() window])),
-                             LeftButton, PlatformEvent::MouseMoved, 0, false, false, false, false, currentTime(), WebCore::ForceAtClick, WebCore::NoTap);
+                             LeftButton, PlatformEvent::MouseMoved, 0, false, false, false, false, WallTime::now(), WebCore::ForceAtClick, WebCore::NoTap);
     _private->coreFrame->eventHandler().dragSourceEndedAt(event, (DragOperation)operation);
 }
 #endif // ENABLE(DRAG_SUPPORT) && PLATFORM(MAC)
index ec57c88a6cad1bd2b4c9c22a8cf013a0107e025a..18e35a5bd04f9a040571711e777845f26c6c999e 100644 (file)
@@ -1018,14 +1018,14 @@ static BOOL isFrameInRange(WebFrame *frame, DOMRange *range)
     case NSEventTypeKeyDown: {
         PlatformKeyboardEvent pe = PlatformEventFactory::createPlatformKeyboardEvent(nsEvent);
         pe.disambiguateKeyDownEvent(PlatformEvent::RawKeyDown);
-        event = KeyboardEvent::create(pe, 0);
+        event = KeyboardEvent::create(pe, nullptr);
         break;
     }
     default:
         break;
     }
     if (button != noButton) {
-        event = MouseEvent::create(eventNames().clickEvent, true, true, currentTime(), 0, [nsEvent clickCount], 0, 0, 0, 0,
+        event = MouseEvent::create(eventNames().clickEvent, true, true, MonotonicTime::now(), 0, [nsEvent clickCount], 0, 0, 0, 0,
 #if ENABLE(POINTER_LOCK)
             0, 0,
 #endif
index f74f3d3c8397e244c2a93c31c9ae5fce3edc0ed1..215e71f5e7ed0f9a35f965f5403002b370b91a7c 100644 (file)
@@ -101,7 +101,7 @@ PlatformMouseEvent generateMouseEvent(WebView* webView, bool isDrag)
     if (SUCCEEDED(webView->viewWindow(&viewWindow)))
         ::ScreenToClient(viewWindow, reinterpret_cast<LPPOINT>(&localpt));
     return PlatformMouseEvent(IntPoint(localpt.x, localpt.y), IntPoint(pt.x, pt.y),
-        isDrag ? LeftButton : NoButton, PlatformEvent::MouseMoved, 0, false, false, false, false, currentTime(), 0, NoTap);
+        isDrag ? LeftButton : NoButton, PlatformEvent::MouseMoved, 0, false, false, false, false, WallTime::now(), 0, NoTap);
 }
 
 STDMETHODIMP WebDropSource::QueryContinueDrag(_In_ BOOL fEscapePressed, _In_ DWORD grfKeyState)