Title: [286973] branches/safari-612-branch/Source/WebKit
Revision
286973
Author
alanc...@apple.com
Date
2021-12-13 12:56:48 -0800 (Mon, 13 Dec 2021)

Log 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

Modified Paths

Diff

Modified: branches/safari-612-branch/Source/WebKit/ChangeLog (286972 => 286973)


--- branches/safari-612-branch/Source/WebKit/ChangeLog	2021-12-13 20:38:56 UTC (rev 286972)
+++ branches/safari-612-branch/Source/WebKit/ChangeLog	2021-12-13 20:56:48 UTC (rev 286973)
@@ -1,3 +1,58 @@
+2021-12-13  Alan Coon  <alanc...@apple.com>
+
+        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
+
+    2021-12-10  Tim Horton  <timothy_hor...@apple.com>
+
+            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.
+
 2021-12-09  Alan Coon  <alanc...@apple.com>
 
         Cherry-pick r286805. rdar://problem/86291413

Modified: branches/safari-612-branch/Source/WebKit/Shared/mac/ScrollingAccelerationCurveMac.mm (286972 => 286973)


--- branches/safari-612-branch/Source/WebKit/Shared/mac/ScrollingAccelerationCurveMac.mm	2021-12-13 20:38:56 UTC (rev 286972)
+++ branches/safari-612-branch/Source/WebKit/Shared/mac/ScrollingAccelerationCurveMac.mm	2021-12-13 20:56:48 UTC (rev 286973)
@@ -116,26 +116,37 @@
         return std::nullopt;
     }
 
-    // FIXME: There is some additional fallback to implement here, though this seems usually sufficient.
-    auto scrollAccelerationType = adoptCF(dynamic_cf_cast<CFStringRef>(IOHIDServiceClientCopyProperty(ioHIDService.get(), CFSTR("HIDScrollAccelerationType"))));
-    if (!scrollAccelerationType) {
-        RELEASE_LOG(ScrollAnimations, "ScrollingAccelerationCurve::fromIOHIDDevice failed to look up acceleration type");
-        return std::nullopt;
-    }
+    auto readFixedPointServiceKey = [&] (CFStringRef key) -> std::optional<float> {
+        auto valueCF = adoptCF(dynamic_cf_cast<CFNumberRef>(IOHIDServiceClientCopyProperty(ioHIDService.get(), key)));
+        if (!valueCF)
+            return std::nullopt;
+        return fromFixedPoint([(NSNumber *)valueCF.get() floatValue]);
+    };
 
-    auto scrollAccelerationCF = adoptCF(dynamic_cf_cast<CFNumberRef>(IOHIDServiceClientCopyProperty(ioHIDService.get(), scrollAccelerationType.get())));
-    if (!scrollAccelerationCF) {
-        RELEASE_LOG(ScrollAnimations, "ScrollingAccelerationCurve::fromIOHIDDevice failed to look up acceleration value");
+    auto scrollAcceleration = [&] () -> std::optional<float> {
+        if (auto scrollAccelerationType = adoptCF(dynamic_cf_cast<CFStringRef>(IOHIDServiceClientCopyProperty(ioHIDService.get(), CFSTR("HIDScrollAccelerationType"))))) {
+            if (auto acceleration = readFixedPointServiceKey(scrollAccelerationType.get()))
+                return acceleration;
+        }
+
+        if (auto acceleration = readFixedPointServiceKey(CFSTR(kIOHIDMouseScrollAccelerationKey)))
+            return acceleration;
+
+        if (auto acceleration = readFixedPointServiceKey(CFSTR(kIOHIDScrollAccelerationKey)))
+            return acceleration;
+
         return std::nullopt;
+    }();
+    if (!scrollAcceleration) {
+        RELEASE_LOG(ScrollAnimations, "ScrollingAccelerationCurve::fromIOHIDDevice failed to look up acceleration");
+        return std::nullopt;
     }
-    auto scrollAcceleration = fromFixedPoint(fromCFNumber(scrollAccelerationCF.get()));
 
-    auto resolutionCF = adoptCF(dynamic_cf_cast<CFNumberRef>(IOHIDServiceClientCopyProperty(ioHIDService.get(), CFSTR(kIOHIDScrollResolutionKey))));
-    if (!resolutionCF) {
+    auto resolution = readFixedPointServiceKey(CFSTR(kIOHIDScrollResolutionKey));
+    if (!resolution) {
         RELEASE_LOG(ScrollAnimations, "ScrollingAccelerationCurve::fromIOHIDDevice failed to look up resolution");
         return std::nullopt;
     }
-    auto resolution = fromFixedPoint([(NSNumber *)resolutionCF.get() floatValue]);
 
     static CFStringRef dispatchFrameRateKey = CFSTR("ScrollMomentumDispatchRate");
     static constexpr float defaultDispatchFrameRate = 60;
@@ -142,7 +153,7 @@
     auto frameRateCF = adoptCF(dynamic_cf_cast<CFNumberRef>(IOHIDServiceClientCopyProperty(ioHIDService.get(), dispatchFrameRateKey)));
     float frameRate = frameRateCF ? fromCFNumber(frameRateCF.get()) : defaultDispatchFrameRate;
 
-    return fromIOHIDCurveArrayWithAcceleration((NSArray *)curves.get(), scrollAcceleration, resolution, frameRate);
+    return fromIOHIDCurveArrayWithAcceleration((NSArray *)curves.get(), *scrollAcceleration, *resolution, frameRate);
 }
 
 std::optional<ScrollingAccelerationCurve> ScrollingAccelerationCurve::fromNativeWheelEvent(const NativeWebWheelEvent& nativeWebWheelEvent)

Modified: branches/safari-612-branch/Source/WebKit/UIProcess/WebPageProxy.cpp (286972 => 286973)


--- branches/safari-612-branch/Source/WebKit/UIProcess/WebPageProxy.cpp	2021-12-13 20:38:56 UTC (rev 286972)
+++ branches/safari-612-branch/Source/WebKit/UIProcess/WebPageProxy.cpp	2021-12-13 20:56:48 UTC (rev 286973)
@@ -2942,7 +2942,7 @@
 
 #if ENABLE(MOMENTUM_EVENT_DISPATCHER)
     if (event.momentumPhase() == WebWheelEvent::PhaseBegan && m_scrollingAccelerationCurve != m_lastSentScrollingAccelerationCurve) {
-        connection->send(Messages::EventDispatcher::SetScrollingAccelerationCurve(m_webPageID, *m_scrollingAccelerationCurve), 0, { }, Thread::QOS::UserInteractive);
+        connection->send(Messages::EventDispatcher::SetScrollingAccelerationCurve(m_webPageID, m_scrollingAccelerationCurve), 0, { }, Thread::QOS::UserInteractive);
         m_lastSentScrollingAccelerationCurve = m_scrollingAccelerationCurve;
     }
 #endif
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to