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:
Martin Robinson 2025-04-16 18:58:52 +02:00 committed by GitHub
parent 7a8e75266f
commit d8a7abda69
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 252 additions and 271 deletions

View file

@ -14,16 +14,10 @@ use raw_window_handle::{
DisplayHandle, OhosDisplayHandle, OhosNdkWindowHandle, RawDisplayHandle, RawWindowHandle,
WindowHandle,
};
/// The EventLoopWaker::wake function will be called from any thread.
/// It will be called to notify embedder that some events are available,
/// and that perform_updates need to be called
pub use servo::EventLoopWaker;
use servo::{self, Servo, WindowRenderingContext, resources};
use servo::{self, EventLoopWaker, ServoBuilder, WindowRenderingContext, resources};
use xcomponent_sys::OH_NativeXComponent;
use crate::egl::app_state::{
Coordinates, RunningAppState, ServoEmbedderCallbacks, ServoWindowCallbacks,
};
use crate::egl::app_state::{Coordinates, RunningAppState, ServoWindowCallbacks};
use crate::egl::host_trait::HostTrait;
use crate::egl::ohos::InitOpts;
use crate::egl::ohos::resources::ResourceReaderInstance;
@ -128,19 +122,11 @@ pub fn init(
RefCell::new(coordinates),
));
let embedder_callbacks = Box::new(ServoEmbedderCallbacks::new(
waker,
#[cfg(feature = "webxr")]
None,
));
let servo = Servo::new(
opts,
preferences,
rendering_context.clone(),
embedder_callbacks,
Default::default(),
);
let servo = ServoBuilder::new(rendering_context.clone())
.opts(opts)
.preferences(preferences)
.event_loop_waker(waker)
.build();
let app_state = RunningAppState::new(
Some(options.url),