⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 286270 in webkit


Ignore:
Timestamp:
Nov 29, 2021, 3:58:33 PM (5 years ago)
Author:
timothy_horton@apple.com
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.

Location:
trunk/Source
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r286265 r286270  
     12021-11-29  Tim Horton  <timothy_horton@apple.com>
     2
     3        Plumb raw platform scrolling deltas along in wheel events
     4        https://bugs.webkit.org/show_bug.cgi?id=233583
     5
     6        Reviewed by Simon Fraser.
     7
     8        * platform/PlatformWheelEvent.cpp:
     9        (WebCore::PlatformWheelEvent::createFromGesture):
     10        * platform/PlatformWheelEvent.h:
     11        (WebCore::PlatformWheelEvent::rawPlatformDelta const):
     12        * PAL/pal/spi/mac/IOKitSPIMac.h:
     13
    1142021-11-29  Wenson Hsieh  <wenson_hsieh@apple.com>
    215
  • trunk/Source/WebCore/PAL/pal/spi/mac/IOKitSPIMac.h

    r285790 r286270  
    8484typedef uint32_t IOHIDEventType;
    8585
     86typedef uint32_t IOHIDEventField;
     87
     88#ifdef __LP64__
     89typedef double IOHIDFloat;
     90#else
     91typedef float IOHIDFloat;
     92#endif
     93
     94#define IOHIDEventFieldBase(type) (type << 16)
     95
     96#define kIOHIDEventFieldScrollBase IOHIDEventFieldBase(kIOHIDEventTypeScroll)
     97static const IOHIDEventField kIOHIDEventFieldScrollX = (kIOHIDEventFieldScrollBase | 0);
     98static const IOHIDEventField kIOHIDEventFieldScrollY = (kIOHIDEventFieldScrollBase | 1);
     99
    86100uint64_t IOHIDEventGetTimeStamp(IOHIDEventRef);
     101IOHIDFloat IOHIDEventGetFloatValue(IOHIDEventRef, IOHIDEventField);
    87102
    88103WTF_EXTERN_C_END
  • trunk/Source/WebCore/platform/PlatformWheelEvent.cpp

    r285790 r286270  
    7777#if PLATFORM(COCOA)
    7878    platformWheelEvent.m_ioHIDEventTimestamp = platformWheelEvent.m_timestamp;
     79    platformWheelEvent.m_rawPlatformDelta = platformWheelEvent.m_rawPlatformDelta;
    7980    platformWheelEvent.m_unacceleratedScrollingDeltaY = deltaY;
    8081#endif // PLATFORM(COCOA)
  • trunk/Source/WebCore/platform/PlatformWheelEvent.h

    r285953 r286270  
    161161   
    162162    WallTime ioHIDEventTimestamp() const { return m_ioHIDEventTimestamp; }
     163
     164    std::optional<FloatSize> rawPlatformDelta() const { return m_rawPlatformDelta; }
    163165#endif
    164166
     
    210212#if PLATFORM(COCOA)
    211213    WallTime m_ioHIDEventTimestamp;
     214    std::optional<FloatSize> m_rawPlatformDelta;
    212215    unsigned m_scrollCount { 0 };
    213216    float m_unacceleratedScrollingDeltaX { 0 };
  • trunk/Source/WebKit/ChangeLog

    r286267 r286270  
     12021-11-29  Tim Horton  <timothy_horton@apple.com>
     2
     3        Plumb raw platform scrolling deltas along in wheel events
     4        https://bugs.webkit.org/show_bug.cgi?id=233583
     5
     6        Reviewed by Simon Fraser.
     7
     8        * Shared/WebEventConversion.cpp:
     9        (WebKit::WebKit2PlatformWheelEvent::WebKit2PlatformWheelEvent):
     10        * Shared/WebWheelEvent.cpp:
     11        (WebKit::WebWheelEvent::WebWheelEvent):
     12        (WebKit::WebWheelEvent::encode const):
     13        (WebKit::WebWheelEvent::decode):
     14        * Shared/WebWheelEvent.h:
     15        (WebKit::WebWheelEvent::rawPlatformDelta const):
     16        * Shared/WebWheelEventCoalescer.cpp:
     17        (WebKit::WebWheelEventCoalescer::coalesce):
     18        * Shared/mac/WebEventFactory.mm:
     19        (WebKit::WebEventFactory::createWebWheelEvent):
     20        Extract and plumb raw unaccelerated (in the HID sense) deltas in scroll
     21        events for use in a future patch.
     22
    1232021-11-29  Chris Dumez  <cdumez@apple.com>
    224
  • trunk/Source/WebKit/Shared/WebEventConversion.cpp

    r285790 r286270  
    171171#if PLATFORM(COCOA)
    172172        m_ioHIDEventTimestamp = webEvent.ioHIDEventTimestamp();
     173        m_rawPlatformDelta = webEvent.rawPlatformDelta();
    173174        m_scrollCount = webEvent.scrollCount();
    174175        m_unacceleratedScrollingDeltaX = webEvent.unacceleratedScrollingDelta().width();
  • trunk/Source/WebKit/Shared/WebWheelEvent.cpp

    r285790 r286270  
    4545
    4646#if PLATFORM(COCOA)
    47 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)
     47WebWheelEvent::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)
    4848    : WebEvent(type, modifiers, timestamp)
    4949    , m_position(position)
     
    5757    , m_hasPreciseScrollingDeltas(hasPreciseScrollingDeltas)
    5858    , m_ioHIDEventTimestamp(ioHIDEventTimestamp)
     59    , m_rawPlatformDelta(rawPlatformDelta)
    5960    , m_scrollCount(scrollCount)
    6061    , m_unacceleratedScrollingDelta(unacceleratedScrollingDelta)
     
    9596#if PLATFORM(COCOA)
    9697    encoder << m_ioHIDEventTimestamp;
     98    encoder << m_rawPlatformDelta;
    9799    encoder << m_scrollCount;
    98100    encoder << m_unacceleratedScrollingDelta;
     
    127129    if (!decoder.decode(t.m_ioHIDEventTimestamp))
    128130        return false;
     131    if (!decoder.decode(t.m_rawPlatformDelta))
     132        return false;
    129133    if (!decoder.decode(t.m_scrollCount))
    130134        return false;
  • trunk/Source/WebKit/Shared/WebWheelEvent.h

    r285790 r286270  
    5454    WebWheelEvent(Type, const WebCore::IntPoint& position, const WebCore::IntPoint& globalPosition, const WebCore::FloatSize& delta, const WebCore::FloatSize& wheelTicks, Granularity, OptionSet<Modifier>, WallTime timestamp);
    5555#if PLATFORM(COCOA)
    56     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);
     56    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);
    5757#elif PLATFORM(GTK) || USE(LIBWPE)
    5858    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);
     
    7272#if PLATFORM(COCOA)
    7373    WallTime ioHIDEventTimestamp() const { return m_ioHIDEventTimestamp; }
     74    std::optional<WebCore::FloatSize> rawPlatformDelta() const { return m_rawPlatformDelta; }
    7475    uint32_t scrollCount() const { return m_scrollCount; }
    7576    const WebCore::FloatSize& unacceleratedScrollingDelta() const { return m_unacceleratedScrollingDelta; }
     
    9697#if PLATFORM(COCOA)
    9798    WallTime m_ioHIDEventTimestamp;
     99    std::optional<WebCore::FloatSize> m_rawPlatformDelta;
    98100    uint32_t m_scrollCount { 0 };
    99101    WebCore::FloatSize m_unacceleratedScrollingDelta;
  • trunk/Source/WebKit/Shared/WebWheelEventCoalescer.cpp

    r285790 r286270  
    7878#if PLATFORM(COCOA)
    7979    auto mergedUnacceleratedScrollingDelta = a.unacceleratedScrollingDelta() + b.unacceleratedScrollingDelta();
     80    std::optional<WebCore::FloatSize> mergedRawPlatformScrollingDelta;
     81    if (a.rawPlatformDelta() && b.rawPlatformDelta())
     82        mergedRawPlatformScrollingDelta = a.rawPlatformDelta().value() + b.rawPlatformDelta().value();
    8083
    81     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());
     84    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);
    8285#elif PLATFORM(GTK) || USE(LIBWPE)
    8386    return WebWheelEvent(WebEvent::Wheel, b.position(), b.globalPosition(), mergedDelta, mergedWheelTicks, b.phase(), b.momentumPhase(), b.granularity(), b.hasPreciseScrollingDeltas(), b.modifiers(), b.timestamp());
  • trunk/Source/WebKit/Shared/mac/WebEventFactory.mm

    r285790 r286270  
    412412    auto timestamp = WebCore::eventTimeStampSince1970(event.timestamp);
    413413
    414     auto ioHIDEventTimestamp = [](NSEvent *event) {
     414    auto ioHIDEventTimestamp = [&]() {
    415415        auto cgEvent = event.CGEvent;
    416416        if (!cgEvent)
    417417            return event.timestamp;
    418418
    419         auto iohidEvent = adoptCF(CGEventCopyIOHIDEvent(cgEvent));
    420         if (!iohidEvent)
     419        auto ioHIDEvent = adoptCF(CGEventCopyIOHIDEvent(cgEvent));
     420        if (!ioHIDEvent)
    421421            return event.timestamp;
    422422
    423         auto ioHIDEventTimestamp = IOHIDEventGetTimeStamp(iohidEvent.get()); // IOEventRef timestamp is mach_absolute_time units.
     423        auto ioHIDEventTimestamp = IOHIDEventGetTimeStamp(ioHIDEvent.get()); // IOEventRef timestamp is mach_absolute_time units.
    424424        return MonotonicTime::fromMachAbsoluteTime(ioHIDEventTimestamp).secondsSinceEpoch().seconds();
    425     }(event);
     425    }();
     426
     427    auto rawPlatformDelta = [&]() -> std::optional<WebCore::FloatSize> {
     428        auto cgEvent = event.CGEvent;
     429        if (!cgEvent)
     430            return std::nullopt;
     431
     432        auto ioHIDEvent = adoptCF(CGEventCopyIOHIDEvent(cgEvent));
     433        if (!ioHIDEvent)
     434            return std::nullopt;
     435       
     436        return { WebCore::FloatSize(-IOHIDEventGetFloatValue(ioHIDEvent.get(), kIOHIDEventFieldScrollX), -IOHIDEventGetFloatValue(ioHIDEvent.get(), kIOHIDEventFieldScrollY)) };
     437    }();
    426438
    427439    auto ioHIDEventWallTime = WebCore::eventTimeStampSince1970(ioHIDEventTimestamp);
     
    429441    return WebWheelEvent(WebEvent::Wheel, WebCore::IntPoint(position), WebCore::IntPoint(globalPosition), WebCore::FloatSize(deltaX, deltaY), WebCore::FloatSize(wheelTicksX, wheelTicksY),
    430442        granularity, directionInvertedFromDevice, phase, momentumPhase, hasPreciseScrollingDeltas,
    431         scrollCount, unacceleratedScrollingDelta, modifiers, timestamp, ioHIDEventWallTime);
     443        scrollCount, unacceleratedScrollingDelta, modifiers, timestamp, ioHIDEventWallTime, rawPlatformDelta);
    432444}
    433445
Note: See TracChangeset for help on using the changeset viewer.