mirror of
https://github.com/servo/servo.git
synced 2025-08-12 00:45:33 +01:00
libservo: Expose a ServoBuilder
(#36549)
Expose a `ServoBuilder` for easily creating Servo instances using default values. This change enables removing `EmbedderTraits`. Testing: This is covered by `Servo` unit tests. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
7a8e75266f
commit
d8a7abda69
17 changed files with 252 additions and 271 deletions
|
@ -8,13 +8,12 @@ use std::sync::{Arc, OnceLock};
|
|||
use std::time::Duration;
|
||||
|
||||
use anyhow::Error;
|
||||
use compositing::windowing::EmbedderMethods;
|
||||
use compositing_traits::rendering_context::{RenderingContext, SoftwareRenderingContext};
|
||||
use crossbeam_channel::{Receiver, Sender, unbounded};
|
||||
use dpi::PhysicalSize;
|
||||
use embedder_traits::EventLoopWaker;
|
||||
use parking_lot::Mutex;
|
||||
use servo::Servo;
|
||||
use servo::{Servo, ServoBuilder};
|
||||
|
||||
pub struct ServoTest {
|
||||
servo: Servo,
|
||||
|
@ -41,14 +40,6 @@ impl ServoTest {
|
|||
);
|
||||
assert!(rendering_context.make_current().is_ok());
|
||||
|
||||
#[derive(Clone)]
|
||||
struct EmbedderMethodsImpl(Arc<AtomicBool>);
|
||||
impl EmbedderMethods for EmbedderMethodsImpl {
|
||||
fn create_event_loop_waker(&mut self) -> Box<dyn embedder_traits::EventLoopWaker> {
|
||||
Box::new(EventLoopWakerImpl(self.0.clone()))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
struct EventLoopWakerImpl(Arc<AtomicBool>);
|
||||
impl EventLoopWaker for EventLoopWakerImpl {
|
||||
|
@ -62,13 +53,9 @@ impl ServoTest {
|
|||
}
|
||||
|
||||
let user_event_triggered = Arc::new(AtomicBool::new(false));
|
||||
let servo = Servo::new(
|
||||
Default::default(),
|
||||
Default::default(),
|
||||
rendering_context.clone(),
|
||||
Box::new(EmbedderMethodsImpl(user_event_triggered)),
|
||||
Default::default(),
|
||||
);
|
||||
let servo = ServoBuilder::new(rendering_context.clone())
|
||||
.event_loop_waker(Box::new(EventLoopWakerImpl(user_event_triggered)))
|
||||
.build();
|
||||
Self { servo }
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue