WebView and Image Bindings
Place an imported page image in Hera Kit while retaining a stable focus target and the native engine handle.
WebView implements the Hera Kit View interface around a shared WebKit instance and a Binding<Image>. The binding describes which imported buffer the scene should reference and how large the page region should be. It is the host's responsibility to keep that description synchronized with buffer imports and viewport changes.
Stable WebView Construction
Use WebView::new after creating the engine and image binding on the UI thread:
use hera_kit::Binding;
use hera_webkit::{Image, WebKit, WebView};
use std::rc::Rc;
fn make_web_view(webkit: Rc<WebKit>, image: Binding<Image>) -> WebView {
WebView::new(webkit, image)
}Retain this value as part of the application's mounted or host-owned state, then clone it when a body needs to include it. Construction creates a local FocusTarget, so rebuilding a fresh WebView on every body evaluation would also create a fresh programmatic focus identity. The browser constructs its view once with its host-owned model and reuses that value in the UI.
Image Binding
Image contains an optional buffer ID together with viewport width and height. Before the first import, buffer: None lets the primitive draw a white placeholder. Once the host has sent an import successfully, it can update the binding with that connection-local buffer ID and request evaluation.
The dimensions also provide the intended page extent during resize. The browser preserves the new viewport dimensions while temporarily displaying the old frame, then replaces its buffer reference when WebKit supplies pixels for the new size. Its host keeps this geometry separate from the descriptor of each actual exported image.
Native Content Composition
Because the primitive implements View, it accepts common Hera Kit wrappers such as frames and clipping:
use hera_kit::{View, ViewExt};
use hera_webkit::WebView;
fn page_region(webview: WebView) -> impl View {
webview.frame(800.0, 600.0).clipped()
}A wrapper controls the region occupied in Kit, but it does not call WebKit::resize for you. The host must explicitly translate authoritative surface geometry into the page viewport and update the engine and binding together. See custom hosting for how the browser subtracts its native chrome from that region.
The primitive uses fill layout to accept finite proposed space. Bound the containing region when it appears in a layout that would otherwise offer an unbounded axis, just as you would for other fill primitives.
Focus and Input
The view opts into Kit focus handling and forwards focus changes to the native engine. A pointer-down event requests local focus before the page receives its interaction, while pointer capture preserves continuation geometry for a drag. Keyboard input is forwarded through the node's general input handler.
Those handlers depend on accepted scene targeting. The browser host preserves input lineage across compatible paint-only updates before delivering events to Kit, allowing older displayed image content to remain interactive without guessing coordinates from a future layout. The input guide describes that boundary and the special handling for DOM Tab traversal.
Source Reference
The following files in the Hera checkout define the behavior described on this page.
crates/webkit/src/view.rsapps/browser/src/ui.rsapps/browser/src/host.rscrates/kit/src/input/lineage.rs