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

Changeset 286973 in webkit


Ignore:
Timestamp:
Dec 13, 2021, 12:56:48 PM (5 years ago)
Author:
Alan Coon
Message:

Cherry-pick r286900. rdar://problem/86344954

Momentum Event Dispatcher: Magic Mouse doesn't use momentum event dispatcher
https://bugs.webkit.org/show_bug.cgi?id=234189
<rdar://problem/86344954>

Reviewed by Simon Fraser.

  • Shared/mac/ScrollingAccelerationCurveMac.mm: (WebKit::fromIOHIDDevice): Fix the FIXME here about the additional fallback values; it turns out Magic Mouse is one device that does not have a value for kIOHIDScrollAccelerationTypeKey, so we need the full fallback chain to support it.
  • UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::sendWheelEvent): Un-wrapping this optional results in losing the engaged state, and sending a garbage ScrollingAccelerationCurve across the wire. The message argument is also an optional, so just pass it along.

The result of this bug was that if you had ever used a device with a curve
for a given page, and then used a device with no curve, MomentumEventDispatcher
would have a garbage curve (from this message trying to "unset" the optional),
and a garbage curve results in chaotic scrolling.

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

Location:
branches/safari-612-branch/Source/WebKit
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-612-branch/Source/WebKit/ChangeLog

    r286806 r286973  
     12021-12-13  Alan Coon  <alancoon@apple.com>
     2
     3        Cherry-pick r286900. rdar://problem/86344954
     4
     5    Momentum Event Dispatcher: Magic Mouse doesn't use momentum event dispatcher
     6    https://bugs.webkit.org/show_bug.cgi?id=234189
     7    <rdar://problem/86344954>
     8   
     9    Reviewed by Simon Fraser.
     10   
     11    * Shared/mac/ScrollingAccelerationCurveMac.mm:
     12    (WebKit::fromIOHIDDevice):
     13    Fix the FIXME here about the additional fallback values; it turns out
     14    Magic Mouse is one device that does not have a value for
     15    kIOHIDScrollAccelerationTypeKey, so we need the full fallback chain to support it.
     16   
     17    * UIProcess/WebPageProxy.cpp:
     18    (WebKit::WebPageProxy::sendWheelEvent):
     19    Un-wrapping this optional results in losing the engaged state, and sending
     20    a garbage ScrollingAccelerationCurve across the wire.
     21    The message argument is also an optional, so just pass it along.
     22   
     23    The result of this bug was that if you had ever used a device with a curve
     24    for a given page, and then used a device with no curve, MomentumEventDispatcher
     25    would have a garbage curve (from this message trying to "unset" the optional),
     26    and a garbage curve results in chaotic scrolling.
     27   
     28   
     29    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@286900 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     30
     31    2021-12-10  Tim Horton  <timothy_horton@apple.com>
     32
     33            Momentum Event Dispatcher: Magic Mouse doesn't use momentum event dispatcher
     34            https://bugs.webkit.org/show_bug.cgi?id=234189
     35            <rdar://problem/86344954>
     36
     37            Reviewed by Simon Fraser.
     38
     39            * Shared/mac/ScrollingAccelerationCurveMac.mm:
     40            (WebKit::fromIOHIDDevice):
     41            Fix the FIXME here about the additional fallback values; it turns out
     42            Magic Mouse is one device that does not have a value for
     43            kIOHIDScrollAccelerationTypeKey, so we need the full fallback chain to support it.
     44
     45            * UIProcess/WebPageProxy.cpp:
     46            (WebKit::WebPageProxy::sendWheelEvent):
     47            Un-wrapping this optional results in losing the engaged state, and sending
     48            a garbage ScrollingAccelerationCurve across the wire.
     49            The message argument is also an optional, so just pass it along.
     50
     51            The result of this bug was that if you had ever used a device with a curve
     52            for a given page, and then used a device with no curve, MomentumEventDispatcher
     53            would have a garbage curve (from this message trying to "unset" the optional),
     54            and a garbage curve results in chaotic scrolling.
     55
    1562021-12-09  Alan Coon  <alancoon@apple.com>
    257
  • branches/safari-612-branch/Source/WebKit/Shared/mac/ScrollingAccelerationCurveMac.mm

    r286691 r286973  
    117117    }
    118118
    119     // FIXME: There is some additional fallback to implement here, though this seems usually sufficient.
    120     auto scrollAccelerationType = adoptCF(dynamic_cf_cast<CFStringRef>(IOHIDServiceClientCopyProperty(ioHIDService.get(), CFSTR("HIDScrollAccelerationType"))));
    121     if (!scrollAccelerationType) {
    122         RELEASE_LOG(ScrollAnimations, "ScrollingAccelerationCurve::fromIOHIDDevice failed to look up acceleration type");
     119    auto readFixedPointServiceKey = [&] (CFStringRef key) -> std::optional<float> {
     120        auto valueCF = adoptCF(dynamic_cf_cast<CFNumberRef>(IOHIDServiceClientCopyProperty(ioHIDService.get(), key)));
     121        if (!valueCF)
     122            return std::nullopt;
     123        return fromFixedPoint([(NSNumber *)valueCF.get() floatValue]);
     124    };
     125
     126    auto scrollAcceleration = [&] () -> std::optional<float> {
     127        if (auto scrollAccelerationType = adoptCF(dynamic_cf_cast<CFStringRef>(IOHIDServiceClientCopyProperty(ioHIDService.get(), CFSTR("HIDScrollAccelerationType"))))) {
     128            if (auto acceleration = readFixedPointServiceKey(scrollAccelerationType.get()))
     129                return acceleration;
     130        }
     131
     132        if (auto acceleration = readFixedPointServiceKey(CFSTR(kIOHIDMouseScrollAccelerationKey)))
     133            return acceleration;
     134
     135        if (auto acceleration = readFixedPointServiceKey(CFSTR(kIOHIDScrollAccelerationKey)))
     136            return acceleration;
     137
     138        return std::nullopt;
     139    }();
     140    if (!scrollAcceleration) {
     141        RELEASE_LOG(ScrollAnimations, "ScrollingAccelerationCurve::fromIOHIDDevice failed to look up acceleration");
    123142        return std::nullopt;
    124143    }
    125144
    126     auto scrollAccelerationCF = adoptCF(dynamic_cf_cast<CFNumberRef>(IOHIDServiceClientCopyProperty(ioHIDService.get(), scrollAccelerationType.get())));
    127     if (!scrollAccelerationCF) {
    128         RELEASE_LOG(ScrollAnimations, "ScrollingAccelerationCurve::fromIOHIDDevice failed to look up acceleration value");
    129         return std::nullopt;
    130     }
    131     auto scrollAcceleration = fromFixedPoint(fromCFNumber(scrollAccelerationCF.get()));
    132 
    133     auto resolutionCF = adoptCF(dynamic_cf_cast<CFNumberRef>(IOHIDServiceClientCopyProperty(ioHIDService.get(), CFSTR(kIOHIDScrollResolutionKey))));
    134     if (!resolutionCF) {
     145    auto resolution = readFixedPointServiceKey(CFSTR(kIOHIDScrollResolutionKey));
     146    if (!resolution) {
    135147        RELEASE_LOG(ScrollAnimations, "ScrollingAccelerationCurve::fromIOHIDDevice failed to look up resolution");
    136148        return std::nullopt;
    137149    }
    138     auto resolution = fromFixedPoint([(NSNumber *)resolutionCF.get() floatValue]);
    139150
    140151    static CFStringRef dispatchFrameRateKey = CFSTR("ScrollMomentumDispatchRate");
     
    143154    float frameRate = frameRateCF ? fromCFNumber(frameRateCF.get()) : defaultDispatchFrameRate;
    144155
    145     return fromIOHIDCurveArrayWithAcceleration((NSArray *)curves.get(), scrollAcceleration, resolution, frameRate);
     156    return fromIOHIDCurveArrayWithAcceleration((NSArray *)curves.get(), *scrollAcceleration, *resolution, frameRate);
    146157}
    147158
  • branches/safari-612-branch/Source/WebKit/UIProcess/WebPageProxy.cpp

    r286740 r286973  
    29432943#if ENABLE(MOMENTUM_EVENT_DISPATCHER)
    29442944    if (event.momentumPhase() == WebWheelEvent::PhaseBegan && m_scrollingAccelerationCurve != m_lastSentScrollingAccelerationCurve) {
    2945         connection->send(Messages::EventDispatcher::SetScrollingAccelerationCurve(m_webPageID, *m_scrollingAccelerationCurve), 0, { }, Thread::QOS::UserInteractive);
     2945        connection->send(Messages::EventDispatcher::SetScrollingAccelerationCurve(m_webPageID, m_scrollingAccelerationCurve), 0, { }, Thread::QOS::UserInteractive);
    29462946        m_lastSentScrollingAccelerationCurve = m_scrollingAccelerationCurve;
    29472947    }
Note: See TracChangeset for help on using the changeset viewer.