Rename InputEvent::MouseLeave to InputEvent::MouseLeftViewport (#38695)

1. `InputEvent::MouseLeave` indicates that mouse has left the viewport
(fired by embedder) or iframe (synthesized in Constellation
f24f225db8/components/constellation/constellation_webview.rs (L119-L122)).
Its handler in script is named as `handle_mouse_leave_event`, which is
very misleading as we have DOM event
[mouseleave](https://w3c.github.io/uievents/#event-type-mouseleave). I
rename it to `MouseLeftViewport` to be consistent with
`WindowEvent::CursorLeft`:
f24f225db8/ports/servoshell/desktop/headed_window.rs (L632-L638)
2. Add doc and rename function, such as `handle_mouse_move_event` to
`handle_native_mouse_move_event` to be closer to
[spec](https://w3c.github.io/uievents/#handle-native-mouse-move).

Testing: Just renaming + skipping unnecessary hit-test in simple case.
Fixes: Nothing but preparing for #38670 and #38435.

---------

Signed-off-by: Euclid Ye <euclid.ye@huawei.com>
This commit is contained in:
Euclid Ye 2025-08-15 17:54:54 +08:00 committed by GitHub
parent 8b574539d1
commit 494493ceb7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 33 additions and 27 deletions

View file

@ -355,7 +355,7 @@ impl WebViewRenderer {
InputEvent::MouseMove(_) => {
self.global.borrow_mut().last_mouse_move_position = event_point;
},
InputEvent::MouseLeave(_) => {
InputEvent::MouseLeftViewport(_) => {
self.global.borrow_mut().last_mouse_move_position = None;
},
InputEvent::MouseButton(_) | InputEvent::Wheel(_) => {},