This is a mostly from-scratch browser built in Rust.
It currently supports a subset of HTML and CSS when rendering, and does not support JavaScript.
Warning
It is not intended to be a production-ready browser and should not be used as such.
- Headless mode
- URL Navigation
- Cookies
- UI theming with user configurable TOML file, see ./docs/theme.md for more details
- Tabs and basic tab management (open, close, switch)
- In-memory history of visited pages for each tab
Supported CSS properties can be found: ./docs/CSS.md.
The browser is composed of 7 subsystems, each responsible for a specific aspect of the browser's functionality.
- IO Subsystem: Responsible for handling all input/output operations, including file system access and network communication.
- HTTP Client: Responsible for making HTTP requests and handling responses.
- HTML Parser: Parses HTML documents and builds the DOM tree.
- Tokenizer: Breaks HTML into tokens.
- DOM Builder: Builds the DOM tree from tokens.
- CSS Parser: Parses CSS stylesheets and builds the CSSOM.
- Tokenizer: Breaks CSS into tokens.
- CSSOM Builder: Builds the CSS Object Model from tokens.
- Layout Engine: Generates the layout tree based on the DOM and style tree.
- Selector Generation: Converts CSSOM to selectors that can be applied to the DOM.
- Style Tree Builder: Combines CSS selectors, and DOM to create the style tree.
- Rendering Engine: Renders the layout tree to the screen via the GPU using
wgpu. - Browser Core: Manages the overall browser state, including tabs, navigation, and communication between subsystems.
- Interface Layer: The browser currently has two interfaces, a graphical user interface and a headless mode, these are built on top of the browser core.
- History management & file-backed history
- Bookmarks
- Download manager
- Form handling
- JavaScript support
- Advanced CSS features (animations, flexbox, grid, etc.)
- Advanced security features (sandboxing, etc.)
- Extensions or plugins
- Spec compliance with all web standards
- Install Rust (https://www.rust-lang.org/tools/install)
- Run the browser using Cargo, the Rust package manager.
cargo runcargo run -- --helpTo run the browser in headless mode, use the following command:
cargo run -- --headlessYou can even specify commands to run in a one-shot manner, for example to navigate to a URL and then print the DOM tree:
cargo run -- --headless --url "https://www.google.com/" --command "body"The project includes unit tests for many subsystems. To run the tests, use the following command:
cargo testTo run tests for a specific subsystem, navigate to that subsystem's crate and run the tests from there. For example, to run tests for the layout engine:
cargo test -p layoutThis project intentionally uses a limited set of dependencies, the goal for this project is to minimize relying on external libraries for core functionality, but I am also realistic about what can be achieved in a reasonable timeframe.
Rust crates dependencies are chosen based on the following criteria:
- Essential functionality that would be impractical to implement from scratch and is out of scope for this project (e.g.,
wgpufor GPU rendering). - Development and testing tools that do not impact the core functionality of the browser (e.g.,
tracingfor logging). - Libraries that would force me to work extensively on other aspects that isn't browser related (e.g.,
serdefor serialization/deserialization). - Temporary dependencies that facilitate developer velocity, these fall into two sub-categories:
- Dependencies that will be replaced by a lower-level dependency eventually (e.g.,
reqwestfor HTTP requests, which could eventually be replaced bycurl/libcurl). - Dependencies that come from another dependency but are used for convenience and can be removed when that dependency is removed (e.g.,
cosmic-textfor text shaping, which is a dependency oficed).
- Dependencies that will be replaced by a lower-level dependency eventually (e.g.,
To generate the most up-to-date list, run the gen_third_party.py script and/or refer to the Cargo.toml file and each individual subsystem crate's Cargo.toml, e.g., crates/errors/Cargo.toml.
This project utilizes some external tools and libraries, these are not dependencies of the browser itself but are used to facilitate development and testing.
- Python 3 - Required to run the Flask server and other scripts.
- Flask - Used for serving test HTML files, allows us to test internal functionality outside of rendering such as cookies, headers, etc.
We have fallback fonts to ensure that the browser can always render text properly, these can be found in: ./assets/font, licenses for these fonts can be found in FONTS.md.
Currently included fonts:
- OpenSans (SIL Open Font License)
- Roboto Mono (SIL Open Font License)
- Roboto Serif (SIL Open Font License)
SVG Icons used in the UI are sourced from Lucide and are licensed under the ISC License, the license can be found in ICONS.md.
This project is licensed under the MIT License - see the LICENSE file for details.
