Skip to content
Daan-25Public

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

58 Commits

Folders and files

Repository files navigation

NoChrome

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.

Current Features

  • 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.class selectors, 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
  • 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/element addEventListener with click and keydown dispatch
  • Form controls: text/password inputs, <textarea>, buttons, checkbox/radio, <select> — with focus, typing, and GET form submission

Limitations (Current Stage)

  • 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
    • querySelector takes a single simple selector (no combinators)
    • a single shared JS context (multi-tab JS is not isolated)
  • Forms submit via GET (POST best-effort); controls lay out block-level, with no caret/selection or <select> dropdown

Requirements

  • 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)

Project Structure

.
├── CMakeLists.txt
├── main.cpp
├── dom.h
├── fonts/
│   └── DejaVuSans.ttf
└── README.md

Build (macOS)

brew install cmake pkg-config sdl2 sdl2_ttf sdl2_image openssl@3 git quickjs
cmake -S . -B build
cmake --build build

Build (Linux)

# 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 build

The 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

Run

./build/NoChrome http://example.com/

Roadmap (High Level)

1) Solid Static Web Support

  • 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

2) Real Networking

  • Redirect handling (301/302/307/308)
  • Content-Type based parsing
  • Compression support (gzip/deflate)
  • Character encoding handling
  • HTTPS via a TLS library

3) Interactivity Foundations

  • Form controls (input, button, textarea)
  • Focus/selection basics
  • Better link states (hover/active)

4) JavaScript (Long-Term)

  • Integrate a JS engine (e.g., QuickJS or another embeddable engine)
  • Minimal DOM bindings
  • Event loop basics

5) Rendering Improvements

  • Images (PNG/JPEG)
  • More robust layout primitives
  • Incremental reflow/paint

Contributing

Issues and PRs are welcome.
If you want to help, focus on small isolated improvements (parser, CSS rules, layout primitives, or networking).

License

MIT

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages