From aca4bde93d603d738479960b7319685645177441 Mon Sep 17 00:00:00 2001 From: Euclid Ye Date: Fri, 15 Aug 2025 16:55:25 +0800 Subject: [PATCH] servoshell: Do not send mouse button events to Servo that happen outside the `WebView` (#38696) `webview_relative_mouse_point` can have negative y-coordinate when at toolbar, but we still would notify compositor the native mousebutton event to do hit-test. Testing: This fixes the way that mouse events are passed from servoshell to Servo, but there is currently no way to test those kind of interactions. Signed-off-by: Euclid Ye --- ports/servoshell/desktop/headed_window.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ports/servoshell/desktop/headed_window.rs b/ports/servoshell/desktop/headed_window.rs index 39021171945..8e9cc88ec42 100644 --- a/ports/servoshell/desktop/headed_window.rs +++ b/ports/servoshell/desktop/headed_window.rs @@ -287,6 +287,10 @@ impl Window { }; let point = self.webview_relative_mouse_point.get(); + // `point` can be outside viewport, such as at toolbar with negative y-coordinate. + if !webview.rect().contains(point) { + return; + } let action = match action { ElementState::Pressed => MouseButtonAction::Down, ElementState::Released => MouseButtonAction::Up,