pub struct WebView { /* private fields */ }Implementations§
Source§impl WebView
impl WebView
pub fn new(system_color_scheme: ColorScheme, js_policy: JsPolicy) -> Self
Sourcepub fn set_css_strategy(&mut self, strategy: CssApplicationStrategy)
pub fn set_css_strategy(&mut self, strategy: CssApplicationStrategy)
Set the CSS application strategy.
Default is Incremental.
Sourcepub fn set_js_policy(&mut self, policy: JsPolicy)
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.
Sourcepub fn set_js_tracing(&mut self, enabled: bool)
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.
Sourcepub fn clear_js_trace(&mut self)
pub fn clear_js_trace(&mut self)
Clears the buffered JavaScript execution trace.
Sourcepub fn set_privileged(&mut self, privileged: bool)
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.
pub fn tick(&mut self) -> Vec<WebViewTask>
pub fn on_html_fetched(&mut self, html: String, document_url: Url)
pub fn on_css_fetched(&mut self, css: String)
pub fn on_css_fetched_from(&mut self, css: String, stylesheet_url: &Url)
Sourcepub fn on_css_import_fetched(&mut self, source: String, url: &Url)
pub fn on_css_import_fetched(&mut self, source: String, url: &Url)
Records a fetched @import-ed stylesheet under its own URL.
Sourcepub fn on_css_import_fetch_failed(&mut self, url: &Url)
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.
Sourcepub fn on_image_fetched(&mut self, source: String, bytes: &[u8]) -> Result<()>
pub fn on_image_fetched(&mut self, source: String, bytes: &[u8]) -> Result<()>
Decodes a fetched image and rebuilds layout using its intrinsic size.
Sourcepub fn on_audio_fetched(&mut self, source: String, bytes: &[u8])
pub fn on_audio_fetched(&mut self, source: String, bytes: &[u8])
Stores fetched audio bytes for the matching <audio> control.
Sourcepub fn on_script_fetched(&mut self, index: usize, source: String)
pub fn on_script_fetched(&mut self, index: usize, source: String)
Executes or queues a fetched external classic script by scheduling mode.
Sourcepub fn on_script_fetch_failed(&mut self, index: usize)
pub fn on_script_fetch_failed(&mut self, index: usize)
Records a failed external classic script without aborting page loading.
Sourcepub fn on_dynamic_script_fetched(
&mut self,
node_id: u64,
source: String,
url: &Url,
)
pub fn on_dynamic_script_fetched( &mut self, node_id: u64, source: String, url: &Url, )
Executes a fetched dynamically inserted script and dispatches load.
Sourcepub fn on_dynamic_script_fetch_failed(&mut self, node_id: u64)
pub fn on_dynamic_script_fetch_failed(&mut self, node_id: u64)
Dispatches error for a dynamically inserted script that failed to load.
pub fn on_dynamic_style_fetched( &mut self, node_id: u64, source: String, stylesheet_url: &Url, )
pub fn on_dynamic_style_fetch_failed(&mut self, node_id: u64)
Sourcepub fn on_js_fetch_succeeded(
&mut self,
request_id: u64,
response: JsFetchResponse,
)
pub fn on_js_fetch_succeeded( &mut self, request_id: u64, response: JsFetchResponse, )
Resolves a JavaScript fetch() request with a network response.
Sourcepub fn on_js_fetch_failed(&mut self, request_id: u64, reason: String)
pub fn on_js_fetch_failed(&mut self, request_id: u64, reason: String)
Rejects a JavaScript fetch() request after a network failure.
Sourcepub fn on_iframe_fetched(&mut self, dom_id: u64, html: String, final_url: Url)
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.
Sourcepub fn on_iframe_fetch_failed(&mut self, dom_id: u64)
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.
Sourcepub fn on_devtools_response(&mut self, id: u64, result: String)
pub fn on_devtools_response(&mut self, id: u64, result: String)
Settles a DevTools inspection request with its JSON envelope.
Sourcepub fn update_page(&mut self)
pub fn update_page(&mut self)
Update page (e.g. DOM changed)
This is a stub method for now.
Sourcepub fn on_js_click(&mut self, dom_id: u32) -> bool
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.
Sourcepub fn on_js_scroll(&mut self, dom_id: u32) -> bool
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.
Sourcepub fn set_text_measurer(&mut self, measurer: Option<Arc<PlatformTextMeasurer>>)
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.
Sourcepub fn text_measurer(&self) -> Option<&Arc<PlatformTextMeasurer>>
pub fn text_measurer(&self) -> Option<&Arc<PlatformTextMeasurer>>
The measurer this web view is using, if one has been created yet.
Sourcepub fn cursor_at(&self, x: f32, y: f32) -> Option<CursorStyle>
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.
Sourcepub fn load_url(&mut self, url: &Url)
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.
Sets the callback invoked when the WebView requests navigation to a URL.
Sourcepub fn set_on_fetch<F>(&mut self, cb: F)
pub fn set_on_fetch<F>(&mut self, cb: F)
Sets the callback invoked when the WebView needs to fetch a resource.
Sourcepub fn set_on_console<F>(&mut self, cb: F)
pub fn set_on_console<F>(&mut self, cb: F)
Sets the callback invoked when a page script logs a console message.
Sourcepub fn set_on_inspect_request<F>(&mut self, cb: F)
pub fn set_on_inspect_request<F>(&mut self, cb: F)
Sets the callback invoked when page script requests DevTools inspection.
pub fn set_system_color_scheme(&mut self, scheme: ColorScheme)
pub fn title(&self) -> Option<&String>
Sourcepub fn set_interaction_paths(
&mut self,
hovered_path: Vec<u32>,
active_path: Vec<u32>,
) -> bool
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.
pub fn clear_active_interaction(&mut self) -> bool
pub fn relayout(&mut self, viewport: (f32, f32))
Sourcepub fn scroll_to_fragment(&mut self, url: &Url)
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.
Sourcepub fn layout_and_info(&self) -> Option<(&LayoutNode, &InfoNode)>
pub fn layout_and_info(&self) -> Option<(&LayoutNode, &InfoNode)>
現在描画可能な Layout / Info を返す(なければ None)
pub fn layout_and_info_mut(&mut self) -> Option<(&LayoutNode, &mut InfoNode)>
Sourcepub fn document_info(&self) -> Option<&DocumentInfo>
pub fn document_info(&self) -> Option<&DocumentInfo>
Returns document info
pub fn document_url(&self) -> Option<&Url>
pub fn base_url(&self) -> Option<&Url>
Sourcepub fn set_animation_visible(&mut self, visible: bool)
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.
pub fn needs_redraw(&self) -> bool
pub fn clear_redraw_flag(&mut self)
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for WebView
impl !RefUnwindSafe for WebView
impl !Send for WebView
impl !Sync for WebView
impl !UnwindSafe for WebView
impl Unpin for WebView
impl UnsafeUnpin for WebView
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
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().