Skip to main content

Engine

Trait Engine 

Source
pub trait Engine {
Show 33 methods // Required methods fn update(&mut self); fn render(&mut self, size: Size<u32>); fn request_render(&mut self, id: ViewId, size: Size<u32>); fn new_view(&mut self, size: Size<u32>, content: Option<PageType>) -> ViewId; fn remove_view(&mut self, id: ViewId); fn focus(&mut self); fn unfocus(&self); fn resize(&mut self, size: Size<u32>); fn handle_keyboard_event(&mut self, id: ViewId, event: Event); fn handle_mouse_event(&mut self, id: ViewId, point: Point, event: Event); fn scroll(&mut self, id: ViewId, delta: ScrollDelta); fn goto(&mut self, id: ViewId, page_type: PageType); fn refresh(&mut self, id: ViewId); fn go_forward(&mut self, id: ViewId); fn go_back(&mut self, id: ViewId); fn get_url(&self, id: ViewId) -> String; fn get_title(&self, id: ViewId) -> String; fn get_cursor(&self, id: ViewId) -> Interaction; fn get_view(&self, id: ViewId) -> &ImageInfo; // Provided methods fn has_view(&self, _id: ViewId) -> bool { ... } fn set_scale_factor(&mut self, _scale: f32) { ... } fn handles_urls(&self) -> bool { ... } fn get_scroll_y(&self, _id: ViewId) -> f32 { ... } fn get_content_height(&self, _id: ViewId) -> f32 { ... } fn get_selected_text(&self, _id: ViewId) -> Option<String> { ... } fn get_selection_rects(&self, _id: ViewId) -> &[[f32; 4]] { ... } fn take_anchor_click(&mut self, _id: ViewId) -> Option<String> { ... } fn scroll_to_fragment(&mut self, _id: ViewId, _fragment: &str) -> bool { ... } fn take_pending_images(&mut self) -> Vec<(ViewId, String, String, bool)> { ... } fn set_css_cache(&mut self, _id: ViewId, _cache: HashMap<String, String>) { ... } fn load_image_from_bytes( &mut self, _id: ViewId, _url: &str, _bytes: &[u8], _redraw_on_ready: bool, ) { ... } fn flush_staged_images(&mut self, _id: ViewId, _size: Size<u32>) { ... } fn view_ids(&self) -> Vec<ViewId> { ... }
}
Expand description

Trait to handle multiple browser engines Currently only supports cpu renders via pixel_buffer Passing a View id that does not exist is handled gracefully (no-op / defaults)

Required Methods§

Source

fn update(&mut self)

Used to do work in the actual browser engine

Source

fn render(&mut self, size: Size<u32>)

Request a new render pass from the engine

Source

fn request_render(&mut self, id: ViewId, size: Size<u32>)

Flush a pending render for a specific view, if one is needed.

This does not force an unconditional render. It only performs the (potentially expensive) render work when the view has been marked dirty by a prior state change (goto, resize, refresh, update, etc.). Callers should treat this as a “render-if-dirty” flush point, not a “render right now regardless” command.

Source

fn new_view(&mut self, size: Size<u32>, content: Option<PageType>) -> ViewId

Creates new a new (possibly blank) view and returns the ViewId to interact with it

Source

fn remove_view(&mut self, id: ViewId)

Removes desired view

Source

fn focus(&mut self)

Focuses webview

Source

fn unfocus(&self)

Unfocuses webview

Source

fn resize(&mut self, size: Size<u32>)

Resizes webview

Source

fn handle_keyboard_event(&mut self, id: ViewId, event: Event)

lets the engine handle keyboard events

Source

fn handle_mouse_event(&mut self, id: ViewId, point: Point, event: Event)

lets the engine handle mouse events

Source

fn scroll(&mut self, id: ViewId, delta: ScrollDelta)

Handles scrolling on view

Source

fn goto(&mut self, id: ViewId, page_type: PageType)

Go to a specific page type

Source

fn refresh(&mut self, id: ViewId)

Refresh specific view

Source

fn go_forward(&mut self, id: ViewId)

Moves forward on view

Source

fn go_back(&mut self, id: ViewId)

Moves back on view

Source

fn get_url(&self, id: ViewId) -> String

Gets current url from view

Source

fn get_title(&self, id: ViewId) -> String

Gets current title from view

Source

fn get_cursor(&self, id: ViewId) -> Interaction

Gets current cursor status from view

Source

fn get_view(&self, id: ViewId) -> &ImageInfo

Gets CPU-rendered webview

Provided Methods§

Source

fn has_view(&self, _id: ViewId) -> bool

Whether a view with this id currently exists.

Source

fn set_scale_factor(&mut self, _scale: f32)

Set the display scale factor for HiDPI rendering. Default is no-op.

Source

fn handles_urls(&self) -> bool

Whether this engine can fetch and render URLs natively. Engines that return false rely on the webview layer to fetch HTML.

Source

fn get_scroll_y(&self, _id: ViewId) -> f32

Current vertical scroll offset (logical pixels).

Source

fn get_content_height(&self, _id: ViewId) -> f32

Total content height (logical pixels). Zero means the engine manages scrolling.

Source

fn get_selected_text(&self, _id: ViewId) -> Option<String>

Gets the currently selected text from a view, if any.

Source

fn get_selection_rects(&self, _id: ViewId) -> &[[f32; 4]]

Selection highlight rectangles for overlay rendering. Returns [x, y, width, height] in logical coordinates, scroll-adjusted.

Source

fn take_anchor_click(&mut self, _id: ViewId) -> Option<String>

Take the last anchor click URL from a view, if any. Called after mouse events to detect link navigation.

Source

fn scroll_to_fragment(&mut self, _id: ViewId, _fragment: &str) -> bool

Scroll to a named fragment (e.g. "section2" for #section2). Returns true if the fragment was found and the view scrolled.

Source

fn take_pending_images(&mut self) -> Vec<(ViewId, String, String, bool)>

Return image URLs discovered during layout that still need fetching. Each entry is (view_id, raw_src, baseurl, redraw_on_ready) — the consumer resolves URLs against baseurl and threads redraw_on_ready back through load_image_from_bytes.

Source

fn set_css_cache(&mut self, _id: ViewId, _cache: HashMap<String, String>)

Pre-load a CSS cache into a view’s container so import_css can resolve stylesheets without network access during parsing.

Source

fn load_image_from_bytes( &mut self, _id: ViewId, _url: &str, _bytes: &[u8], _redraw_on_ready: bool, )

Inject fetched image bytes into a view’s container, keyed by the raw src value from the HTML. When redraw_on_ready is true, the image doesn’t affect layout (CSS background or <img> with explicit dimensions) so doc.render() can be skipped — only a redraw is needed.

Source

fn flush_staged_images(&mut self, _id: ViewId, _size: Size<u32>)

Flush all staged images into the document and redraw. Called when all in-flight image fetches have completed so the full batch is processed in a single redraw.

Source

fn view_ids(&self) -> Vec<ViewId>

Return all active view IDs.

Implementors§