Remove dependency on gesture events in swiper and modernize

Commit: bb6a9b9a | 2025-06-03 16:41:00+00:00

← Back to List

Remove dependency on gesture events in swiper and modernize

Moderate
Commit Hash: bb6a9b9aadd8f963f1411991df4659261bd35bce
Commit Time: 2025-06-03 16:41:00+00:00
Impact Level: Moderate
Generated By: webview2-upstream-sentry
Upstream Review: View Upstream Review 🔗

📋 Summary

This submission primarily removes RenderWidgetHostViewCocoa’s dependency on legacy gesture events (beginGestureWithEvent: and endGestureWithEvent:) and introduces modernization improvements. On macOS 10.11 and later, these gesture events are no longer sent, but the code continued to invoke these methods for compensation. This change allows RenderWidgetHostViewCocoa to directly forward scroll events to the swiper, letting the swiper decide how to handle them, and updates the corresponding test code to match the new implementation. The main changes include:
1. Removed the beginGestureWithEvent and endGestureWithEvent methods from the RenderWidgetHostViewMacDelegate protocol.
2. Eliminated calls to these gesture methods in render_widget_host_view_cocoa.mm, instead directly handling scroll events in the scrollWheel method.
3. Integrated the gesture begin/end logic directly into the handleScrollWheelEvent method in HistorySwiper, processing them by checking event.phase.
4. Updated a large amount of test code, removing simulation of gesture events and adopting a more modern implementation approach.

🎯 Impact Analysis

This change has a moderate impact on WebView2Mac. The main impacts include:
1. **API Compatibility Impact**: If downstream implementations of WebView2Mac rely on the beginGestureWithEvent and endGestureWithEvent methods of RenderWidgetHostViewMacDelegate, these methods have been completely removed and require corresponding adjustments.
2. **Gesture Handling Workflow Changes**: The detection of gesture start and end is now fully integrated into scroll event processing, identified via NSEventPhaseBegan and NSEventPhaseEnded. This may affect gesture recognition and history navigation functionality in WebView2Mac.
3. **Remote Cocoa Behavior Changes**: In render_widget_host_view_cocoa.mm, the processing logic of the scrollWheel method has undergone significant changes. Gesture detection now fully depends on the delegate's handleEvent method, which may impact event handling for WebView2Mac in Remote Cocoa environments.
4. **Testing and Verification Impact**: The extensive updates to test code indicate major changes in API and behavior. WebView2Mac needs to verify whether its gesture handling functionality works correctly under the new implementation.
Overall, although this change aims to modernize and remove dependencies on obsolete APIs, it may cause functional impacts on downstream code (such as WebView2Mac) that depend on these APIs.

Impacted Classes:

RenderWidgetHostViewMacDelegate RenderWidgetHostViewCocoa HistorySwiper ChromeRenderWidgetHostViewMacDelegate AppShimRenderWidgetHostViewMacDelegate ShellRenderWidgetHostViewMacDelegate