Attempting to modify selection while zoomed in results in fast, unexpected scrolling.
https://bugs.webkit.org/show_bug.cgi?id=292897
rdar://150884677

Reviewed by Aditya Keerthi.

With the change in 290497@main I changed the code to have a static offset
that didn't change with zoom. Before it was taking the minimum of a static
offset and the delta of how far the point had traveled, which was almost
always small, so it was always the small number, and scrolling was slow
but also wasn't affected by zooming. We just need to scale the static
offsets and speed by the current zoom factor to keep a consistent experience
at any zoom level.

* Source/WebCore/page/ios/EventHandlerIOS.mm:
(WebCore::adjustAutoscrollDestinationForInsetEdges):
(WebCore::EventHandler::targetPositionInWindowForSelectionAutoscroll const):

Canonical link: https://commits.webkit.org/294874@main
diff --git a/Source/WebCore/page/ios/EventHandlerIOS.mm b/Source/WebCore/page/ios/EventHandlerIOS.mm
index a25583f..cc8670c 100644
--- a/Source/WebCore/page/ios/EventHandlerIOS.mm
+++ b/Source/WebCore/page/ios/EventHandlerIOS.mm
@@ -622,12 +622,12 @@
     m_autoscrollController->stopAutoscrollTimer();
 }
 
-static IntPoint adjustAutoscrollDestinationForInsetEdges(IntPoint autoscrollPoint, std::optional<IntPoint> initialAutoscrollPoint, FloatRect unobscuredRootViewRect)
+static IntPoint adjustAutoscrollDestinationForInsetEdges(IntPoint autoscrollPoint, std::optional<IntPoint> initialAutoscrollPoint, FloatRect unobscuredRootViewRect, float zoomScale)
 {
     IntPoint resultPoint = autoscrollPoint;
 
-    const float edgeInset = 100;
-    const float maximumScrollingSpeed = 40;
+    const float edgeInset = 100 / zoomScale;
+    const float maximumScrollingSpeed = 40 / zoomScale;
     const float insetDistanceThreshold = edgeInset / 2;
 
     // FIXME: Ideally we would only inset on edges that touch the edge of the screen,
@@ -687,6 +687,10 @@
     if (!frame->isMainFrame())
         return m_targetAutoscrollPositionInRootView;
 
+    RefPtr page = frame->page();
+    if (!page)
+        return m_targetAutoscrollPositionInRootView;
+
     Ref frameView = *frame->view();
 
     // All work is done in "unscrolled" root view coordinates (as if delegatesScrolling were off),
@@ -697,7 +701,7 @@
     FloatRect unobscuredContentRectInUnscrolledRootView = frameView->contentsToRootView(frameView->unobscuredContentRect());
     unobscuredContentRectInUnscrolledRootView.move(-scrollPosition);
 
-    return adjustAutoscrollDestinationForInsetEdges(m_targetAutoscrollPositionInUnscrolledRootView, m_initialAutoscrollPositionInUnscrolledRootView, unobscuredContentRectInUnscrolledRootView) + scrollPosition;
+    return adjustAutoscrollDestinationForInsetEdges(m_targetAutoscrollPositionInUnscrolledRootView, m_initialAutoscrollPositionInUnscrolledRootView, unobscuredContentRectInUnscrolledRootView, page->pageScaleFactor()) + scrollPosition;
 }
 
 bool EventHandler::shouldUpdateAutoscroll()