← All issues

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

17c30e3

macOS의 텍스트 인터랙션은 기존 EventHandler 경로와 NSTextSelectionManager 기반의 AppKit-gestures 경로, 두 가지로 분리되어 있습니다. AppKit 경로에서는 UI process가 gesture 인식을 담당하고, extent-point 업데이트를 IPC를 통해 web process로 전달합니다. Web process는 scroll 상태를 관리하면서 scroll 알림을 역방향으로 전송하는데, Autoscroll은 web process 내부의 AutoscrollController가 50ms Selection 타이머로 구동합니다. iOS에서는 UIKit의 UITextAutoscrolling 프로토콜이 두 경로를 연결해 주지만, AppKit에는 이에 해당하는 메커니즘이 없습니다.

Source/WebCore/page/EventHandler.cpp

void EventHandler::updateSelectionForMouseDrag()
{
if (!supportsSelectionUpdatesOnMouseDrag())
return;
 
+#if PLATFORM(COCOA)
+ // Selection-drag 중에는 UI process가 페이지 autoscroll에 맞춰 selection을 다시 확장하므로,
+ // 오래된 마지막 mouse 위치를 사용해 여기서 중복으로 re-extend하지 않도록 한다.
+ if (m_isAutoscrolling)
+ return;
+#endif
-#endif // !PLATFORM(IOS_FAMILY)
+#endif // !PLATFORM(COCOA)

이 commit은 기존 iOS autoscroll 구현을 재활용하여, AppKit-gestures 경로에서 macOS의 selection-drag autoscroll을 구현합니다. 이를 위해 세 가지 변경이 추가되었습니다. 먼저 EventHandler에 edge-band 근접 감지 함수(isPointNearSelectionAutoscrollEdge)가 추가되었고, updateSelectionForMouseDrag에는 억제 guard가 적용되었습니다. 아울러 WKTextSelectionController에 UI process 측 re-extension hook이 추가되어, drag 진행 중 scroll 이벤트마다 호출됩니다. Web process는 extent-point IPC가 수신될 때마다 edge 근접 여부를 평가해 autoscroll 타이머를 시작하거나 취소합니다. scroll이 발생하면 UI process에 알림을 전송하고, UI process는 그 알림을 받아 새로 드러난 콘텐츠 영역으로 selection을 다시 확장합니다.

텍스트 selection을 위한 UI process와 web process 간의 양방향 cross-process feedback loop가 새롭게 도입되었습니다. IPC 경로, 좌표 변환 로직, 타이머 기반 state machine 모두 macOS에는 기존에 없던 구조입니다.

🔒

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

더 확인하려면 구독해 주세요