Add Servo engine host runtime

This commit is contained in:
2026-05-07 18:47:37 -04:00
parent 8f0f577928
commit b787486f8e
11 changed files with 6138 additions and 106 deletions
+69 -1
View File
@@ -5,11 +5,73 @@ use crate::ServoHostError;
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum WebViewState {
Created,
Attached,
Loading,
Complete,
Sleeping,
Crashed,
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct WebViewSnapshot {
webview_id: WebViewId,
tab_id: TabId,
profile_id: ProfileId,
state: WebViewState,
url: Option<String>,
title: Option<String>,
has_pending_frame: bool,
}
impl WebViewSnapshot {
#[must_use]
pub fn new(
webview_id: WebViewId,
tab_id: TabId,
profile_id: ProfileId,
state: WebViewState,
url: Option<String>,
title: Option<String>,
has_pending_frame: bool,
) -> Self {
Self { webview_id, tab_id, profile_id, state, url, title, has_pending_frame }
}
#[must_use]
pub fn webview_id(&self) -> &WebViewId {
&self.webview_id
}
#[must_use]
pub fn tab_id(&self) -> &TabId {
&self.tab_id
}
#[must_use]
pub fn profile_id(&self) -> &ProfileId {
&self.profile_id
}
#[must_use]
pub fn state(&self) -> &WebViewState {
&self.state
}
#[must_use]
pub fn url(&self) -> Option<&str> {
self.url.as_deref()
}
#[must_use]
pub fn title(&self) -> Option<&str> {
self.title.as_deref()
}
#[must_use]
pub fn has_pending_frame(&self) -> bool {
self.has_pending_frame
}
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct NavigationRequest {
pub webview_id: WebViewId,
@@ -48,4 +110,10 @@ pub trait ServoHost {
) -> Result<(), ServoHostError>;
fn state(&self, webview_id: &WebViewId) -> Result<WebViewState, ServoHostError>;
fn snapshot(&self, webview_id: &WebViewId) -> Result<WebViewSnapshot, ServoHostError>;
fn tick(&mut self) -> bool;
fn paint(&mut self, webview_id: &WebViewId) -> Result<(), ServoHostError>;
}