Skip to main content

BrowserApp

Struct BrowserApp 

Source
pub struct BrowserApp { /* private fields */ }
Expand description

Main browser application struct.

Responsibilities:

  • Manage the window collection and per-window BrowserUi instances.
  • Forward winit window events to each window’s UI.
  • Coordinate resource loading and route fetched results to the owning window.

Tab state, input handling, and rendering are delegated to BrowserUi / [BrowserRenderer].

Typical lifecycle:

  1. Construct BrowserApp::new(...), which wires platform components (network, system).
  2. Create Tab objects, wrap them in a BrowserUi, and call set_default_ui.
  3. Call run() to start the event loop. Each loop iteration:
    • Forward winit events to the owning window’s BrowserUi.
    • Tick the UI, forward fetch requests to the network, and route responses back.

Example usage:

use orinium_browser::browser::{BrowserApp, BrowserUi, Tab};

let mut tab = Tab::default();
tab.navigate("resource:///test/test.html".parse().unwrap());
let mut app = BrowserApp::default();
app.set_default_ui(BrowserUi::with_tab(tab));
app.run().unwrap();

Implementations§

Source§

impl BrowserApp

Source

pub fn run(self) -> Result<()>

Starts the main browser event loop asynchronously. Returns an error if no default UI was set via set_default_ui.

Source

pub fn new( default_window_size: (u32, u32), default_window_title: String, ) -> Result<Self, Error>

Creates a new browser instance with the given default window size and title. Windows are registered later via open_window.

Source

pub fn open_window_with_ui( &mut self, window_id: WindowId, geometry: WindowGeometry, root_ui: BrowserUi, )

Opens a window showing a caller-supplied UI.

This is the in-process entry point used by embedders that build one UI per window. The BrowserHost port deliberately offers no such hook: the OS shell only knows how to describe a window, never what to put in it.

Source

pub fn close_window(&mut self, window_id: WindowId)

Removes a window’s state when the window is closed.

Source

pub fn set_default_ui(&mut self, ui: BrowserUi)

Sets the UI to use when the first window opens. Must be called before run().

Source

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

Handles a winit window event for the given window and returns a BrowserCommand.

Source

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

Rebuilds the render tree and sends draw commands to the GPU for the given window.

Source

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

Applies the current draw commands for the given window to the GPU renderer.

Source

pub fn window_size(&self, window_id: WindowId) -> (f32, f32)

Returns the current window size for the given window as (width, height) in floating-point pixels.

Source

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

Returns the window title for the given window.

Trait Implementations§

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.

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. Read more
Source§

fn has_pending_default_window(&self) -> bool

Whether a UI is still waiting to be installed in the first window. Read more
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.
Source§

impl Default for BrowserApp

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