Expand description
teksilo-webview — an embeddable WebView widget for Teksilo.
An engine shows its page in one of two ways, and its backend says which
(WebViewRendering):
- A native subview (WKWebView, WebView2 and WebKitGTK, through wry): the engine owns its rendering and lives as an OS view on top of the wgpu pass. The widget keeps it positioned, clipped and hidden; the two sections below are about this case.
- A surface (Servo): the engine renders offscreen into a picture the
widget draws inside the pass, like any other content. Clipping, overlays
and dormancy then need no help from the engine, and the widget forwards
pointer, scroll and keyboard input to it (
WebViewInputEvent).
Either way the crate 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 a native subview 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.
Re-exports§
pub use controls::WebViewControl;pub use controls::WebViewControlAnswer;pub use controls::WebViewControlPresenter;pub use controls::WebViewSelectOption;
Modules§
- controls
- Dialogs and pickers a page opens, for the application to present.
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. 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.
- Page
Accessibility Update - An incremental update of a page’s accessibility tree, in page node ids.
- 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
Pump Payload - Boxed inside
AppEvent::Externalwhen aWebViewRendering::Surfaceengine asks to run.teksilo-appanswers it on the main thread withWebViewRegistry::pump. - 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
Edit Command - A clipboard command the page should carry out on its own selection or
focused field, sent as
WebViewInputEvent::Edit. - WebView
Event - A browser lifecycle / JS→Rust event surfaced by a backend.
- WebView
Input - Who owns pointer input over the page’s rectangle.
- WebView
Input Event - Input the widget forwards to a
WebViewRendering::Surfaceengine. - 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
Rendering - How an engine shows its page, as its backend reports through
WebViewBackend::rendering. - WebView
Touch Phase - The phase of a touch contact in
WebViewInputEvent::Touch. - 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.
Constants§
- MEMORY_
SURFACE_ COLOUR - The colour of every frame a surface
MemoryWebViewBackendcommits: opaque, and neither black nor white, so it is told apart from a cleared buffer.
Traits§
- WebView
Backend - Swappable web-view engine backend.
- WebView
Handle - A live engine view. Dropping the handle tears it 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. - memory_
surface_ registry - The same with a surface backend (
MemoryWebViewBackend::surface). - 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.