Skip to main content

Crate teksilo_webview

Crate teksilo_webview 

Source
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::SharedWebViewControlPresenter;
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§

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. 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.
PageAccessibilityUpdate
An incremental update of a page’s accessibility tree, in page node ids.
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.
WebViewPumpPayload
Boxed inside AppEvent::External when a WebViewRendering::Surface engine asks to run. teksilo-app answers it on the main thread with WebViewRegistry::pump.
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.
WebViewEditCommand
A clipboard command the page should carry out on its own selection or focused field, sent as WebViewInputEvent::Edit.
WebViewEvent
A browser lifecycle / JS→Rust event surfaced by a backend.
WebViewInput
Who owns pointer input over the page’s rectangle.
WebViewInputEvent
Input the widget forwards to a WebViewRendering::Surface engine.
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.
WebViewRendering
How an engine shows its page, as its backend reports through WebViewBackend::rendering.
WebViewTouchPhase
The phase of a touch contact in WebViewInputEvent::Touch.
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.

Constants§

MEMORY_SURFACE_COLOUR
The colour of every frame a surface MemoryWebViewBackend commits: opaque, and neither black nor white, so it is told apart from a cleared buffer.

Traits§

WebViewBackend
Swappable web-view engine backend.
WebViewHandle
A live engine view. Dropping the handle tears it 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.
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§

SharedWebViewStyle
Shared, theme-installable handle to a WebViewStyle.