Title: [286712] branches/safari-612.4.2.1-branch/Source
Revision
286712
Author
alanc...@apple.com
Date
2021-12-08 13:25:12 -0800 (Wed, 08 Dec 2021)

Log Message

Cherry-pick r285790. rdar://problem/85928816

    Attach IOHIDEvent timestamps to wheel events
    https://bugs.webkit.org/show_bug.cgi?id=233051

    Reviewed by Wenson Hsieh.
    Source/WebCore:

    On some macOS devices, there can be significant deltas between NSEvent timestamps,
    and the timestamps on underlying IOHIDEvents (rdar://85309639). This makes momentum
    velocity computation unpredictable; we can get better results by using IOHIDEvent
    timestamps.

    * platform/PlatformWheelEvent.cpp:
    (WebCore::PlatformWheelEvent::createFromGesture):
    * platform/PlatformWheelEvent.h:
    (WebCore::PlatformWheelEvent::ioHIDEventTimestamp const):
    * platform/mac/PlatformEventFactoryMac.h:
    * platform/mac/PlatformEventFactoryMac.mm:
    (WebCore::eventTimeStampSince1970):
    (WebCore::PlatformMouseEventBuilder::PlatformMouseEventBuilder):
    (WebCore::PlatformWheelEventBuilder::PlatformWheelEventBuilder):
    (WebCore::PlatformKeyboardEventBuilder::PlatformKeyboardEventBuilder):

    Source/WebCore/PAL:

    Expose a few bits of SPI needed.

    * pal/spi/cg/CoreGraphicsSPI.h:
    * pal/spi/cocoa/IOKitSPI.h:

    Source/WebKit:

    On some macOS devices, there can be significant deltas between NSEvent timestamps,
    and the timestamps on underlying IOHIDEvents (rdar://85309639). This makes momentum
    velocity computation unpredictable; we can get better results by using IOHIDEvent
    timestamps.

    * Shared/WebEventConversion.cpp:
    (WebKit::WebKit2PlatformWheelEvent::WebKit2PlatformWheelEvent):
    * Shared/WebWheelEvent.cpp:
    (WebKit::WebWheelEvent::WebWheelEvent):
    (WebKit::WebWheelEvent::encode const):
    (WebKit::WebWheelEvent::decode):
    * Shared/WebWheelEvent.h:
    (WebKit::WebWheelEvent::ioHIDEventTimestamp const):
    * Shared/WebWheelEventCoalescer.cpp:
    (WebKit::WebWheelEventCoalescer::coalesce):
    * Shared/ios/WebIOSEventFactory.mm:
    (WebIOSEventFactory::createWebWheelEvent):
    * Shared/mac/NativeWebGestureEventMac.mm:
    * Shared/mac/WebEventFactory.mm:
    (WebKit::WebEventFactory::createWebMouseEvent):
    (WebKit::WebEventFactory::createWebWheelEvent):
    (WebKit::WebEventFactory::createWebKeyboardEvent):

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@285790 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: branches/safari-612.4.2.1-branch/Source/WebCore/ChangeLog (286711 => 286712)


--- branches/safari-612.4.2.1-branch/Source/WebCore/ChangeLog	2021-12-08 21:25:05 UTC (rev 286711)
+++ branches/safari-612.4.2.1-branch/Source/WebCore/ChangeLog	2021-12-08 21:25:12 UTC (rev 286712)
@@ -1,5 +1,89 @@
 2021-12-01  Alan Coon  <alanc...@apple.com>
 
+        Cherry-pick r285790. rdar://problem/85928816
+
+    Attach IOHIDEvent timestamps to wheel events
+    https://bugs.webkit.org/show_bug.cgi?id=233051
+    
+    Reviewed by Wenson Hsieh.
+    Source/WebCore:
+    
+    On some macOS devices, there can be significant deltas between NSEvent timestamps,
+    and the timestamps on underlying IOHIDEvents (rdar://85309639). This makes momentum
+    velocity computation unpredictable; we can get better results by using IOHIDEvent
+    timestamps.
+    
+    * platform/PlatformWheelEvent.cpp:
+    (WebCore::PlatformWheelEvent::createFromGesture):
+    * platform/PlatformWheelEvent.h:
+    (WebCore::PlatformWheelEvent::ioHIDEventTimestamp const):
+    * platform/mac/PlatformEventFactoryMac.h:
+    * platform/mac/PlatformEventFactoryMac.mm:
+    (WebCore::eventTimeStampSince1970):
+    (WebCore::PlatformMouseEventBuilder::PlatformMouseEventBuilder):
+    (WebCore::PlatformWheelEventBuilder::PlatformWheelEventBuilder):
+    (WebCore::PlatformKeyboardEventBuilder::PlatformKeyboardEventBuilder):
+    
+    Source/WebCore/PAL:
+    
+    Expose a few bits of SPI needed.
+    
+    * pal/spi/cg/CoreGraphicsSPI.h:
+    * pal/spi/cocoa/IOKitSPI.h:
+    
+    Source/WebKit:
+    
+    On some macOS devices, there can be significant deltas between NSEvent timestamps,
+    and the timestamps on underlying IOHIDEvents (rdar://85309639). This makes momentum
+    velocity computation unpredictable; we can get better results by using IOHIDEvent
+    timestamps.
+    
+    * Shared/WebEventConversion.cpp:
+    (WebKit::WebKit2PlatformWheelEvent::WebKit2PlatformWheelEvent):
+    * Shared/WebWheelEvent.cpp:
+    (WebKit::WebWheelEvent::WebWheelEvent):
+    (WebKit::WebWheelEvent::encode const):
+    (WebKit::WebWheelEvent::decode):
+    * Shared/WebWheelEvent.h:
+    (WebKit::WebWheelEvent::ioHIDEventTimestamp const):
+    * Shared/WebWheelEventCoalescer.cpp:
+    (WebKit::WebWheelEventCoalescer::coalesce):
+    * Shared/ios/WebIOSEventFactory.mm:
+    (WebIOSEventFactory::createWebWheelEvent):
+    * Shared/mac/NativeWebGestureEventMac.mm:
+    * Shared/mac/WebEventFactory.mm:
+    (WebKit::WebEventFactory::createWebMouseEvent):
+    (WebKit::WebEventFactory::createWebWheelEvent):
+    (WebKit::WebEventFactory::createWebKeyboardEvent):
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@285790 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-11-14  Simon Fraser  <simon.fra...@apple.com>
+
+            Attach IOHIDEvent timestamps to wheel events
+            https://bugs.webkit.org/show_bug.cgi?id=233051
+
+            Reviewed by Wenson Hsieh.
+
+            On some macOS devices, there can be significant deltas between NSEvent timestamps,
+            and the timestamps on underlying IOHIDEvents (rdar://85309639). This makes momentum
+            velocity computation unpredictable; we can get better results by using IOHIDEvent
+            timestamps.
+
+            * platform/PlatformWheelEvent.cpp:
+            (WebCore::PlatformWheelEvent::createFromGesture):
+            * platform/PlatformWheelEvent.h:
+            (WebCore::PlatformWheelEvent::ioHIDEventTimestamp const):
+            * platform/mac/PlatformEventFactoryMac.h:
+            * platform/mac/PlatformEventFactoryMac.mm:
+            (WebCore::eventTimeStampSince1970):
+            (WebCore::PlatformMouseEventBuilder::PlatformMouseEventBuilder):
+            (WebCore::PlatformWheelEventBuilder::PlatformWheelEventBuilder):
+            (WebCore::PlatformKeyboardEventBuilder::PlatformKeyboardEventBuilder):
+
+2021-12-01  Alan Coon  <alanc...@apple.com>
+
         Cherry-pick r285786. rdar://problem/85928816
 
     Clean up IOKit SPI headers

Modified: branches/safari-612.4.2.1-branch/Source/WebCore/PAL/ChangeLog (286711 => 286712)


--- branches/safari-612.4.2.1-branch/Source/WebCore/PAL/ChangeLog	2021-12-08 21:25:05 UTC (rev 286711)
+++ branches/safari-612.4.2.1-branch/Source/WebCore/PAL/ChangeLog	2021-12-08 21:25:12 UTC (rev 286712)
@@ -1,5 +1,78 @@
 2021-12-01  Alan Coon  <alanc...@apple.com>
 
+        Cherry-pick r285790. rdar://problem/85928816
+
+    Attach IOHIDEvent timestamps to wheel events
+    https://bugs.webkit.org/show_bug.cgi?id=233051
+    
+    Reviewed by Wenson Hsieh.
+    Source/WebCore:
+    
+    On some macOS devices, there can be significant deltas between NSEvent timestamps,
+    and the timestamps on underlying IOHIDEvents (rdar://85309639). This makes momentum
+    velocity computation unpredictable; we can get better results by using IOHIDEvent
+    timestamps.
+    
+    * platform/PlatformWheelEvent.cpp:
+    (WebCore::PlatformWheelEvent::createFromGesture):
+    * platform/PlatformWheelEvent.h:
+    (WebCore::PlatformWheelEvent::ioHIDEventTimestamp const):
+    * platform/mac/PlatformEventFactoryMac.h:
+    * platform/mac/PlatformEventFactoryMac.mm:
+    (WebCore::eventTimeStampSince1970):
+    (WebCore::PlatformMouseEventBuilder::PlatformMouseEventBuilder):
+    (WebCore::PlatformWheelEventBuilder::PlatformWheelEventBuilder):
+    (WebCore::PlatformKeyboardEventBuilder::PlatformKeyboardEventBuilder):
+    
+    Source/WebCore/PAL:
+    
+    Expose a few bits of SPI needed.
+    
+    * pal/spi/cg/CoreGraphicsSPI.h:
+    * pal/spi/cocoa/IOKitSPI.h:
+    
+    Source/WebKit:
+    
+    On some macOS devices, there can be significant deltas between NSEvent timestamps,
+    and the timestamps on underlying IOHIDEvents (rdar://85309639). This makes momentum
+    velocity computation unpredictable; we can get better results by using IOHIDEvent
+    timestamps.
+    
+    * Shared/WebEventConversion.cpp:
+    (WebKit::WebKit2PlatformWheelEvent::WebKit2PlatformWheelEvent):
+    * Shared/WebWheelEvent.cpp:
+    (WebKit::WebWheelEvent::WebWheelEvent):
+    (WebKit::WebWheelEvent::encode const):
+    (WebKit::WebWheelEvent::decode):
+    * Shared/WebWheelEvent.h:
+    (WebKit::WebWheelEvent::ioHIDEventTimestamp const):
+    * Shared/WebWheelEventCoalescer.cpp:
+    (WebKit::WebWheelEventCoalescer::coalesce):
+    * Shared/ios/WebIOSEventFactory.mm:
+    (WebIOSEventFactory::createWebWheelEvent):
+    * Shared/mac/NativeWebGestureEventMac.mm:
+    * Shared/mac/WebEventFactory.mm:
+    (WebKit::WebEventFactory::createWebMouseEvent):
+    (WebKit::WebEventFactory::createWebWheelEvent):
+    (WebKit::WebEventFactory::createWebKeyboardEvent):
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@285790 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-11-14  Simon Fraser  <simon.fra...@apple.com>
+
+            Attach IOHIDEvent timestamps to wheel events
+            https://bugs.webkit.org/show_bug.cgi?id=233051
+
+            Reviewed by Wenson Hsieh.
+
+            Expose a few bits of SPI needed.
+
+            * pal/spi/cg/CoreGraphicsSPI.h:
+            * pal/spi/cocoa/IOKitSPI.h:
+
+2021-12-01  Alan Coon  <alanc...@apple.com>
+
         Cherry-pick r285786. rdar://problem/85928816
 
     Clean up IOKit SPI headers

Modified: branches/safari-612.4.2.1-branch/Source/WebCore/PAL/pal/spi/cg/CoreGraphicsSPI.h (286711 => 286712)


--- branches/safari-612.4.2.1-branch/Source/WebCore/PAL/pal/spi/cg/CoreGraphicsSPI.h	2021-12-08 21:25:05 UTC (rev 286711)
+++ branches/safari-612.4.2.1-branch/Source/WebCore/PAL/pal/spi/cg/CoreGraphicsSPI.h	2021-12-08 21:25:12 UTC (rev 286712)
@@ -32,6 +32,10 @@
 #include <pal/spi/cocoa/IOSurfaceSPI.h>
 #endif
 
+#if PLATFORM(MAC)
+#include <pal/spi/cocoa/IOKitSPI.h>
+#endif
+
 #if USE(APPLE_INTERNAL_SDK)
 
 #include <CoreGraphics/CGContextDelegatePrivate.h>
@@ -42,6 +46,7 @@
 
 #if PLATFORM(MAC)
 #include <CoreGraphics/CGAccessibility.h>
+#include <CoreGraphics/CGEventPrivate.h>
 #endif
 
 #else
@@ -350,6 +355,7 @@
 typedef int32_t CGSDisplayID;
 CGSDisplayID CGSMainDisplayID(void);
 
+IOHIDEventRef CGEventCopyIOHIDEvent(CGEventRef);
 #endif // PLATFORM(MAC)
 
 #if ENABLE(PDFKIT_PLUGIN) && !USE(APPLE_INTERNAL_SDK)

Modified: branches/safari-612.4.2.1-branch/Source/WebCore/PAL/pal/spi/mac/IOKitSPIMac.h (286711 => 286712)


--- branches/safari-612.4.2.1-branch/Source/WebCore/PAL/pal/spi/mac/IOKitSPIMac.h	2021-12-08 21:25:05 UTC (rev 286711)
+++ branches/safari-612.4.2.1-branch/Source/WebCore/PAL/pal/spi/mac/IOKitSPIMac.h	2021-12-08 21:25:12 UTC (rev 286712)
@@ -43,6 +43,8 @@
 #define kIOHIDProductIDKey "ProductID"
 
 WTF_EXTERN_C_BEGIN
+
+typedef struct __IOHIDEvent * IOHIDEventRef;
 typedef struct CF_BRIDGED_TYPE(id) __IOHIDServiceClient * IOHIDServiceClientRef;
 typedef struct CF_BRIDGED_TYPE(id) __IOHIDEventSystemClient * IOHIDEventSystemClientRef;
 typedef void (^IOHIDServiceClientBlock)(void *, void *, IOHIDServiceClientRef);
@@ -81,6 +83,8 @@
 };
 typedef uint32_t IOHIDEventType;
 
+uint64_t IOHIDEventGetTimeStamp(IOHIDEventRef);
+
 WTF_EXTERN_C_END
 
 #endif // USE(APPLE_INTERNAL_SDK)

Modified: branches/safari-612.4.2.1-branch/Source/WebCore/platform/PlatformWheelEvent.cpp (286711 => 286712)


--- branches/safari-612.4.2.1-branch/Source/WebCore/platform/PlatformWheelEvent.cpp	2021-12-08 21:25:05 UTC (rev 286711)
+++ branches/safari-612.4.2.1-branch/Source/WebCore/platform/PlatformWheelEvent.cpp	2021-12-08 21:25:12 UTC (rev 286712)
@@ -75,6 +75,7 @@
 #endif // ENABLE(KINETIC_SCROLLING)
 
 #if PLATFORM(COCOA)
+    platformWheelEvent.m_ioHIDEventTimestamp = platformWheelEvent.m_timestamp;
     platformWheelEvent.m_unacceleratedScrollingDeltaY = deltaY;
 #endif // PLATFORM(COCOA)
 

Modified: branches/safari-612.4.2.1-branch/Source/WebCore/platform/PlatformWheelEvent.h (286711 => 286712)


--- branches/safari-612.4.2.1-branch/Source/WebCore/platform/PlatformWheelEvent.h	2021-12-08 21:25:05 UTC (rev 286711)
+++ branches/safari-612.4.2.1-branch/Source/WebCore/platform/PlatformWheelEvent.h	2021-12-08 21:25:12 UTC (rev 286712)
@@ -152,6 +152,8 @@
     unsigned scrollCount() const { return m_scrollCount; }
     float unacceleratedScrollingDeltaX() const { return m_unacceleratedScrollingDeltaX; }
     float unacceleratedScrollingDeltaY() const { return m_unacceleratedScrollingDeltaY; }
+    
+    WallTime ioHIDEventTimestamp() const { return m_ioHIDEventTimestamp; }
 #endif
 
 #if ENABLE(ASYNC_SCROLLING)
@@ -200,6 +202,7 @@
     PlatformWheelEventPhase m_momentumPhase { PlatformWheelEventPhase::None };
 #endif
 #if PLATFORM(COCOA)
+    WallTime m_ioHIDEventTimestamp;
     unsigned m_scrollCount { 0 };
     float m_unacceleratedScrollingDeltaX { 0 };
     float m_unacceleratedScrollingDeltaY { 0 };

Modified: branches/safari-612.4.2.1-branch/Source/WebCore/platform/mac/PlatformEventFactoryMac.h (286711 => 286712)


--- branches/safari-612.4.2.1-branch/Source/WebCore/platform/mac/PlatformEventFactoryMac.h	2021-12-08 21:25:05 UTC (rev 286711)
+++ branches/safari-612.4.2.1-branch/Source/WebCore/platform/mac/PlatformEventFactoryMac.h	2021-12-08 21:25:12 UTC (rev 286712)
@@ -50,7 +50,7 @@
 WEBCORE_EXPORT String keyIdentifierForKeyEvent(NSEvent *);
 WEBCORE_EXPORT String keyForKeyEvent(NSEvent *);
 WEBCORE_EXPORT String codeForKeyEvent(NSEvent *);
-WEBCORE_EXPORT WallTime eventTimeStampSince1970(NSEvent *);
+WEBCORE_EXPORT WallTime eventTimeStampSince1970(NSTimeInterval);
 
 WEBCORE_EXPORT OptionSet<PlatformEvent::Modifier> modifiersForEvent(NSEvent *);
 WEBCORE_EXPORT void getWheelEventDeltas(NSEvent *, float& deltaX, float& deltaY, BOOL& continuous);

Modified: branches/safari-612.4.2.1-branch/Source/WebCore/platform/mac/PlatformEventFactoryMac.mm (286711 => 286712)


--- branches/safari-612.4.2.1-branch/Source/WebCore/platform/mac/PlatformEventFactoryMac.mm	2021-12-08 21:25:05 UTC (rev 286711)
+++ branches/safari-612.4.2.1-branch/Source/WebCore/platform/mac/PlatformEventFactoryMac.mm	2021-12-08 21:25:12 UTC (rev 286712)
@@ -607,9 +607,9 @@
     return systemStartupTime;
 }
 
-WallTime eventTimeStampSince1970(NSEvent* event)
+WallTime eventTimeStampSince1970(NSTimeInterval timestamp)
 {
-    return WallTime::fromRawSeconds(static_cast<double>(cachedStartupTimeIntervalSince1970() + [event timestamp]));
+    return WallTime::fromRawSeconds(static_cast<double>(cachedStartupTimeIntervalSince1970() + timestamp));
 }
 
 static inline bool isKeyUpEvent(NSEvent *event)
@@ -720,7 +720,7 @@
         }
 
         m_modifiers = modifiersForEvent(event);
-        m_timestamp = eventTimeStampSince1970(event);
+        m_timestamp = eventTimeStampSince1970(event.timestamp);
 
         // PlatformMouseEvent
         m_position = pointForEvent(event, windowView);
@@ -755,7 +755,7 @@
         // PlatformEvent
         m_type = PlatformEvent::Wheel;
         m_modifiers = modifiersForEvent(event);
-        m_timestamp = eventTimeStampSince1970(event);
+        m_timestamp = eventTimeStampSince1970(event.timestamp);
 
         // PlatformWheelEvent
         m_position = pointForEvent(event, windowView);
@@ -794,7 +794,7 @@
         // PlatformEvent
         m_type = isKeyUpEvent(event) ? PlatformEvent::KeyUp : PlatformEvent::KeyDown;
         m_modifiers = modifiersForEvent(event);
-        m_timestamp = eventTimeStampSince1970(event);
+        m_timestamp = eventTimeStampSince1970(event.timestamp);
 
         // PlatformKeyboardEvent
         m_text = textFromEvent(event);

Modified: branches/safari-612.4.2.1-branch/Source/WebKit/ChangeLog (286711 => 286712)


--- branches/safari-612.4.2.1-branch/Source/WebKit/ChangeLog	2021-12-08 21:25:05 UTC (rev 286711)
+++ branches/safari-612.4.2.1-branch/Source/WebKit/ChangeLog	2021-12-08 21:25:12 UTC (rev 286712)
@@ -1,3 +1,94 @@
+2021-12-01  Alan Coon  <alanc...@apple.com>
+
+        Cherry-pick r285790. rdar://problem/85928816
+
+    Attach IOHIDEvent timestamps to wheel events
+    https://bugs.webkit.org/show_bug.cgi?id=233051
+    
+    Reviewed by Wenson Hsieh.
+    Source/WebCore:
+    
+    On some macOS devices, there can be significant deltas between NSEvent timestamps,
+    and the timestamps on underlying IOHIDEvents (rdar://85309639). This makes momentum
+    velocity computation unpredictable; we can get better results by using IOHIDEvent
+    timestamps.
+    
+    * platform/PlatformWheelEvent.cpp:
+    (WebCore::PlatformWheelEvent::createFromGesture):
+    * platform/PlatformWheelEvent.h:
+    (WebCore::PlatformWheelEvent::ioHIDEventTimestamp const):
+    * platform/mac/PlatformEventFactoryMac.h:
+    * platform/mac/PlatformEventFactoryMac.mm:
+    (WebCore::eventTimeStampSince1970):
+    (WebCore::PlatformMouseEventBuilder::PlatformMouseEventBuilder):
+    (WebCore::PlatformWheelEventBuilder::PlatformWheelEventBuilder):
+    (WebCore::PlatformKeyboardEventBuilder::PlatformKeyboardEventBuilder):
+    
+    Source/WebCore/PAL:
+    
+    Expose a few bits of SPI needed.
+    
+    * pal/spi/cg/CoreGraphicsSPI.h:
+    * pal/spi/cocoa/IOKitSPI.h:
+    
+    Source/WebKit:
+    
+    On some macOS devices, there can be significant deltas between NSEvent timestamps,
+    and the timestamps on underlying IOHIDEvents (rdar://85309639). This makes momentum
+    velocity computation unpredictable; we can get better results by using IOHIDEvent
+    timestamps.
+    
+    * Shared/WebEventConversion.cpp:
+    (WebKit::WebKit2PlatformWheelEvent::WebKit2PlatformWheelEvent):
+    * Shared/WebWheelEvent.cpp:
+    (WebKit::WebWheelEvent::WebWheelEvent):
+    (WebKit::WebWheelEvent::encode const):
+    (WebKit::WebWheelEvent::decode):
+    * Shared/WebWheelEvent.h:
+    (WebKit::WebWheelEvent::ioHIDEventTimestamp const):
+    * Shared/WebWheelEventCoalescer.cpp:
+    (WebKit::WebWheelEventCoalescer::coalesce):
+    * Shared/ios/WebIOSEventFactory.mm:
+    (WebIOSEventFactory::createWebWheelEvent):
+    * Shared/mac/NativeWebGestureEventMac.mm:
+    * Shared/mac/WebEventFactory.mm:
+    (WebKit::WebEventFactory::createWebMouseEvent):
+    (WebKit::WebEventFactory::createWebWheelEvent):
+    (WebKit::WebEventFactory::createWebKeyboardEvent):
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@285790 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-11-14  Simon Fraser  <simon.fra...@apple.com>
+
+            Attach IOHIDEvent timestamps to wheel events
+            https://bugs.webkit.org/show_bug.cgi?id=233051
+
+            Reviewed by Wenson Hsieh.
+
+            On some macOS devices, there can be significant deltas between NSEvent timestamps,
+            and the timestamps on underlying IOHIDEvents (rdar://85309639). This makes momentum
+            velocity computation unpredictable; we can get better results by using IOHIDEvent
+            timestamps.
+
+            * Shared/WebEventConversion.cpp:
+            (WebKit::WebKit2PlatformWheelEvent::WebKit2PlatformWheelEvent):
+            * Shared/WebWheelEvent.cpp:
+            (WebKit::WebWheelEvent::WebWheelEvent):
+            (WebKit::WebWheelEvent::encode const):
+            (WebKit::WebWheelEvent::decode):
+            * Shared/WebWheelEvent.h:
+            (WebKit::WebWheelEvent::ioHIDEventTimestamp const):
+            * Shared/WebWheelEventCoalescer.cpp:
+            (WebKit::WebWheelEventCoalescer::coalesce):
+            * Shared/ios/WebIOSEventFactory.mm:
+            (WebIOSEventFactory::createWebWheelEvent):
+            * Shared/mac/NativeWebGestureEventMac.mm:
+            * Shared/mac/WebEventFactory.mm:
+            (WebKit::WebEventFactory::createWebMouseEvent):
+            (WebKit::WebEventFactory::createWebWheelEvent):
+            (WebKit::WebEventFactory::createWebKeyboardEvent):
+
 2021-12-03  Russell Epstein  <repst...@apple.com>
 
         Cherry-pick r286505. rdar://problem/85918531

Modified: branches/safari-612.4.2.1-branch/Source/WebKit/Shared/WebEventConversion.cpp (286711 => 286712)


--- branches/safari-612.4.2.1-branch/Source/WebKit/Shared/WebEventConversion.cpp	2021-12-08 21:25:05 UTC (rev 286711)
+++ branches/safari-612.4.2.1-branch/Source/WebKit/Shared/WebEventConversion.cpp	2021-12-08 21:25:12 UTC (rev 286712)
@@ -169,6 +169,7 @@
         m_hasPreciseScrollingDeltas = webEvent.hasPreciseScrollingDeltas();
 #endif
 #if PLATFORM(COCOA)
+        m_ioHIDEventTimestamp = webEvent.ioHIDEventTimestamp();
         m_scrollCount = webEvent.scrollCount();
         m_unacceleratedScrollingDeltaX = webEvent.unacceleratedScrollingDelta().width();
         m_unacceleratedScrollingDeltaY = webEvent.unacceleratedScrollingDelta().height();

Modified: branches/safari-612.4.2.1-branch/Source/WebKit/Shared/WebWheelEvent.cpp (286711 => 286712)


--- branches/safari-612.4.2.1-branch/Source/WebKit/Shared/WebWheelEvent.cpp	2021-12-08 21:25:05 UTC (rev 286711)
+++ branches/safari-612.4.2.1-branch/Source/WebKit/Shared/WebWheelEvent.cpp	2021-12-08 21:25:12 UTC (rev 286712)
@@ -44,7 +44,7 @@
 }
 
 #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, OptionSet<Modifier> modifiers, WallTime 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, OptionSet<Modifier> modifiers, WallTime timestamp, WallTime ioHIDEventTimestamp)
     : WebEvent(type, modifiers, timestamp)
     , m_position(position)
     , m_globalPosition(globalPosition)
@@ -55,6 +55,7 @@
     , m_momentumPhase(momentumPhase)
     , m_directionInvertedFromDevice(directionInvertedFromDevice)
     , m_hasPreciseScrollingDeltas(hasPreciseScrollingDeltas)
+    , m_ioHIDEventTimestamp(ioHIDEventTimestamp)
     , m_scrollCount(scrollCount)
     , m_unacceleratedScrollingDelta(unacceleratedScrollingDelta)
 {
@@ -92,6 +93,7 @@
     encoder << m_hasPreciseScrollingDeltas;
 #endif
 #if PLATFORM(COCOA)
+    encoder << m_ioHIDEventTimestamp;
     encoder << m_scrollCount;
     encoder << m_unacceleratedScrollingDelta;
 #endif
@@ -122,6 +124,8 @@
         return false;
 #endif
 #if PLATFORM(COCOA)
+    if (!decoder.decode(t.m_ioHIDEventTimestamp))
+        return false;
     if (!decoder.decode(t.m_scrollCount))
         return false;
     if (!decoder.decode(t.m_unacceleratedScrollingDelta))

Modified: branches/safari-612.4.2.1-branch/Source/WebKit/Shared/WebWheelEvent.h (286711 => 286712)


--- branches/safari-612.4.2.1-branch/Source/WebKit/Shared/WebWheelEvent.h	2021-12-08 21:25:05 UTC (rev 286711)
+++ branches/safari-612.4.2.1-branch/Source/WebKit/Shared/WebWheelEvent.h	2021-12-08 21:25:12 UTC (rev 286712)
@@ -53,7 +53,7 @@
 
     WebWheelEvent(Type, const WebCore::IntPoint& position, const WebCore::IntPoint& globalPosition, const WebCore::FloatSize& delta, const WebCore::FloatSize& wheelTicks, Granularity, OptionSet<Modifier>, 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, OptionSet<Modifier>, WallTime 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, OptionSet<Modifier>, WallTime timestamp, WallTime ioHIDEventTimestamp);
 #elif PLATFORM(GTK) || USE(LIBWPE)
     WebWheelEvent(Type, const WebCore::IntPoint& position, const WebCore::IntPoint& globalPosition, const WebCore::FloatSize& delta, const WebCore::FloatSize& wheelTicks, Phase, Phase momentumPhase, Granularity, bool hasPreciseScrollingDeltas, OptionSet<Modifier>, WallTime timestamp);
 #endif
@@ -70,6 +70,7 @@
     bool hasPreciseScrollingDeltas() const { return m_hasPreciseScrollingDeltas; }
 #endif
 #if PLATFORM(COCOA)
+    WallTime ioHIDEventTimestamp() const { return m_ioHIDEventTimestamp; }
     uint32_t scrollCount() const { return m_scrollCount; }
     const WebCore::FloatSize& unacceleratedScrollingDelta() const { return m_unacceleratedScrollingDelta; }
 #endif
@@ -87,11 +88,13 @@
     uint32_t m_granularity { ScrollByPageWheelEvent };
     uint32_t m_phase { Phase::PhaseNone };
     uint32_t m_momentumPhase { Phase::PhaseNone };
+
     bool m_directionInvertedFromDevice { false };
 #if PLATFORM(COCOA) || PLATFORM(GTK) || USE(LIBWPE)
     bool m_hasPreciseScrollingDeltas { false };
 #endif
 #if PLATFORM(COCOA)
+    WallTime m_ioHIDEventTimestamp;
     uint32_t m_scrollCount { 0 };
     WebCore::FloatSize m_unacceleratedScrollingDelta;
 #endif

Modified: branches/safari-612.4.2.1-branch/Source/WebKit/Shared/WebWheelEventCoalescer.cpp (286711 => 286712)


--- branches/safari-612.4.2.1-branch/Source/WebKit/Shared/WebWheelEventCoalescer.cpp	2021-12-08 21:25:05 UTC (rev 286711)
+++ branches/safari-612.4.2.1-branch/Source/WebKit/Shared/WebWheelEventCoalescer.cpp	2021-12-08 21:25:12 UTC (rev 286712)
@@ -78,7 +78,7 @@
 #if PLATFORM(COCOA)
     auto mergedUnacceleratedScrollingDelta = a.unacceleratedScrollingDelta() + b.unacceleratedScrollingDelta();
 
-    return WebWheelEvent(WebEvent::Wheel, b.position(), b.globalPosition(), mergedDelta, mergedWheelTicks, b.granularity(), b.directionInvertedFromDevice(), b.phase(), b.momentumPhase(), b.hasPreciseScrollingDeltas(), b.scrollCount(), mergedUnacceleratedScrollingDelta, b.modifiers(), b.timestamp());
+    return WebWheelEvent(WebEvent::Wheel, b.position(), b.globalPosition(), mergedDelta, mergedWheelTicks, b.granularity(), b.directionInvertedFromDevice(), b.phase(), b.momentumPhase(), b.hasPreciseScrollingDeltas(), b.scrollCount(), mergedUnacceleratedScrollingDelta, b.modifiers(), b.timestamp(), b.ioHIDEventTimestamp());
 #elif PLATFORM(GTK) || USE(LIBWPE)
     return WebWheelEvent(WebEvent::Wheel, b.position(), b.globalPosition(), mergedDelta, mergedWheelTicks, b.phase(), b.momentumPhase(), b.granularity(), b.hasPreciseScrollingDeltas(), b.modifiers(), b.timestamp());
 #else

Modified: branches/safari-612.4.2.1-branch/Source/WebKit/Shared/ios/WebIOSEventFactory.mm (286711 => 286712)


--- branches/safari-612.4.2.1-branch/Source/WebKit/Shared/ios/WebIOSEventFactory.mm	2021-12-08 21:25:05 UTC (rev 286711)
+++ branches/safari-612.4.2.1-branch/Source/WebKit/Shared/ios/WebIOSEventFactory.mm	2021-12-08 21:25:12 UTC (rev 286712)
@@ -161,7 +161,7 @@
     WebCore::FloatSize delta(deltaVector.dx, deltaVector.dy);
     WebCore::FloatSize wheelTicks = delta;
     wheelTicks.scale(1. / static_cast<float>(WebCore::Scrollbar::pixelsPerLineStep()));
-
+    auto timestamp = MonotonicTime::fromRawSeconds(event.timestamp).approximateWallTime();
     return {
         WebKit::WebEvent::Wheel,
         scrollLocation,
@@ -176,7 +176,8 @@
         1,
         delta,
         { },
-        MonotonicTime::fromRawSeconds(event.timestamp).approximateWallTime()
+        timestamp,
+        timestamp
     };
 }
 #endif

Modified: branches/safari-612.4.2.1-branch/Source/WebKit/Shared/mac/NativeWebGestureEventMac.mm (286711 => 286712)


--- branches/safari-612.4.2.1-branch/Source/WebKit/Shared/mac/NativeWebGestureEventMac.mm	2021-12-08 21:25:05 UTC (rev 286711)
+++ branches/safari-612.4.2.1-branch/Source/WebKit/Shared/mac/NativeWebGestureEventMac.mm	2021-12-08 21:25:12 UTC (rev 286712)
@@ -62,7 +62,7 @@
     : WebGestureEvent(
         webEventTypeForNSEvent(event),
         OptionSet<WebEvent::Modifier> { },
-        WebCore::eventTimeStampSince1970(event),
+        WebCore::eventTimeStampSince1970(event.timestamp),
         WebCore::IntPoint(pointForEvent(event, view)),
         event.type == NSEventTypeMagnify ? event.magnification : 0,
         event.type == NSEventTypeRotate ? event.rotation : 0)

Modified: branches/safari-612.4.2.1-branch/Source/WebKit/Shared/mac/WebEventFactory.mm (286711 => 286712)


--- branches/safari-612.4.2.1-branch/Source/WebKit/Shared/mac/WebEventFactory.mm	2021-12-08 21:25:05 UTC (rev 286711)
+++ branches/safari-612.4.2.1-branch/Source/WebKit/Shared/mac/WebEventFactory.mm	2021-12-08 21:25:12 UTC (rev 286712)
@@ -32,6 +32,7 @@
 #import <WebCore/PlatformEventFactoryMac.h>
 #import <WebCore/Scrollbar.h>
 #import <WebCore/WindowsKeyboardCodes.h>
+#import <pal/spi/cg/CoreGraphicsSPI.h>
 #import <pal/spi/mac/NSMenuSPI.h>
 #import <wtf/ASCIICType.h>
 
@@ -353,7 +354,7 @@
     float deltaZ = [event deltaZ];
     int clickCount = clickCountForEvent(event);
     auto modifiers = modifiersForEvent(event);
-    auto timestamp = WebCore::eventTimeStampSince1970(event);
+    auto timestamp = WebCore::eventTimeStampSince1970(event.timestamp);
     int eventNumber = [event eventNumber];
     int menuTypeForEvent = typeForEvent(event);
 
@@ -408,9 +409,26 @@
     }
 
     auto modifiers = modifiersForEvent(event);
-    auto timestamp = WebCore::eventTimeStampSince1970(event);
+    auto timestamp = WebCore::eventTimeStampSince1970(event.timestamp);
 
-    return WebWheelEvent(WebEvent::Wheel, WebCore::IntPoint(position), WebCore::IntPoint(globalPosition), WebCore::FloatSize(deltaX, deltaY), WebCore::FloatSize(wheelTicksX, wheelTicksY), granularity, directionInvertedFromDevice, phase, momentumPhase, hasPreciseScrollingDeltas, scrollCount, unacceleratedScrollingDelta, modifiers, timestamp);
+    auto ioHIDEventTimestamp = [](NSEvent *event) {
+        auto cgEvent = event.CGEvent;
+        if (!cgEvent)
+            return event.timestamp;
+
+        auto iohidEvent = adoptCF(CGEventCopyIOHIDEvent(cgEvent));
+        if (!iohidEvent)
+            return event.timestamp;
+
+        auto ioHIDEventTimestamp = IOHIDEventGetTimeStamp(iohidEvent.get()); // IOEventRef timestamp is mach_absolute_time units.
+        return MonotonicTime::fromMachAbsoluteTime(ioHIDEventTimestamp).secondsSinceEpoch().seconds();
+    }(event);
+
+    auto ioHIDEventWallTime = WebCore::eventTimeStampSince1970(ioHIDEventTimestamp);
+
+    return WebWheelEvent(WebEvent::Wheel, WebCore::IntPoint(position), WebCore::IntPoint(globalPosition), WebCore::FloatSize(deltaX, deltaY), WebCore::FloatSize(wheelTicksX, wheelTicksY),
+        granularity, directionInvertedFromDevice, phase, momentumPhase, hasPreciseScrollingDeltas,
+        scrollCount, unacceleratedScrollingDelta, modifiers, timestamp, ioHIDEventWallTime);
 }
 
 WebKeyboardEvent WebEventFactory::createWebKeyboardEvent(NSEvent *event, bool handledByInputMethod, bool replacesSoftSpace, const Vector<WebCore::KeypressCommand>& commands)
@@ -428,7 +446,7 @@
     bool isKeypad                   = isKeypadEvent(event);
     bool isSystemKey                = false; // SystemKey is always false on the Mac.
     auto modifiers = modifiersForEvent(event);
-    auto timestamp                  = WebCore::eventTimeStampSince1970(event);
+    auto timestamp                  = WebCore::eventTimeStampSince1970(event.timestamp);
 
     // Always use 13 for Enter/Return -- we don't want to use AppKit's different character for Enter.
     if (windowsVirtualKeyCode == VK_RETURN) {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to