Skip to main content

WebViewController

Struct WebViewController 

Source
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

Source

pub fn new(id: impl Into<ElementId>) -> Self

Create a controller for a WebView element id.

Source

pub fn id(&self) -> SharedString

Return the WebView element id this controller targets.

Source

pub fn navigate( &self, window: &mut Window, url: impl Into<SharedString>, ) -> Result<()>

Navigate the target WebView to a new URL.

Source

pub fn navigate_with_headers( &self, window: &mut Window, url: impl Into<SharedString>, headers: HeaderMap, ) -> Result<()>

Navigate the target WebView to a new URL with additional request headers.

Source

pub fn load_html( &self, window: &mut Window, html: impl Into<SharedString>, ) -> Result<()>

Load an HTML string into the target WebView.

Source

pub fn evaluate_javascript( &self, window: &mut Window, script: impl Into<SharedString>, ) -> Result<()>

Evaluate JavaScript in the target WebView.

Source

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.

Source

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.

Source

pub fn remove_inserted_css(&self, window: &mut Window, key: &str) -> Result<()>

Remove a named runtime CSS block inserted with Self::insert_css.

Source

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.

Source

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.

Source

pub fn stop_finding(&self, window: &mut Window) -> Result<()>

Clear the active browser find selection in the target WebView.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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<()>

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn post_message(&self, window: &mut Window, message: Value) -> Result<()>

Post a structured message into the target WebView.

Source

pub fn post_bridge_message( &self, window: &mut Window, message: impl Into<WebViewBridgeMessage>, ) -> Result<()>

Post a typed bridge envelope into the target WebView.

Source

pub fn respond_to_bridge_message( &self, window: &mut Window, request: &WebViewBridgeMessage, payload: Value, ) -> Result<()>

Respond to a JavaScript window.kael.invoke(...) request.

Source

pub fn reject_bridge_message( &self, window: &mut Window, request: &WebViewBridgeMessage, message: impl Into<String>, ) -> Result<()>

Reject a JavaScript window.kael.invoke(...) request.

Source

pub fn reload(&self, window: &mut Window) -> Result<()>

Reload the target WebView.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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).

Source

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.

Source

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.

Source

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.

Source

pub fn disable_media_text_tracks(&self, window: &mut Window) -> Result<()>

Disable all browser text tracks on current WebView media elements.

Source

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.

Source

pub fn exit_media_fullscreen(&self, window: &mut Window) -> Result<()>

Exit browser fullscreen when the WebView document is fullscreen.

Source

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.

Source

pub fn exit_media_picture_in_picture(&self, window: &mut Window) -> Result<()>

Exit browser picture-in-picture when an element is currently active.

Source

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.

Source

pub fn mute_media(&self, window: &mut Window) -> Result<()>

Mute every browser media element in the target WebView.

Source

pub fn unmute_media(&self, window: &mut Window) -> Result<()>

Unmute every browser media element in the target WebView.

Source

pub fn go_back(&self, window: &mut Window) -> Result<()>

Navigate the target WebView backward if possible.

Source

pub fn go_forward(&self, window: &mut Window) -> Result<()>

Navigate the target WebView forward if possible.

Source

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.

Source

pub fn close_devtools(&self, window: &mut Window) -> Result<()>

Close WebView developer tools when the active backend supports it.

Source

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.

Source

pub fn print(&self, window: &mut Window) -> Result<()>

Open the platform print dialog for the target WebView content.

Source

pub fn set_zoom_factor(&self, window: &mut Window, factor: f64) -> Result<()>

Set the target WebView’s browser zoom factor.

Source

pub fn focus(&self, window: &mut Window) -> Result<()>

Move focus into the target WebView when the active backend supports it.

Source

pub fn focus_parent(&self, window: &mut Window) -> Result<()>

Move focus from the target WebView back to the parent window.

Source

pub fn clear_browsing_data(&self, window: &mut Window) -> Result<()>

Clear cookies, cache, local storage, and other browsing data for this WebView profile.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn url( &self, window: &mut Window, callback: impl Fn(Result<SharedString, SharedString>) + 'static, ) -> Result<()>

Read the current URL reported by this WebView.

Source

pub fn cookies( &self, window: &mut Window, callback: impl Fn(Result<Vec<WebViewCookie>, SharedString>) + 'static, ) -> Result<()>

Read all cookies visible to this WebView.

Source

pub fn cookies_for_url( &self, window: &mut Window, url: impl Into<SharedString>, callback: impl Fn(Result<Vec<WebViewCookie>, SharedString>) + 'static, ) -> Result<()>

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

Source§

fn clone(&self) -> WebViewController

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for WebViewController

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for WebViewController

Source§

impl Hash for WebViewController

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for WebViewController

Source§

fn eq(&self, other: &WebViewController) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for WebViewController

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &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
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more