Skip to main content

BrowserHost

Trait BrowserHost 

Source
pub trait BrowserHost {
    // Required methods
    fn default_window_size(&self) -> (u32, u32);
    fn default_window_title(&self) -> String;
    fn open_window(&mut self, window_id: WindowId, geometry: WindowGeometry);
    fn has_pending_default_window(&self) -> bool;
    fn close_window(&mut self, window_id: WindowId);
    fn window_title(&self, window_id: WindowId) -> String;
    fn handle_window_event(
        &mut self,
        window_id: WindowId,
        event: WindowEvent,
        sink: &mut dyn DrawSink,
    ) -> ShellCommand;
    fn apply_draw_commands(
        &mut self,
        window_id: WindowId,
        sink: &mut dyn DrawSink,
    );
    fn poll_window(&mut self, window_id: WindowId) -> bool;
}
Expand description

The browser side of the shell contract.

The shell calls these methods; the browser core implements them. Every method takes and returns platform-owned values only.

Required Methods§

Source

fn default_window_size(&self) -> (u32, u32)

The size to give a newly opened window.

Source

fn default_window_title(&self) -> String

The title to give a newly opened window.

Source

fn open_window(&mut self, window_id: WindowId, geometry: WindowGeometry)

Registers a window with the host.

The host decides what the window shows: the first call installs the UI it was given before the loop started, and any later call opens an empty window.

Source

fn has_pending_default_window(&self) -> bool

Whether a UI is still waiting to be installed in the first window.

The shell checks this before creating the first window so it can report a misconfigured startup instead of silently opening a blank window.

Source

fn close_window(&mut self, window_id: WindowId)

Forgets a window that the shell closed.

Source

fn window_title(&self, window_id: WindowId) -> String

The current title for a window.

Source

fn handle_window_event( &mut self, window_id: WindowId, event: WindowEvent, sink: &mut dyn DrawSink, ) -> ShellCommand

Handles one OS event for a window and reports what the shell should do.

Source

fn apply_draw_commands(&mut self, window_id: WindowId, sink: &mut dyn DrawSink)

Uploads the window’s pending draw commands to the sink, without presenting.

Source

fn poll_window(&mut self, window_id: WindowId) -> bool

Advances background page work for a window, returning whether it needs a repaint.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl BrowserHost for BrowserApp

Bridges the browser core to the OS shell.

The trait lives in crate::platform::system::shell so the event loop can be driven by any host without naming a browser type.