# libweb
**Repository Path**: xinligg/libweb
## Basic Information
- **Project Name**: libweb
- **Description**: 一个用 C11 编写的小型浏览器引擎库
- **Primary Language**: Unknown
- **License**: MIT
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2026-10-20
- **Last Updated**: 2026-11-06
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# libweb
`libweb` is a small embeddable web rendering engine written in C11. It is
deliberately built like a miniature browser: an HTML parser, a CSS cascade and
layout engine, a software rasterizer, and a DOM with a JavaScript runtime. The
rendering side uses software canvas, while the scripting side uses
[quickjs](https://github.com/quickjs-ng/quickjs).
The main library is about **0.8 MB** in a release archive (including its
anti-aliased bitmap fonts and the vendored SVG rasterizer). It has no mandatory dependency other than libc and
libm. PNG/JPEG/GIF and HTTPS support are enabled automatically when
zlib/libjpeg/giflib/OpenSSL are found at build time, and a system CJK font is
used through FreeType when available.
## Features
HTML
- tolerant tokenizer/tree builder with implicit `html`/`head`/`body`
- implied end tags for `p`, `li`, `dt`/`dd`, table rows/cells, options, headings
- attributes, comments, doctype, raw-text elements (`script`, `style`, `title`,
`textarea`), common named and numeric character references
- fragment parsing used by `innerHTML`, `document.write` and the C API
CSS
- selectors: type, `*`, `.class`, `#id`, descendant, child `>`, adjacent `+`,
sibling `~`, attribute selectors, `:first-child`, `:last-child`,
`:only-child`, `:root`, `:link`, `:hover`, `:focus`, `:nth-child`
- cascade with user-agent/author/inline origins, specificity, source order and
`!important`; inheritance
- properties: display, position, visibility, colors, backgrounds, fonts,
line-height, text align/decoration/indent, white-space, margins, padding,
borders, width/height/min/max, list styles, opacity, overflow, top/right/
bottom/left, z-index, flex/grid properties
- CSS custom properties (`--x`) and `var(--x, fallback)` with inheritance and
copy-on-write sharing
- stylesheet rules indexed by rightmost id/class/tag, with per-node candidate
filtering and match de-duplication
- width-based `@media` queries are evaluated against the current viewport;
`@supports`/`@layer` bodies are applied optimistically
- shorthands: margin, padding, border, border sides, background, font,
list-style; inline `style` attributes
- compact built-in user-agent stylesheet
Layout and paint
- block and inline formatting, line boxes, whitespace collapsing, `pre`
handling, wrapping, text alignment and justification
- simplified left/right floats, absolute/fixed/relative positioning with
`top/right/bottom/left`, `z-index`, `box-sizing: border-box`
- flexbox subset: row/column and reverse direction, grow/shrink/basis, gap,
justify-content, align-items/self, `order`, single-line layout
- grid subset: `grid-template-columns` with px/percent/fr/auto/repeat, gap,
row-major auto placement
- margins (sibling collapsing), borders, padding, auto margins, percentages,
inline-blocks with shrink-to-fit, replaced image boxes, `overflow:hidden`
clipping
- list markers (disc/circle/square/decimal/alpha/roman)
- software RGBA rasterizer with anti-aliased text, borders, backgrounds and
scaled images; output to caller-provided pixels or a full-page buffer
- embedded Latin bitmap faces plus on-demand FreeType fallback for CJK and
other scripts
- hit testing, hover/focus tracking, default link navigation
JavaScript (quickjs-ng)
- DOM: `Node`, `Element`, `Text`, `Document`, traversal, mutation, attributes,
`classList`, `style`/`getComputedStyle`, `innerHTML`, `textContent`,
`querySelector(All)`, `getElementById`, `getElementsBy*`, geometry
- events: `addEventListener`/`removeEventListener`/`dispatchEvent`, capture and
bubble phases, `preventDefault`/`stopPropagation`, inline `on*` handlers,
`DOMContentLoaded` and `load`
- timers and scheduling: `setTimeout`/`setInterval`, `clear*`,
`requestAnimationFrame`, `queueMicrotask`
- platform: `console`, `alert`, `location`, `navigator`, `performance.now`,
`innerWidth`/`innerHeight`, synchronous `fetch` (resolved through a Promise)
- scripts are executed in document order, including external `src` scripts
Loading
- `file:`, `data:` and plain file paths
- HTTP/1.1 and HTTPS GET (OpenSSL) with redirects, chunked bodies, keep-alive
connection reuse and timeouts
- parallel resource prefetch pool, engine-level resource cache, static module
import discovery, and decoded-image cache
- relative URL resolution, percent-decoding, base64 data URIs, ``
- images: PNG (zlib), JPEG (libjpeg), GIF (giflib, first frame), BMP and binary PPM
- SVG through the vendored nanosvg/nanosvgrast: inline `