mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01: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.
|
/// 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.
|
/// The application window.
|
||||||
pub window: Rc<Window>,
|
pub window: Rc<dyn WindowMethods>,
|
||||||
|
|
||||||
/// The port on which we receive messages.
|
/// The port on which we receive messages.
|
||||||
port: CompositorReceiver,
|
port: CompositorReceiver,
|
||||||
|
@ -356,9 +356,9 @@ pub enum CompositeTarget {
|
||||||
PngFile(Rc<String>),
|
PngFile(Rc<String>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
impl IOCompositor {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
window: Rc<Window>,
|
window: Rc<dyn WindowMethods>,
|
||||||
state: InitialCompositorState,
|
state: InitialCompositorState,
|
||||||
composite_target: CompositeTarget,
|
composite_target: CompositeTarget,
|
||||||
exit_after_load: bool,
|
exit_after_load: bool,
|
||||||
|
|
|
@ -44,7 +44,7 @@ enum App {
|
||||||
Initial(Waker),
|
Initial(Waker),
|
||||||
Running {
|
Running {
|
||||||
window_delegate: Rc<WindowDelegate>,
|
window_delegate: Rc<WindowDelegate>,
|
||||||
servo: Servo<WindowDelegate>,
|
servo: Servo,
|
||||||
},
|
},
|
||||||
Exiting,
|
Exiting,
|
||||||
}
|
}
|
||||||
|
|
|
@ -176,8 +176,8 @@ mod media_platform {
|
||||||
/// application Servo is embedded in. Clients then create an event
|
/// application Servo is embedded in. Clients then create an event
|
||||||
/// loop to pump messages between the embedding application and
|
/// loop to pump messages between the embedding application and
|
||||||
/// various browser components.
|
/// various browser components.
|
||||||
pub struct Servo<Window: WindowMethods + 'static + ?Sized> {
|
pub struct Servo {
|
||||||
compositor: IOCompositor<Window>,
|
compositor: IOCompositor,
|
||||||
constellation_chan: Sender<ConstellationMsg>,
|
constellation_chan: Sender<ConstellationMsg>,
|
||||||
embedder_receiver: EmbedderReceiver,
|
embedder_receiver: EmbedderReceiver,
|
||||||
messages_for_embedder: Vec<(Option<TopLevelBrowsingContextId>, EmbedderMsg)>,
|
messages_for_embedder: Vec<(Option<TopLevelBrowsingContextId>, EmbedderMsg)>,
|
||||||
|
@ -221,10 +221,7 @@ impl webrender_api::RenderNotifier for RenderNotifier {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Window> Servo<Window>
|
impl Servo {
|
||||||
where
|
|
||||||
Window: WindowMethods + 'static + ?Sized,
|
|
||||||
{
|
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "tracing",
|
feature = "tracing",
|
||||||
tracing::instrument(
|
tracing::instrument(
|
||||||
|
@ -233,16 +230,15 @@ where
|
||||||
level = "trace",
|
level = "trace",
|
||||||
)
|
)
|
||||||
)]
|
)]
|
||||||
#[allow(clippy::new_ret_no_self)]
|
|
||||||
pub fn new(
|
pub fn new(
|
||||||
opts: Opts,
|
opts: Opts,
|
||||||
preferences: Preferences,
|
preferences: Preferences,
|
||||||
rendering_context: Rc<dyn RenderingContext>,
|
rendering_context: Rc<dyn RenderingContext>,
|
||||||
mut embedder: Box<dyn EmbedderMethods>,
|
mut embedder: Box<dyn EmbedderMethods>,
|
||||||
window: Rc<Window>,
|
window: Rc<dyn WindowMethods>,
|
||||||
user_agent: Option<String>,
|
user_agent: Option<String>,
|
||||||
composite_target: CompositeTarget,
|
composite_target: CompositeTarget,
|
||||||
) -> Servo<Window> {
|
) -> Self {
|
||||||
// Global configuration options, parsed from the command line.
|
// Global configuration options, parsed from the command line.
|
||||||
opts::set_options(opts);
|
opts::set_options(opts);
|
||||||
let opts = opts::get();
|
let opts = opts::get();
|
||||||
|
@ -982,7 +978,7 @@ where
|
||||||
log::set_max_level(filter);
|
log::set_max_level(filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn window(&self) -> &Window {
|
pub fn window(&self) -> &Rc<dyn WindowMethods> {
|
||||||
&self.compositor.window
|
&self.compositor.window
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ use std::{env, fs};
|
||||||
use log::{info, trace};
|
use log::{info, trace};
|
||||||
use raw_window_handle::HasDisplayHandle;
|
use raw_window_handle::HasDisplayHandle;
|
||||||
use servo::base::id::WebViewId;
|
use servo::base::id::WebViewId;
|
||||||
use servo::compositing::windowing::EmbedderEvent;
|
use servo::compositing::windowing::{EmbedderEvent, WindowMethods};
|
||||||
use servo::compositing::CompositeTarget;
|
use servo::compositing::CompositeTarget;
|
||||||
use servo::config::opts::Opts;
|
use servo::config::opts::Opts;
|
||||||
use servo::config::prefs::Preferences;
|
use servo::config::prefs::Preferences;
|
||||||
|
@ -45,7 +45,7 @@ pub struct App {
|
||||||
opts: Opts,
|
opts: Opts,
|
||||||
preferences: Preferences,
|
preferences: Preferences,
|
||||||
servo_shell_preferences: ServoShellPreferences,
|
servo_shell_preferences: ServoShellPreferences,
|
||||||
servo: Option<Servo<dyn WindowPortsMethods>>,
|
servo: Option<Servo>,
|
||||||
webviews: Option<WebViewManager<dyn WindowPortsMethods>>,
|
webviews: Option<WebViewManager<dyn WindowPortsMethods>>,
|
||||||
event_queue: Vec<EmbedderEvent>,
|
event_queue: Vec<EmbedderEvent>,
|
||||||
suspended: Cell<bool>,
|
suspended: Cell<bool>,
|
||||||
|
@ -194,7 +194,18 @@ impl App {
|
||||||
None
|
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.
|
// Implements embedder methods, used by libservo and constellation.
|
||||||
let embedder = Box::new(EmbedderCallbacks::new(self.waker.clone(), xr_discovery));
|
let embedder = Box::new(EmbedderCallbacks::new(self.waker.clone(), xr_discovery));
|
||||||
|
|
||||||
|
@ -208,7 +219,7 @@ impl App {
|
||||||
self.preferences.clone(),
|
self.preferences.clone(),
|
||||||
Rc::new(rendering_context),
|
Rc::new(rendering_context),
|
||||||
embedder,
|
embedder,
|
||||||
window.clone(),
|
Rc::new(window),
|
||||||
self.servo_shell_preferences.user_agent.clone(),
|
self.servo_shell_preferences.user_agent.clone(),
|
||||||
composite_target,
|
composite_target,
|
||||||
);
|
);
|
||||||
|
|
|
@ -80,7 +80,7 @@ pub struct WebView {}
|
||||||
|
|
||||||
pub struct ServoGlue {
|
pub struct ServoGlue {
|
||||||
rendering_context: SurfmanRenderingContext,
|
rendering_context: SurfmanRenderingContext,
|
||||||
servo: Servo<ServoWindowCallbacks>,
|
servo: Servo,
|
||||||
batch_mode: bool,
|
batch_mode: bool,
|
||||||
need_present: bool,
|
need_present: bool,
|
||||||
callbacks: Rc<ServoWindowCallbacks>,
|
callbacks: Rc<ServoWindowCallbacks>,
|
||||||
|
@ -107,7 +107,7 @@ pub struct ServoGlue {
|
||||||
impl ServoGlue {
|
impl ServoGlue {
|
||||||
pub(super) fn new(
|
pub(super) fn new(
|
||||||
rendering_context: SurfmanRenderingContext,
|
rendering_context: SurfmanRenderingContext,
|
||||||
servo: Servo<ServoWindowCallbacks>,
|
servo: Servo,
|
||||||
callbacks: Rc<ServoWindowCallbacks>,
|
callbacks: Rc<ServoWindowCallbacks>,
|
||||||
servoshell_preferences: ServoShellPreferences,
|
servoshell_preferences: ServoShellPreferences,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue