A from-scratch browser project in C++ with SDL2, SDL2_ttf and sdl2_image.
Goal: evolve this project into a fully working browser over time, built step by step without embedding Chromium/WebKit.
The current implementation is an early prototype of the rendering and UI pipeline.
- Windowed GUI with tabs (Ctrl+T new tab, Ctrl+W close tab, Ctrl+L focus address bar)
- HTTP and HTTPS page loading (OpenSSL): redirects (301/302/303/307/308), chunked transfer, gzip/deflate decompression, and legacy-charset (iso-8859-1/windows-1252) → UTF-8
- HTML rendering with a block box model (margins, padding, borders, backgrounds, width, text-align) and inline images (PNG/JPEG via SDL2_image)
- Clickable links and trackpad-friendly scrolling
- CSS support (early v0.x)
- tag, class, id and
tag.classselectors, comma groups, inline styles, external stylesheets - text:
color,font-size,font-weight - box:
margin,padding,border,background-color,width(px/%,margin: auto),text-align,display: none
- tag, class, id and
- JavaScript support (JavaScriptCore on macOS, QuickJS elsewhere)
console,alert,performance.now,setTimeout/clearTimeout,fetch(Promise +.then)- DOM:
getElementById,querySelector(#id/.class/tag),createElement,document.body/head,textContent/innerHTML,style.display,setAttribute/getAttribute,appendChild/removeChild,parentNode - events:
window/document/elementaddEventListenerwithclickandkeydowndispatch
- Form controls: text/password inputs,
<textarea>, buttons, checkbox/radio,<select>— with focus, typing, and GET form submission
- Block-level box model only (no inline boxes, floats, flexbox/grid; tables stack as blocks)
- Single-pass layout (no margin collapsing); CSS is a small subset
- JavaScript is a useful subset, not a complete engine integration:
- no ES module loading, event bubbling, or
removeEventListener querySelectortakes a single simple selector (no combinators)- a single shared JS context (multi-tab JS is not isolated)
- no ES module loading, event bubbling, or
- Forms submit via GET (POST best-effort); controls lay out block-level, with no caret/selection or
<select>dropdown
- C++17 compiler
- CMake
- SDL2, SDL2_ttf, SDL2_image
- OpenSSL (for HTTPS)
- A JavaScript engine: JavaScriptCore (bundled on macOS) or QuickJS (other platforms)
- A TTF font (DejaVu Sans ships in
fonts/; common system fonts are used as a fallback)
.
├── CMakeLists.txt
├── main.cpp
├── dom.h
├── fonts/
│ └── DejaVuSans.ttf
└── README.md
brew install cmake pkg-config sdl2 sdl2_ttf sdl2_image openssl@3 git quickjs
cmake -S . -B build
cmake --build build# Debian/Ubuntu
sudo apt-get install cmake g++ libsdl2-dev libsdl2-ttf-dev libsdl2-image-dev libssl-dev quickjs libquickjs
cmake -S . -B build
cmake --build buildThe JavaScript engine is QuickJS on non-Apple platforms and JavaScriptCore on macOS; both share the same DOM tree. To build the JavaScriptCore backend on Linux (via WebKitGTK — handy for parity testing):
sudo apt-get install libjavascriptcoregtk-4.1-dev
cmake -S . -B build-jsc -DNOCHROME_FORCE_JSC=ON
cmake --build build-jsc./build/NoChrome http://example.com/- HTML tokenizer + real DOM tree
- Better text nodes and whitespace handling
- External CSS loading
- Improved selector support (descendants, grouping, basic specificity)
- A minimal box model:
- block/inline
- margins/padding
- background colors
- per-line height based on font sizes
- Redirect handling (301/302/307/308)
- Content-Type based parsing
- Compression support (gzip/deflate)
- Character encoding handling
- HTTPS via a TLS library
- Form controls (input, button, textarea)
- Focus/selection basics
- Better link states (hover/active)
- Integrate a JS engine (e.g., QuickJS or another embeddable engine)
- Minimal DOM bindings
- Event loop basics
- Images (PNG/JPEG)
- More robust layout primitives
- Incremental reflow/paint
Issues and PRs are welcome.
If you want to help, focus on small isolated improvements (parser, CSS rules, layout primitives, or networking).
MIT