mirror of
https://github.com/servo/servo.git
synced 2025-09-27 23:30:08 +01:00
script/compositor: Send mouseleave
events when cursor moves between <iframe>
s (#38539)
Properly send `mouseleave` events when the cursor moves between `<iframe>`s. This allows a better handling of cursor changes and status text updates. Specifically, we do not need to continuously update the cursor and the value can be cached in the `Document`. In addition, status updates can now be sent properly when moving focus between `<iframe>`s. Note that style updates for `:hover` values are still broken, but less so than before. Now the hover state on the `Node` is updated, but for some reason the restyle isn't taking place properly. This maintains the status quo as far as behavior goes when hover moves between `<iframe>`s. This change also adds a helper data structure to `Document` which will eventually be responsible for event handling. Testing: Cursor and status change are currently very hard to test as the API test harness makes this difficult at the moment. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
parent
82ca2b92cd
commit
b75c3feb97
11 changed files with 307 additions and 210 deletions
|
@ -329,23 +329,23 @@ impl WebViewRenderer {
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) fn dispatch_point_input_event(&self, mut event: InputEvent) -> bool {
|
||||
// Events that do not need to do hit testing are sent directly to the
|
||||
// constellation to filter down.
|
||||
let Some(point) = event.point() else {
|
||||
return false;
|
||||
};
|
||||
|
||||
// If we can't find a pipeline to send this event to, we cannot continue.
|
||||
let Some(result) = self
|
||||
.global
|
||||
.borrow()
|
||||
.hit_test_at_point(point)
|
||||
.into_iter()
|
||||
.nth(0)
|
||||
else {
|
||||
warn!("Empty hit test result for input event, ignoring.");
|
||||
return false;
|
||||
pub(crate) fn dispatch_input_event_with_hit_testing(&self, mut event: InputEvent) -> bool {
|
||||
let event_point = event.point();
|
||||
let hit_test_result = match event_point {
|
||||
Some(point) => {
|
||||
let hit_test_result = self
|
||||
.global
|
||||
.borrow()
|
||||
.hit_test_at_point(point)
|
||||
.into_iter()
|
||||
.nth(0);
|
||||
if hit_test_result.is_none() {
|
||||
warn!("Empty hit test result for input event, ignoring.");
|
||||
return false;
|
||||
}
|
||||
hit_test_result
|
||||
},
|
||||
None => None,
|
||||
};
|
||||
|
||||
match event {
|
||||
|
@ -353,7 +353,7 @@ impl WebViewRenderer {
|
|||
touch_event.init_sequence_id(self.touch_handler.current_sequence_id);
|
||||
},
|
||||
InputEvent::MouseMove(_) => {
|
||||
self.global.borrow_mut().last_mouse_move_position = Some(point);
|
||||
self.global.borrow_mut().last_mouse_move_position = event_point;
|
||||
},
|
||||
InputEvent::MouseLeave(_) => {
|
||||
self.global.borrow_mut().last_mouse_move_position = None;
|
||||
|
@ -363,7 +363,7 @@ impl WebViewRenderer {
|
|||
}
|
||||
|
||||
if let Err(error) = self.global.borrow().constellation_sender.send(
|
||||
EmbedderToConstellationMessage::ForwardInputEvent(self.id, event, Some(result)),
|
||||
EmbedderToConstellationMessage::ForwardInputEvent(self.id, event, hit_test_result),
|
||||
) {
|
||||
warn!("Sending event to constellation failed ({error:?}).");
|
||||
false
|
||||
|
@ -438,11 +438,11 @@ impl WebViewRenderer {
|
|||
}
|
||||
}
|
||||
|
||||
self.dispatch_point_input_event(event);
|
||||
self.dispatch_input_event_with_hit_testing(event);
|
||||
}
|
||||
|
||||
fn send_touch_event(&mut self, event: TouchEvent) -> bool {
|
||||
self.dispatch_point_input_event(InputEvent::Touch(event))
|
||||
self.dispatch_input_event_with_hit_testing(InputEvent::Touch(event))
|
||||
}
|
||||
|
||||
pub(crate) fn on_touch_event(&mut self, event: TouchEvent) {
|
||||
|
@ -706,13 +706,15 @@ impl WebViewRenderer {
|
|||
/// <http://w3c.github.io/touch-events/#mouse-events>
|
||||
fn simulate_mouse_click(&mut self, point: DevicePoint) {
|
||||
let button = MouseButton::Left;
|
||||
self.dispatch_point_input_event(InputEvent::MouseMove(MouseMoveEvent::new(point)));
|
||||
self.dispatch_point_input_event(InputEvent::MouseButton(MouseButtonEvent::new(
|
||||
self.dispatch_input_event_with_hit_testing(InputEvent::MouseMove(MouseMoveEvent::new(
|
||||
point,
|
||||
)));
|
||||
self.dispatch_input_event_with_hit_testing(InputEvent::MouseButton(MouseButtonEvent::new(
|
||||
MouseButtonAction::Down,
|
||||
button,
|
||||
point,
|
||||
)));
|
||||
self.dispatch_point_input_event(InputEvent::MouseButton(MouseButtonEvent::new(
|
||||
self.dispatch_input_event_with_hit_testing(InputEvent::MouseButton(MouseButtonEvent::new(
|
||||
MouseButtonAction::Up,
|
||||
button,
|
||||
point,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue