pub struct BrowserApp { /* private fields */ }Expand description
Main browser application struct.
Responsibilities:
- Manage the window collection and per-window
BrowserUiinstances. - 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:
- Construct
BrowserApp::new(...), which wires platform components (network, system). - Create
Tabobjects, wrap them in aBrowserUi, and callset_default_ui. - 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.
- Forward winit events to the owning window’s
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
impl BrowserApp
Sourcepub fn run(self) -> Result<()>
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.
Sourcepub fn new(
default_window_size: (u32, u32),
default_window_title: String,
) -> Result<Self, Error>
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.
Sourcepub fn open_window_with_ui(
&mut self,
window_id: WindowId,
geometry: WindowGeometry,
root_ui: BrowserUi,
)
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.
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 set_default_ui(&mut self, ui: BrowserUi)
pub fn set_default_ui(&mut self, ui: BrowserUi)
Sets the UI to use when the first window opens.
Must be called before run().
Sourcepub fn handle_window_event(
&mut self,
window_id: WindowId,
event: WindowEvent,
sink: &mut dyn DrawSink,
) -> BrowserCommand
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.
Sourcepub fn redraw(&mut self, window_id: WindowId, sink: &mut dyn DrawSink)
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.
Sourcepub fn apply_draw_commands(&self, window_id: WindowId, sink: &mut dyn DrawSink)
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.
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§
Source§impl BrowserHost for BrowserApp
Bridges the browser core to the OS shell.
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)
fn default_window_size(&self) -> (u32, u32)
Source§fn default_window_title(&self) -> String
fn default_window_title(&self) -> String
Source§fn open_window(&mut self, window_id: WindowId, geometry: WindowGeometry)
fn open_window(&mut self, window_id: WindowId, geometry: WindowGeometry)
Source§fn has_pending_default_window(&self) -> bool
fn has_pending_default_window(&self) -> bool
Source§fn close_window(&mut self, window_id: WindowId)
fn close_window(&mut self, window_id: WindowId)
Source§fn window_title(&self, window_id: WindowId) -> String
fn window_title(&self, window_id: WindowId) -> String
Source§fn handle_window_event(
&mut self,
window_id: WindowId,
event: WindowEvent,
sink: &mut dyn DrawSink,
) -> ShellCommand
fn handle_window_event( &mut self, window_id: WindowId, event: WindowEvent, sink: &mut dyn DrawSink, ) -> ShellCommand
Source§fn apply_draw_commands(&mut self, window_id: WindowId, sink: &mut dyn DrawSink)
fn apply_draw_commands(&mut self, window_id: WindowId, sink: &mut dyn DrawSink)
Source§fn poll_window(&mut self, window_id: WindowId) -> bool
fn poll_window(&mut self, window_id: WindowId) -> bool
Auto Trait Implementations§
impl !Freeze for BrowserApp
impl !RefUnwindSafe for BrowserApp
impl !Send for BrowserApp
impl !Sync for BrowserApp
impl !UnwindSafe for BrowserApp
impl Unpin for BrowserApp
impl UnsafeUnpin 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
§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> ⓘ
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
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
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().