Skip to main content

WebViewHandle

Trait WebViewHandle 

Source
pub trait WebViewHandle: 'static {
Show 14 methods // Required methods fn set_bounds(&self, bounds: Rect, scale_factor: f32); fn load_url(&self, url: &str); fn load_html(&self, html: &str, base_url: Option<&str>); fn eval(&self, script: &str); fn post_message(&self, msg: &str); fn reload(&self); fn go_back(&self); fn go_forward(&self); fn stop(&self); fn set_visible(&self, visible: bool); fn set_focus(&self); fn set_input_passthrough(&self, passthrough: bool); // Provided methods fn open_devtools(&self) { ... } fn close_devtools(&self) { ... }
}
Expand description

A live native engine subview. Dropping the handle tears the subview down (RAII, same contract as ExternalDndGuard).

All methods are &self — the handle is cheaply shareable and the engine state lives behind the platform’s own interior mutability.

Required Methods§

Source

fn set_bounds(&self, bounds: Rect, scale_factor: f32)

Reposition / resize the native subview within its parent window. bounds is in logical pixels (Teksilo’s coordinate system); scale_factor is the host window’s HiDPI scale. Most engines position in logical units, but some need device pixels (bounds × scale_factor) because their own toolkit runs at a different scale than the wgpu surface — notably WebKitGTK on X11/XWayland, which uses integer GDK scaling and ignores fractional factors. Issued whenever the widget’s layout bounds or the window scale change.

Source

fn load_url(&self, url: &str)

Navigate to a URL.

Source

fn load_html(&self, html: &str, base_url: Option<&str>)

Load inline HTML.

Source

fn eval(&self, script: &str)

Evaluate JavaScript in the page.

Source

fn post_message(&self, msg: &str)

Rust → JS: dispatch a teksilo-message MessageEvent carrying msg.

Source

fn reload(&self)

Reload the current page.

Source

fn go_back(&self)

Navigate back in history.

Source

fn go_forward(&self)

Navigate forward in history.

Source

fn stop(&self)

Stop the current load.

Source

fn set_visible(&self, visible: bool)

Show / hide the native subview. Load-bearing: a native subview lives outside the wgpu pass, so framework dormancy (a Switcher parking the page) does NOT hide it — the WebView widget bridges its activation signal to this call. See WebView’s rustdoc.

Source

fn set_focus(&self)

Give the engine subview keyboard focus.

Source

fn set_input_passthrough(&self, passthrough: bool)

Ask the engine to stop taking pointer input over its own rectangle, so the OS delivers those events to the host window and Teksilo routes them — the engine half of WebViewInput::Transparent.

Ask the engine to stop taking pointer input over its own rectangle, so the OS delivers those events to the host window and Teksilo routes them — the engine half of WebViewInput::Transparent.

Not every engine can do this — the call needs control over the native surface’s hit region, which the embedding API may simply not expose — and one that cannot must say so through WebViewEvent::ConsoleMessage — the channel this crate already reserves for reporting an unsupported operation — rather than accept the call and change nothing. There is deliberately no return value and no default implementation: an answer invented here would be an answer for an engine nobody asked.

Not every engine can do this, and one that cannot must say so through WebViewEvent::ConsoleMessage — the channel this crate already reserves for reporting an unsupported operation — rather than accept the call and change nothing. There is deliberately no return value and no default implementation: an answer invented here would be an answer for an engine nobody asked.

Provided Methods§

Source

fn open_devtools(&self)

Open the engine’s developer tools (no-op on backends that don’t expose them — Servo’s embedding API has no clean devtools hook today).

Source

fn close_devtools(&self)

Close the engine’s developer tools (no-op where unsupported).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§