Remove type parameter from Servo and IOCompositor (#35121) (#35156)

* Remove type parameter from Servo and IOCompositor (#35121)

Signed-off-by: Delan Azabani <dazabani@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>

* Fix compile error in libservo example

Signed-off-by: Delan Azabani <dazabani@igalia.com>

* Fix compile error in servoshell

Signed-off-by: Delan Azabani <dazabani@igalia.com>

---------

Signed-off-by: Delan Azabani <dazabani@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Delan Azabani 2025-01-24 15:41:21 +08:00 committed by GitHub
parent b95fa5ddd6
commit 8976f2420c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 28 additions and 21 deletions

View file

@ -13,7 +13,7 @@ use std::{env, fs};
use log::{info, trace};
use raw_window_handle::HasDisplayHandle;
use servo::base::id::WebViewId;
use servo::compositing::windowing::EmbedderEvent;
use servo::compositing::windowing::{EmbedderEvent, WindowMethods};
use servo::compositing::CompositeTarget;
use servo::config::opts::Opts;
use servo::config::prefs::Preferences;
@ -45,7 +45,7 @@ pub struct App {
opts: Opts,
preferences: Preferences,
servo_shell_preferences: ServoShellPreferences,
servo: Option<Servo<dyn WindowPortsMethods>>,
servo: Option<Servo>,
webviews: Option<WebViewManager<dyn WindowPortsMethods>>,
event_queue: Vec<EmbedderEvent>,
suspended: Cell<bool>,
@ -194,7 +194,18 @@ impl App {
None
};
let window = window.clone();
// TODO: Remove this once dyn upcasting coercion stabilises
// <https://github.com/rust-lang/rust/issues/65991>
struct UpcastedWindow(Rc<dyn WindowPortsMethods>);
impl WindowMethods for UpcastedWindow {
fn get_coordinates(&self) -> servo::compositing::windowing::EmbedderCoordinates {
self.0.get_coordinates()
}
fn set_animation_state(&self, state: servo::compositing::windowing::AnimationState) {
self.0.set_animation_state(state);
}
}
let window = UpcastedWindow(window.clone());
// Implements embedder methods, used by libservo and constellation.
let embedder = Box::new(EmbedderCallbacks::new(self.waker.clone(), xr_discovery));
@ -208,7 +219,7 @@ impl App {
self.preferences.clone(),
Rc::new(rendering_context),
embedder,
window.clone(),
Rc::new(window),
self.servo_shell_preferences.user_agent.clone(),
composite_target,
);