A lightweight HTML/CSS/JS rendering engine built from scratch with C++17 and OpenGL.
- HTML Parsing - Tokenizer, element parser, text parser
- CSS Parsing - Tokenizer, selector parser, declaration parser, keyframe parser
- Style Engine - Selector matching, property resolution, transitions, animations
- Layout Engine - Block, inline, flex, grid, positioned layout modes
- OpenGL Rendering - Primitives, text (stb_truetype), images (stb_image), SVG (nanosvg), shaders, textures
document.getElementById(id)document.getElementsByClassName(name)document.querySelector(selector)document.querySelectorAll(selector)document.createElement(tagName)document.bodydocument.documentElementelement.textContent/element.innerTextelement.innerHTMLelement.classNameelement.classList.add(...)/.remove(...)/.toggle(cls, force)element.getAttribute(name)element.appendChild(child)element.querySelector(selector)/element.querySelectorAll(selector)
element.style.backgroundColorelement.style.colorelement.style.displayelement.style.opacityelement.style.transform
element.addEventListener(type, callback)document.addEventListener(type, callback)window.addEventListener(type, callback)window.dispatchEvent(targetId, type, data)
setTimeout(callback, delay)requestAnimationFrame(callback)
console.log(...args)console.error(...args)console.warn(...args)console.info(...args)
documentwindowconsole
- Keyboard - keydown/keyup events
- Mouse - click, hover, cursor tracking
- Scroll - wheel events, scrollable containers
- Node tree overlay (
--debugor--debug=element) - Text rendering debug (
--debug=text) - Dimension debug (
--debug=dimens) - Animation debug (
--debug=anim)
- CMake 3.10+
- C++17 compatible compiler (MSVC, GCC, Clang)
- OpenGL
- One of the following backends:
- GLFW (default) -
glfw3 - Wayland/Weston -
wayland-client,wayland-egl,EGL,GLESv2 - X11/EGL -
X11,EGL,OpenGL
- GLFW (default) -
cmake -B build
cmake --build build --config Release# Wayland/Weston
cmake -B build -DWESTON_PLATFORM=ON
# X11/EGL
cmake -B build -DDXORG_PLATFORM=ON# Default page
build\Release\linweb.exe
# Specific HTML file
build\Release\linweb.exe examples/index.html
# With debug overlay
build\Release\linweb.exe --debug examples/index.html
build\Release\linweb.exe --debug=dimens examples/index.html
build\Release\linweb.exe --debug=anim examples/index.html├── assets/
│ └── fonts/ # TrueType font files (Arial, Monospace)
├── examples/
│ ├── ps3/ # PS3 WebOS-style demo app
│ ├── tests/ # HTML/CSS feature tests
│ ├── index.html # CERN-inspired demo page
│ ├── new_features.html # Typography, scroll, margin collapse demo
│ └── ... # Various feature demos
├── external/
│ ├── glad/ # OpenGL loader
│ ├── nanosvg/ # SVG parser
│ ├── quickjs/ # JavaScript engine
│ └── stb/ # stb_image, stb_truetype
├── src/
│ ├── core/ # DOM tree, navigator, helpers
│ ├── debug/ # Node tree view, debug visualizer
│ ├── layout/ # Block, inline, flex, grid, positioned
│ ├── parser/
│ │ ├── css/ # CSS tokenizer & parsers
│ │ └── html/ # HTML tokenizer & parsers
│ ├── platform/ # Window abstraction (GLFW, Weston, X11)
│ ├── renderer/ # Shaders, textures, fonts, SVG, primitives
│ ├── scripting/ # JS engine, DOM/style/event/timer bindings
│ ├── style/ # Style engine, transitions, animations
│ └── utils/ # File I/O, traversal, scroll manager
├── CMakeLists.txt
└── README.md
- Elements:
div,span,p,h1-h3,a,img,button,input,header,footer,nav,section,main,aside,article,dl,dt,dd,ul,ol,li,strong,em,code,br,style,script,link - Inline elements with proper whitespace handling
- Default browser-like styles for tags
- External and inline CSS
- External and inline JavaScript
- Resource path resolution for images and scripts
- Selectors: element, class, ID, descendant, child, pseudo-classes (
:hover,:focus,:active) - Box model: margin, padding, border (width, color, style, radius)
- Display:
block,inline,inline-block,flex,grid,none - Flexbox: direction, wrap, justify-content, align-items, gap
- Grid: template columns/rows, gap, column/row spanning
- Positioning:
static,relative,absolute,fixed(with top/left/right/bottom) - Typography: font-family, font-size, font-weight, text-align, color, line-height
- Background: color, image
- Transitions: property, duration, timing-function, delay
- Animations: keyframes, name, duration, iteration-count, direction
- Transforms: translate, rotate, scale (2D)
- CSS Filters: blur, invert, drop-shadow
- Overflow: visible, hidden, scroll, auto
- Z-index stacking
- Margin collapse
- Opacity
- Gradients: linear, radial
- Inline SVG rendering
- Box shadow
On startup, the engine prints a performance breakdown of each pipeline stage:
- HTML Parsing (ms + node count)
- Resources Loading (ms + style count)
- CSS Parsing (ms + rule count)
- Style Tree (ms + styled node count)
- Layout Tree (ms + box count)