compositor: Make input event handling per-WebView (#35716)

This is another step in the move to having a per-WebView renderer. In
this step event handling is made per-WebView. Most events sent to Servo
are sent via the WebView API already, so this just moves more event
handling code to the per-WebView render portion of the compositor.

- ServoRenderer is given shared ownership and interior mutability as
  it is now shared among all WebView(Renderers).
- Some messages coming from other parts of Servo must now carry a
  WebViewId as well so that they can be associated with a particular
  WebView.
- There needs to be some reorganization of `ServoRenderer` in order to
  avoid issues with double borrow of `RefCells`.

Signed-off-by: Delan Azabani <dazabani@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Delan Azabani 2025-03-06 02:47:13 +08:00 committed by GitHub
parent 16aeeaec85
commit 69e7499479
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 1016 additions and 887 deletions

View file

@ -339,23 +339,30 @@ impl WebView {
point: DeviceIntPoint,
touch_event_action: TouchEventType,
) {
self.inner()
.compositor
.borrow_mut()
.on_scroll_event(location, point, touch_event_action);
self.inner().compositor.borrow_mut().notify_scroll_event(
self.id(),
location,
point,
touch_event_action,
);
}
pub fn notify_input_event(&self, event: InputEvent) {
// Events with a `point` first go to the compositor for hit testing.
if event.point().is_some() {
self.inner().compositor.borrow_mut().on_input_event(event);
self.inner()
.compositor
.borrow_mut()
.notify_input_event(self.id(), event);
return;
}
self.inner()
.constellation_proxy
.send(ConstellationMsg::ForwardInputEvent(
event, None, /* hit_test */
self.id(),
event,
None, /* hit_test */
))
}
@ -366,7 +373,7 @@ impl WebView {
}
pub fn notify_vsync(&self) {
self.inner().compositor.borrow_mut().on_vsync();
self.inner().compositor.borrow_mut().on_vsync(self.id());
}
pub fn resize(&self, new_size: PhysicalSize<u32>) {
@ -401,7 +408,7 @@ impl WebView {
self.inner()
.compositor
.borrow_mut()
.on_pinch_zoom_window_event(new_pinch_zoom);
.set_pinch_zoom(self.id(), new_pinch_zoom);
}
pub fn exit_fullscreen(&self) {