BrowserApp

Struct BrowserApp 

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

Main browser application struct.

Responsibilities:

  • Manage collection of Tab instances and the active tab index.
  • Coordinate resource loading and pending fetch lifecycle.
  • Orchestrate engine work (layout/draw-command generation) and submit commands to the renderer.
  • Process input and window events and propagate them to tabs/UI.

Typical lifecycle:

  1. Construct BrowserApp::new(...), which wires platform components (network, renderer, system).
  2. Create Tab objects and call add_tab / navigate as needed.
  3. Call run() to start the event loop. Each loop iteration:
    • Poll platform events (keyboard/mouse/window).
    • Update input state and dispatch to the active tab.
    • If DOM/CSS changes occurred, request layout and regenerate draw commands.
    • Submit draw commands to the platform-specific renderer.
  4. Manage asynchronous resource fetches: match responses to pending fetch IDs and notify tabs.

Example usage:

use orinium_browser::browser::BrowserApp;
use orinium_browser::browser::Tab;

let mut app = BrowserApp::default();
let mut tab = Tab::new();
tab.navigate("resource:///test/compatibility_test.html".parse().unwrap());
app.add_tab(tab);
app.run().unwrap();

Contributor guidance:

  • Add small unit tests to validate tab lifecycle, fetch handling, and draw-command generation.
  • Prefer adding examples under examples/ to demonstrate end-to-end behavior.

Implementations§

Source§

impl BrowserApp

Source

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

Starts the main browser event loop asynchronously.

Source

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

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( &mut self, window_id: WindowId, window_size: (u32, u32), window_title: String, scale_factor: f64, tab_id: usize, )

Registers a new window with the given id, size, title, scale factor, and associated tab.

Source

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

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

Source

pub fn default_window_size(&self) -> (f32, f32)

Returns the default window size for opening new windows.

Source

pub fn default_window_title(&self) -> String

Returns the default window title for opening new windows.

Source

pub fn tick(&mut self) -> BrowserCommand

Source

pub fn handle_window_event( &mut self, window_id: WindowId, event: WindowEvent, gpu: &mut GpuRenderer, ) -> BrowserCommand

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

Source

pub fn new_empty_tab(&mut self) -> usize

Adds a new empty tab and returns its index.

Source

pub fn handle_mouse_click(tab: &mut Tab, x: f32, y: f32)

Handles a mouse click in the given tab at the specified coordinates.

Source

pub fn redraw(&mut self, window_id: WindowId, gpu: &mut GpuRenderer)

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, gpu: &mut GpuRenderer)

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

Source

pub fn add_tab(&mut self, tab: Tab)

Adds a new tab to the browser.

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

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