Skip to main content

Crate teksilo_webview

Crate teksilo_webview 

Source
Expand description

teksilo-webview — an embeddable WebView widget for Teksilo.

A web view is the one widget that cannot render into Teksilo’s wgpu surface: every realistic engine (WKWebView, WebView2, WebKitGTK, Servo) owns its own rendering and lives as a native subview on top of the wgpu pass. This crate accepts that reality and mirrors the established platform-backend pattern — a swappable WebViewBackend creates an engine-specific WebViewHandle, and a per-app WebViewRegistry (installed in app-state) routes JS→Rust / lifecycle events back to the widget.

use teksilo_webview::WebView;

let _wv = WebView::new()
    .url("https://example.com")
    .title_signal(title_signal.clone())
    .loading_signal(loading_signal.clone())
    .on_message(|msg, _ctx| println!("JS said: {msg}"));

§The Switcher / dormancy caveat

Because the engine surface lives outside the wgpu pass, “not painted” does NOT mean “hidden” for a WebView. When a Switcher / TabWidget / visible_when gate parks the widget dormant, the framework simply stops painting it — but the native subview keeps floating over the output. WebView closes this gap by bridging the framework’s per-node activation signal (BuildContext::activation_signal) to the engine’s set_visible: tab-away → set_visible(false), tab-back → set_visible (true). This is the one place a widget must explicitly mirror framework visibility onto an OS resource, and it is wired automatically here.

§Who owns the pointer over the page

A native subview is above the wgpu pass for input as well as for pixels: the OS routes a press over its rectangle to the engine, and Teksilo is not told. WebViewInput is the declaration of which side owns that rectangle, and it decides four things at once — see the enum’s docs.

Structs§

DownloadOutcome
A finished (or failed) download, passed to WebView::on_download_finished.
DownloadStart
A download the page started, passed to WebView::on_download_started.
MemoryWebViewBackend
In-memory deterministic backend for headless tests. Records every op into a shared MemoryWebViewRecords; never renders. Mirrors MemoryFileDialog.
MemoryWebViewRecords
Shared, cloneable recorder. Both the backend and the test hold a clone, so the test can read the op log after driving the tree.
NavigationInfo
A navigation the page initiated, passed to WebView::on_navigation.
NoopWebViewBackend
A backend that renders nothing and records nothing — every call is a no-op.
RecipeWebViewStyle
Default IntUI web-view style. Stateless; reads theme tokens at paint time.
WebView
An embeddable web view. Composing widget: it delegates layout/paint to a style-built overlay and drives a native engine subview on top.
WebViewAttributes
Engine configuration accumulated by the WebView builders and handed to WebViewBackend::open.
WebViewEventPayload
Boxed inside AppEvent::External when a backend produces an event. teksilo-app’s app-event handler downcasts to this type and routes to WebViewRegistry::deliver. Mirrors FileDialogEventPayload.
WebViewId
Process-unique identity for a single web view instance. Allocated once at WebView construction and stable across rebuilds, so backend events route to the correct widget. Same shape as MenuItemId.
WebViewRegistry
Per-app web-view service. Registered in app-state by TeksiloAppBuilderWebViewExt::install_web_view (in the teksilo umbrella crate); reachable from any build() / handler via ctx.app_state::<WebViewRegistry>(). Cloneable; clones share the same backend and event-callback map.
WebViewStyleConfig
Inputs handed to a WebViewStyle to build the web view’s overlay chrome.

Enums§

ConsoleLevel
Severity of a WebViewEvent::ConsoleMessage.
PageLoadState
Page-load lifecycle phase, passed to WebView::on_page_load.
WebSource
What a web view should initially display.
WebViewEvent
A browser lifecycle / JS→Rust event surfaced by a backend.
WebViewInput
Who owns pointer input over the page’s rectangle.
WebViewOp
One recorded backend operation. Lets tests assert the exact call sequence (open → set_bounds → set_visible(false) → set_visible(true) → …) without a real engine, window, or GPU.
WebViewVisualState
Lifecycle/visual state of a web view, driving the overlay chrome. Defined here (not in teksilo-webview) so the core style trait and the default recipe can both name it — mirroring DropZoneVisualState.

Traits§

WebViewBackend
Swappable web-view engine backend.
WebViewHandle
A live native engine subview. Dropping the handle tears the subview down (RAII, same contract as ExternalDndGuard).
WebViewStyle
Tier-3 style protocol for WebView. Produces the overlay body shown behind/around the native engine surface.

Functions§

is_wayland
Whether the process is running under a Wayland session — the signal for choosing the Servo backend (wry’s WebKitGTK does X11 reparenting only).
memory_registry
Convenience: a registry backed by a fresh MemoryWebViewBackend, plus its shared recorder. The one-liner headless-test setup.
pump_gtk_events
No-op stub on platforms / builds where wry’s GTK loop isn’t in play.

Type Aliases§

SharedWebViewStyle
Shared, theme-installable handle to a WebViewStyle.