mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
* 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:
parent
b95fa5ddd6
commit
8976f2420c
5 changed files with 28 additions and 21 deletions
|
@ -97,9 +97,9 @@ impl FrameTreeId {
|
|||
}
|
||||
|
||||
/// NB: Never block on the constellation, because sometimes the constellation blocks on us.
|
||||
pub struct IOCompositor<Window: WindowMethods + ?Sized> {
|
||||
pub struct IOCompositor {
|
||||
/// The application window.
|
||||
pub window: Rc<Window>,
|
||||
pub window: Rc<dyn WindowMethods>,
|
||||
|
||||
/// The port on which we receive messages.
|
||||
port: CompositorReceiver,
|
||||
|
@ -356,9 +356,9 @@ pub enum CompositeTarget {
|
|||
PngFile(Rc<String>),
|
||||
}
|
||||
|
||||
impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
||||
impl IOCompositor {
|
||||
pub fn new(
|
||||
window: Rc<Window>,
|
||||
window: Rc<dyn WindowMethods>,
|
||||
state: InitialCompositorState,
|
||||
composite_target: CompositeTarget,
|
||||
exit_after_load: bool,
|
||||
|
|
|
@ -44,7 +44,7 @@ enum App {
|
|||
Initial(Waker),
|
||||
Running {
|
||||
window_delegate: Rc<WindowDelegate>,
|
||||
servo: Servo<WindowDelegate>,
|
||||
servo: Servo,
|
||||
},
|
||||
Exiting,
|
||||
}
|
||||
|
|
|
@ -176,8 +176,8 @@ mod media_platform {
|
|||
/// application Servo is embedded in. Clients then create an event
|
||||
/// loop to pump messages between the embedding application and
|
||||
/// various browser components.
|
||||
pub struct Servo<Window: WindowMethods + 'static + ?Sized> {
|
||||
compositor: IOCompositor<Window>,
|
||||
pub struct Servo {
|
||||
compositor: IOCompositor,
|
||||
constellation_chan: Sender<ConstellationMsg>,
|
||||
embedder_receiver: EmbedderReceiver,
|
||||
messages_for_embedder: Vec<(Option<TopLevelBrowsingContextId>, EmbedderMsg)>,
|
||||
|
@ -221,10 +221,7 @@ impl webrender_api::RenderNotifier for RenderNotifier {
|
|||
}
|
||||
}
|
||||
|
||||
impl<Window> Servo<Window>
|
||||
where
|
||||
Window: WindowMethods + 'static + ?Sized,
|
||||
{
|
||||
impl Servo {
|
||||
#[cfg_attr(
|
||||
feature = "tracing",
|
||||
tracing::instrument(
|
||||
|
@ -233,16 +230,15 @@ where
|
|||
level = "trace",
|
||||
)
|
||||
)]
|
||||
#[allow(clippy::new_ret_no_self)]
|
||||
pub fn new(
|
||||
opts: Opts,
|
||||
preferences: Preferences,
|
||||
rendering_context: Rc<dyn RenderingContext>,
|
||||
mut embedder: Box<dyn EmbedderMethods>,
|
||||
window: Rc<Window>,
|
||||
window: Rc<dyn WindowMethods>,
|
||||
user_agent: Option<String>,
|
||||
composite_target: CompositeTarget,
|
||||
) -> Servo<Window> {
|
||||
) -> Self {
|
||||
// Global configuration options, parsed from the command line.
|
||||
opts::set_options(opts);
|
||||
let opts = opts::get();
|
||||
|
@ -982,7 +978,7 @@ where
|
|||
log::set_max_level(filter);
|
||||
}
|
||||
|
||||
pub fn window(&self) -> &Window {
|
||||
pub fn window(&self) -> &Rc<dyn WindowMethods> {
|
||||
&self.compositor.window
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
);
|
||||
|
|
|
@ -80,7 +80,7 @@ pub struct WebView {}
|
|||
|
||||
pub struct ServoGlue {
|
||||
rendering_context: SurfmanRenderingContext,
|
||||
servo: Servo<ServoWindowCallbacks>,
|
||||
servo: Servo,
|
||||
batch_mode: bool,
|
||||
need_present: bool,
|
||||
callbacks: Rc<ServoWindowCallbacks>,
|
||||
|
@ -107,7 +107,7 @@ pub struct ServoGlue {
|
|||
impl ServoGlue {
|
||||
pub(super) fn new(
|
||||
rendering_context: SurfmanRenderingContext,
|
||||
servo: Servo<ServoWindowCallbacks>,
|
||||
servo: Servo,
|
||||
callbacks: Rc<ServoWindowCallbacks>,
|
||||
servoshell_preferences: ServoShellPreferences,
|
||||
) -> Self {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue