Skip to main content

WebView

Struct WebView 

Source
pub struct WebView { /* private fields */ }

Implementations§

Source§

impl WebView

Source

pub fn new(system_color_scheme: ColorScheme, js_policy: JsPolicy) -> Self

Source

pub fn set_css_strategy(&mut self, strategy: CssApplicationStrategy)

Set the CSS application strategy.

Default is Incremental.

Source

pub fn set_js_policy(&mut self, policy: JsPolicy)

Sets the JavaScript execution policy.

The policy is applied to <noscript> parsing on the next document load and takes effect immediately for execution: disabling it drops the JS runtime, cancels pending script work, and stops running scripts.

Source

pub fn set_js_tracing(&mut self, enabled: bool)

Enables or disables JavaScript execution tracing.

The preference is kept across navigations; buffered events belong to the current page and are cleared on load.

Source

pub fn clear_js_trace(&mut self)

Clears the buffered JavaScript execution trace.

Source

pub fn js_policy(&self) -> JsPolicy

Returns the current JavaScript execution policy.

Source

pub fn set_privileged(&mut self, privileged: bool)

Marks this webview as rendering a browser-created chrome document.

Chrome webviews derive Permissions::chrome instead of the ordinary content capabilities for their document URL.

Source

pub fn tick(&mut self) -> Vec<WebViewTask>

Source

pub fn on_html_fetched(&mut self, html: String, document_url: Url)

Source

pub fn on_css_fetched(&mut self, css: String)

Source

pub fn on_css_fetched_from(&mut self, css: String, stylesheet_url: &Url)

Source

pub fn on_css_import_fetched(&mut self, source: String, url: &Url)

Records a fetched @import-ed stylesheet under its own URL.

Source

pub fn on_css_import_fetch_failed(&mut self, url: &Url)

Records a failed @import fetch: the sheet contributes nothing, and its importers proceed without it instead of blocking the load.

Source

pub fn on_image_fetched(&mut self, source: String, bytes: &[u8]) -> Result<()>

Decodes a fetched image and rebuilds layout using its intrinsic size.

Source

pub fn on_audio_fetched(&mut self, source: String, bytes: &[u8])

Stores fetched audio bytes for the matching <audio> control.

Source

pub fn on_script_fetched(&mut self, index: usize, source: String)

Executes or queues a fetched external classic script by scheduling mode.

Source

pub fn on_script_fetch_failed(&mut self, index: usize)

Records a failed external classic script without aborting page loading.

Source

pub fn on_dynamic_script_fetched( &mut self, node_id: u64, source: String, url: &Url, )

Executes a fetched dynamically inserted script and dispatches load.

Source

pub fn on_dynamic_script_fetch_failed(&mut self, node_id: u64)

Dispatches error for a dynamically inserted script that failed to load.

Source

pub fn on_dynamic_style_fetched( &mut self, node_id: u64, source: String, stylesheet_url: &Url, )

Source

pub fn on_dynamic_style_fetch_failed(&mut self, node_id: u64)

Source

pub fn on_js_fetch_succeeded( &mut self, request_id: u64, response: JsFetchResponse, )

Resolves a JavaScript fetch() request with a network response.

Source

pub fn on_js_fetch_failed(&mut self, request_id: u64, reason: String)

Rejects a JavaScript fetch() request after a network failure.

Source

pub fn on_iframe_fetched(&mut self, dom_id: u64, html: String, final_url: Url)

Installs parsed iframe HTML as the host element’s contentDocument and fires its load event.

Source

pub fn on_iframe_fetch_failed(&mut self, dom_id: u64)

Marks an iframe load as failed so later contentDocument accesses do not keep re-queuing a fetch.

Source

pub fn on_devtools_response(&mut self, id: u64, result: String)

Settles a DevTools inspection request with its JSON envelope.

Source

pub fn update_page(&mut self)

Update page (e.g. DOM changed)

This is a stub method for now.

Source

pub fn on_js_click(&mut self, dom_id: u32) -> bool

Dispatches a click on the given DOM snapshot node id to the page’s JS.

Resolves the live DOM node behind the snapshot id, translates it to the JS-facing dom id and hands the click to the JS thread. Returns whether a redraw is needed; the JS result triggers the relayout once applied.

Source

pub fn on_js_scroll(&mut self, dom_id: u32) -> bool

Dispatches a scroll event on the given DOM snapshot node id to the page’s JS.

Resolves the live DOM node behind the snapshot id, translates it to the JS-facing dom id and hands the scroll to the JS thread. Returns whether a redraw is needed; the JS result triggers the relayout once applied.

Source

pub fn set_text_measurer(&mut self, measurer: Option<Arc<PlatformTextMeasurer>>)

Installs a text measurer created by the owning Tab, so its shape cache survives across navigations instead of being rebuilt (and re-shaped from scratch) for every document.

A None measurer leaves the web view to create its own on first use.

Source

pub fn text_measurer(&self) -> Option<&Arc<PlatformTextMeasurer>>

The measurer this web view is using, if one has been created yet.

Source

pub fn cursor_at(&self, x: f32, y: f32) -> Option<CursorStyle>

Returns the cursor style for the element under the given point, if any.

The point is in CSS pixels relative to the viewport origin.

Walks the hit path from innermost to outermost. The first node with an explicit cursor (anything other than auto) wins. If every node is auto, text nodes get text (I-beam) and everything else gets default.

Source

pub fn navigate(&mut self)

Source

pub fn load_url(&mut self, url: &Url)

Loads a URL, resetting the WebView state and notifying the embedder via on_navigation.

The embedder is responsible for fetching the document and calling on_html_fetched with the result. If no on_navigation callback is set, this method only resets internal state without requesting a fetch.

Source

pub fn set_on_navigation<F>(&mut self, cb: F)
where F: Fn(&Url) + 'static,

Sets the callback invoked when the WebView requests navigation to a URL.

Source

pub fn set_on_fetch<F>(&mut self, cb: F)
where F: Fn(&Url, FetchKind) + 'static,

Sets the callback invoked when the WebView needs to fetch a resource.

Source

pub fn set_on_console<F>(&mut self, cb: F)
where F: Fn(u32, &str) + 'static,

Sets the callback invoked when a page script logs a console message.

Source

pub fn set_on_inspect_request<F>(&mut self, cb: F)
where F: Fn(u64, &str, &str) + 'static,

Sets the callback invoked when page script requests DevTools inspection.

Source

pub fn set_system_color_scheme(&mut self, scheme: ColorScheme)

Source

pub fn title(&self) -> Option<&String>

Source

pub fn set_interaction_paths( &mut self, hovered_path: Vec<u32>, active_path: Vec<u32>, ) -> bool

Updates pointer interaction state used for :hover/:active resolution.

Returns true when the state changed and a relayout was requested.

Source

pub fn clear_active_interaction(&mut self) -> bool

Source

pub fn relayout(&mut self, viewport: (f32, f32))

Source

pub fn scroll_to_fragment(&mut self, url: &Url)

Scrolls the already-loaded document to the fragment in url without reloading it (same-document anchor navigation, e.g. <a href="#id">).

The page stays loaded and only the scroll position and URL change; an empty fragment scrolls back to the top of the document. Fragments are percent-decoded before matching, so #my%20id reaches <div id="my id">.

The current document URL is recorded so page scripts (location.hash, location.href) and the address bar reflect the new location.

Source

pub fn layout_and_info(&self) -> Option<(&LayoutNode, &InfoNode)>

現在描画可能な Layout / Info を返す(なければ None)

Source

pub fn layout_and_info_mut(&mut self) -> Option<(&LayoutNode, &mut InfoNode)>

Source

pub fn document_info(&self) -> Option<&DocumentInfo>

Returns document info

Source

pub fn document_url(&self) -> Option<&Url>

Source

pub fn base_url(&self) -> Option<&Url>

Source

pub fn set_animation_visible(&mut self, visible: bool)

Sets whether this view is visible for animation timing.

When hidden, animation timelines are paused and no continuous redraw is requested. Visibility changes take effect on the next tick/sample.

Source

pub fn needs_redraw(&self) -> bool

Source

pub fn clear_redraw_flag(&mut self)

Trait Implementations§

Source§

impl Default for WebView

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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
§

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

§

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

§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<S> FromSample<S> for S

§

fn from_sample_(s: S) -> S

§

impl<T> Instrument for T

§

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

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

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
§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

§

fn into_sample(self) -> T

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

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

Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

§

fn to_sample_(self) -> U

Source§

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

Source§

type Error = Infallible

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

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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