Title: [286270] trunk/Source
Revision
286270
Author
timothy_hor...@apple.com
Date
2021-11-29 15:58:33 -0800 (Mon, 29 Nov 2021)

Log Message

Plumb raw platform scrolling deltas along in wheel events
https://bugs.webkit.org/show_bug.cgi?id=233583

Reviewed by Simon Fraser.

Source/WebCore:

* platform/PlatformWheelEvent.cpp:
(WebCore::PlatformWheelEvent::createFromGesture):
* platform/PlatformWheelEvent.h:
(WebCore::PlatformWheelEvent::rawPlatformDelta const):
* PAL/pal/spi/mac/IOKitSPIMac.h:

Source/WebKit:

* Shared/WebEventConversion.cpp:
(WebKit::WebKit2PlatformWheelEvent::WebKit2PlatformWheelEvent):
* Shared/WebWheelEvent.cpp:
(WebKit::WebWheelEvent::WebWheelEvent):
(WebKit::WebWheelEvent::encode const):
(WebKit::WebWheelEvent::decode):
* Shared/WebWheelEvent.h:
(WebKit::WebWheelEvent::rawPlatformDelta const):
* Shared/WebWheelEventCoalescer.cpp:
(WebKit::WebWheelEventCoalescer::coalesce):
* Shared/mac/WebEventFactory.mm:
(WebKit::WebEventFactory::createWebWheelEvent):
Extract and plumb raw unaccelerated (in the HID sense) deltas in scroll
events for use in a future patch.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (286269 => 286270)


--- trunk/Source/WebCore/ChangeLog	2021-11-29 23:46:29 UTC (rev 286269)
+++ trunk/Source/WebCore/ChangeLog	2021-11-29 23:58:33 UTC (rev 286270)
@@ -1,3 +1,16 @@
+2021-11-29  Tim Horton  <timothy_hor...@apple.com>
+
+        Plumb raw platform scrolling deltas along in wheel events
+        https://bugs.webkit.org/show_bug.cgi?id=233583
+
+        Reviewed by Simon Fraser.
+
+        * platform/PlatformWheelEvent.cpp:
+        (WebCore::PlatformWheelEvent::createFromGesture):
+        * platform/PlatformWheelEvent.h:
+        (WebCore::PlatformWheelEvent::rawPlatformDelta const):
+        * PAL/pal/spi/mac/IOKitSPIMac.h:
+
 2021-11-29  Wenson Hsieh  <wenson_hs...@apple.com>
 
         Add a basic heuristic for sizing text in image overlay blocks

Modified: trunk/Source/WebCore/PAL/pal/spi/mac/IOKitSPIMac.h (286269 => 286270)


--- trunk/Source/WebCore/PAL/pal/spi/mac/IOKitSPIMac.h	2021-11-29 23:46:29 UTC (rev 286269)
+++ trunk/Source/WebCore/PAL/pal/spi/mac/IOKitSPIMac.h	2021-11-29 23:58:33 UTC (rev 286270)
@@ -83,7 +83,22 @@
 };
 typedef uint32_t IOHIDEventType;
 
+typedef uint32_t IOHIDEventField;
+
+#ifdef __LP64__
+typedef double IOHIDFloat;
+#else
+typedef float IOHIDFloat;
+#endif
+
+#define IOHIDEventFieldBase(type) (type << 16)
+
+#define kIOHIDEventFieldScrollBase IOHIDEventFieldBase(kIOHIDEventTypeScroll)
+static const IOHIDEventField kIOHIDEventFieldScrollX = (kIOHIDEventFieldScrollBase | 0);
+static const IOHIDEventField kIOHIDEventFieldScrollY = (kIOHIDEventFieldScrollBase | 1);
+
 uint64_t IOHIDEventGetTimeStamp(IOHIDEventRef);
+IOHIDFloat IOHIDEventGetFloatValue(IOHIDEventRef, IOHIDEventField);
 
 WTF_EXTERN_C_END
 

Modified: trunk/Source/WebCore/platform/PlatformWheelEvent.cpp (286269 => 286270)


--- trunk/Source/WebCore/platform/PlatformWheelEvent.cpp	2021-11-29 23:46:29 UTC (rev 286269)
+++ trunk/Source/WebCore/platform/PlatformWheelEvent.cpp	2021-11-29 23:58:33 UTC (rev 286270)
@@ -76,6 +76,7 @@
 
 #if PLATFORM(COCOA)
     platformWheelEvent.m_ioHIDEventTimestamp = platformWheelEvent.m_timestamp;
+    platformWheelEvent.m_rawPlatformDelta = platformWheelEvent.m_rawPlatformDelta;
     platformWheelEvent.m_unacceleratedScrollingDeltaY = deltaY;
 #endif // PLATFORM(COCOA)
 

Modified: trunk/Source/WebCore/platform/PlatformWheelEvent.h (286269 => 286270)


