mirror of
https://github.com/servo/servo.git
synced 2025-09-23 05:10:09 +01:00
Rename InputEvent::MouseLeave
to InputEvent::MouseLeftViewport
(#38695)
1. `InputEvent::MouseLeave` indicates that mouse has left the viewport (fired by embedder) or iframe (synthesized in Constellationf24f225db8/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:
parent
8b574539d1
commit
494493ceb7
6 changed files with 33 additions and 27 deletions
|
@ -5,7 +5,7 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
use base::id::{BrowsingContextId, PipelineId};
|
||||
use embedder_traits::{InputEvent, MouseLeaveEvent, Theme};
|
||||
use embedder_traits::{InputEvent, MouseLeftViewportEvent, Theme};
|
||||
use euclid::Point2D;
|
||||
use log::warn;
|
||||
use script_traits::{ConstellationInputEvent, ScriptThreadMessage};
|
||||
|
@ -72,7 +72,7 @@ impl ConstellationWebView {
|
|||
|
||||
// If there's no hit test, send the event to either the hovered or focused browsing context,
|
||||
// depending on the event type.
|
||||
let browsing_context_id = if matches!(event.event, InputEvent::MouseLeave(_)) {
|
||||
let browsing_context_id = if matches!(event.event, InputEvent::MouseLeftViewport(_)) {
|
||||
self.hovered_browsing_context_id
|
||||
.unwrap_or(self.focused_browsing_context_id)
|
||||
} else {
|
||||
|
@ -117,9 +117,10 @@ impl ConstellationWebView {
|
|||
};
|
||||
|
||||
let mut synthetic_mouse_leave_event = event.clone();
|
||||
synthetic_mouse_leave_event.event = InputEvent::MouseLeave(MouseLeaveEvent {
|
||||
focus_moving_to_another_iframe: true,
|
||||
});
|
||||
synthetic_mouse_leave_event.event =
|
||||
InputEvent::MouseLeftViewport(MouseLeftViewportEvent {
|
||||
focus_moving_to_another_iframe: true,
|
||||
});
|
||||
|
||||
let _ = pipeline
|
||||
.event_loop
|
||||
|
@ -129,7 +130,7 @@ impl ConstellationWebView {
|
|||
));
|
||||
};
|
||||
|
||||
if let InputEvent::MouseLeave(_) = &event.event {
|
||||
if let InputEvent::MouseLeftViewport(_) = &event.event {
|
||||
update_hovered_browsing_context(None);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -96,7 +96,7 @@ mod from_compositor {
|
|||
InputEvent::Keyboard(..) => target_variant!("Keyboard"),
|
||||
InputEvent::MouseButton(..) => target_variant!("MouseButton"),
|
||||
InputEvent::MouseMove(..) => target_variant!("MouseMove"),
|
||||
InputEvent::MouseLeave(..) => target_variant!("MouseLeave"),
|
||||
InputEvent::MouseLeftViewport(..) => target_variant!("MouseLeftViewport"),
|
||||
InputEvent::Touch(..) => target_variant!("Touch"),
|
||||
InputEvent::Wheel(..) => target_variant!("Wheel"),
|
||||
InputEvent::Scroll(..) => target_variant!("Scroll"),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue