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§
- Download
Outcome - A finished (or failed) download, passed to
WebView::on_download_finished. - Download
Start - A download the page started, passed to
WebView::on_download_started. - Memory
WebView Backend - In-memory deterministic backend for headless tests. Records every op into a
shared
MemoryWebViewRecords; never renders. MirrorsMemoryFileDialog. - Memory
WebView Records - Shared, cloneable recorder. Both the backend and the test hold a clone, so the test can read the op log after driving the tree.
- Navigation
Info - A navigation the page initiated, passed to
WebView::on_navigation. - Noop
WebView Backend - A backend that renders nothing and records nothing — every call is a no-op.
- Recipe
WebView Style - 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.
- WebView
Attributes - Engine configuration accumulated by the
WebViewbuilders and handed toWebViewBackend::open. - WebView
Event Payload - Boxed inside
AppEvent::Externalwhen a backend produces an event.teksilo-app’s app-event handler downcasts to this type and routes toWebViewRegistry::deliver. MirrorsFileDialogEventPayload. - WebView
Id - Process-unique identity for a single web view instance. Allocated once at
WebViewconstruction and stable across rebuilds, so backend events route to the correct widget. Same shape asMenuItemId. - WebView
Registry - Per-app web-view service. Registered in app-state by
TeksiloAppBuilderWebViewExt::install_web_view(in theteksiloumbrella crate); reachable from anybuild()/ handler viactx.app_state::<WebViewRegistry>(). Cloneable; clones share the same backend and event-callback map. - WebView
Style Config - Inputs handed to a
WebViewStyleto build the web view’s overlay chrome.
Enums§
- Console
Level - Severity of a
WebViewEvent::ConsoleMessage. - Page
Load State - Page-load lifecycle phase, passed to
WebView::on_page_load. - WebSource
- What a web view should initially display.
- WebView
Event - A browser lifecycle / JS→Rust event surfaced by a backend.
- WebView
Input - Who owns pointer input over the page’s rectangle.
- WebView
Op - 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.
- WebView
Visual State - 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 — mirroringDropZoneVisualState.
Traits§
- WebView
Backend - Swappable web-view engine backend.
- WebView
Handle - A live native engine subview. Dropping the handle tears the subview down
(RAII, same contract as
ExternalDndGuard). - WebView
Style - 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§
- Shared
WebView Style - Shared, theme-installable handle to a
WebViewStyle.