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

Changeset 286713 in webkit


Ignore:
Timestamp:
Dec 8, 2021, 1:25:18 PM (5 years ago)
Author:
Alan Coon
Message:

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

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.

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

Location:
branches/safari-612.4.2.1-branch/Source
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-612.4.2.1-branch/Source/WebCore/ChangeLog

    r286712 r286713  
     12021-12-01  Alan Coon  <alancoon@apple.com>
     2
     3        Cherry-pick r286270. rdar://problem/85928816
     4
     5    Plumb raw platform scrolling deltas along in wheel events
     6    https://bugs.webkit.org/show_bug.cgi?id=233583
     7   
     8    Reviewed by Simon Fraser.
     9   
     10    Source/WebCore:
     11   
     12    * platform/PlatformWheelEvent.cpp:
     13    (WebCore::PlatformWheelEvent::createFromGesture):
     14    * platform/PlatformWheelEvent.h:
     15    (WebCore::PlatformWheelEvent::rawPlatformDelta const):
     16    * PAL/pal/spi/mac/IOKitSPIMac.h:
     17   
     18    Source/WebKit:
     19   
     20    * Shared/WebEventConversion.cpp:
     21    (WebKit::WebKit2PlatformWheelEvent::WebKit2PlatformWheelEvent):
     22    * Shared/WebWheelEvent.cpp:
     23    (WebKit::WebWheelEvent::WebWheelEvent):
     24    (WebKit::WebWheelEvent::encode const):
     25    (WebKit::WebWheelEvent::decode):
     26    * Shared/WebWheelEvent.h:
     27    (WebKit::WebWheelEvent::rawPlatformDelta const):
     28    * Shared/WebWheelEventCoalescer.cpp:
     29    (WebKit::WebWheelEventCoalescer::coalesce):
     30    * Shared/mac/WebEventFactory.mm:
     31    (WebKit::WebEventFactory::createWebWheelEvent):
     32    Extract and plumb raw unaccelerated (in the HID sense) deltas in scroll
     33    events for use in a future patch.
     34   
     35   
     36    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@286270 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     37
     38    2021-11-29  Tim Horton  <timothy_horton@apple.com>
     39
     40            Plumb raw platform scrolling deltas along in wheel events
     41            https://bugs.webkit.org/show_bug.cgi?id=233583
     42
     43            Reviewed by Simon Fraser.
     44
     45            * platform/PlatformWheelEvent.cpp:
     46            (WebCore::PlatformWheelEvent::createFromGesture):
     47            * platform/PlatformWheelEvent.h:
     48            (WebCore::PlatformWheelEvent::rawPlatformDelta const):
     49            * PAL/pal/spi/mac/IOKitSPIMac.h:
     50
    1512021-12-01  Alan Coon  <alancoon@apple.com>
    252
  • branches/safari-612.4.2.1-branch/Source/WebCore/PAL/pal/spi/mac/IOKitSPIMac.h

    r286712 r286713  
    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
  • branches/safari-612.4.2.1-branch/Source/WebCore/platform/PlatformWheelEvent.cpp

    r286712 r286713  
    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)
  • branches/safari-612.4.2.1-branch/Source/WebCore/platform/PlatformWheelEvent.h

    r286712 r286713  
    155155   
    156156    WallTime ioHIDEventTimestamp() const { return m_ioHIDEventTimestamp; }
     157
     158    std::optional<FloatSize> rawPlatformDelta() const { return m_rawPlatformDelta; }
    157159#endif
    158160
     
    204206#if PLATFORM(COCOA)
    205207    WallTime m_ioHIDEventTimestamp;
     208    std::optional<FloatSize> m_rawPlatformDelta;
    206209    unsigned m_scrollCount { 0 };
    207210    float m_unacceleratedScrollingDeltaX { 0 };
  • branches/safari-612.4.2.1-branch/Source/WebKit/ChangeLog

    r286712 r286713  
     12021-12-01  Alan Coon  <alancoon@apple.com>
     2
     3        Cherry-pick r286270. rdar://problem/85928816
     4
     5    Plumb raw platform scrolling deltas along in wheel events
     6    https://bugs.webkit.org/show_bug.cgi?id=233583
     7   
     8    Reviewed by Simon Fraser.
     9   
     10    Source/WebCore:
     11   
     12    * platform/PlatformWheelEvent.cpp:
     13    (WebCore::PlatformWheelEvent::createFromGesture):
     14    * platform/PlatformWheelEvent.h:
     15    (WebCore::PlatformWheelEvent::rawPlatformDelta const):
     16    * PAL/pal/spi/mac/IOKitSPIMac.h:
     17   
     18    Source/WebKit:
     19   
     20    * Shared/WebEventConversion.cpp:
     21    (WebKit::WebKit2PlatformWheelEvent::WebKit2PlatformWheelEvent):
     22    * Shared/WebWheelEvent.cpp:
     23    (WebKit::WebWheelEvent::WebWheelEvent):
     24    (WebKit::WebWheelEvent::encode const):
     25    (WebKit::WebWheelEvent::decode):
     26    * Shared/WebWheelEvent.h:
     27    (WebKit::WebWheelEvent::rawPlatformDelta const):
     28    * Shared/WebWheelEventCoalescer.cpp:
     29    (WebKit::WebWheelEventCoalescer::coalesce):
     30    * Shared/mac/WebEventFactory.mm:
     31    (WebKit::WebEventFactory::createWebWheelEvent):
     32    Extract and plumb raw unaccelerated (in the HID sense) deltas in scroll
     33    events for use in a future patch.
     34   
     35   
     36    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@286270 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     37
     38    2021-11-29  Tim Horton  <timothy_horton@apple.com>
     39
     40            Plumb raw platform scrolling deltas along in wheel events
     41            https://bugs.webkit.org/show_bug.cgi?id=233583
     42
     43            Reviewed by Simon Fraser.
     44
     45            * Shared/WebEventConversion.cpp:
     46            (WebKit::WebKit2PlatformWheelEvent::WebKit2PlatformWheelEvent):
     47            * Shared/WebWheelEvent.cpp:
     48            (WebKit::WebWheelEvent::WebWheelEvent):
     49            (WebKit::WebWheelEvent::encode const):
     50            (WebKit::WebWheelEvent::decode):
     51            * Shared/WebWheelEvent.h:
     52            (WebKit::WebWheelEvent::rawPlatformDelta const):
     53            * Shared/WebWheelEventCoalescer.cpp:
     54            (WebKit::WebWheelEventCoalescer::coalesce):
     55            * Shared/mac/WebEventFactory.mm:
     56            (WebKit::WebEventFactory::createWebWheelEvent):
     57            Extract and plumb raw unaccelerated (in the HID sense) deltas in scroll
     58            events for use in a future patch.
     59
    1602021-12-01  Alan Coon  <alancoon@apple.com>
    261
  • branches/safari-612.4.2.1-branch/Source/WebKit/Shared/WebEventConversion.cpp

    r286712 r286713  
    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();
  • branches/safari-612.4.2.1-branch/Source/WebKit/Shared/WebWheelEvent.cpp

    r286712 r286713  
    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;
  • branches/safari-612.4.2.1-branch/Source/WebKit/Shared/WebWheelEvent.h

    r286712 r286713  
    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;
  • branches/safari-612.4.2.1-branch/Source/WebKit/Shared/WebWheelEventCoalescer.cpp

    r286712 r286713  
    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());
  • branches/safari-612.4.2.1-branch/Source/WebKit/Shared/mac/WebEventFactory.mm

    r286712 r286713  
    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.