servoshell: Fix --no-default-features and make webxr optional on ohos/android (#34242)

* servoshell: fix --no-default-features

The Embeddertraits only contain `register_webxr` if the
webxr feature is enabled, hence we also need to guard
the trait implementation.

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>

* ohos/android: Make webxr optional in servoshell

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>

---------

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
This commit is contained in:
Jonathan Schwender 2024-11-13 21:02:30 +01:00 committed by GitHub
parent 47a243614f
commit 6b6697e97b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 16 additions and 4 deletions

View file

@ -40,6 +40,7 @@ pub struct InitOptions {
pub url: Option<String>,
pub coordinates: Coordinates,
pub density: f32,
#[cfg(feature = "webxr")]
pub xr_discovery: Option<webxr::Discovery>,
pub surfman_integration: SurfmanIntegration,
pub prefs: Option<HashMap<String, PrefValue>>,
@ -109,6 +110,7 @@ pub fn init(
let embedder_callbacks = Box::new(ServoEmbedderCallbacks::new(
waker,
#[cfg(feature = "webxr")]
init_opts.xr_discovery,
gl.clone(),
));

View file

@ -141,7 +141,12 @@ pub fn init(
rendering_context.clone(),
));
let embedder_callbacks = Box::new(ServoEmbedderCallbacks::new(waker, None, gl.clone()));
let embedder_callbacks = Box::new(ServoEmbedderCallbacks::new(
waker,
#[cfg(feature = "webxr")]
None,
gl.clone(),
));
let servo = Servo::new(
embedder_callbacks,

View file

@ -651,6 +651,7 @@ impl ServoGlue {
pub(super) struct ServoEmbedderCallbacks {
waker: Box<dyn EventLoopWaker>,
#[cfg(feature = "webxr")]
xr_discovery: Option<webxr::Discovery>,
#[allow(unused)]
gl: Rc<dyn gl::Gl>,
@ -659,11 +660,12 @@ pub(super) struct ServoEmbedderCallbacks {
impl ServoEmbedderCallbacks {
pub(super) fn new(
waker: Box<dyn EventLoopWaker>,
xr_discovery: Option<webxr::Discovery>,
#[cfg(feature = "webxr")] xr_discovery: Option<webxr::Discovery>,
gl: Rc<dyn gl::Gl>,
) -> Self {
Self {
waker,
#[cfg(feature = "webxr")]
xr_discovery,
gl,
}
@ -676,6 +678,7 @@ impl EmbedderMethods for ServoEmbedderCallbacks {
self.waker.clone()
}
#[cfg(feature = "webxr")]
fn register_webxr(
&mut self,
registry: &mut webxr::MainThreadRegistry,