pub struct WebViewController { /* private fields */ }Expand description
A small command handle for an embedded WebView.
Keep this next to the element’s id to avoid threading raw string ids through app code when navigating, posting messages, or evaluating JavaScript.
Implementations§
Source§impl WebViewController
impl WebViewController
Sourcepub fn id(&self) -> SharedString
pub fn id(&self) -> SharedString
Return the WebView element id this controller targets.
Navigate the target WebView to a new URL.
Navigate the target WebView to a new URL with additional request headers.
Sourcepub fn load_html(
&self,
window: &mut Window,
html: impl Into<SharedString>,
) -> Result<()>
pub fn load_html( &self, window: &mut Window, html: impl Into<SharedString>, ) -> Result<()>
Load an HTML string into the target WebView.
Sourcepub fn evaluate_javascript(
&self,
window: &mut Window,
script: impl Into<SharedString>,
) -> Result<()>
pub fn evaluate_javascript( &self, window: &mut Window, script: impl Into<SharedString>, ) -> Result<()>
Evaluate JavaScript in the target WebView.
Sourcepub fn evaluate_javascript_with_result(
&self,
window: &mut Window,
script: impl Into<SharedString>,
callback: impl Fn(Result<SharedString, SharedString>) + Send + Sync + 'static,
) -> Result<()>
pub fn evaluate_javascript_with_result( &self, window: &mut Window, script: impl Into<SharedString>, callback: impl Fn(Result<SharedString, SharedString>) + Send + Sync + 'static, ) -> Result<()>
Evaluate JavaScript in the target WebView and receive the serialized result.
The returned value is the backend’s JSON string serialization of the JavaScript result.
Sourcepub fn insert_css(
&self,
window: &mut Window,
key: &str,
css: &str,
) -> Result<()>
pub fn insert_css( &self, window: &mut Window, key: &str, css: &str, ) -> Result<()>
Insert or replace a named runtime CSS block in the target WebView.
This mirrors browser-runtime hosted CSS injection(...) workflows for hosted
widgets and browser-media islands, while using an app-chosen key so CSS
can be updated or removed deterministically later.
Sourcepub fn remove_inserted_css(&self, window: &mut Window, key: &str) -> Result<()>
pub fn remove_inserted_css(&self, window: &mut Window, key: &str) -> Result<()>
Remove a named runtime CSS block inserted with Self::insert_css.
Sourcepub fn find_text(
&self,
window: &mut Window,
query: impl Into<SharedString>,
options: WebViewFindOptions,
callback: impl Fn(Result<bool, SharedString>) + Send + Sync + 'static,
) -> Result<()>
pub fn find_text( &self, window: &mut Window, query: impl Into<SharedString>, options: WebViewFindOptions, callback: impl Fn(Result<bool, SharedString>) + Send + Sync + 'static, ) -> Result<()>
Find text in the target WebView and move browser selection to the match.
The callback receives Ok(true) when the browser found and selected a
match, Ok(false) when no match was found, or Err(...) when script
execution failed.
Sourcepub fn find_text_result(
&self,
window: &mut Window,
query: impl Into<SharedString>,
options: WebViewFindOptions,
callback: impl Fn(Result<WebViewFindResult, SharedString>) + Send + Sync + 'static,
) -> Result<()>
pub fn find_text_result( &self, window: &mut Window, query: impl Into<SharedString>, options: WebViewFindOptions, callback: impl Fn(Result<WebViewFindResult, SharedString>) + Send + Sync + 'static, ) -> Result<()>
Find text and return a richer result for native find bars.
The browser still owns the active selection via window.find(...), while
Kael also counts DOM text matches in the current document so apps can
show result counts without custom page JavaScript. Cross-origin frames
and backend-native find match details are not included.
Sourcepub fn stop_finding(&self, window: &mut Window) -> Result<()>
pub fn stop_finding(&self, window: &mut Window) -> Result<()>
Clear the active browser find selection in the target WebView.
Sourcepub fn stop_finding_with_action(
&self,
window: &mut Window,
action: WebViewStopFindAction,
) -> Result<()>
pub fn stop_finding_with_action( &self, window: &mut Window, action: WebViewStopFindAction, ) -> Result<()>
Stop finding with an native desktop selection action.
This mirrors hosted find stop(action): ClearSelection
removes the current browser selection, KeepSelection leaves it alone,
and ActivateSelection focuses/scrolls the selected match where browser
APIs allow it.
Sourcepub fn edit_command(
&self,
window: &mut Window,
command: WebViewEditCommand,
callback: impl Fn(Result<bool, SharedString>) + Send + Sync + 'static,
) -> Result<()>
pub fn edit_command( &self, window: &mut Window, command: WebViewEditCommand, callback: impl Fn(Result<bool, SharedString>) + Send + Sync + 'static, ) -> Result<()>
Execute a browser edit command in the target WebView.
This covers common browser-runtime hosted page controller edit commands such as copy,
cut, paste, select all, undo, and redo. The callback receives the
browser’s boolean document.execCommand(...) result.
Sourcepub fn insert_text(
&self,
window: &mut Window,
text: impl Into<SharedString>,
callback: impl Fn(Result<bool, SharedString>) + Send + Sync + 'static,
) -> Result<()>
pub fn insert_text( &self, window: &mut Window, text: impl Into<SharedString>, callback: impl Fn(Result<bool, SharedString>) + Send + Sync + 'static, ) -> Result<()>
Insert text into the focused browser editor or form control.
This mirrors browser-runtime hosted page controller.insertText(...) for command palettes,
AI agents, test automation, and native editor chrome that need to type
into hosted inputs or contenteditable documents without bespoke page
JavaScript. The callback receives whether the browser accepted or
emulated the insertion.
Sourcepub fn focus_selector(
&self,
window: &mut Window,
selector: impl Into<SharedString>,
callback: impl Fn(Result<bool, SharedString>) + Send + Sync + 'static,
) -> Result<()>
pub fn focus_selector( &self, window: &mut Window, selector: impl Into<SharedString>, callback: impl Fn(Result<bool, SharedString>) + Send + Sync + 'static, ) -> Result<()>
Focus the first element matching a CSS selector in the target WebView.
This is a small browser-island automation helper for native chrome,
tests, and AI agents. It avoids repeating raw querySelector(...)
snippets when an app needs to focus a hosted input, editor, or control
before sending edit commands.
Sourcepub fn click_selector(
&self,
window: &mut Window,
selector: impl Into<SharedString>,
callback: impl Fn(Result<bool, SharedString>) + Send + Sync + 'static,
) -> Result<()>
pub fn click_selector( &self, window: &mut Window, selector: impl Into<SharedString>, callback: impl Fn(Result<bool, SharedString>) + Send + Sync + 'static, ) -> Result<()>
Click the first element matching a CSS selector in the target WebView.
This is useful for WebView-hosted buttons, links, tabs, and test fixtures where native code or an agent needs to trigger normal browser click behavior without custom page JavaScript.
Sourcepub fn add_class(
&self,
window: &mut Window,
selector: impl Into<SharedString>,
class_name: impl Into<SharedString>,
callback: impl Fn(Result<bool, SharedString>) + Send + Sync + 'static,
) -> Result<()>
pub fn add_class( &self, window: &mut Window, selector: impl Into<SharedString>, class_name: impl Into<SharedString>, callback: impl Fn(Result<bool, SharedString>) + Send + Sync + 'static, ) -> Result<()>
Add a CSS class to the first element matching a selector.
This is a small DOM customization helper for hosted widgets, context
menus, tests, and agents. It uses normal classList.add(...) browser
behavior and does not pierce cross-origin frames or shadow roots.
Sourcepub fn remove_class(
&self,
window: &mut Window,
selector: impl Into<SharedString>,
class_name: impl Into<SharedString>,
callback: impl Fn(Result<bool, SharedString>) + Send + Sync + 'static,
) -> Result<()>
pub fn remove_class( &self, window: &mut Window, selector: impl Into<SharedString>, class_name: impl Into<SharedString>, callback: impl Fn(Result<bool, SharedString>) + Send + Sync + 'static, ) -> Result<()>
Remove a CSS class from the first element matching a selector.
Sourcepub fn toggle_class(
&self,
window: &mut Window,
selector: impl Into<SharedString>,
class_name: impl Into<SharedString>,
force: Option<bool>,
callback: impl Fn(Result<bool, SharedString>) + Send + Sync + 'static,
) -> Result<()>
pub fn toggle_class( &self, window: &mut Window, selector: impl Into<SharedString>, class_name: impl Into<SharedString>, force: Option<bool>, callback: impl Fn(Result<bool, SharedString>) + Send + Sync + 'static, ) -> Result<()>
Toggle a CSS class on the first element matching a selector.
Pass Some(true) or Some(false) to force the final state, or None
to invert the current class state.
Sourcepub fn set_attribute(
&self,
window: &mut Window,
selector: impl Into<SharedString>,
name: impl Into<SharedString>,
value: impl Into<SharedString>,
callback: impl Fn(Result<bool, SharedString>) + Send + Sync + 'static,
) -> Result<()>
pub fn set_attribute( &self, window: &mut Window, selector: impl Into<SharedString>, name: impl Into<SharedString>, value: impl Into<SharedString>, callback: impl Fn(Result<bool, SharedString>) + Send + Sync + 'static, ) -> Result<()>
Set an attribute on the first element matching a selector.
Use this for simple hosted-widget state such as aria-*, data-*,
hidden, src, or controls. Page script and browser validation still
own the final behavior of sensitive attributes.
Sourcepub fn remove_attribute(
&self,
window: &mut Window,
selector: impl Into<SharedString>,
name: impl Into<SharedString>,
callback: impl Fn(Result<bool, SharedString>) + Send + Sync + 'static,
) -> Result<()>
pub fn remove_attribute( &self, window: &mut Window, selector: impl Into<SharedString>, name: impl Into<SharedString>, callback: impl Fn(Result<bool, SharedString>) + Send + Sync + 'static, ) -> Result<()>
Remove an attribute from the first element matching a selector.
Sourcepub fn set_style_property(
&self,
window: &mut Window,
selector: impl Into<SharedString>,
name: impl Into<SharedString>,
value: impl Into<SharedString>,
callback: impl Fn(Result<bool, SharedString>) + Send + Sync + 'static,
) -> Result<()>
pub fn set_style_property( &self, window: &mut Window, selector: impl Into<SharedString>, name: impl Into<SharedString>, value: impl Into<SharedString>, callback: impl Fn(Result<bool, SharedString>) + Send + Sync + 'static, ) -> Result<()>
Set one inline CSS property on the first element matching a selector.
The property name is passed to style.setProperty(...), so CSS custom
properties are allowed. This intentionally targets inline styles for
narrow app/agent customization; use Self::insert_css for larger
stylesheet-level changes.
Sourcepub fn remove_style_property(
&self,
window: &mut Window,
selector: impl Into<SharedString>,
name: impl Into<SharedString>,
callback: impl Fn(Result<bool, SharedString>) + Send + Sync + 'static,
) -> Result<()>
pub fn remove_style_property( &self, window: &mut Window, selector: impl Into<SharedString>, name: impl Into<SharedString>, callback: impl Fn(Result<bool, SharedString>) + Send + Sync + 'static, ) -> Result<()>
Remove one inline CSS property from the first element matching a selector.
Sourcepub fn set_form_value(
&self,
window: &mut Window,
selector: impl Into<SharedString>,
value: impl Into<SharedString>,
callback: impl Fn(Result<bool, SharedString>) + Send + Sync + 'static,
) -> Result<()>
pub fn set_form_value( &self, window: &mut Window, selector: impl Into<SharedString>, value: impl Into<SharedString>, callback: impl Fn(Result<bool, SharedString>) + Send + Sync + 'static, ) -> Result<()>
Set the value of the first form control matching a CSS selector.
This covers common hosted form automation for inputs, textareas,
selects, checkboxes, radios, and contenteditable elements. It dispatches
normal input and change events so page listeners can react as if the
user edited the control.
Sourcepub fn submit_form(
&self,
window: &mut Window,
selector: impl Into<SharedString>,
callback: impl Fn(Result<bool, SharedString>) + Send + Sync + 'static,
) -> Result<()>
pub fn submit_form( &self, window: &mut Window, selector: impl Into<SharedString>, callback: impl Fn(Result<bool, SharedString>) + Send + Sync + 'static, ) -> Result<()>
Submit the first form matching or containing a CSS selector.
The selector may point at a <form> or at a control inside a form. Kael
uses the browser’s requestSubmit() path when available so normal
validation and submit handlers run.
Sourcepub fn reset_form(
&self,
window: &mut Window,
selector: impl Into<SharedString>,
callback: impl Fn(Result<bool, SharedString>) + Send + Sync + 'static,
) -> Result<()>
pub fn reset_form( &self, window: &mut Window, selector: impl Into<SharedString>, callback: impl Fn(Result<bool, SharedString>) + Send + Sync + 'static, ) -> Result<()>
Reset the first form matching or containing a CSS selector.
The selector may point at a <form> or at a control inside a form. Kael
calls the browser’s normal form.reset() path so reset events and
default values are handled by the hosted document.
Sourcepub fn copy(
&self,
window: &mut Window,
callback: impl Fn(Result<bool, SharedString>) + Send + Sync + 'static,
) -> Result<()>
pub fn copy( &self, window: &mut Window, callback: impl Fn(Result<bool, SharedString>) + Send + Sync + 'static, ) -> Result<()>
Copy the current browser selection in the target WebView.
Sourcepub fn cut(
&self,
window: &mut Window,
callback: impl Fn(Result<bool, SharedString>) + Send + Sync + 'static,
) -> Result<()>
pub fn cut( &self, window: &mut Window, callback: impl Fn(Result<bool, SharedString>) + Send + Sync + 'static, ) -> Result<()>
Cut the current browser selection in the target WebView.
Sourcepub fn paste(
&self,
window: &mut Window,
callback: impl Fn(Result<bool, SharedString>) + Send + Sync + 'static,
) -> Result<()>
pub fn paste( &self, window: &mut Window, callback: impl Fn(Result<bool, SharedString>) + Send + Sync + 'static, ) -> Result<()>
Paste into the focused editable browser element when the backend allows it.
Sourcepub fn select_all(
&self,
window: &mut Window,
callback: impl Fn(Result<bool, SharedString>) + Send + Sync + 'static,
) -> Result<()>
pub fn select_all( &self, window: &mut Window, callback: impl Fn(Result<bool, SharedString>) + Send + Sync + 'static, ) -> Result<()>
Select all editable/browser document content in the target WebView.
Sourcepub fn undo(
&self,
window: &mut Window,
callback: impl Fn(Result<bool, SharedString>) + Send + Sync + 'static,
) -> Result<()>
pub fn undo( &self, window: &mut Window, callback: impl Fn(Result<bool, SharedString>) + Send + Sync + 'static, ) -> Result<()>
Undo the last browser editing action in the target WebView.
Sourcepub fn redo(
&self,
window: &mut Window,
callback: impl Fn(Result<bool, SharedString>) + Send + Sync + 'static,
) -> Result<()>
pub fn redo( &self, window: &mut Window, callback: impl Fn(Result<bool, SharedString>) + Send + Sync + 'static, ) -> Result<()>
Redo the last undone browser editing action in the target WebView.
Sourcepub fn delete_selection(
&self,
window: &mut Window,
callback: impl Fn(Result<bool, SharedString>) + Send + Sync + 'static,
) -> Result<()>
pub fn delete_selection( &self, window: &mut Window, callback: impl Fn(Result<bool, SharedString>) + Send + Sync + 'static, ) -> Result<()>
Delete the current browser selection in the target WebView.
Sourcepub fn selected_text(
&self,
window: &mut Window,
callback: impl Fn(Result<SharedString, SharedString>) + Send + Sync + 'static,
) -> Result<()>
pub fn selected_text( &self, window: &mut Window, callback: impl Fn(Result<SharedString, SharedString>) + Send + Sync + 'static, ) -> Result<()>
Read the current browser selection as text.
This mirrors browser-runtime hosted selected-text query for context menus,
inspectors, find bars, and hosted editor chrome. It handles both normal
document selections and focused <input> / <textarea> selection ranges.
Sourcepub fn selected_html(
&self,
window: &mut Window,
callback: impl Fn(Result<SharedString, SharedString>) + Send + Sync + 'static,
) -> Result<()>
pub fn selected_html( &self, window: &mut Window, callback: impl Fn(Result<SharedString, SharedString>) + Send + Sync + 'static, ) -> Result<()>
Read the current browser selection as HTML.
This is useful for rich-editor context menus, inspectors, and export
flows. Normal document selections are serialized from cloned selection
ranges; focused <input> / <textarea> selections are returned as
escaped text because those controls do not expose rich HTML fragments.
Sourcepub fn document_html(
&self,
window: &mut Window,
callback: impl Fn(Result<SharedString, SharedString>) + Send + Sync + 'static,
) -> Result<()>
pub fn document_html( &self, window: &mut Window, callback: impl Fn(Result<SharedString, SharedString>) + Send + Sync + 'static, ) -> Result<()>
Read the current document element as serialized HTML.
This mirrors the common browser-runtime stack pattern of calling
executeJavaScript("document.documentElement.outerHTML") for page
inspectors, export flows, bug reports, and AI-agent page understanding.
Cross-origin frames remain owned by the browser engine and are not
expanded into this string.
Sourcepub fn document_snapshot(
&self,
window: &mut Window,
callback: impl Fn(Result<WebViewDocumentSnapshot, SharedString>) + Send + Sync + 'static,
) -> Result<()>
pub fn document_snapshot( &self, window: &mut Window, callback: impl Fn(Result<WebViewDocumentSnapshot, SharedString>) + Send + Sync + 'static, ) -> Result<()>
Read a structured snapshot of the current document.
This is intended for diagnostics, tests, page inspectors, and AI-agent page understanding. It captures same-origin top-document metadata, visible text, headings, links, images, and forms without expanding cross-origin frames or fetching resource bytes.
Sourcepub fn element_snapshot(
&self,
window: &mut Window,
selector: impl Into<SharedString>,
callback: impl Fn(Result<Option<WebViewElementSnapshot>, SharedString>) + Send + Sync + 'static,
) -> Result<()>
pub fn element_snapshot( &self, window: &mut Window, selector: impl Into<SharedString>, callback: impl Fn(Result<Option<WebViewElementSnapshot>, SharedString>) + Send + Sync + 'static, ) -> Result<()>
Read a structured snapshot for the first element matching a CSS selector.
This is a narrower companion to Self::document_snapshot for native
inspectors, tests, and AI agents that need to decide how to interact
with a hosted control before calling selector-scoped mutation helpers.
It only inspects the current top document; cross-origin frames and
shadow roots remain owned by the browser engine.
Sourcepub fn capture_dom_image(
&self,
window: &mut Window,
selector: impl Into<SharedString>,
options: WebViewDomImageCaptureOptions,
callback: impl Fn(Result<Option<SharedString>, SharedString>) + Send + Sync + 'static,
) -> Result<()>
pub fn capture_dom_image( &self, window: &mut Window, selector: impl Into<SharedString>, options: WebViewDomImageCaptureOptions, callback: impl Fn(Result<Option<SharedString>, SharedString>) + Send + Sync + 'static, ) -> Result<()>
Capture a same-document DOM element as an SVG data URL.
This is a lightweight thumbnail/preview helper for app-owned hosted
widgets. It clones the selected element, inlines computed styles, and
wraps the clone in an SVG foreignObject. It is not a native pixel
screenshot, does not pierce cross-origin frames or shadow roots, and
browser media, canvas, WebGL, and external resources may not serialize
with visual fidelity.
Sourcepub fn trigger_download(
&self,
window: &mut Window,
url: impl Into<SharedString>,
filename: Option<impl Into<SharedString>>,
callback: impl Fn(Result<WebViewDownloadTriggerResult, SharedString>) + Send + Sync + 'static,
) -> Result<()>
pub fn trigger_download( &self, window: &mut Window, url: impl Into<SharedString>, filename: Option<impl Into<SharedString>>, callback: impl Fn(Result<WebViewDownloadTriggerResult, SharedString>) + Send + Sync + 'static, ) -> Result<()>
Ask the hosted document to trigger a browser download for a URL.
This is designed for native context menus and agents that receive a
linkHref, imageSrc, or mediaSrc from Kael’s WebView bridges and
need a “Save…” command without taking over networking. The URL is
resolved against the current document and the filename is passed as the
browser <a download> hint. Browser origin rules, response headers,
and Kael’s download policy handlers still decide whether and where the
download actually completes.
Sourcepub fn download_url(
&self,
window: &mut Window,
url: impl Into<SharedString>,
filename: Option<impl Into<SharedString>>,
callback: impl Fn(Result<WebViewDownloadTriggerResult, SharedString>) + Send + Sync + 'static,
) -> Result<()>
pub fn download_url( &self, window: &mut Window, url: impl Into<SharedString>, filename: Option<impl Into<SharedString>>, callback: impl Fn(Result<WebViewDownloadTriggerResult, SharedString>) + Send + Sync + 'static, ) -> Result<()>
Alias for WebViewController::trigger_download.
Sourcepub fn favicons(
&self,
window: &mut Window,
callback: impl Fn(Result<Vec<SharedString>, SharedString>) + Send + Sync + 'static,
) -> Result<()>
pub fn favicons( &self, window: &mut Window, callback: impl Fn(Result<Vec<SharedString>, SharedString>) + Send + Sync + 'static, ) -> Result<()>
Read favicon candidates from the current document.
This mirrors native desktop tab chrome that reacts to hosted page icons.
It returns resolved URLs from <link rel="icon">, shortcut icons,
Apple touch icons, and mask icons in document order. It does not fetch
or decode image bytes.
Sourcepub fn title(
&self,
window: &mut Window,
callback: impl Fn(Result<SharedString, SharedString>) + Send + Sync + 'static,
) -> Result<()>
pub fn title( &self, window: &mut Window, callback: impl Fn(Result<SharedString, SharedString>) + Send + Sync + 'static, ) -> Result<()>
Read the current document.title from the target WebView.
This mirrors browser-runtime hosted title query for tab labels,
breadcrumbs, inspectors, and restore flows that need the title on
demand rather than only through title-change events.
Sourcepub fn user_agent(
&self,
window: &mut Window,
callback: impl Fn(Result<SharedString, SharedString>) + Send + Sync + 'static,
) -> Result<()>
pub fn user_agent( &self, window: &mut Window, callback: impl Fn(Result<SharedString, SharedString>) + Send + Sync + 'static, ) -> Result<()>
Read the effective browser user agent from the target WebView.
This mirrors browser-runtime hosted user-agent query for diagnostics,
hosted service compatibility checks, and verifying custom
WebViewOptions::user_agent configuration.
Sourcepub fn is_loading(
&self,
window: &mut Window,
callback: impl Fn(Result<bool, SharedString>) + Send + Sync + 'static,
) -> Result<()>
pub fn is_loading( &self, window: &mut Window, callback: impl Fn(Result<bool, SharedString>) + Send + Sync + 'static, ) -> Result<()>
Read whether the target WebView document is still loading.
This mirrors the common browser-runtime hosted loading query workflow for
app-owned loading indicators and route guards. It is based on
document.readyState !== "complete" rather than backend-native network
activity counters.
Sourcepub fn can_go_back(
&self,
window: &mut Window,
callback: impl Fn(Result<bool, SharedString>) + Send + Sync + 'static,
) -> Result<()>
pub fn can_go_back( &self, window: &mut Window, callback: impl Fn(Result<bool, SharedString>) + Send + Sync + 'static, ) -> Result<()>
Read whether the target WebView likely has a previous history entry.
This mirrors the common browser-runtime hosted back-state query workflow for
native Back buttons. It uses the browser History API
(history.length > 1), which is portable but less precise than
backend-native navigation-stack state.
Sourcepub fn can_go_forward(
&self,
window: &mut Window,
callback: impl Fn(Result<bool, SharedString>) + Send + Sync + 'static,
) -> Result<()>
pub fn can_go_forward( &self, window: &mut Window, callback: impl Fn(Result<bool, SharedString>) + Send + Sync + 'static, ) -> Result<()>
Read whether the target WebView likely has a forward history entry.
This mirrors the common browser-runtime hosted forward-state query workflow
for native Forward buttons. Browser JavaScript cannot inspect the
backend forward stack directly, so this reads an app/page-provided
window.__kaelNavigationState.canGoForward marker when present and
otherwise returns false conservatively. Use
WebViewOptions::navigation_state_bridge or
WebView::navigation_state_bridge for app-owned pages that need a
portable Forward button before native backend stack reads are exposed.
Sourcepub fn viewport_snapshot(
&self,
window: &mut Window,
callback: impl Fn(Result<WebViewScrollEvent, SharedString>) + Send + Sync + 'static,
) -> Result<()>
pub fn viewport_snapshot( &self, window: &mut Window, callback: impl Fn(Result<WebViewScrollEvent, SharedString>) + Send + Sync + 'static, ) -> Result<()>
Read the current top-document viewport and scroll state.
Sourcepub fn scroll_to(
&self,
window: &mut Window,
x: f64,
y: f64,
callback: impl Fn(Result<WebViewScrollEvent, SharedString>) + Send + Sync + 'static,
) -> Result<()>
pub fn scroll_to( &self, window: &mut Window, x: f64, y: f64, callback: impl Fn(Result<WebViewScrollEvent, SharedString>) + Send + Sync + 'static, ) -> Result<()>
Scroll the current top document to an absolute position in CSS pixels.
Sourcepub fn scroll_by(
&self,
window: &mut Window,
delta_x: f64,
delta_y: f64,
callback: impl Fn(Result<WebViewScrollEvent, SharedString>) + Send + Sync + 'static,
) -> Result<()>
pub fn scroll_by( &self, window: &mut Window, delta_x: f64, delta_y: f64, callback: impl Fn(Result<WebViewScrollEvent, SharedString>) + Send + Sync + 'static, ) -> Result<()>
Scroll the current top document by a relative delta in CSS pixels.
Sourcepub fn scroll_selector_into_view(
&self,
window: &mut Window,
selector: impl Into<SharedString>,
callback: impl Fn(Result<Option<WebViewScrollEvent>, SharedString>) + Send + Sync + 'static,
) -> Result<()>
pub fn scroll_selector_into_view( &self, window: &mut Window, selector: impl Into<SharedString>, callback: impl Fn(Result<Option<WebViewScrollEvent>, SharedString>) + Send + Sync + 'static, ) -> Result<()>
Scroll the first matching top-document element into view.
Returns Ok(None) when the selector is invalid or no element matches.
Shadow roots and cross-origin frames remain browser-owned.
Sourcepub fn post_message(&self, window: &mut Window, message: Value) -> Result<()>
pub fn post_message(&self, window: &mut Window, message: Value) -> Result<()>
Post a structured message into the target WebView.
Sourcepub fn post_bridge_message(
&self,
window: &mut Window,
message: impl Into<WebViewBridgeMessage>,
) -> Result<()>
pub fn post_bridge_message( &self, window: &mut Window, message: impl Into<WebViewBridgeMessage>, ) -> Result<()>
Post a typed bridge envelope into the target WebView.
Sourcepub fn respond_to_bridge_message(
&self,
window: &mut Window,
request: &WebViewBridgeMessage,
payload: Value,
) -> Result<()>
pub fn respond_to_bridge_message( &self, window: &mut Window, request: &WebViewBridgeMessage, payload: Value, ) -> Result<()>
Respond to a JavaScript window.kael.invoke(...) request.
Sourcepub fn reject_bridge_message(
&self,
window: &mut Window,
request: &WebViewBridgeMessage,
message: impl Into<String>,
) -> Result<()>
pub fn reject_bridge_message( &self, window: &mut Window, request: &WebViewBridgeMessage, message: impl Into<String>, ) -> Result<()>
Reject a JavaScript window.kael.invoke(...) request.
Sourcepub fn stop_loading(&self, window: &mut Window) -> Result<()>
pub fn stop_loading(&self, window: &mut Window) -> Result<()>
Stop loading resources in the target WebView.
This mirrors browser-runtime hosted load stop through the browser’s
standard window.stop() primitive so it works across supported
WebView backends.
Sourcepub fn play_media(&self, window: &mut Window) -> Result<()>
pub fn play_media(&self, window: &mut Window) -> Result<()>
Play every browser media element in the target WebView.
Browser autoplay and user-gesture policies still apply. Rejected
play() promises are intentionally swallowed so a single blocked or
unsupported element does not break the rest of the page script.
Sourcepub fn pause_media(&self, window: &mut Window) -> Result<()>
pub fn pause_media(&self, window: &mut Window) -> Result<()>
Pause every browser media element in the target WebView.
This is useful for WebView-hosted video/audio fallbacks, docs widgets, calls, and other browser-media islands when the native app needs to pause playback during navigation, window hiding, or route changes.
Sourcepub fn set_media_muted(&self, window: &mut Window, muted: bool) -> Result<()>
pub fn set_media_muted(&self, window: &mut Window, muted: bool) -> Result<()>
Mute or unmute every browser media element in the target WebView.
This changes the muted property on current <audio> and <video>
elements. New media elements created by the page should still be managed
by page code or an injected script.
Sourcepub fn set_media_volume(&self, window: &mut Window, volume: f32) -> Result<()>
pub fn set_media_volume(&self, window: &mut Window, volume: f32) -> Result<()>
Set the volume on every browser media element in the target WebView.
Values are clamped to the browser media element range of 0.0..=1.0.
Sourcepub fn set_media_playback_rate(
&self,
window: &mut Window,
rate: f32,
) -> Result<()>
pub fn set_media_playback_rate( &self, window: &mut Window, rate: f32, ) -> Result<()>
Set the playback rate on every browser media element in the target WebView.
Values below zero are clamped to 0.0; individual browsers may still
reject rates outside their supported media playback range.
Sourcepub fn seek_media_secs(&self, window: &mut Window, seconds: f64) -> Result<()>
pub fn seek_media_secs(&self, window: &mut Window, seconds: f64) -> Result<()>
Seek every browser media element in the target WebView to a time in seconds.
Sourcepub fn media_command(
&self,
window: &mut Window,
selector: impl Into<SharedString>,
command: WebViewMediaCommand,
callback: impl Fn(Result<bool, SharedString>) + Send + Sync + 'static,
) -> Result<()>
pub fn media_command( &self, window: &mut Window, selector: impl Into<SharedString>, command: WebViewMediaCommand, callback: impl Fn(Result<bool, SharedString>) + Send + Sync + 'static, ) -> Result<()>
Run a media command on the first matching browser media element.
The selector may point at an <audio>, <video>, or descendant element.
This is the selector-scoped counterpart to broad helpers such as
Self::play_media and Self::pause_media.
Sourcepub fn set_media_source(
&self,
window: &mut Window,
selector: impl Into<SharedString>,
source: impl Into<SharedString>,
callback: impl Fn(Result<bool, SharedString>) + Send + Sync + 'static,
) -> Result<()>
pub fn set_media_source( &self, window: &mut Window, selector: impl Into<SharedString>, source: impl Into<SharedString>, callback: impl Fn(Result<bool, SharedString>) + Send + Sync + 'static, ) -> Result<()>
Set the source URL for the first matching browser media element.
The selector may point at an <audio>, <video>, or nested <source>
element. Kael updates the element’s src and calls the browser’s normal
load() path so metadata, buffering, and media events are owned by the
embedded engine.
Sourcepub fn set_media_options(
&self,
window: &mut Window,
selector: impl Into<SharedString>,
options: WebViewMediaElementOptions,
callback: impl Fn(Result<bool, SharedString>) + Send + Sync + 'static,
) -> Result<()>
pub fn set_media_options( &self, window: &mut Window, selector: impl Into<SharedString>, options: WebViewMediaElementOptions, callback: impl Fn(Result<bool, SharedString>) + Send + Sync + 'static, ) -> Result<()>
Apply common browser media properties to the first matching element.
The selector may point at an <audio>, <video>, or descendant element.
Kael sets normal media playback surface properties/attributes such as controls,
loop, autoplay, muted, playsinline, poster, preload, controlslist, and
disablePictureInPicture where the browser supports them.
Sourcepub fn capture_media_frame(
&self,
window: &mut Window,
selector: impl Into<SharedString>,
options: WebViewMediaFrameCaptureOptions,
callback: impl Fn(Result<Option<SharedString>, SharedString>) + Send + Sync + 'static,
) -> Result<()>
pub fn capture_media_frame( &self, window: &mut Window, selector: impl Into<SharedString>, options: WebViewMediaFrameCaptureOptions, callback: impl Fn(Result<Option<SharedString>, SharedString>) + Send + Sync + 'static, ) -> Result<()>
Capture the current frame from the first matching browser video element.
The selector may point at a <video> or descendant element. Kael draws
the current video frame into a canvas and returns a data URL. Browser
CORS/tainted-canvas rules still apply; unavailable or uncapturable frames
return Ok(None).
Sourcepub fn add_media_text_track(
&self,
window: &mut Window,
selector: impl Into<SharedString>,
track: WebViewMediaTextTrackOptions,
callback: impl Fn(Result<bool, SharedString>) + Send + Sync + 'static,
) -> Result<()>
pub fn add_media_text_track( &self, window: &mut Window, selector: impl Into<SharedString>, track: WebViewMediaTextTrackOptions, callback: impl Fn(Result<bool, SharedString>) + Send + Sync + 'static, ) -> Result<()>
Add a browser text track to the first matching media element.
The selector may point at an <audio>, <video>, or descendant element.
Kael appends a real <track> child, so the embedded browser owns WebVTT
loading, cue parsing, and TextTrack state.
Sourcepub fn remove_media_text_track(
&self,
window: &mut Window,
selector: impl Into<SharedString>,
track_selector: impl Into<SharedString>,
callback: impl Fn(Result<bool, SharedString>) + Send + Sync + 'static,
) -> Result<()>
pub fn remove_media_text_track( &self, window: &mut Window, selector: impl Into<SharedString>, track_selector: impl Into<SharedString>, callback: impl Fn(Result<bool, SharedString>) + Send + Sync + 'static, ) -> Result<()>
Remove matching browser text-track elements from the first matching media element.
The media selector may point at an <audio>, <video>, or descendant
element. The track selector matches a track element’s id, label, srclang,
kind, src, or zero-based index.
Sourcepub fn select_media_text_track(
&self,
window: &mut Window,
selector: &str,
) -> Result<()>
pub fn select_media_text_track( &self, window: &mut Window, selector: &str, ) -> Result<()>
Select matching browser text tracks and disable the rest.
The selector matches a track’s id, label, language, or zero-based index
string across all current WebView <audio> and <video> elements.
Sourcepub fn disable_media_text_tracks(&self, window: &mut Window) -> Result<()>
pub fn disable_media_text_tracks(&self, window: &mut Window) -> Result<()>
Disable all browser text tracks on current WebView media elements.
Sourcepub fn request_media_fullscreen(&self, window: &mut Window) -> Result<()>
pub fn request_media_fullscreen(&self, window: &mut Window) -> Result<()>
Request browser fullscreen for the first available video or media element.
Browser user-gesture and embedding policies still apply. Rejected fullscreen promises are swallowed so unsupported pages do not break app script execution.
Sourcepub fn exit_media_fullscreen(&self, window: &mut Window) -> Result<()>
pub fn exit_media_fullscreen(&self, window: &mut Window) -> Result<()>
Exit browser fullscreen when the WebView document is fullscreen.
Sourcepub fn request_media_picture_in_picture(
&self,
window: &mut Window,
) -> Result<()>
pub fn request_media_picture_in_picture( &self, window: &mut Window, ) -> Result<()>
Request picture-in-picture for the first video element that supports it.
Browser support, page attributes, permissions, and user-gesture policies still apply. Rejected promises are swallowed.
Sourcepub fn exit_media_picture_in_picture(&self, window: &mut Window) -> Result<()>
pub fn exit_media_picture_in_picture(&self, window: &mut Window) -> Result<()>
Exit browser picture-in-picture when an element is currently active.
Sourcepub fn media_state(
&self,
window: &mut Window,
callback: impl Fn(Result<Vec<WebViewMediaElementState>, SharedString>) + Send + Sync + 'static,
) -> Result<()>
pub fn media_state( &self, window: &mut Window, callback: impl Fn(Result<Vec<WebViewMediaElementState>, SharedString>) + Send + Sync + 'static, ) -> Result<()>
Read state for every browser media element in the target WebView.
This snapshots current <audio> and <video> elements so native chrome
can drive WebView-hosted players without hand-written state scraping.
Sourcepub fn mute_media(&self, window: &mut Window) -> Result<()>
pub fn mute_media(&self, window: &mut Window) -> Result<()>
Mute every browser media element in the target WebView.
Sourcepub fn unmute_media(&self, window: &mut Window) -> Result<()>
pub fn unmute_media(&self, window: &mut Window) -> Result<()>
Unmute every browser media element in the target WebView.
Sourcepub fn go_back(&self, window: &mut Window) -> Result<()>
pub fn go_back(&self, window: &mut Window) -> Result<()>
Navigate the target WebView backward if possible.
Sourcepub fn go_forward(&self, window: &mut Window) -> Result<()>
pub fn go_forward(&self, window: &mut Window) -> Result<()>
Navigate the target WebView forward if possible.
Sourcepub fn open_devtools(&self, window: &mut Window) -> Result<()>
pub fn open_devtools(&self, window: &mut Window) -> Result<()>
Open WebView developer tools when the active backend supports it.
Devtools are available in debug builds on Wry-backed WebViews. Release builds require a backend/devtools feature that may not be enabled.
Sourcepub fn close_devtools(&self, window: &mut Window) -> Result<()>
pub fn close_devtools(&self, window: &mut Window) -> Result<()>
Close WebView developer tools when the active backend supports it.
Sourcepub fn is_devtools_open(
&self,
window: &mut Window,
callback: impl Fn(Result<bool, SharedString>) + 'static,
) -> Result<()>
pub fn is_devtools_open( &self, window: &mut Window, callback: impl Fn(Result<bool, SharedString>) + 'static, ) -> Result<()>
Read whether WebView developer tools are open when the active backend supports it.
Sourcepub fn print(&self, window: &mut Window) -> Result<()>
pub fn print(&self, window: &mut Window) -> Result<()>
Open the platform print dialog for the target WebView content.
Sourcepub fn set_zoom_factor(&self, window: &mut Window, factor: f64) -> Result<()>
pub fn set_zoom_factor(&self, window: &mut Window, factor: f64) -> Result<()>
Set the target WebView’s browser zoom factor.
Sourcepub fn focus(&self, window: &mut Window) -> Result<()>
pub fn focus(&self, window: &mut Window) -> Result<()>
Move focus into the target WebView when the active backend supports it.
Sourcepub fn focus_parent(&self, window: &mut Window) -> Result<()>
pub fn focus_parent(&self, window: &mut Window) -> Result<()>
Move focus from the target WebView back to the parent window.
Sourcepub fn clear_browsing_data(&self, window: &mut Window) -> Result<()>
pub fn clear_browsing_data(&self, window: &mut Window) -> Result<()>
Clear cookies, cache, local storage, and other browsing data for this WebView profile.
Sourcepub fn storage_snapshot(
&self,
window: &mut Window,
callback: impl Fn(Result<WebViewStorageSnapshot, SharedString>) + Send + Sync + 'static,
) -> Result<()>
pub fn storage_snapshot( &self, window: &mut Window, callback: impl Fn(Result<WebViewStorageSnapshot, SharedString>) + Send + Sync + 'static, ) -> Result<()>
Read localStorage and sessionStorage from the current document.
This is an on-demand companion to WebViewOptions::storage_bridge.
Browser origin/security rules still apply; blocked areas are returned
with available: false and an error string instead of being treated as
a transport failure.
Sourcepub fn set_storage_item(
&self,
window: &mut Window,
area: WebViewStorageArea,
key: impl Into<SharedString>,
value: impl Into<SharedString>,
callback: impl Fn(Result<WebViewStorageMutationResult, SharedString>) + Send + Sync + 'static,
) -> Result<()>
pub fn set_storage_item( &self, window: &mut Window, area: WebViewStorageArea, key: impl Into<SharedString>, value: impl Into<SharedString>, callback: impl Fn(Result<WebViewStorageMutationResult, SharedString>) + Send + Sync + 'static, ) -> Result<()>
Set one key in the current document’s browser Web Storage.
Sourcepub fn remove_storage_item(
&self,
window: &mut Window,
area: WebViewStorageArea,
key: impl Into<SharedString>,
callback: impl Fn(Result<WebViewStorageMutationResult, SharedString>) + Send + Sync + 'static,
) -> Result<()>
pub fn remove_storage_item( &self, window: &mut Window, area: WebViewStorageArea, key: impl Into<SharedString>, callback: impl Fn(Result<WebViewStorageMutationResult, SharedString>) + Send + Sync + 'static, ) -> Result<()>
Remove one key from the current document’s browser Web Storage.
Sourcepub fn clear_storage_area(
&self,
window: &mut Window,
area: WebViewStorageArea,
callback: impl Fn(Result<WebViewStorageMutationResult, SharedString>) + Send + Sync + 'static,
) -> Result<()>
pub fn clear_storage_area( &self, window: &mut Window, area: WebViewStorageArea, callback: impl Fn(Result<WebViewStorageMutationResult, SharedString>) + Send + Sync + 'static, ) -> Result<()>
Clear one current-document browser Web Storage area.
Sourcepub fn url(
&self,
window: &mut Window,
callback: impl Fn(Result<SharedString, SharedString>) + 'static,
) -> Result<()>
pub fn url( &self, window: &mut Window, callback: impl Fn(Result<SharedString, SharedString>) + 'static, ) -> Result<()>
Read the current URL reported by this WebView.
Read all cookies visible to this WebView.
Read cookies for a URL from this WebView.
Set a cookie in this WebView profile.
Delete a cookie from this WebView profile.
Trait Implementations§
Source§impl Clone for WebViewController
impl Clone for WebViewController
Source§fn clone(&self) -> WebViewController
fn clone(&self) -> WebViewController
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for WebViewController
impl Debug for WebViewController
impl Eq for WebViewController
Source§impl Hash for WebViewController
impl Hash for WebViewController
Source§impl PartialEq for WebViewController
impl PartialEq for WebViewController
impl StructuralPartialEq for WebViewController
Auto Trait Implementations§
impl Freeze for WebViewController
impl RefUnwindSafe for WebViewController
impl Send for WebViewController
impl Sync for WebViewController
impl Unpin for WebViewController
impl UnsafeUnpin for WebViewController
impl UnwindSafe for WebViewController
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more