--- trunk/Source/WebCore/platform/PlatformWheelEvent.h	2021-11-29 23:46:29 UTC (rev 286269)
+++ trunk/Source/WebCore/platform/PlatformWheelEvent.h	2021-11-29 23:58:33 UTC (rev 286270)
@@ -160,6 +160,8 @@
     FloatSize unacceleratedScrollingDelta() const { return { m_unacceleratedScrollingDeltaX, m_unacceleratedScrollingDeltaY }; }
     
     WallTime ioHIDEventTimestamp() const { return m_ioHIDEventTimestamp; }
+
+    std::optional<FloatSize> rawPlatformDelta() const { return m_rawPlatformDelta; }
 #endif
 
 #if ENABLE(ASYNC_SCROLLING)
@@ -209,6 +211,7 @@
 #endif
 #if PLATFORM(COCOA)
     WallTime m_ioHIDEventTimestamp;
+    std::optional<FloatSize> m_rawPlatformDelta;
     unsigned m_scrollCount { 0 };
     float m_unacceleratedScrollingDeltaX { 0 };
     float m_unacceleratedScrollingDeltaY { 0 };

Modified: trunk/Source/WebKit/ChangeLog (286269 => 286270)


--- trunk/Source/WebKit/ChangeLog	2021-11-29 23:46:29 UTC (rev 286269)
+++ trunk/Source/WebKit/ChangeLog	2021-11-29 23:58:33 UTC (rev 286270)
@@ -1,3 +1,25 @@
+2021-11-29  Tim Horton  <timothy_hor...@apple.com>
+
+        Plumb raw platform scrolling deltas along in wheel events
+        https://bugs.webkit.org/show_bug.cgi?id=233583
+
+        Reviewed by Simon Fraser.
+
+        * Shared/WebEventConversion.cpp:
+        (WebKit::WebKit2PlatformWheelEvent::WebKit2PlatformWheelEvent):
+        * Shared/WebWheelEvent.cpp:
+        (WebKit::WebWheelEvent::WebWheelEvent):
+        (WebKit::WebWheelEvent::encode const):
+        (WebKit::WebWheelEvent::decode):
+        * Shared/WebWheelEvent.h:
+        (WebKit::WebWheelEvent::rawPlatformDelta const):
+        * Shared/WebWheelEventCoalescer.cpp:
+        (WebKit::WebWheelEventCoalescer::coalesce):
+        * Shared/mac/WebEventFactory.mm:
+        (WebKit::WebEventFactory::createWebWheelEvent):
+        Extract and plumb raw unaccelerated (in the HID sense) deltas in scroll
+        events for use in a future patch.
+
 2021-11-29  Chris Dumez  <cdu...@apple.com>
 
         Add WebKitAdditions bits for captive portal mode

Modified: trunk/Source/WebKit/Shared/WebEventConversion.cpp (286269 => 286270)


--- trunk/Source/WebKit/Shared/WebEventConversion.cpp	2021-11-29 23:46:29 UTC (rev 286269)
+++ trunk/Source/WebKit/Shared/WebEventConversion.cpp	2021-11-29 23:58:33 UTC (rev 286270)
@@ -170,6 +170,7 @@
 #endif
 #if PLATFORM(COCOA)
         m_ioHIDEventTimestamp = webEvent.ioHIDEventTimestamp();
+        m_rawPlatformDelta = webEvent.rawPlatformDelta();
         m_scrollCount = webEvent.scrollCount();
         m_unacceleratedScrollingDeltaX = webEvent.unacceleratedScrollingDelta().width();
         m_unacceleratedScrollingDeltaY = webEvent.unacceleratedScrollingDelta().height();

Modified: trunk/Source/WebKit/Shared/WebWheelEvent.cpp (286269 => 286270)


--- trunk/Source/WebKit/Shared/WebWheelEvent.cpp	2021-11-29 23:46:29 UTC (rev 286269)
+++ trunk/Source/WebKit/Shared/WebWheelEvent.cpp	2021-11-29 23:58:33 UTC (rev 286270)
@@ -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, WallTime ioHIDEventTimestamp)
+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, std::optional<WebCore::FloatSize> rawPlatformDelta)
     : WebEvent(type, modifiers, timestamp)
     , m_position(position)
     , m_globalPosition(globalPosition)
@@ -56,6 +56,7 @@
     , m_directionInvertedFromDevice(directionInvertedFromDevice)
     , m_hasPreciseScrollingDeltas(hasPreciseScrollingDeltas)
     , m_ioHIDEventTimestamp(ioHIDEventTimestamp)
+    , m_rawPlatformDelta(rawPlatformDelta)
     , m_scrollCount(scrollCount)
     , m_unacceleratedScrollingDelta(unacceleratedScrollingDelta)
 {
@@ -94,6 +95,7 @@
 #endif
 #if PLATFORM(COCOA)
     encoder << m_ioHIDEventTimestamp;
+    encoder << m_rawPlatformDelta;
     encoder << m_scrollCount;
     encoder << m_unacceleratedScrollingDelta;
 #endif
@@ -126,6 +128,8 @@
 #if PLATFORM(COCOA)
     if (!decoder.decode(t.m_ioHIDEventTimestamp))
         return false;
+    if (!decoder.decode(t.m_rawPlatformDelta))
+        return false;
     if (!decoder.decode(t.m_scrollCount))
         return false;
     if (!decoder.decode(t.m_unacceleratedScrollingDelta))

Modified: trunk/Source/WebKit/Shared/WebWheelEvent.h (286269 => 286270)


--- trunk/Source/WebKit/Shared/WebWheelEvent.h	2021-11-29 23:46:29 UTC (rev 286269)
+++ trunk/Source/WebKit/Shared/WebWheelEvent.h	2021-11-29 23:58:33 UTC (rev 286270)
@@ -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, WallTime ioHIDEventTimestamp);
+    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, std::optional<WebCore::FloatSize> rawPlatformDelta);
 #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
