chore: remove WindowMethods::rendering_context (#34780)

* Create Servo without initial webview ID

Signed-off-by: Wu Yuwei <yuweiwu@pm.me>

* Add rendering context in App struct

Signed-off-by: Wu Yuwei <yuweiwu@pm.me>

* Make webview manager optional

Signed-off-by: Wu Yuwei <yuweiwu@pm.me>

* Move window creation to init

Signed-off-by: Wu Yuwei <yuweiwu@pm.me>

* Create window from external rendering context

Signed-off-by: Wu Yuwei <yuweiwu@pm.me>

* Resize surface in compositor

Signed-off-by: Wu Yuwei <yuweiwu@pm.me>

* Obey clippy

Signed-off-by: Wu Yuwei <yuweiwu@pm.me>

* Update Android and OHOS

Signed-off-by: Wu Yuwei <yuweiwu@pm.me>

* Add missing arguent on OHOS

Signed-off-by: Wu Yuwei <yuweiwu@pm.me>

* Show webview after focused on Android and OH

Signed-off-by: Wu Yuwei <yuweiwu@pm.me>

* Remove rendering_context in ServoWindowCallbacks

Signed-off-by: Wu Yuwei <yuweiwu@pm.me>

* Create surface before swapchain in headless mode

Signed-off-by: Wu Yuwei <yuweiwu@pm.me>

---------

Signed-off-by: Wu Yuwei <yuweiwu@pm.me>
This commit is contained in:
Ngo Iok Ui (Wu Yu Wei) 2025-01-01 17:26:23 +09:00 committed by GitHub
parent 59c7ac680e
commit d581acab3b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 200 additions and 253 deletions

View file

@ -9,6 +9,7 @@ use std::rc::Rc;
use log::{debug, error, info};
use ohos_sys::xcomponent::{OH_NativeXComponent, OH_NativeXComponent_GetXComponentSize};
use servo::base::id::WebViewId;
use servo::compositing::windowing::EmbedderEvent;
use servo::compositing::CompositeTarget;
use servo::embedder_traits::resources;
@ -118,8 +119,14 @@ pub fn init(
let surface_type = SurfaceType::Widget { native_widget };
info!("Creating rendering context");
let rendering_context = RenderingContext::create(&connection, &adapter, surface_type)
let rendering_context = RenderingContext::create(&connection, &adapter, None)
.or(Err("Failed to create surface manager"))?;
let surface = rendering_context
.create_surface(surface_type)
.or(Err("Failed to create surface"))?;
rendering_context
.bind_surface(surface)
.or(Err("Failed to bind surface"))?;
info!("before ServoWindowCallbacks...");
@ -127,7 +134,6 @@ pub fn init(
callbacks,
RefCell::new(Coordinates::new(0, 0, width, height, width, height)),
options.display_density as f32,
rendering_context.clone(),
));
let embedder_callbacks = Box::new(ServoEmbedderCallbacks::new(
@ -137,6 +143,7 @@ pub fn init(
));
let servo = Servo::new(
rendering_context.clone(),
embedder_callbacks,
window_callbacks.clone(),
// User agent: Mozilla/5.0 (<Phone|PC|Tablet>; HarmonyOS 5.0) bla bla
@ -146,7 +153,7 @@ pub fn init(
let mut servo_glue = ServoGlue::new(
rendering_context,
servo.servo,
servo,
window_callbacks,
Some(options.resource_dir),
);
@ -156,7 +163,7 @@ pub fn init(
.ok()
.unwrap_or_else(|| ServoUrl::parse("about:blank").expect("Infallible"));
let _ = servo_glue.process_event(EmbedderEvent::NewWebView(initial_url, servo.browser_id));
let _ = servo_glue.process_event(EmbedderEvent::NewWebView(initial_url, WebViewId::new()));
Ok(servo_glue)
}