← All issues

[AppKit Gestures] Selection-drag autoscroll to the window edge on macOS

17c30e3

WebKit separates text interaction on macOS into the legacy EventHandler path and the newer AppKit-gestures path driven by NSTextSelectionManager. In the AppKit path the UI process owns gesture recognition and sends extent-point updates to the web process over IPC; the web process owns scroll state and fires back scroll notifications. Autoscroll is driven by AutoscrollController's 50ms Selection timer inside the web process. On iOS, UIKit's UITextAutoscrolling protocol bridges these; AppKit has no equivalent.

Source/WebCore/page/EventHandler.cpp

void EventHandler::updateSelectionForMouseDrag()
{
if (!supportsSelectionUpdatesOnMouseDrag())
return;
 
+#if PLATFORM(COCOA)
+ // During a selection-drag, the UI process re-extends the selection as the page
+ // autoscrolls, so don't also re-extend here using the stale last-known mouse position.
+ if (m_isAutoscrolling)
+ return;
+#endif
-#endif // !PLATFORM(IOS_FAMILY)
+#endif // !PLATFORM(COCOA)

This commit implements selection-drag autoscroll on macOS for the AppKit-gestures path by reusing the existing iOS autoscroll machinery. It adds edge-band proximity detection in EventHandler (isPointNearSelectionAutoscrollEdge), a suppression guard in updateSelectionForMouseDrag, and a UI-process re-extension hook in WKTextSelectionController that fires on every scroll event while a drag is in-flight. The web process evaluates edge proximity on each incoming extent-point IPC and starts or cancels the autoscroll timer, then notifies the UI process on scroll so it can re-extend the selection into newly revealed content.

This introduces a new bidirectional cross-process feedback loop between the UI and web process for text selection, creating new IPC paths, coordinate-transform logic, and a timer-driven state machine that didn't exist on macOS before.

🔒

New cross-process autoscroll feedback loop with concurrent timer and IPC paths — several edge cases in state management are worth investigating.

Subscribe to read more