Historical Sliding Code Cleanup and Refactoring

Commit: 2e0b5fd8 | 2025-06-10 21:58:08+00:00

← Back to List

Historical Sliding Code Cleanup and Refactoring

Minor
Commit Hash: 2e0b5fd855ceeb4c7438a1417652607f845daeb1
Commit Time: 2025-06-10 21:58:08+00:00
Impact Level: Minor
Generated By: webview2-upstream-sentry
Upstream Review: View Upstream Review 🔗

📋 Summary

This submission performs a comprehensive cleanup and refactoring of the historical swipe code. The main changes include:
1. Renamed the AcceptMouseEventsOption enum to AcceptMouseEvents and converted it to a strongly typed enum; enum values were renamed from kAcceptMouseEventsXxx to kWhenInXxx or kAlways.
2. Refactored the touch event handling logic in the HistorySwiper class, replacing boolean flags with std::optional, and improved variable naming and code organization.
3. Improved documentation and code structure for Magic Mouse event handling.
4. Used constexpr instead of const for constant definitions, and replaced custom implementations with standard library functions such as std::abs and std::clamp.
5. Updated a large number of method and variable names to more accurately reflect their functionality, such as renaming averagePositionInEvent to averagePositionInTouchEvent.
6. Enhanced code comments, especially regarding the handling flow of different types of scroll events.

🎯 Impact Analysis

This refactoring primarily affects mouse event acceptance behavior and the historical swipe gesture handling mechanism. The potential impacts on WebView2Mac include:
1. Mouse event handling: The refactoring of the AcceptMouseEvents enumeration may affect WebView2Mac’s mouse event response behavior in inactive window states, especially in scenarios requiring customized mouse event acceptance strategies.
2. Touch event handling: The refactoring of touch event handling logic in HistorySwiper may impact the implementation of custom gesture recognition functionality in WebView2Mac.
3. API compatibility: Although the changes to enumeration value naming remain semantically consistent, downstream code that directly uses these enumeration values may need to be updated accordingly.
4. As this is a code cleanup rather than a functional change, the core historical swipe logic remains unchanged, so the actual functional impact on WebView2Mac is relatively minor.
5. Improvements in code quality facilitate subsequent maintenance and expansion, having a positive effect on long-term stability.

Impacted Classes:

AcceptMouseEvents HistorySwiper RenderWidgetHostViewCocoa ChromeRenderWidgetHostViewMacDelegate RenderWidgetHostViewMacDelegate