@@ -71,6 +71,7 @@
 #endif
 #if PLATFORM(COCOA)
     WallTime ioHIDEventTimestamp() const { return m_ioHIDEventTimestamp; }
+    std::optional<WebCore::FloatSize> rawPlatformDelta() const { return m_rawPlatformDelta; }
     uint32_t scrollCount() const { return m_scrollCount; }
     const WebCore::FloatSize& unacceleratedScrollingDelta() const { return m_unacceleratedScrollingDelta; }
 #endif
@@ -95,6 +96,7 @@
 #endif
 #if PLATFORM(COCOA)
     WallTime m_ioHIDEventTimestamp;
+    std::optional<WebCore::FloatSize> m_rawPlatformDelta;
     uint32_t m_scrollCount { 0 };
     WebCore::FloatSize m_unacceleratedScrollingDelta;
 #endif

Modified: trunk/Source/WebKit/Shared/WebWheelEventCoalescer.cpp (286269 => 286270)


--- trunk/Source/WebKit/Shared/WebWheelEventCoalescer.cpp	2021-11-29 23:46:29 UTC (rev 286269)
+++ trunk/Source/WebKit/Shared/WebWheelEventCoalescer.cpp	2021-11-29 23:58:33 UTC (rev 286270)
@@ -77,8 +77,11 @@
 
 #if PLATFORM(COCOA)
     auto mergedUnacceleratedScrollingDelta = a.unacceleratedScrollingDelta() + b.unacceleratedScrollingDelta();
+    std::optional<WebCore::FloatSize> mergedRawPlatformScrollingDelta;
+    if (a.rawPlatformDelta() && b.rawPlatformDelta())
+        mergedRawPlatformScrollingDelta = a.rawPlatformDelta().value() + b.rawPlatformDelta().value();
 
-    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());
+    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(), mergedRawPlatformScrollingDelta);
 #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: trunk/Source/WebKit/Shared/mac/WebEventFactory.mm (286269 => 286270)


--- trunk/Source/WebKit/Shared/mac/WebEventFactory.mm	2021-11-29 23:46:29 UTC (rev 286269)
+++ trunk/Source/WebKit/Shared/mac/WebEventFactory.mm	2021-11-29 23:58:33 UTC (rev 286270)
@@ -411,24 +411,36 @@
     auto modifiers = modifiersForEvent(event);
     auto timestamp = WebCore::eventTimeStampSince1970(event.timestamp);
 
-    auto ioHIDEventTimestamp = [](NSEvent *event) {
+    auto ioHIDEventTimestamp = [&]() {
         auto cgEvent = event.CGEvent;
         if (!cgEvent)
             return event.timestamp;
 
-        auto iohidEvent = adoptCF(CGEventCopyIOHIDEvent(cgEvent));
-        if (!iohidEvent)
+        auto ioHIDEvent = adoptCF(CGEventCopyIOHIDEvent(cgEvent));
+        if (!ioHIDEvent)
             return event.timestamp;
 
-        auto ioHIDEventTimestamp = IOHIDEventGetTimeStamp(iohidEvent.get()); // IOEventRef timestamp is mach_absolute_time units.
+        auto ioHIDEventTimestamp = IOHIDEventGetTimeStamp(ioHIDEvent.get()); // IOEventRef timestamp is mach_absolute_time units.
         return MonotonicTime::fromMachAbsoluteTime(ioHIDEventTimestamp).secondsSinceEpoch().seconds();
-    }(event);
+    }();
 
+    auto rawPlatformDelta = [&]() -> std::optional<WebCore::FloatSize> {
+        auto cgEvent = event.CGEvent;
+        if (!cgEvent)
+            return std::nullopt;
+
+        auto ioHIDEvent = adoptCF(CGEventCopyIOHIDEvent(cgEvent));
+        if (!ioHIDEvent)
+            return std::nullopt;
+        
+        return { WebCore::FloatSize(-IOHIDEventGetFloatValue(ioHIDEvent.get(), kIOHIDEventFieldScrollX), -IOHIDEventGetFloatValue(ioHIDEvent.get(), kIOHIDEventFieldScrollY)) };
+    }();
+
     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);
+        scrollCount, unacceleratedScrollingDelta, modifiers, timestamp, ioHIDEventWallTime, rawPlatformDelta);
 }
 
 WebKeyboardEvent WebEventFactory::createWebKeyboardEvent(NSEvent *event, bool handledByInputMethod, bool replacesSoftSpace, const Vector<WebCore::KeypressCommand>& commands)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to