pub struct BrowserApp { /* private fields */ }Expand description
Main browser application struct.
Responsibilities:
- Manage collection of
Tabinstances 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:
- Construct
BrowserApp::new(...), which wires platform components (network, renderer, system). - Create
Tabobjects and calladd_tab/navigateas needed. - 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.
- 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
impl BrowserApp
Sourcepub fn new(
default_window_size: (u32, u32),
default_window_title: String,
) -> Self
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.
Sourcepub fn open_window(
&mut self,
window_id: WindowId,
window_size: (u32, u32),
window_title: String,
scale_factor: f64,
tab_id: usize,
)
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.
Sourcepub fn close_window(&mut self, window_id: WindowId)
pub fn close_window(&mut self, window_id: WindowId)
Removes a window’s state when the window is closed.
Sourcepub fn default_window_size(&self) -> (f32, f32)
pub fn default_window_size(&self) -> (f32, f32)
Returns the default window size for opening new windows.
Sourcepub fn default_window_title(&self) -> String
pub fn default_window_title(&self) -> String
Returns the default window title for opening new windows.
pub fn tick(&mut self) -> BrowserCommand
Sourcepub fn handle_window_event(
&mut self,
window_id: WindowId,
event: WindowEvent,
gpu: &mut GpuRenderer,
) -> BrowserCommand
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.
Sourcepub fn new_empty_tab(&mut self) -> usize
pub fn new_empty_tab(&mut self) -> usize
Adds a new empty tab and returns its index.
Sourcepub fn handle_mouse_click(tab: &mut Tab, x: f32, y: f32)
pub fn handle_mouse_click(tab: &mut Tab, x: f32, y: f32)
Handles a mouse click in the given tab at the specified coordinates.
Sourcepub fn redraw(&mut self, window_id: WindowId, gpu: &mut GpuRenderer)
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.
Sourcepub fn apply_draw_commands(&self, window_id: WindowId, gpu: &mut GpuRenderer)
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.
Sourcepub fn window_size(&self, window_id: WindowId) -> (f32, f32)
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.
Sourcepub fn window_title(&self, window_id: WindowId) -> String
pub fn window_title(&self, window_id: WindowId) -> String
Returns the window title for the given window.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BrowserApp
impl !RefUnwindSafe for BrowserApp
impl !Send for BrowserApp
impl !Sync for BrowserApp
impl Unpin for BrowserApp
impl !UnwindSafe for BrowserApp
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<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>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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
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().