Browser engine
Tide’s engine is about 35,000 lines of C: around 13,000 for HTML, CSS, layout and paint, and 22,000 for Surf, its JavaScript engine, and the DOM.
Pipeline#
URL ─▶ loader (HTTP/TLS, cookies, redirects, CSP/SRI/CORS checks)
─▶ HTML tokenizer + tree builder (quirks mode, forms)
─▶ CSS: external + inline stylesheets ─▶ cascade + computed style
─▶ layout: block, inline, floats, positioning, flexbox, grid
─▶ paint: backgrounds, borders, shadows, text, images, SVG
─▶ JavaScript: DOM bindings, events, timers, storage ─▶ restyle / relayout
Source map#
| File | Responsibility |
|---|---|
url.c, loader.c | URL parsing, fetching, redirects, meta refresh |
html.c, forms.c | Tokenizer, tree construction, form controls |
css.c | Parsing, selector matching, cascade, computed values |
layout.c, paint.c | Box tree, formatting contexts, painting |
cookies.c, security.c | Cookie jar, CSP, SRI, mixed content, origin rules |
svg_glue.c | Inline and image SVG through the shared renderer |
js/ | Lexer, parser, bytecode compiler, VM, GC, built-ins, regex, DOM, CORS, storage |
Surf, the JavaScript engine#
Surf parses source into an AST, compiled to bytecode and run on a stack VM with a tracing garbage collector. The built-ins cover ES2020: classes, destructuring, spread, iterators and generators, async functions and async generators, Promise, Map and Set, typed arrays, JSON, RegExp, Date and Math. DOM bindings expose documents, elements, events, timers, fetch/XHR (through CORS) and per-origin localStorage. A small JavaScript prelude is assembled into the kernel at build time.
Security#
- Content Security Policy from headers and
<meta>, includingscript-srcwith nonces and hashes. - Subresource Integrity for scripts and stylesheets.
- CORS for
fetchand XHR, with preflights. - Cookie attributes (
Secure,HttpOnly,SameSite, domain/path rules) and storage isolated by origin. - An engine fuzzer (
tests/browser/fuzz_engine.c) exercises the parser, cascade and layout with random input.
User scripts: opting out
Tide’s first-party user-script manager, Script Bay (coming with extensions in 2.0 “Reef”), and any other VoluSys user-script host will not inject scripts into a page that opts out in either of these ways:
<!-- in the page -->
<meta name="user-scripts" content="none">
# or as an HTTP response header
User-Scripts: none
The opt-out applies per frame, so an embedded frame can declare it on its own. It’s a VoluSys convention and doesn’t affect other browsers.
What’s next#
ES modules, Canvas 2D, Shadow DOM, Intl and developer tools are in progress for the 1.x updates. Per-site renderer processes and WebExtensions with Manifest V2 come in 2.0 “Reef”.